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
View notes.jl
#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
View CoreDataExtensions.swift
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
View keyboard.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)
...
}
View gist:958c12ef70e7ae78670ef9a6adfe86c0
(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
View UICollectionView + NSFetchedResultsController.swift
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
View pr2width.js
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
View gist:fb6e059f092776fb62bada8e35b2f39c
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
View pause_resume.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