Random Color with seed

extension UIColor
{
    func randomColor(seed: String) -> UIColor
    {
       
        var total: Int = 0
        for u in seed.unicodeScalars {
            total += Int(UInt32(u))
        }
       
        srand48(total * 200)
        let r = CGFloat(drand48())
        srand48(total)
        let g = CGFloat(drand48())
        srand48(total / 200)
        let b = CGFloat(drand48())
       
        return UIColor(red: r, green: g, blue: b, alpha: 1)
    }
}

let str = "abcd"
let a = UIColor().randomColor(seed: str)
is the same with
let b = UIColor().randomColor(seed: str)
is the same with
let c = UIColor().randomColor(seed: str)
etc etc

Tags: 

Dispatch async

DispatchQueue.global(qos: .background).async {
    // Background Thread
    DispatchQueue.main.async {
        // Run UI Updates or call completion block
    }
}

Main and Background Queues

let main = DispatchQueue.main
let background = DispatchQueue.global()
let helper = DispatchQueue(label: "another_thread")
Working with async and sync threads!

background.async { //async tasks here }
background.sync { //sync tasks here }

Tags: 

NSAttributedString

One liner swift 4:

label.attributedText = NSAttributedString(string: "Text", attributes:
    [.underlineStyle: NSUnderlineStyle.styleSingle.rawValue])

Tags: 

Wifi qr code format

Wi-Fi QR Code Format

WIFI:T:WPA;S:mynetwork;P:mypasscode;;

    WPA—the authentication type
    mynetwork — the network SSID
    mypasscode — the password
    ⚠️ Hidden SSIDs are not supported.

Tags: 

Remove Android Studio

rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm -Rf ~/Library/Preferences/com.google.android.*
rm -Rf ~/Library/Preferences/com.android.*
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*
rm -Rf ~/.AndroidStudio*
rm -Rf ~/.gradle
rm -Rf ~/.android
rm -Rf ~/Library/Android*

Device Enrollment notification

move

/System/Library/LaunchAgents/com.apple.ManagedClientAgent.enrollagent.plist
/System/Library/LaunchDaemons/com.apple.ManagedClient.enroll.plist

to
/Library/LaunchAgentsDisabled and /Library/LaunchDaemonsDisabled

Tags: 

Objects Without xml

in activity

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);


        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        float height = displayMetrics.heightPixels;
        float width = displayMetrics.widthPixels;

        RelativeLayout myLayout = new RelativeLayout(this);
        myLayout.setBackgroundColor(Color.BLUE);

        Button myButton = new Button(this);
        myButton.setText("Press me");
        myButton.setBackgroundColor(Color.YELLOW);
        float w = (width*(float)0.3);
        myButton.setLayoutParams(new RelativeLayout.LayoutParams((int)w, (int)w));
        myButton.setX(width*(float)0.1);
        myButton.setY(width*(float)0.1);

        myLayout.addView(myButton);
        setContentView(myLayout);
    }

Docker.qcow2 never shrinks

~/Library/Containers/com.docker.docker/

rm Docker.qcow2

Tags: 

price in SKProduct in local currency

func priceStringForProduct(item: SKProduct) -> String? {
        let price = item.price
        if price == 0 {
            return "Free!" //todo: Translate
        } else {
            let numberFormatter = NumberFormatter()
            let locale = item.priceLocale
            numberFormatter.numberStyle = .currency
            numberFormatter.locale = locale
            return numberFormatter.string(from: price)
        }
    }

Tags: 

