Skip to content

Instantly share code, notes, and snippets.

@alyssaq
alyssaq / jsconfasia.md
Last active February 13, 2024 07:59
2013 jsconf.asia
@alyssaq
alyssaq / ghpages-sync-master.md
Last active December 30, 2015 11:18
Sync gh-pages with master
git push -f origin master:gh-pages

Automated way:
Add the following 2 lines to the [remote "origin"] section of .git/config:

push = +refs/heads/master:refs/heads/gh-pages
push = +refs/heads/master:refs/heads/master

Now when you do:

@alyssaq
alyssaq / gist:8415699
Created January 14, 2014 09:36
Macbook Pro Envrionment
Sublime
https://github.com/revolunet/sublimetext-markdown-preview
@alyssaq
alyssaq / inheritance.md
Last active February 13, 2024 07:58
Javascript Inheritance
function Animal(name) {
  this.name = name;
};
Animal.prototype.move = function(meters) {
  console.log(this.name+" moved "+meters+"m.");
};

function Snake() {
  Animal.apply(this, Array.prototype.slice.call(arguments));

};

@alyssaq
alyssaq / 3.3 Packages.md
Last active January 4, 2016 06:49
Installing and upgrading python

###pip3.3

  $ curl -O http://python-distribute.org/distribute_setup.py
  $ python3 distribute_setup.py
  $ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
  $ python3 get-pip.py
  $ rm get-pip.py
@alyssaq
alyssaq / dom-query.js
Last active February 13, 2024 07:58
DOM query
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6
window.$ = function(s) {
var c = {
'#': 'ById',
'.': 'sByClassName',
'@': 'sByName',
'=': 'sByTagName'}[s[0]];
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1))
};
@alyssaq
alyssaq / gist:9705672
Last active August 29, 2015 13:57
Setting up numpy, scipy
mkvirtualenv ml
pip install --upgrade setuptools
curl -o install_superpack.sh https://raw.github.com/fonnesbeck/ScipySuperpack/master/install_superpack.sh
sh install_superpack.sh
@alyssaq
alyssaq / install_superpack.sh
Last active August 29, 2015 13:57
install_superpack.sh
#!/bin/sh
PYTHON='/usr/bin/python'
GIT_FILENAME='git-1.7.7.3-intel-universal-snow-leopard'
GIT_VOLUME='/Volumes/Git 1.7.7.3 Snow Leopard Intel Universal/'
GFORTRAN='gcc-42-5666.3-darwin11.pkg'
SUDO='sudo'
BRANCH='master'
if [ -z "$VIRTUAL_ENV" ]; then
# Standard Python env
@alyssaq
alyssaq / multithreading.py
Created April 2, 2014 05:29
python multithreading
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Sample multithreading with bottle.py
Requirements: requests, bottle
To run:
$ python app.py
To post data, open another command shell and type:
@alyssaq
alyssaq / batch_add_mongodb.js
Last active February 13, 2024 07:58
Batch add Documents to Mongodb
var mongoose = require('mongoose');
var DATA = require('../data/dataSources');
var dataSourceSchema = new mongoose.Schema({
sourceid: {type: Number, index: true},
status: {type: String, default: 'active'},
name: String,
provider: {type: String, lowercase: true, default: 'google_adwords'},
updated: {type: Date, default: Date.now}
});