Skip to content

Instantly share code, notes, and snippets.

@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
@bhollis
bhollis / blog.js.coffee
Last active July 17, 2021 08:05
A simple, made-up example of the code for a simple AngularJS blog viewer as a more detailed exploration of http://benhollis.net/blog/2014/01/17/cleanly-declaring-angularjs-services-with-coffeescript/ . Yes, I know about `$resource`, but I prefer not to use it.
app = angular.module 'BlogExample', []
# Simple controller that loads all blog posts
app.controller 'BlogCtrl', ['$scope', 'Blog', ($scope, Blog) ->
# Get all the blog posts
Blog.all().then (posts) ->
$scope.posts = posts
# Extend the $scope with our own properties, all in one big block
# I like this because it looks like declaring a class.
@mollerse
mollerse / gulpfile-express.js
Last active March 28, 2021 20:07
Gulpfile for livereload + static server
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
@vojd
vojd / clj-libgdx.sh
Last active January 3, 2016 01:48
Creates a skeleton for using Clojure and libGDX. Usage: ``sh clj-libgdx.sh name_of_project``
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'Please give your project a name'
exit 0
fi
echo "Creating new clojure-project with libgdx"
git clone git@github.com:vojd/libgdx-skeleton-clj.git
cd libgdx-skeleton-clj
@mbostock
mbostock / .block
Last active March 2, 2024 12:15
Arc Tween
license: gpl-3.0
@gasman
gasman / pnginator.rb
Created April 30, 2012 18:08
pnginator: pack Javascript into a self-extracting PNG
#!/usr/bin/env ruby -w
# pnginator.rb: pack a .js file into a PNG image with an HTML payload;
# when saved with an .html extension and opened in a browser, the HTML extracts and executes
# the javascript.
# Usage: ruby pnginator.rb input.js output.png.html
# By Gasman <http://matt.west.co.tt/>
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos
from compressor.filters import CompilerFilter
class CoffeeCompilerFinder(staticfiles.finders.AppDirectoriesFinder):
"""
A quick hacked up staticfiles-finder that will automatically recompile .coffee files to .js and serve the .js file
It will respond to a request for /foo/bar/baz.js and if the coffee-file with the same name in that same dir is newer then
then js-file requested then the js-file will be recompiled.
I did this to not have to manually recompile my scripts or use the watcher and still be compatible with require.js
without have to change the code once i deploy with compiled js-files. it depends on django-compressor at the moment
but if you dont use that its just a small class to lift out from it.
@phpdude
phpdude / nginx.conf
Last active February 28, 2024 04:36
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@bohde
bohde / api.py
Created May 18, 2011 14:19
Example of ToMany resources in Django Tastypie
v1_api = Api(api_name='v1')
v1_api.register(BookResource())
# Intentionally left out PageResource
@pelletier
pelletier / fabfile.py
Created November 28, 2010 12:50
Deployment script for Python-based web applications which use Gunicorn following the Capistrano way.
"""
Thomas Pelletier's Python deployment script.
MIT Licensed.
We assume that:
* deploy.py lives in the root of your project.
* In the same directory, there is a dependencies.txt file, in PIP format.
* Remote host has a working Python+VENV+PIP environment.
* You have enough privileges.