emitter explosion

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
         createParticles()
    }

    func createParticles() {
        let v = UIView(frame: CGRect(x: 180, y: 220, width: 60, height: 60))
        //v.backgroundColor = .lightGray
        view.addSubview(v)
        let particleEmitter = CAEmitterLayer()
       
        particleEmitter.emitterPosition = CGPoint(x: 30, y: 30)
        particleEmitter.emitterShape = kCAEmitterLayerSphere
        particleEmitter.emitterSize = CGSize(width: 1, height: 1)
       
        let red = makeEmitterCell(color: UIColor.red)
        let green = makeEmitterCell(color: UIColor.green)
        let blue = makeEmitterCell(color: UIColor.blue)
       
        particleEmitter.emitterCells = [red, green, blue]
       
        v.layer.addSublayer(particleEmitter)
        UIView.animate(withDuration: 2.0, animations: {
            v.alpha = 0
        }) { (_) in
            v.layer.sublayers?.removeAll()
        }
    }
   
    func makeEmitterCell(color: UIColor) -> CAEmitterCell {
        let cell = CAEmitterCell()
        cell.birthRate = 2.5
        cell.lifetime = 1.9
        cell.lifetimeRange = 1
        cell.color = color.cgColor
        cell.velocity = 158
        cell.velocityRange = 45
        cell.emissionLongitude = CGFloat.pi
        cell.emissionRange = CGFloat.pi
        cell.spin = 4
        cell.spinRange = 6
        cell.scaleRange = 0.04
        cell.scaleSpeed = 0.3
        cell.xAcceleration = -0.03
        cell.yAcceleration = -0.05
        cell.zAcceleration = 0.2
       
        cell.contents = UIImage(named: "cp")?.cgImage
        return cell
    }
}

Tags: 

version build

if let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString"),
            let build = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String)
{
     versionLabel.text = "v\(version).\(build)"
}

Tags: 

String contains substring

extension String {
    func contains(find: String) -> Bool{
        return self.range(of: find) != nil
    }
    func containsIgnoringCase(find: String) -> Bool{
        return self.range(of: find, options: .caseInsensitive) != nil
    }
}

Tags: 

Image from UIView

func imageWithView(inView: UIView) -> UIImage? {
    UIGraphicsBeginImageContextWithOptions(inView.bounds.size, inView.isOpaque, 0.0)
    defer { UIGraphicsEndImageContext() }
    if let context = UIGraphicsGetCurrentContext() {
        inView.layer.render(in: context)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        return image
    }
    return nil
}

Tags: 

iPhone x uiviewcontroller

class BaseVC: UIViewController
{
   var shouldHideHomeIndicator     = false
   public let stage                = UIView()

   override func viewDidLoad() {
       super.viewDidLoad()
       HLog.info(function:#function, message: "BaseVC")

       navigationController?.setToolbarHidden(true, animated: false)
       navigationController?.navigationBar.isHidden = true

       setupLayout()
   }


   override func viewDidAppear(_ animated: Bool) {
       super.viewDidAppear(animated)

       self.shouldHideHomeIndicator = true
       if #available(iOS 11.0, *) {
           self.setNeedsUpdateOfHomeIndicatorAutoHidden()
       } else {
           // Fallback on earlier versions
       }
   }

   override var prefersStatusBarHidden: Bool
   {
       return true
   }

   override func preferredScreenEdgesDeferringSystemGestures() ->
UIRectEdge {
       return .top
   }

   override func prefersHomeIndicatorAutoHidden() -> Bool
   {
       return shouldHideHomeIndicator
   }
   //MARK: - Layout
   func setupLayout()
   {
       createStage()
   }

   func createStage()
   {

       let ninesixteen = (sw/9.0*16.0).rounded()
       if ninesixteen <= sh
       {
           stage.frame = Frame(x: 0, y: 0, width: sw, height: ninesixteen)
       }
       else
       {
           stage.frame = Frame(x: 0, y: 0, width: sh/16.0*9.0, height: sh)
       }
       stage.backgroundColor = .clear
       stage.center = view.center
       view.addSubview(stage)
   }

   //MARK: - Helper
   func goto(vc:UIViewController)
   {
       AudioPlayerHelper.play(audioButtonClick)
       UIApplication.shared.keyWindow?.rootViewController = vc.self
   }
}

Tags: 

array with functions

class Bla
{
   let arrayOfFunctions = [function1, function2]

   func function1()
   {
      print("function1")
   }

    func function2() {
        print("function2")
    }

