Skip to content

Instantly share code, notes, and snippets.

@LeZuse
LeZuse / function.js
Created May 7, 2012 23:31
JS Function.prototype.curry
function toArray(enum) {
return Array.prototype.slice.call(enum);
}
Function.prototype.curry = function() {
if (arguments.length<1) {
return this; //nothing to curry with - return function
}
var __method = this;
var args = toArray(arguments);
@LeZuse
LeZuse / uri.js
Created May 8, 2012 00:10 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@LeZuse
LeZuse / client.js
Created July 5, 2012 17:18 — forked from jankuca/client.js
OT in JS
var area = document.getElementById('area');
var buffer = [];
var position = 0;
var last_id = 1;
var last_length = 0;
var socket = io.connect('http://localhost:5000');
@LeZuse
LeZuse / gist:3101388
Created July 12, 2012 22:05
V8: stack trace
Error.stackTraceLimit = Infinity;
// Called before getting the stack property
Error.prepareStackTrace = function(e,s){
console.log(e,s);
};
// "Error" object
var a = {toString:function()
{
@LeZuse
LeZuse / compose.html
Created July 14, 2012 16:15
OT: compose
<html>
<head>
<title>testing</title>
</head>
<body>
<script type="text/javascript" src="compose.js"></script>
<div id="res"></div>
</body>
</html>
@LeZuse
LeZuse / gist:3112890
Created July 14, 2012 19:25
OT: apply operation
var apply_operation = function(content, op) {
var buffer = content.split('');
var cursor = 0;
op.forEach(function (action) {
if (action.retain) {
cursor += action.retain;
// console.log('retain', '+'+action.retain, buffer.join(''), cursor);
}
else if (action.insert) {
var args = [cursor, 0];
@LeZuse
LeZuse / js
Created September 5, 2012 21:11
Moon
var ApplicationController = function (users) {
this.$scope.current_user = users.index('identity').one();
};
ApplicationController.prototype.logout = function () {
delete this.$scope.current_user;
};
@LeZuse
LeZuse / wsgi.py
Created November 7, 2012 15:05
WSGI script with virtualenv activation with Django
"""
WSGI config for csshat project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
@LeZuse
LeZuse / wsgi.py
Created November 7, 2012 15:28
WSGI script with virtualenv activation with Flask
import os
import sys
# Install venv by `virtualenv --distribute venv`
# Then install depedencies: `source venv/bin/active`
# `pip install -r requirements.txt`
activate_this = '/var/www/apache/csshat.com/csshat.com/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
path = os.path.join(os.path.dirname(__file__), os.pardir)
@LeZuse
LeZuse / .vimrc
Created December 14, 2012 21:28
Vim config
" highlight
syntax on
" use utf8
set encoding=utf-8 nobomb
" identation plugin
filetype plugin indent on
" disable compat