Skip to content

Instantly share code, notes, and snippets.

@pablasso
pablasso / gist:4163042
Created November 28, 2012 18:22
Callback
io.sockets.on('connection', function(socket){
console.log('client just connected');
socket.emit('joined', {message:'client just connected'});
socket.on('getCities', function(data, callback){
console.log('getCities');
callback([{name:'city 1'}, {name:'city 2'}]);
});
});
(function(j,l){var g=typeof"",i=typeof undefined,c=typeof function(){},d=typeof{},h=function(o,n){return typeof o===n},a=function(n){return h(n,g)},e=function(n){return h(n,i)},b=function(n){return h(n,c)},m=function(n){return h(n,d)},k=function(n){return typeof HTMLElement==="object"?n instanceof HTMLElement:typeof n==="object"&&n.nodeType===1&&typeof n.nodeName==="string"},f=function(H){var E={MooTools:"$$",Prototype:"$$",jQuery:"*"},w=0,s="SCI-",x={},t=H||"simpleCart",J={},C={},u={},F=j.localStorage,B=j.console||{msgs:[],log:function(L){B.msgs.push(L)}},z="value",I="text",K="html",y="click",D={USD:{code:"USD",symbol:"$",name:"US Dollar"},AUD:{code:"AUD",symbol:"$",name:"Australian Dollar"},BRL:{code:"BRL",symbol:"R$",name:"Brazilian Real"},CAD:{code:"CAD",symbol:"$",name:"Canadian Dollar"},CZK:{code:"CZK",symbol:" Kč",name:"Czech Koruna",after:true},DKK:{code:"DKK",symbol:"DKK ",name:"Danish Krone"},EUR:{code:"EUR",symbol:"€",name:"Euro"},HKD:{code:"HKD",symbol:"&#36
@pablasso
pablasso / Macros.h
Last active October 13, 2015 07:07
I usually import this on my prefix.pch
// by Marcus Zarra
#ifdef DEBUG
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
#define DLog(...) do { } while (0)
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
@pablasso
pablasso / gsl.rb
Created November 1, 2012 18:06
GSL
require 'formula'
class Gsl < Formula
url 'http://ftp.gnu.org/gnu/gsl/gsl-1.14.tar.gz'
mirror 'http://ftpmirror.gnu.org/gsl/gsl-1.14.tar.gz'
homepage 'http://www.gnu.org/software/gsl/'
md5 'd55e7b141815412a072a3f0e12442042'
option :universal
def install
@pablasso
pablasso / test.rb
Created October 24, 2012 22:32
Net::FTP and UTF-8
# encoding: UTF-8
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
require 'net/ftp'
require 'debugger'
require 'fileutils'
module Net
class FTP
def storbinary(cmd, file, blocksize, rest_offset = nil, &block) # :yield: data
@pablasso
pablasso / gist:3164957
Created July 23, 2012 17:46
users on linux
useradd -d /home/user -s /bin/bash -m user
usermod -a -G group user
@pablasso
pablasso / gist:2649434
Created May 9, 2012 22:38
Growl notify on current song played on iTunes
tell application "Growl"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to {"iTunes Playing Track"}
-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the growl prefpane.
set the enabledNotificationsList to {"iTunes Playing Track"}
-- Register our script with growl.
@pablasso
pablasso / gist:2415016
Created April 18, 2012 16:59
Copy an UIView by archiving and unarchiving
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:originalView];
UIView *viewCopy = [NSKeyedUnarchiver unarchiveObjectWithData:archivedData];
@pablasso
pablasso / gist:2212624
Created March 27, 2012 04:51
Add all files with the "@" character to subversion. AKA subversion sucks.
svn status | grep "^?" | awk '{print $2}' | xargs -I {} svn add {}@
@pablasso
pablasso / gist:2159752
Created March 22, 2012 17:05
Filling a UITableView
// to fill a table you need to implement the protocol UITableViewDataSource in the Header and implement this //methods:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section