   func useTheFuncs()
   {
    let fn1 = arrayOfFunctions[0]
    fn1(self)()
   }
}

Tags: 

CABasicAnimation

grow shrink, heartbeat?

let img = UIImage(named: "red_star_2")
let imgv = UIImageView(image: img)
let theAnimation = CABasicAnimation()
theAnimation.keyPath = "transform.scale"
theAnimation.duration = 0.7
theAnimation.repeatCount = .infinity
theAnimation.autoreverses = true
theAnimation.fromValue = 1.0
theAnimation.toValue = 1.3
theAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
imgv.layer.add(theAnimation, forKey: "animateOpacity")
imgv.center = CGPoint(x: 50, y: 50)
view.addSubview(imgv)

rotation
let kRotationAnimationKey = "com.myapplication.rotationanimationkey"

let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation")
        rotationAnimation.fromValue = 0.0
        rotationAnimation.toValue = Float(M_PI * 2.0)
        rotationAnimation.duration = 0.2
        rotationAnimation.repeatCount = Float.infinity
        turningStar.layer.add(rotationAnimation, forKey: kRotationAnimationKey)

with completion
import UIKit
import PlaygroundSupport

let viewFrame = CGRect(x: 0, y: 0, width: 500, height: 500)
let view = UIView(frame: viewFrame)
view.backgroundColor = .white
PlaygroundPage.current.liveView = view

let v = UIView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
v.backgroundColor = .red
view.addSubview(v)

CATransaction.begin()
print("start")
let a = CABasicAnimation(keyPath: "position")
a.fromValue = [100, 100]
a.toValue = [200, 200]
a.duration = 2
CATransaction.setCompletionBlock{ print("ended")
}

v.layer.add(a, forKey: nil)
CATransaction.commit()

Tags: 

Link write review in app store

#available(iOS 10, *)!!!

let appID = "959379869"

if let checkURL = URL(string: "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=\(appID)&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8") {
    open(url: checkURL)
} else {
    print("invalid url")
}

...

func open(url: URL) {
    if #available(iOS 10, *) {
        UIApplication.shared.open(url, options: [:], completionHandler: { (success) in
            print("Open \(url): \(success)")
        })
    } else if UIApplication.shared.openURL(url) {
            print("Open \(url)")
    }
}

Tags: 

Action order for CAKeyframeAnimation

Swift 3

CATransaction.begin()
CATransaction.setCompletionBlock {
    //Actions to be done after animation
}
//Animation Code
CATransaction.commit()

Array copy clone

//Protocal that copyable class should conform
protocol Copying {
    init(original: Self)
}

//Concrete class extension
extension Copying {
    func copy() -> Self {
        return Self.init(original: self)
    }
}

//Array extension for elements conforms the Copying protocol
extension Array where Element: Copying {
    func clone() -> Array {
        var copiedArray = Array<Element>()
        for element in self {
            copiedArray.append(element.copy())
        }
        return copiedArray
    }
}

//Simple Swift class that uses the Copying protocol
final class MyClass: Copying {
    let id: Int
    let name: String
   
    init(id: Int, name: String) {
        self.id = id
        self.name = name
    }
   
    required init(original: MyClass) {
        id = original.id
        name = original.name
    }
}

//Array cloning
let objects = [MyClass]()
//fill objects array with elements
let clonedObjects = objects.clone()

Tags: 

Blurred footprint

extension uiimage

public func modifiedImage(_ draw: (CGContext, CGRect) -> ()) -> UIImage {
       
        // using scale correctly preserves retina images
        UIGraphicsBeginImageContextWithOptions(size, false, scale)
        let context: CGContext! = UIGraphicsGetCurrentContext()
        assert(context != nil)
       
        // correctly rotate image
        context.translateBy(x: 0, y: size.height)
        context.scaleBy(x: 1.0, y: -1.0)
       
        let rect = CGRect(x: 0.0, y: 0.0, width: size.width, height: size.height)
       
        draw(context, rect)
       
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image!
    }
