Skip to content

Instantly share code, notes, and snippets.

View tobsn's full-sized avatar

Tobsn tobsn

  • San Francisco/Diego, USA; Munich, Germany;
View GitHub Profile
@tobsn
tobsn / base
Created May 28, 2014 14:28
nginx - sub_filter replace head with the current folder as base href for sub project folder structure
View base
location / {
if ($uri ~* ^/([^.\?/]+)) {
set $foldername "$1";
}
sub_filter "<head>" "<head><base href=\"${scheme}://${host}/${foldername}/\">";
}
View states_boundingbox.json
{
"Mississippi": [30.1477890014648, 34.9960556030273, -91.6550140380859, -88.0980072021484],
"Oklahoma": [33.6191940307617, 37.0021362304688, -103.002571105957, -94.4312133789062],
"Delaware": [38.4511260986328, 39.8394355773926, -75.7890472412109, -74.9846343994141],
"Minnesota": [43.4994277954102, 49.3844909667969, -97.2392654418945, -89.4833831787109],
"Illinois": [36.9701309204102, 42.5083045959473, -91.513053894043, -87.0199203491211],
"Arkansas": [33.0041046142578, 36.4996032714844, -94.6178131103516, -89.6422424316406],
"New Mexico": [31.3323001861572, 37.0001411437988, -109.050178527832, -103.000862121582],
"Indiana": [37.7717399597168, 41.7613716125488, -88.0997085571289, -84.7845764160156],
"Louisiana": [28.9210300445557, 33.019458770752, -94.0431518554688, -88.817008972168],
View gist:304154
# Basic text search with relevancy for MongoDB.
# See http://blog.tty.nl/2010/02/08/simple-ranked-text-search-for-mongodb/
# Copythingie 2010 - Ward Bekker - ward@tty.nl
#create (or empty) a docs collection
doc_col = MongoMapper.connection.db('example_db').collection('docs')
doc_col.remove({})
#add some sample data
doc_col.insert({ "txt" => "it is what it is"})
View imageAsCropped
// Kosso imageAsCropped
// added to TiBlob.m
// requires 4 arguments : x, y, width, height
- (id)imageAsCropped:(id)args
{
[self ensureImageLoaded];
if (image!=nil)
{
ENSURE_ARG_COUNT(args,4);
View gist:665535
// modified version of https://github.com/pangratz/dnd-file-upload by pangratz
// modified by : kosso
// date : 06 November 2010
// added some options for:
// allowMultiple
// allowedExtensions
// maximumFileSize
// also added dragEnter and dragLeave functions to enable change of appearance of the dropzone
@3rd-Eden
3rd-Eden / detect.client.socket.io.js
Created April 5, 2011 08:20
Serverside client transport detection for Socket.io
View detect.client.socket.io.js
require.paths.unshift('/usr/local/lib/node/socket.io/lib/socket.io/transports');
var htmlfile = require('htmlfile')
, flashsocket = require('flashsocket')
, jsonppolling = require('jsonp-polling')
, websocket = require('websocket')
, xhrmultipart = require('xhr-multipart')
, xhrpolling = require('xhr-polling');
var http = require('http')
, io = require('socket.io');
@chjj
chjj / simple_request.js
Created May 19, 2011 22:46
simple request
View simple_request.js
var http = require('http')
, parse = require('url').parse
, StringDecoder = require('string_decoder').StringDecoder;
var LIMIT = 10 * 1024;
var request = function(url, body, func) {
if (typeof url !== 'object') {
url = parse(url);
}
@tobsn
tobsn / taffydb.capping.js
Created May 5, 2012 10:19
capping taffydb
View taffydb.capping.js
TAFFY.extend( 'capped', function( i, runInsert, runRemove ) {
var c = this.getDBI().cap || false;
if( c && ( c < ( this.count() + 1 ) ) ) {
while( c < ( this.count() + 1 ) ) {
this.getDBI().remove( this.context().results[0].___id );
this.context({
run: null
});
this.getDBI().removeCommit( runRemove );
}
@purwandi
purwandi / base.php
Created June 15, 2012 02:14
My Base Model for Laravel
View base.php
<?php
/**
* Base Model
*
* @package Extends Model Laravel
* @version 1.0
* @author Purwandi <free6300@gmail.com>
* @link http://purwand.me
*/
class Base extends Eloquent{
View gist:2983440
<?php
require 'vendor/autoload.php';
$loop = new React\EventLoop\StreamSelectLoop();
$app = function ($request, $response) use ($loop) {
$response->writeHead(200, []);
$fh = fopen('http://localhost/', 'r');