Skip to content

Instantly share code, notes, and snippets.

@xeoncross
xeoncross / aloha-config.js
Created September 12, 2012 15:24 — forked from evo42/aloha-config.js
Aloha Editor -- send content via ajax to a backend php script to save the data edited with Aloha Editor
( function ( window, undefined ) {
var Aloha = window.Aloha || ( window.Aloha = {} );
Aloha.settings = {
logLevels: { 'error': true, 'warn': true, 'info': true, 'debug': false, 'deprecated': true },
errorhandling: false,
ribbon: false,
locale: 'en',
floatingmenu: {
width: 630,
@markstreich
markstreich / gist:3667944
Created September 7, 2012 17:27
PhantomJS: Ajax response capture through console.log
var page = require('webpage').create();
page.open('http://www.website.com/', function (status) {
if (status === 'success') {
captureAjaxResponsesToConsole();
}
});
function captureAjaxResponsesToConsole() {
// logs ajax response contents to console so sublime's onConsoleMessage can use the contents
@rjz
rjz / cs-jq-plugin-template.coffee
Created September 3, 2012 17:01
Coffeescript jQuery Plugin Class Template
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->
@MoOx
MoOx / less2stylus.js
Created August 27, 2012 17:37 — forked from lancejpollard/less2stylus.coffee
Convert LESS to Stylus
// Usage : less2stylusDir('../src/css/');
var fs = require('fs');
// this less 2 stylus conversion script make a stylus easy to read syntax
// - let the braces
// - replace the @ for var as $
// - let semicolons
function less2stylus(less)
@HirotoKagotani
HirotoKagotani / my_fputcsv.php
Created August 22, 2012 05:44
Improved fputcsv() PHP function allowing to have $escape character parameter
<?php
// In order to solve the problem of a backslash followed by a double quote
// (https://bugs.php.net/bug.php?id=43225), I wrote a new function.
// This is compatible with fputcsv() except for the additional 5th argument $escape,
// which has the same meaning as that of fgetcsv().
// If you set it to '"' (double quote), every double quote is escaped by itself.
// The version I posted on http://php.net/manual/en/function.fputcsv.php has a little bug.
@xeoncross
xeoncross / index.php
Created July 19, 2012 17:16
MySQL database relations
<?php
require('relations.php');
$database = 'relations';
header('Content-Type: text/plain; charset="UTF-8"');
$relations = relations($database);
@sgmurphy
sgmurphy / url_slug.php
Created July 12, 2012 15:52
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@dheerajrajagopal
dheerajrajagopal / WeightedPageRank.py
Created June 12, 2012 05:51
Weighted PageRank Python (PageRank courtesy: diogojc)
import numpy as np
from scipy.sparse import csc_matrix
import random
def column(matrix, i):
return [row[i] for row in matrix]
def pageRank(G, s = 0.85, maxerr = .001):
"""
Computes the pagerank for each of the n states.
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@bhenerey
bhenerey / ideal ops.md
Created May 23, 2012 19:40
ideal ops checklist

In a perfect world, where things are done well, not just quickly, I would expect to find the following when joining the company:

Documentation

  • Accurate / up-to-date systems architecture diagram

  • Accurate / up-to-date network diagram

  • Out-of-hours support plan

  • Incident management plan