public func tintPictogram(with fillColor: UIColor) -> UIImage {
       
        return modifiedImage { context, rect in
            // draw tint color
            context.setBlendMode(.normal)
            fillColor.setFill()
            context.fill(rect)
           
            // mask by alpha values of original image
            context.setBlendMode(.destinationIn)
            context.setAlpha(0.15)
            context.draw(cgImage!, in: rect)
        }
    }

general:
func blurImage(_ image:UIImage) -> UIImage? {
    let context = CIContext(options: nil)
    let inputImage = CIImage(image: image)
    let originalOrientation = image.imageOrientation
    let originalScale = image.scale
   
    let filter = CIFilter(name: "CIGaussianBlur")
    filter?.setValue(inputImage, forKey: kCIInputImageKey)
    filter?.setValue(3.0, forKey: kCIInputRadiusKey)
    let outputImage = filter?.outputImage
   
    var cgImage:CGImage?
   
    if let asd = outputImage
    {
        cgImage = context.createCGImage(asd, from: (inputImage?.extent)!)
    }
   
    if let cgImageA = cgImage
    {
        return UIImage(cgImage: cgImageA, scale: originalScale, orientation: originalOrientation)
    }
   
    return nil
}

use:
if let image = UIImage(named:name)
            {
                 let tintimg = image.tintPictogram(with: .black)
                if let shadowedimage = blurImage(tintimg){
                //...    shadowImages.append(shadowedimage)
                }
               
            }

Tags: 

notes from new es6

probeer in:
http://jsbin.com/

imports

You got two different types of exports: default (unnamed) and named exports:

default => export default ...;

named => export const someData = ...;

You can import default exports like this:

import someNameOfYourChoice from './path/to/file.js';

Named exports have to be imported by their name:

import { someData } from './path/to/file.js'

snips

const myName = 'hjh';
///console.log(myName);

function printName(name){
  console.log(name);
}
const printName2 = (name,age) =>{
  console.log('2: '+name+' age: '+age);
}
//printName("hhhh");
//printName2("hhhh");

const multiply = (number) =>{
  return number * 2;
}
const multiply2 = number => number * 2;

//printName(multiply(4));
//printName(multiply2(4));

class Person{
 
  constructor(name){
    this.name = name;
  }
 
  call() {
    console.log( 'hi from '+ this.name);
  }
}
const p = new Person('hjc');
p.call();

const numbers = [1,2,3];
//spread
const newNumbers = [...numbers,4];
console.log('newNumbers: '+newNumbers);
const newPerson = {
  ...p,
  age: 26
}
console.log(newPerson)

const filter = (...args) => {
  return args.filter(el => el === 1);
}

console.log('filter : '+filter(1,2,3));

[num1,num2] = numbers;
console.log(num1,num2);

// Arrrays & Class's are copied by reference!

const person3 = {
  name: 'Max'
}

const person4 = person3;
const person5 = {
  ...person3
}
person3.name = 'Manu';

console.log(person4);
console.log(person5);

// array .map function
const doubleNumbers = numbers.map((num)=> {return num*2});
console.log('double numbers '+doubleNumbers);

meer array functions
map() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
find() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
findIndex() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
filter() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
reduce() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
concat() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
slice() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
splice() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...

react components playground:
https://codepen.io

Tags: 

React Native notes

ESlint

npm install --save-dev eslint-config-rallycoding 

create .eslintrc:
{
  "extends":"rallycoding"
}

create-react-native-app AwesomeProject
cd AwesomeProject
npm start

down grading nom 5 =>4
npm install -g npm@4

Tags: 

shake animations

func shakeByRotateView(view:UIView){
    let shake:CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation")
    shake.duration = 0.12
    shake.repeatCount = Float.infinity
    shake.autoreverses = true
   
    shake.fromValue = NSNumber(value: 0.05*Double.pi)
    shake.toValue = NSNumber(value: -0.05*Double.pi)
    view.layer.add(shake, forKey: "lineRotation")
}

