Skip to content

Instantly share code, notes, and snippets.

@kennethkalmer
kennethkalmer / gist:278814
Created January 16, 2010 13:14
node.js SMTP Server
/*
smtpd.js is SMTP server written for node.js
MIT License
*/
var tcp = require('tcp');
var sys = require('sys');
@drewlesueur
drewlesueur / chrome.html
Created June 4, 2010 08:14
drag and drop files chrome
<!doctype html>
<html>
<head>
</head>
<body style="width:1000px; height: 1000px;">
<h1>Drop</h1>
<script>
@drewlesueur
drewlesueur / php_automator.php
Created September 30, 2010 00:22
PHP Automater
<?php
//Use this script to automatically log into a site and grab protected info.
//code modified from
// http://www.knowledgesutra.com/forums/topic/38162-automatic-login-using-curl/
//see also
//http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
// INIT CURL
$ch = curl_init();
//needed for https
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
@drewlesueur
drewlesueur / CRUD-nodejs-mongodb.coffee
Created October 2, 2010 09:29
Mongo db crud example
#Examples of crud operations on node.js using node-mongodb-native (in coffeescript)
mongo = require("mongodb")
host = 'localhost'
port = mongo.Connection.DEFAULT_PORT
this.ObjectID = mongo.ObjectID
this.db = new mongo.Db 'mydb', new mongo.Server(host, port, {}), {}
@drewlesueur
drewlesueur / csv_to_array.php
Created November 17, 2010 03:42
Simple Csv parser for PHP <= 5.2
public static function csv_to_array($csv) {
if (substr($csv,-1) != "\n" && substr($csv,-1) != "\r") {
$csv .= "\n";
}
$len = strlen($csv);
$table = array();
$cur_row = array();
$cur_val = "";
$state = "first item";
@drewlesueur
drewlesueur / image_functions.php
Created November 17, 2010 03:42
Simple image manipulation functions for php
public static function resize_image($image, $w, $h) {
$ret = imagecreatetruecolor($w, $h);
imagealphablending( $ret, false );
imagesavealpha( $ret, true );
imagecopyresampled($ret, $image, 0, 0, 0, 0, $w, $h, imagesx($image), imagesy($image));
//imageantialias($ret,true);
return $ret;
}
public static function overlay_image($image, $overlay, $x, $y) {
@jashkenas
jashkenas / 1-adjacency.js
Created December 10, 2010 22:18
Snippet from Zepto.js, translated to CoffeeScript.
var adjacencyOperators = {
append: 'beforeEnd',
prepend: 'afterBegin',
before: 'beforeBegin',
after: 'afterEnd'
};
for (key in adjacencyOperators)
$.fn[key] = (function(operator) {
return function(html){
@orlin
orlin / undermix.coffee
Created December 15, 2010 18:59
underscore.js with strings and other mixins (a node.js module)
define (require, exports, module) ->
_ = require("underscore")
_.mixin require("underscore.string")
_.mixin
# Converts the arguments list to an Array
aToArr: (list) ->
if _.isArguments(list)
_.toArray(list).slice(0)
else
@olsonjeffery
olsonjeffery / gist:749108
Created December 20, 2010 22:21
issue with backbone + zepto in ff 3.6
The Error:
element["insertAdjacent" + (html instanceof Element ? "Element" : "HTML")] is not a function
http://localhost:8080/scripts/zepto.js
Line 145
the zepto.js is 5ecaa (HEAD of the zepto repo)
backbone.js is 261059 (HEAD of backbone's repo)
the stack looks like..
@dawsontoth
dawsontoth / InfiniteScrollableView.js
Created February 3, 2011 20:54
Infinite scrollable list.
/**
* We're going to create an infinite scrollable list. In this case, we're going to show a date. When you swipe left,
* you'll see yesterday. Then the day before yesterday, and so on. Swiping right shows you tomorrow, and so on.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Track where we are in the infinite scrollable views, and define how large of a step goes between each view.
*/
var currentDate = new Date(), msIntervalBetweenViews = 1000/*ms*/ * 60/*s*/ * 60/*m*/ * 24/*h*/;