This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func swizzleReplacingCharacters() { | |
let originalMethod = class_getInstanceMethod( | |
NSString.self, #selector(NSString.replacingCharacters(in:with:))) | |
let swizzledMethod = class_getInstanceMethod( | |
NSString.self, #selector(NSString.swizzledReplacingCharacters(in:with:))) | |
guard let original = originalMethod, let swizzled = swizzledMethod else { | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(self) { | |
'use strict'; | |
if (self.fetch && self.fetch.hack) { | |
return | |
} | |
var TIMEOUT = 10000; | |
var support = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from commander import * | |
class TestCommander(unittest.TestCase): | |
def test_run(self): | |
r = run("ping", "localhost") | |
self.assertIsNone(r) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var semver = require('semver'); | |
var NwVersions = require('nw-builder/lib/versions'); | |
var nwDownloadUrl = 'http://dl.nwjs.io/'; | |
function findNwVersion(version) { | |
return new Promise(function(resolve, reject) { | |
NwVersions.getVersions(nwDownloadUrl) | |
.then(function(versions) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
import polydivisible | |
def ppoly(ab): | |
a,b = ab | |
polydivisible.main(["polydivisible",str(a),str(b)]) | |
def main(): | |
with Pool(4) as p: | |
bs = zip(range(26,51),range(26,51)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WriteManyInts where | |
import System.IO | |
import Control.Exception(bracket) | |
import qualified Data.Binary as Binary | |
import qualified Data.ByteString.Lazy as ByteString | |
writeManyInts name n | |
| n <= 0 = error "n <= 0" | |
| otherwise = bracket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
; | |
; Adds 'Open in Atom' to context menu (when you right click) in Windows Explorer. | |
; | |
; Based on https://github.com/Zren/atom-windows-context-menu. It didn't work | |
; https://github.com/Zren/atom-windows-context-menu/issues/1. | |
; | |
; Save this file to disk with a .reg extension. Replace C:\\Atom\\atom.exe with | |
; the path to the atom executable on your machine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
Given a string and a character, remove from the string all single occurrences | |
of the character, while retaining all multiple consecutive instances of the | |
character. For instance, given string “XabXXcdX”, removing singleton Xs | |
leaves the string “abXXcd”. | |
http://programmingpraxis.com/2014/06/06/remove-singleton/ | |
-} | |
{- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
http://programmingpraxis.com/2014/06/10/balanced-delimiters-2/ | |
Examples of strings that pass: {}, [], (), a(b)c, abc[d], a(b)c{d[e]} | |
Examples of strings that don’t pass: {], (], a(b]c, abc[d}, a(b)c{d[e}] | |
-} | |
import Control.Monad(foldM,mapM_) | |
isHead _ [] = False | |
isHead x xs = x == head xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sax = require("sax"), | |
strict = true, // set to false for html-mode | |
parser = sax.parser(strict); | |
parser.onerror = function (e) { | |
// an error happened. | |
console.log("error"); | |
console.log(e); | |
parser.resume(); | |
}; |