Skip to content

Instantly share code, notes, and snippets.

View ilmsg's full-sized avatar
😍
love me love my bug

Eak Netpanya ilmsg

😍
love me love my bug
View GitHub Profile
@gobengo
gobengo / node-gchat.js
Created January 22, 2011 06:17
node.js-driven Google Chat bot
var xmpp = require('node-xmpp'),
secret = require('./secret'),
util = require('util');
var creds = {
jid: '[email protected]',
password: secret.pw, //string
};
var GChat = function(creds) {
@liangzan
liangzan / recursiveRemoveFiles.js
Created February 2, 2011 14:12
A Node.js script to remove all files in a directory recursively
var fs = require('fs')
, path = require('path')
, _ = require('underscore');
var rootPath = "/path/to/remove";
removeDirForce(rootPath);
// path should have trailing slash
function removeDirForce(dirPath) {
fs.readdir(dirPath, function(err, files) {
@powdahound
powdahound / hipchat_bot.js
Created April 25, 2011 18:35
Basic XMPP bot example for HipChat using node.js
// Basic XMPP bot example for HipChat using node.js
// To use:
// 1. Set config variables
// 2. Run `node hipchat_bot.js`
// 3. Send a message like "!weather 94085" in the room with the bot
var request = require('request'); // github.com/mikeal/request
var sys = require('sys');
var util = require('util');
@mebens
mebens / camera.lua
Created May 8, 2011 20:52
Example code for part 3 of my Cameras in Love2D tutorial series.
camera = {}
camera._x = 0
camera._y = 0
camera.scaleX = 1
camera.scaleY = 1
camera.rotation = 0
function camera:set()
love.graphics.push()
love.graphics.rotate(-self.rotation)
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt
@sugyan
sugyan / xmas.pl
Created June 7, 2011 07:40
npm xmas
#!/usr/bin/env perl
use strict;
use warnings;
use Encode 'encode_utf8';
my $s = ' ' . encode_utf8(pack 'U', 0x2605);
my $f = encode_utf8(pack 'U', 0xFF0F);
my $b = encode_utf8(pack 'U', 0xFF3C);
my $o = [ map { encode_utf8(pack 'U', $_) } (
0x0069, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@bradfitz
bradfitz / gist:1080626
Created July 13, 2011 16:05
Optional parameters in Go hack
// A cute hack demonstrating one (weird?) way of doing optional
// parameters in Go.
//
// Please don't write code like this. It is fun code, though.
//
// Output: (see it live at golang.org)
//
// I like cheese.
// Do you like cheese too?
// I DO!
@giudinvx
giudinvx / slideshare-downloader.sh
Last active November 17, 2022 01:00
Slideshare Downloader
#!/bin/bash
#-----------------------------------------------
# Modify 4/08/2018 by giudinvx
# Email giudinvx[at]gmail[dot]com
#-----------------------------------------------
# Author: Andrea Lazzarotto
# http://andrealazzarotto.com
# [email protected]
@MasterEx
MasterEx / Code.java
Created August 26, 2011 16:07
A source code encoder and a demonstration using it with PHP as a proof of concept
package coder;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;