Skip to content

Instantly share code, notes, and snippets.

@jasonwyatt
jasonwyatt / MySingleton.js
Created July 26, 2011 15:09
Singleton Pattern with Require JS
define(function(){
var instance = null;
function MySingleton(){
if(instance !== null){
throw new Error("Cannot instantiate more than one MySingleton, use MySingleton.getInstance()");
}
this.initialize();
}
@darkseed
darkseed / Reachability.h
Created August 30, 2011 23:16 — forked from dhoerl/Reachability.h
Reachability (iOS) ARCified
/*
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Version: 2.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
@jewelsea
jewelsea / PopupExample.java
Created February 27, 2012 18:50
JavaFX Popup example
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Popup;
import javafx.stage.Stage;
@angelolloqui
angelolloqui / RKRequest+CacheControl.h
Created August 15, 2012 14:52
RestKit addition to add a new cache policy that checks the Cache-Control HTTP header
//
// RKRequest+CacheControl.h
//
// Created by Angel on 8/10/12.
// Copyright (c) 2012 Xaton. All rights reserved.
//
#import "RKRequest.h"
@benlodotcom
benlodotcom / ClearApplicationCache.m
Last active April 13, 2017 09:41
Methods to flush the HTML5 Application Cache on iOS. In a UIWebView Webkit uses an sqlite database to store the resources associated to a cache manifest, as there is no API yet to flush the Application Cache you can use this method which delete entries directly from the database. However, this approach could break anytime if the implementation o…
static NSString *cacheDatabaseName = @"ApplicationCache.db";
static NSString *cacheGroupTable = @"CacheGroups";
static NSString *cacheGroupTableManifestURLColums = @"manifestURL";
static NSString *cacheTable = @"Caches";
static NSString *cacheTableCacheGroupId = @"cacheGroup";
/**
Clears the cached resources associated to a cache group.
@param manifestURLs An array of `NSString` containing the URLs of the cache manifests for which you want to clear the resources.
@buzzdecafe
buzzdecafe / Functor.js
Last active October 18, 2023 07:28 — forked from CrossEye/Functor.js
(function(global) {
global.Functor = function(conf) {
Functor.types[conf.key] = {
obj: conf.obj,
fmap: conf.fmap
};
};
Functor.types = {};
(ns bowling_kata.core
(:use midje.sweet))
(defn strike [x & xs]
(when (= x 10)
[[10 (first xs) (second xs)] xs]))
(defn spare [x y & xs]
(when (= 10 (+ x y))
[[x y (first xs)] xs]))
@jonathandixon
jonathandixon / .gitignore
Last active January 5, 2021 22:01
Cordova CLI project .gitignore and helper script. Useful when you don't want to commit the platforms and plugins directories to version control. http://stackoverflow.com/q/17911204/417568
platforms/
plugins/
@magicshui
magicshui / tsji.py
Last active December 31, 2015 19:58
字数统计
#!/usr/bin/python
# -*- coding: utf-8 -*-
# 分别统计中文和英文的字数,不包括标点符号。
# Author: Pan Junyong from zopen.cn, panjy at zopen dot cn
import re
import sys
from types import StringType
import operator
import urllib2

Install cask that extends the brew command :

brew install phinze/cask/brew-cask

Install calibre using cask :

brew cask install calibre