Skip to content

Instantly share code, notes, and snippets.

View nazywamsiepawel's full-sized avatar
:bowtie:
hummus is life

pawel.io nazywamsiepawel

:bowtie:
hummus is life
View GitHub Profile
@nazywamsiepawel
nazywamsiepawel / notes.jl
Last active November 1, 2018 14:07
Notes and snippets on Julia lang
#Make a comment just like in Python
#to run > julia testing.jl
#Simple arrays
println("Hello World")
a = [1, 2, 3, 4, 5]
println(a)
b = [1 2 3; 4 5 6; 7 8 9]
@nazywamsiepawel
nazywamsiepawel / CoreDataExtensions.swift
Created July 2, 2018 14:38
Some useful core data extensions + threading
import UIKit
import CoreData
public class Mappable : NSManagedObject {
var className: String {
return String(describing: type(of: self))
}
@nazywamsiepawel
nazywamsiepawel / keyboard.swift
Created March 28, 2017 17:15
handling keyboard Notifications with swift 3.swift
override function viewDidLoad() {
...
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChangeFrame), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
...
}
(sudo) docker pull mdillon/postgis:latest
Then just set your env vars:
export POSTGRES_IMAGE="mdillon/postgis"
export POSTGRES_IMAGE_VERSION="latest"
Then you just use the plugin to create a new database.
@nazywamsiepawel
nazywamsiepawel / UICollectionView + NSFetchedResultsController.swift
Created October 17, 2016 13:18
UICollectionView + NSFetchedResultsController Swift 3 / iOS 10
var blockOperations: [BlockOperation] = []
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
if type == NSFetchedResultsChangeType.insert {
print("Insert Object: \(newIndexPath)")
blockOperations.append(
BlockOperation(block: { [weak self] in
@nazywamsiepawel
nazywamsiepawel / pr2width.js
Created July 25, 2016 10:15
Fraction window width react native
function pr2width(nom, denom){
const window = Dimensions.get('window')
const fraction = window.width / denom
return fraction*nom
}
@nazywamsiepawel
nazywamsiepawel / gist:fb6e059f092776fb62bada8e35b2f39c
Created April 20, 2016 20:46
Custom back button / chevron + gesture recognizer
self.navigationItem.leftBarButtonItem =
UIBarButtonItem(image:UIImage(named:"chevron_left"), style:.Plain, target:self, action:"backButtonPressed:");
self.navigationController!.interactivePopGestureRecognizer!.delegate = self;
@nazywamsiepawel
nazywamsiepawel / pause_resume.swift
Created January 4, 2016 22:01
Pause / Resume CABasicAnimation with Swift
func pauseAnimation(){
var pausedTime = layer.convertTime(CACurrentMediaTime(), fromLayer: nil)
layer.speed = 0.0
layer.timeOffset = pausedTime
}
func resumeAnimation(){
var pausedTime = layer.timeOffset
layer.speed = 1.0
layer.timeOffset = 0.0