Skip to content

Instantly share code, notes, and snippets.

View zaaack's full-sized avatar
🏠
Working from home

Zack Young zaaack

🏠
Working from home
View GitHub Profile
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = seed ^ str.length;
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);
@gleicon
gleicon / zemitter.js
Created June 9, 2011 02:16
ZeroMQ and Node.js pub/sub emitter
// ZeroMQ PUB/SUB + Multicast (PGM) enabled event emitter for node.js
// gleicon - 2011
var util = require("util");
var events = require("events");
var zeromq = require("../node_modules/zeromq"); // check the right path
var sys = require("sys");
function DistEventEmitter(name, remote_node) {
events.EventEmitter.call(this);
@rtgibbons
rtgibbons / VBoxReloadKext.sh
Created March 12, 2012 19:51 — forked from timdream/VBoxReloadKext.sh
Script: reload VirtualBox kernel extension in Mac OS X
#!/bin/bash
unload() {
kextstat | grep "org.virtualbox.kext.VBoxUSB" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxUSB
kextstat | grep "org.virtualbox.kext.VBoxNetFlt" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
kextstat | grep "org.virtualbox.kext.VBoxNetAdp" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
kextstat | grep "org.virtualbox.kext.VBoxDrv" > /dev/null 2>&1 && sudo kextunload -b org.virtualbox.kext.VBoxDrv
}
load() {
@ufologist
ufologist / Base File.sublime-settings
Created May 16, 2013 09:14
Sublime Text User Preferences -- Eclipse shortcuts for Sublime Text
{
"alignment_chars" : ["=", ":"]
}
@netwjx
netwjx / autoproxy.md
Last active December 9, 2017 12:29
autoproxy rules

AutoProxy 代理规则

  • 查看
  • 修订版本

Posted in

  • AutoProxy
  • gfwList
  • Rule
@afternoon
afternoon / rename_js_files.sh
Created February 15, 2014 18:04
Rename .js files to .ts
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
@unhammer
unhammer / merlin-init.sh
Last active February 12, 2023 05:40
Create .merlin file for a project with all your ocamlfind packages and .opam sources in there
#!/bin/sh
if test -f .merlin; then
echo ".merlin already exists, bailing out ..." >&2
exit 1
else
# You could add your default EXT's and such to this list:
@famousgarkin
famousgarkin / powershell-proxy-set-clear.ps1
Last active July 24, 2024 17:04
PowerShell Set-Proxy, Clear-proxy
# NOTE: registry keys for IE 8, may vary for other versions
$regPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings'
function Clear-Proxy
{
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 0
Set-ItemProperty -Path $regPath -Name ProxyServer -Value ''
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value ''
[Environment]::SetEnvironmentVariable('http_proxy', $null, 'User')
@chenglou
chenglou / gist:34b155691a6f58091953
Last active February 6, 2025 01:08
Better feature for React key

key is pretty much crucial for state perservation in React. As of React 0.13 it can't do the following things:

  • Clone state
<Comp key={1} /><Comp key={1} />
  • Preserve component state across different parents:
//...
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
authorizations: {
someName: function() {
// This function will get called /before/ each request
// ... UNLESS you have a 'security' tag in the swagger.json file, in which case you must add 'someName' to the list of auths.
console.log('explore the request object...',this) // Take a look in the console tab to see what's available.
this.headers['x-swagger'] = 'value'; // Example header