Skip to content

Instantly share code, notes, and snippets.

@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) {
@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 / 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 / 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 / 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>
@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');