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
@agatkamazur
agatkamazur / sortable_handle.js
Created September 8, 2011 05:12
sortable handle
$("#lista ").sortable(handle: "li a");
@nobuh
nobuh / readdir.js
Created September 14, 2011 06:58
readdir - node.js readdir sample
var fs = require('fs');
fs.readdir( process.argv[2], function (err, files) {
if (!err)
console.log(files);
else
throw err;
});
console.log("Fired callback.");
@adrianbravo
adrianbravo / encrypt-decrypt.js
Created September 22, 2011 00:08
Basic Node.js crypto cipher/decipher example.
var crypto = require('crypto')
, key = 'salt_from_the_user_document'
, plaintext = 'password'
, cipher = crypto.createCipher('aes-256-cbc', key)
, decipher = crypto.createDecipher('aes-256-cbc', key);
cipher.update(plaintext, 'utf8', 'base64');
var encryptedPassword = cipher.final('base64')
decipher.update(encryptedPassword, 'base64', 'utf8');
@ericnkatz
ericnkatz / facebook-like-check.php
Last active September 27, 2015 11:27
Check if person "Likes" the facebook page.
<?php
/*
* Check to see if a person likes the current facebook page.
*/
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["page"]["liked"])) {
@MasterEx
MasterEx / id.php
Created October 9, 2011 00:27
PHP - insert unique identifier to file - steganography
<?php
function sendfile($file,$identifier,$id_length) {
if (file_exists($file)) {
$filesize = filesize($file)+$id_length;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');

Sample PHP+Mongo app on Heroku

  1. Install any of the Mongo add-ons available at http://addons.heroku.com

  2. Vendor the Mongo driver with your application. You can download it here:

    https://github.com/wuputah/heroku-libraries/raw/master/php/mongo/mongo.so
    

    Add it to a folder like "ext".

@jankuca
jankuca / example.js
Created November 12, 2011 16:40
gzip for native node.js http.Server
var http = require('http');
var gzip = require('http-gzip');
var server = http.createServer(function (req, res) {
gzip(req, res);
res.writeHead(200, {
'content-type': 'text/plain'
});
res.write('I am gonna be gzip encoded, dude!');
@wilsonpage
wilsonpage / reqUrl.js
Created November 25, 2011 14:38
A function I made that wraps the node http.request function to make it a little more friendly. In my case I am using it for API route testing.
// module dependencies
var http = require('http'),
url = require('url');
/**
* UrlReq - Wraps the http.request function making it nice for unit testing APIs.
*
* @param {string} reqUrl The required url in any form
* @param {object} options An options object (this is optional)
@tj
tj / app.js
Created December 17, 2011 23:15
express 3.x cookie session middleware example
var express = require('express')
, cookieSessions = require('./cookie-sessions');
var app = express();
app.use(express.cookieParser('manny is cool'));
app.use(cookieSessions('sid'));
app.get('/', function(req, res){
req.session.count = req.session.count || 0;
@Fandora
Fandora / MVC or not-MVC.js
Created December 19, 2011 03:25
MVC or not-MVC
app.post("/api/upload-picture", function(req, res) {
if(!req.session.signined) {
throw new BadRequest("signin first");
}
if(!req.files.picture) {
throw new BadRequest("illegal file element name");
}
var h = new UploadPictureHandler(req, res);
h.run();
});