func shakeView(view:UIView){
    let shake:CABasicAnimation = CABasicAnimation(keyPath: "position")
    shake.duration = 0.1
    shake.repeatCount = 2
    shake.autoreverses = true
   
    var from_point:CGPoint = CGPoint(x:view.center.x - 5,y: view.center.y)
    var from_value:NSValue = NSValue(cgPoint: from_point)
   
    var to_point:CGPoint = CGPoint(x:view.center.x + 5,y: view.center.y)
    var to_value:NSValue = NSValue(cgPoint: to_point)
   
    shake.fromValue = from_value
    shake.toValue = to_value
    view.layer.add(shake, forKey: "position")
}

Tags: 

Python rest_framework Docker setup

Dockerfile

FROM python:3

ENV PYTHONUNBUFFERED = 1
RUN mkdir /code
WORKDIR /code
COPY . /code/
RUN pip install -r requirements.txt

docker-compose.yml

version: '3'

services:
  web:
    build: .
    command: python src/profiles_project/manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"

docker-compose run web python src/profiles_project/manage.py migrate

docker-compose up

Codable Decodable

enum PlanetState:String, CodingKey {
    case UnLocked = "unlocked"
    case Locked = "locked"
    case Completed = "completed"
    case Tutorial = "tutorial"
    case ComingSoon = "comingsoon"
}


class Planet: Codable
{
    var state:PlanetState
    var order:Int
    var planetBrev:String
    var bought:Bool
    var collectableGold:Int
   
    enum CodingKeys: String, CodingKey
    {
        case state      = "state"
        case order      = "order"
        case planetBrev = "planetBrev"
        case bought     = "bought"
        case collectableGold = "collectableGold"
    }
   
    init(state: PlanetState, order: Int, planetBrev:String, bought: Bool, collectableGold:Int = -1)
    {
        self.state = state
        self.order = order
        self.planetBrev = planetBrev
        self.bought = bought
        self.collectableGold = collectableGold
    }
   
    required init(from decoder: Decoder) throws {
       
        let values = try decoder.container(keyedBy: CodingKeys.self)
        self.state = (try PlanetState(rawValue: values.decode(String.self, forKey: CodingKeys.state)))!
        self.order = try values.decode(Int.self, forKey: CodingKeys.order)
        self.planetBrev = try values.decode(String.self, forKey: CodingKeys.planetBrev)
        self.bought = try values.decode(Bool.self, forKey: CodingKeys.bought)
        self.collectableGold = try values.decode(Int.self, forKey: CodingKeys.collectableGold)
    }
   
    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try? container.encode(self.state.stringValue, forKey: CodingKeys.state)
        try? container.encode(self.order, forKey: CodingKeys.order)
        try? container.encode(self.planetBrev, forKey: CodingKeys.planetBrev)
        try? container.encode(self.bought, forKey: CodingKeys.bought)
        try? container.encode(self.collectableGold, forKey: CodingKeys.collectableGold)
    }
}

