Skip to content

Instantly share code, notes, and snippets.

View bebraw's full-sized avatar

Juho Vepsäläinen bebraw

View GitHub Profile
@stevenh512
stevenh512 / gitconfig-git
Created June 11, 2012 10:51
URL rewriting in .gitconfig
# Use git and git+ssh instead of https
[url "git://github.com/"]
insteadOf = https://github.com/
[url "[email protected]:"]
pushInsteadOf = "git://github.com/"
[url "[email protected]:"]
pushInsteadOf = "https://github.com/"
@mattpodwysocki
mattpodwysocki / main.html
Created September 13, 2012 05:16
RxJS + Require.JS
<!DOCTYPE html>
<html>
<head>
<title>RequireJS</title>
<script data-main="scripts/main" src="scripts/require.js"></script>
</head>
<body>
<div id="coordinates">0,0</div>
<div id="delta">0</div>
<ul id="buffer"></ul>
@jed
jed / rendering_templates_obsolete.md
Created October 19, 2012 05:07
Rendering templates obsolete

(tl;dr DOM builders like [domo][domo] trump HTML templates on the client.)

Like all web developers, I've used a lot of template engines. Like most, I've also written a few of them, some of which even [fit in a tweet][140].

The first open-source code I ever wrote was also one of the the first template engines for node.js, [a port][node-tmpl] of the mother of all JavaScript template engines, [John Resig][jresig]'s [micro-templates][tmpl]. Of course, these days you can't swing a dead cat without hitting a template engine; one in eight packages on npm ([2,220][npm templates] of 16,226 as of 10/19) involve templates.

John's implementation has since evolved and [lives on in Underscore.js][underscore], which means it's the default choice for templating in Backbone.js. And for a while, it's all I would ever use when building a client-side app.

But I can't really see the value in client-side HTML templates anymore.

@stantonk
stantonk / doit
Created November 15, 2012 22:46
Install python 2.7.3 on CentOS 5.8
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
yum groupinstall "Development tools"
yum install zlib-devel
yum install bzip2-devel openssl-devel ncurses-devel
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2
cd Python-2.7.3
@asalant
asalant / connectWithRetry.js
Created November 17, 2012 01:24
Retry connecting to mongo if initial connect fails
var mongoose = require('mongoose')
var mongoUrl = "mongodb://localhost:27017/test"
var connectWithRetry = function() {
return mongoose.connect(mongoUrl, function(err) {
if (err) {
console.error('Failed to connect to mongo on startup - retrying in 5 sec', err);
setTimeout(connectWithRetry, 5000);
}
});
@jwcobb
jwcobb / Install MAPP stack on Mavericks using MacPorts.md
Last active March 15, 2018 14:50
Install MAPP/MAMP stack on OS X Mavericks using MacPorts.

Install MAPP (MAMP) stack on Mavericks using MacPorts

I keep most of my Apache/PHP/Percona (MySQL) configuration stuff in a local Git repository so I can track changes and I symlink to those from where they should be so you will see commands such as

 sudo ln -s ~/Documents/configs/PHP/fat-tony.local/php55.ini /opt/local/etc/php55/php.ini 

If you don’t have a similar setup, just copy your configuration files to where they need to be.

I like to prepend some of the commands with time just for curiosity’s sake to see how long it takes.

@ericzou
ericzou / bootstrap_angular_js_manually.js
Created December 29, 2012 17:51
Manually bootstrap Angular JS
window.onload = function() {
var $rootElement = angular.element(window.document);
var modules = ['ng', 'myApp', function($provide) {
$provide.value('$rootElement', $rootElement);
}];
var $injector = angular.injector(modules);
var $compile = $injector.get('$compile');
var compositeLinkFn = $compile($rootElement);
@josdejong
josdejong / gist:4537647
Last active September 27, 2022 22:55
String interpolation method for underscore.js.
/*
String interpolation method for underscore.js
Usage:
var props = {
first: 'Jos',
last: 'de Jong'
};
var message = _.interpolate('Hello $first $last, welcome!', props);
@thejhh
thejhh / test.js
Last active December 11, 2015 20:28
Building equations for multiple systems from JavaScript presentation by calling a function
"use strict";
/** Query builder */
function build_query(type, schema) {
// Metadata for builder
var _converters = {
js:{
or: function(x, y) { return '(' + x + ') || (' + y + ')'; },
and: function(x, y) { return '(' + x + ') && (' + y + ')'; },