Skip to content

Instantly share code, notes, and snippets.

View darrensapalo's full-sized avatar

Darren darrensapalo

View GitHub Profile
@darrensapalo
darrensapalo / launch_sublime_from_terminal.markdown
Last active April 1, 2016 05:39 — forked from artero/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

Using Sublime Text 2

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

Using Sublime Text 3

@darrensapalo
darrensapalo / overtime.py
Created April 12, 2016 16:09
Acquire the entries in my google calendar that are related to our family driver, to compute for his over time.
from __future__ import print_function
import httplib2
import os
from apiclient import discovery
import oauth2client
from oauth2client import client
from oauth2client import tools
@darrensapalo
darrensapalo / Sequential observables
Created November 8, 2016 15:00
Sequential observables
ObstetricBabyManager
.getAll()
.doOnNext { baby in
baby.Name = "John Smith"
}
.observeOn(ConcurrentDispatchQueueScheduler.init(queue: AsyncTaskUtil.backgroundThread))
.subscribeOn(MainScheduler.instance)
.flatMap { baby in
return ObstetricBabyManager.persist(baby)
}
@darrensapalo
darrensapalo / Limiting simultaneous downloads using RxAlamofire
Created November 11, 2016 06:41
Separate your code to make it more readable. It makes it easier to debug as well.
import RxSwift
example ("Helping Sebastian Roth") {
let disposeBag = DisposeBag()
// Data model representing the current download progress
struct DownloadProgress {
var numberOfCompletedDownloads: Int
var progress: Float
@darrensapalo
darrensapalo / Exiting the Rx Monad
Created November 15, 2016 15:04
Exiting the Rx Monad
import RxSwift
protocol DeviceConnectionProtocol {
var id : Observable<String> { get }
}
class Person : DeviceConnectionProtocol {
var myName: String! = nil
@darrensapalo
darrensapalo / Observable.zip
Last active November 16, 2016 17:05
Observable.zip guarantees that an emission will trigger only when both/all the observables have emitted.
import RxSwift
let backgroundThread = DispatchQueue(label: "com.rx.testing")
let numbers : Observable<Int> = Observable.create { obx in
[1,2,3,4,5].forEach { e in
obx.onNext(e)
}
obx.onCompleted()
return Disposables.create()
@darrensapalo
darrensapalo / UIFont+.swift
Last active June 2, 2021 09:42 — forked from ptsakyrellis/UIFont+.swift
UIFont extensions to be able to get bold and bold italic fonts directly from a UIFont object
/**
Swift 2
UIFont extensions to be able to get bold and bold italic fonts directly
from a UIFont object
*/
import Foundation
import UIKit
extension UIFont {
@darrensapalo
darrensapalo / rxswift3networkcalltoobject
Last active July 8, 2019 15:20
Swift 3 example of a network request wrapped as an RxSwift Observable and converted into a class object
import Foundation
import RxSwift
let networkQueue = DispatchQueue(label: "com.appName.networkQueue")
class Queue {
var name: String
public init (_ name: String) {
self.name = name
@darrensapalo
darrensapalo / diagnosis.md
Created December 7, 2017 03:23
Hot Module Replacement for Vue.js and Express

Notes on _cluster2.setupMaster is not a function issue.

I encountered this same problem.

My stack is: Vue.js (2.5.0), Express (4.16.2). Following this tutorial for React + Node.js, I was trying to do the same but for vuejs.

Changes to the file server were detected by the client process; webpack was able to compile it properly, but the server runs into this problem after running the two processes in parallel.

_cluster2.default.setupMaster is not a function

%%% This output was generated by the following command:
%%% /home/gingerbeard/candc/bin/boxer --stdin --semantics fol
%%% I want food
id(1,1).
fol(1,some(A,and(n1person(A),some(B,some(C,and(r1theme(B,C),and(r1agent(B,A),and(v1want(B),n1food(C))))))))).
First order logic representation
There exists some A