load
do {
   let planet = try decoder.decode(Planet.self, from: pData)
   HLog.info(function: #function, message: "planet \(planet.planetBrev) \(planet.collectableGold)")
   self.planets.append(planet)
} catch {
    print("error \(error)")
}

save to default for example
if let jsonData = try? encoder.encode(planet)
            {
                defaults.set(jsonData, forKey: "\(Constants.kQuarkPlanetSave)\(planet.planetBrev)")
                HLog.info(function: #function, message: "defaults did save data \(planet.planetBrev)")
                savedPlanets.append(planet.planetBrev)
            }

class Excercise: Encodable,Decodable {
    var date:Date
    var remarks:[String]
   
    init(date:Date,remarks:[String]) {
        self.date = date
        self.remarks = remarks
    }
 
}

let x = Excercise(date:Date(),remarks:["avc","def"])
let encoder = JSONEncoder()
let jsonData = try encoder.encode(x)
String(data: jsonData, encoding: .utf8)!//"{"date":531262938.28764498,"remarks":["avc","def"]}"
let decoder = JSONDecoder()
let decoded = try decoder.decode(Excercise.self, from: jsonData)
decoded.date//"Nov 1, 2017 at 10:01 PM"
decoded.remarks//["avc", "def"]
type(of: decoded)//Excercise.Type

Tags: 

UILabel outlined / stroked text

class StrokedLabel: UILabel {
   
    var strockedText: String = "" {
        willSet(newValue) {
            let strokeTextAttributes = [
                NSAttributedStringKey(rawValue: NSAttributedStringKey.strokeColor.rawValue) : UIColor.black,
                NSAttributedStringKey(rawValue: NSAttributedStringKey.foregroundColor.rawValue) : UIColor.white,
                NSAttributedStringKey(rawValue: NSAttributedStringKey.strokeWidth.rawValue) : -4.0,
                NSAttributedStringKey(rawValue: NSAttributedStringKey.font.rawValue) : UIFont.boldSystemFont(ofSize: 30)
                ] as [NSAttributedStringKey : Any]?
           
            let customizedText = NSAttributedString(string: newValue
                , attributes: strokeTextAttributes)
           
           
           
            attributedText = customizedText
        }
    }
}

Tags: 

raspi config ssh problem

ssh pi@192.168.1.27
Connection reset by 192.168.1.27 port 22
solution:

sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server

Path Finding

import GameplayKit

let graph = GKGraph()


let nodeA = GKGraphNode()
let nodeB = GKGraphNode()
let nodeC = GKGraphNode()
let nodeD = GKGraphNode()
let nodeE = GKGraphNode()


graph.addNodes([nodeA,nodeB,nodeC,nodeD,nodeE])
nodeA.addConnectionsToNodes([nodeB,nodeD], bidirectional: true)
nodeB.addConnectionsToNodes( [nodeD], bidirectional: true)
nodeC.addConnectionsToNodes( [nodeE], bidirectional: false)
nodeD.addConnectionsToNodes( [nodeC], bidirectional: false)
let path:[GKGraphNode] = graph.findPathFromNode(nodeA, toNode: nodeE)

Tags: 

Server side Swift

Kitura

mkdir serverside
cd serverside/
mkdir server
cd server
docker run -itv $(pwd):/projects --name projects -w /projects -p 8089:8089 -p 8090:8090 -p 5984:5984 twostraws/server-side-swift /bin/bash
docker start projects
docker attach projects
root@c661e0faa890:/projects# mkdir project1
root@c661e0faa890:/projects# cd project1/
root@c661e0faa890:/projects/project1# swift package init --type executable
root@c661e0faa890:/projects/project1# swift build
root@c661e0faa890:/projects/project1# .build/debug/project1
Hello, world!

change package to:
let package = Package(
name: "project1",
dependencies: [
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1),
.Package(url: "https://github.com/IBM-Swift/HeliumLogger.git", majorVersion: 1),
.Package(url: "https://github.com/IBM-Swift/Kitura-StencilTemplateEngine.git", majorVersion: 1)
]
)

swift build
swift package generate-xcodeproj

docker ps - shows a list of running containers
docker ps -a shows list all projects

docker start #NAME PROJ#
docker attach #NAME#
ctrl-p ctrl-q to get back to local terminal without stopping
docker start -i #NAME#

Vapor

Use & adjust Post template.
change in fluent.json
"driver":"memory" into "driver":"sqlite"

create
sqlite.json
insert
{
"path":"pokemonDB.sqlite"
}

in config+Setup
change setupPreparations into desired Pokemon class

private func setupPreparations() throws {
        preparations.append(Post.self)
        preparations.append(Pokemon.self)
    }

in router
get("version"){
            request in
            let result = try Pokemon.database?.driver.raw("select sqlite_version();")
            return try JSON(node: result)
        }

MySql

start mysql server
docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

Tags: 

bitbucket push origin problem

With Bitbucket problem on the raspi :
git push -u origin master
Counting objects: 87, done.
error: pack-objects died of signal 9
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
../html# fatal: write error: Bad file descriptor

git config pack.windowMemory 10m
git config pack.packSizeLimit 20m

Pages

Subscribe to hjsnips RSS