Skip to content

Instantly share code, notes, and snippets.

View MechanisM's full-sized avatar
💩

Eugene MechanisM MechanisM

💩
  • MechanisM
  • Vancouver, BC, Canada
View GitHub Profile
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
import redis
from django.conf import settings
from django.core.signals import request_finished
try:
from eventlet.corolocal import local
except ImportError:
from threading import local
"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.
Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@jacobian
jacobian / authuser.md
Created March 30, 2012 00:35
Upgrading auth.User - the profile approach

Upgrading auth.User - the profile approach

This proposal presents a "middle ground" approach to improving and refactoring auth.User, based around a new concept of "profiles". These profiles provide the main customization hook for the user model, but the user model itself stays concrete and cannot be replaced.

I call it a middle ground because it doesn't go as far as refactoring the whole auth app -- a laudable goal, but one that I believe will ultimately take far too long -- but goes a bit further than just fixing the most egregious errors (username length, for example).

This proposal includes a fair number of design decisions -- you're reading the fifth or sixth draft. To keep things clear, the options have been pruned out and on the one I think is the "winner" is still there. But see the FAQ at the end for some discussion and justification of various choices.

The User model

@pix2D
pix2D / config.php
Created April 29, 2012 20:04
ActiveCollab 3 + NGINX + PHP-FPM + SSL + /public as document root
<?php
/**
* activeCollab configuration file
*/
define('ROOT', '/home/example/public_html/activecollab');
define('ROOT_URL', 'https://example.com');
define('URL_BASE', ROOT_URL . '/');
define('ASSETS_URL', ROOT_URL . '/assets');
@simoncoulton
simoncoulton / nginx-uwsgi-python3
Created May 7, 2012 04:39
Setting up Nginx, uWSGI & Python3
======================================
Setting up Nginx, uWSGI and Python3
======================================
First off, I'm traditionally a PHP developer, but am looking at moving across to Python. I really struggled to find decent documentation on how to get a server up and running for deploying Python web applications from the point of view of someone coming from PHP. The main problems I came across with documentation were:
1) Only showed you how to run the server for a single web application.
2) Only showed you how to configure the app, not the server it was running on.
My preferred workflow for development is by setting up a new VM in VMware Fusion and then forwarding through all requests to that VM via /etc/hosts. This might not be the optimal way to get things up and running, but it works for me.
@mrdoob
mrdoob / gist:3504382
Created August 28, 2012 21:09
Encoding png sequence + audio into a webm with good quality.
ffmpeg -r 24 -i sequence/%d.png -i audio.aif -g 120 -level 216 -profile 0 -qmax 42 -qmin 10 -rc_buf_aggressivity 0.95 -vb 2M video.webm
@addyosmani
addyosmani / cranium.js
Last active February 7, 2019 15:02
Cranium
/* Cranium MVC
* A minimalist MVC implementation written for
* demonstration purposes at my workshops
* http://addyosmani.com
* Copyright (c) 2012 Addy Osmani; Licensed MIT */
var Cranium = Cranium || {};
// Set DOM selection utility
@hatefulcrawdad
hatefulcrawdad / foundation4-grid.html
Created December 13, 2012 21:39
We've been going back and forth on how to best approach our grid for Foundation 4.0. We had a lot to consider since we're moving towards mobile-first with this release. After about 4 iterations, we wanted to post what we've got to get feedback from our beloved Scss community. This is the Scss version. From here we'll be building new semantic gri…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Foundation 4 Grid Test</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<!-- Disregard these styles, they are for giving rows and columns a temporary BG color for better visibility -->