Skip to content

Instantly share code, notes, and snippets.

//
// GIFDownloader.h
// TheJoysOfCode
//
// Created by Bob on 29/10/12.
// Copyright (c) 2012 Tall Developments. All rights reserved.
//
#import <Foundation/Foundation.h>
@janodev
janodev / chrome.sh
Created November 26, 2014 19:30
Use chrome.sh to launch a stable patched Chrome from the terminal. See https://devforums.apple.com/message/1076597#1076597
clang -dynamiclib -framework AppKit patch.m -o patch.dylib
env DYLD_INSERT_LIBRARIES=patch.dylib "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
@janodev
janodev / gist:69fd3d2b2d3c50ca685c
Created February 29, 2016 16:15
How to get, install, and configure a free SSL certificate for your website:
~ $ git clone https://github.com/letsencrypt/letsencrypt
~ $ cd letsencrypt
~ $ letsencrypt-auto --renew-by-default --webroot -w /var/www/ --email jano@website.com --text --agree-tos -d website.com -d www.website.com auth
~ $ letsencrypt --apache
@janodev
janodev / ThrottledQueue.swift
Created May 1, 2016 11:05
Throttling queue. Useful to discard button clicks until the button action is done executing.
import Foundation
/*
Execute asynchronous tasks concurrently until reaching a given 'max' number.
Tasks queued while there is already a 'max' number of concurrent tasks are silently discarded.
Usage: ThrottledQueue(1).queueAction { finish in /* work */ finish() }
*/
struct ThrottledQueue
{
@-moz-document domain("safaribooksonline.com") {
.card-annotation .annotation-quote,
.resizer .draggable-containment-wrapper:after,
.resizer .draggable-containment-wrapper:before,
body.video,
#lesson-fragment,
#sbo-rt-content
{
font-family: sans-serif !important;
}
@janodev
janodev / semaphore.swift
Last active June 4, 2016 21:37
Mutex built on dispatch_semaphore
import Foundation
// a mutex built on a semaphore
// see http://www.cocoawithlove.com/blog/2016/06/02/threads-and-mutexes.html
struct DispatchSemaphore {
let s = dispatch_semaphore_create(1)
func sync<R>(@noescape f: () throws -> R) rethrows -> R {
_ = dispatch_semaphore_wait(s, DISPATCH_TIME_FOREVER)
defer { _ = dispatch_semaphore_signal(s) }
return try f()
find . -type f -a ! -name ".DS_Store" -exec shasum '{}' \; > shasums.txt
shasum -c < shasums.txt > check.txt
cat check.txt | fgrep -v OK
// BASIC SWITCH
enum Media { case Book }
extension Media : CustomStringConvertible
{
var description: String {
switch self {
case .Book: return "bible"
}
@janodev
janodev / gist:62849315b65590916f7d5d30cb31b9a6
Created July 29, 2016 10:18 — forked from reiz/gist:d67512deee814705134e
Vagrantfile for a Java dev. environment with Oracle Java 8 and Eclipse.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
@janodev
janodev / install.sh
Created August 3, 2016 10:11
Install El Capitan on a Virtual Box image
#!/bin/bash
# Mount the Installer image
hdiutil attach /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
# Create El Capitan sparseimage of 7316mb with a Single Partition - Apple Partition Map
hdiutil create -o /tmp/ElCapitan -size 7316m -layout SPUD -fs HFS+J -type SPARSE
# Mount the El Capitan sparseimage
hdiutil attach /tmp/ElCapitan.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build