Skip to content

Instantly share code, notes, and snippets.

View normanzb's full-sized avatar
🛵
stay safe

Norm X normanzb

🛵
stay safe
  • Somewhere decentralised
  • London
  • 14:18 (UTC +01:00)
View GitHub Profile
@normanzb
normanzb / gist:4507630
Last active December 10, 2015 23:08
Putting methods on prototype always memory efficient? No, use case should be considered carefully when design.
rubbish = [];
// Method 1, Suppose be memory efficient
// because we reuse the 2 function instance on the prototype chain
var MethodOnProto = function(){
};
MethodOnProto.prototype.method1 = function(){
this.method2();
};
MethodOnProto.prototype.method2 = function(){
@normanzb
normanzb / gist:4982472
Created February 19, 2013 02:02
music seeker crash report
Process: MusicSeekerX [32987]
Path: /Applications/MusicSeekerX.app/Contents/MacOS/MusicSeekerX
Identifier: MusicSeekerX.MusicSeekerX
Version: 3.3 (3.3)
Code Type: X86-64 (Native)
Parent Process: launchd [260]
User ID: 501
Date/Time: 2013-02-19 10:00:26.911 +0800
OS Version: Mac OS X 10.8.2 (12C60)
@normanzb
normanzb / gist:5080456
Created March 4, 2013 06:44
gadget test
var g1 = new Gadget();
var Extended = Gadget.extend({
'hub/test': function(topic, arg){
assert.same(test_args, arg)
return [test_args.reverse()];
}
});
var e1 = new Extended();
@normanzb
normanzb / gist:7673817
Last active December 29, 2015 12:59
generate vanity bitcoin addr
!function(){
for(var i = 0; i < 66999;i++){
var key = new Bitcoin.ECKey(false);
var bitcoinAddress = key.getBitcoinAddress();
var privateKeyWif = key.getBitcoinWalletImportFormat();
var testkey = bitcoinAddress.toLowerCase();
if (
testkey.indexOf('norm') == 1 ||
testkey.indexOf('hongyu') == 1 ||
@normanzb
normanzb / gist:8674259
Created January 28, 2014 19:18
css facebook button
.btn-facebook
{
position: relative;
display: inline-block;
outline: 1px solid #29447e;
border-top: 1px solid #879ac0;
width: auto;
height: 38px;
padding: 0 14px 0 54px;
@normanzb
normanzb / validateEmail.js
Last active August 29, 2015 13:56
email format very loose check
function validateEmail(email) {
// The real RFC complain email format check will be something look like this
// http://ex-parrot.com/~pdw/Mail-RFC822-Address.html
// so let's make a very loose check here to let go most cases
if ( typeof email != "string" ) {
return false;
}
var pstAt = email.indexOf('@');
@normanzb
normanzb / appendParam.js
Last active August 29, 2015 13:56
Quick url parameter appending
function appendParam(url, param){
var parts = url.split(/\?([^#]*)#?/);
var host = parts.shift();
var hash = parts.pop();
var params = parts == 0 ? [] : parts.join('?').split('&');
params.push(param);
return host + '?' + params.join('&') + ((hash == null || hash == 0) ? '' : ('#' + hash));
};
#!/bin/bash
# Open iPhone Simulator on default location for XCode 4.3
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
# Open mobile safari
echo Open mobile safari on emulator and press return
read
# Plug debug to MobileSafari.app
@normanzb
normanzb / getLog.js
Last active August 29, 2015 13:57
function that returns logs on IOS 5 (use with the console shim i wrote)
window.getLogs = (function (){
var inner = function(){return ""};
require(['src/shim/console','src/differ'], function(console, differUtil){
var oldLogs = console.logs();
inner = function(){
var logs = console.logs();