Skip to content

Instantly share code, notes, and snippets.

View ydaniv's full-sized avatar

Yehonatan Daniv ydaniv

View GitHub Profile
@vicalejuri
vicalejuri / django-crossdomainxhr-middleware.py
Created June 5, 2010 17:47
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
try:
import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active June 18, 2024 18:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@ydaniv
ydaniv / supr.js
Created July 10, 2011 06:43
simple wrapper for the ES5 Object.create mechanism and a function that fetches overridden methods from the prototype chain.
/*
* Copyright (C) 2011 Yehonatan Daniv <maggotfish@gmail.com>
*
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
*
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*
* supr.js is a simple wrapper for the Object.create mechanism of ES5,
* to ease the creation of objects via the Create function.
@tellnes
tellnes / index.js
Created June 14, 2012 13:15
SVG Rasterizer service for Node.js
var connect = require('connect')
, exec = require('child_process').exec
, fs = require('fs')
, path = require('path')
, seaport = require('seaport')
// Detect tmp dir
var TMP_DIR = (function() {
var dirs = [process.env.TMP, '/tmp', process.cwd()]
@ydaniv
ydaniv / mozGetMatchedCSSRules.js
Created July 2, 2012 12:32
A Gecko only polyfill for Webkit's window.getMatchedCSSRules
// polyfill window.getMatchedCSSRules() in FireFox 6+
if ( typeof window.getMatchedCSSRules !== 'function' ) {
var ELEMENT_RE = /[\w-]+/g,
ID_RE = /#[\w-]+/g,
CLASS_RE = /\.[\w-]+/g,
ATTR_RE = /\[[^\]]+\]/g,
// :not() pseudo-class does not add to specificity, but its content does as if it was outside it
PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g,
PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g;
// convert an array-like object to array
@mikeric
mikeric / application.css
Last active December 9, 2022 03:48
Rivets.js todo list demo
.done {
opacity: 0.5;
text-decoration: line-through;
}
@magnetikonline
magnetikonline / precompresscssjswebfont.sh
Last active July 1, 2022 04:47
Recursively pre-compress (gzip) CSS/JavaScript/webfont assets for use Nginx and its HttpGzipStaticModule module.
#!/bin/bash -e
function compressResource {
gzip --best --stdout "$1" >"$1.gz"
touch --no-create --reference="$1" "$1.gz"
echo "Compressed: $1 > $1.gz"
}
function main {
@bolshchikov
bolshchikov / case
Last active December 17, 2015 18:49
Live templates for JetBrains WebStrorm. The name of a gist is the registered abbreviation.
case '$STATEMENT$':
$END$
break;
@plentz
plentz / nginx.conf
Last active July 2, 2024 13:20
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
/*!
* jQuery JavaScript Library v2.1.1pre
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license