Skip to content

Instantly share code, notes, and snippets.

View eyvoro's full-sized avatar
🏠
Working from home

eyvoro

🏠
Working from home
View GitHub Profile
@rduplain
rduplain / README.rst
Created February 13, 2011 05:21
Demonstrate use of fixture with Flask-SQLAlchemy and Flask-Testing.

Demonstrate use of fixture with Flask-SQLAlchemy and Flask-Testing. February 13, 2011 Ron DuPlain <[email protected]>

Post any feedback to: [email protected]

Get this gist:

git clone git://gist.github.com/824472.git Flask-SQLAlchemy-Fixture
cd Flask-SQLAlchemy-Fixture
@FSX
FSX / async_psycopg2.py
Created March 8, 2011 22:11
A module for asynchronous PostgreSQL queries in Tornado.
#!/usr/bin/env python
__author__ = 'Frank Smit <[email protected]>'
__version__ = '0.1.0'
import functools
import psycopg2
from tornado.ioloop import IOLoop, PeriodicCallback
@evansd
evansd / heapqutils.py
Created May 17, 2011 17:18
Some useful iterator functions
# For more explanation and usage examples, see:
# http://www.drhevans.com/blog/posts/331-comparing-large-data-sets-in-python/
from itertools import imap, izip, count, repeat, tee
import heapq
def full_outer_join(*iterables, **kwargs):
"""
Perform a full outer join on a sequence of sorted iterables, where the
key function supplies the join condition.
@bryanchow
bryanchow / middleware.py
Created June 20, 2011 06:08
Django SSL Redirect Middleware - Django middleware for automatically redirecting to HTTPS for specific URLs
# https://gist.github.com/1035190
# See also: Snippets 85, 240, 880 at http://www.djangosnippets.org/
#
# Minimally, the following settings are required:
#
# SSL_ENABLED = True
# SSL_URLS = (
# r'^/some/pattern/',
# )
@balupton
balupton / ajaxify-html5-native.js
Created August 15, 2011 06:38
Ajaxify a Website with the HTML5 History API, jQuery and ScrollTo
// https://gist.github.com/1145804
(function(window,undefined){
// Prepare our Variables
var
history = window.history,
$ = window.jQuery,
document = window.document;
// Check to see if the HTML5 History API is enabled for our Browser
@biesnecker
biesnecker / ScalaJetty.scala
Created August 17, 2011 23:17
Main method
package com.biesnecker.scalajetty
import cc.spray._
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.xml.XmlConfiguration
import org.eclipse.jetty.webapp.WebAppContext
import java.io.File
object ScalaJetty {
@scribu
scribu / wp.tidy
Created August 29, 2011 16:51
CSSTidy format for WordPress CSS
| {
|| {|
| |;|
}|
|
}
|||
|

JavaScript Class Syntax

Let's build a JavaScript class syntax from first principles. For the purpose of this exercise, let's assume that the purpose of the class syntax is to add much-needed sugar to common JavaScript idioms.

Let's start with how JavaScript "classes" work today:

// this is a constructor
Person = function() {
 this // `this` is a new instance of Person
@rduplain
rduplain / app.py
Created November 10, 2011 15:44
Customize Flask to select a template based on some criteria.
"Customize Flask to select a template based on some criteria."
import os
from flask import Flask, request, render_template
from flask.helpers import locked_cached_property
from jinja2 import FileSystemLoader, TemplateNotFound
# Import a detection utility from your project, not defined here.
# Takes a request object and returns True if browser is mobile.
@retronym
retronym / config.scala
Last active May 9, 2018 05:47
Styles of config propagation: Manual, Implicits, DynamicVariable, Reader
package scalaz.example
object Reader extends App {
/**
* Manual propagation of the environment (in the example, `contextRoot`.)
*/
object Config0 {
def fragment1(contextRoot: String) = <a href={contextRoot + "/foo"}>foo</a>