Skip to content

Instantly share code, notes, and snippets.

View jyoungblood's full-sized avatar

Jonathan Youngblood jyoungblood

View GitHub Profile
@mollerse
mollerse / gulpfile-express.js
Last active March 28, 2021 20:07
Gulpfile for livereload + static server
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
@arvis
arvis / app.js
Created August 15, 2012 08:46
Basic express and mongoose CRUD application
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, mongoose = require('mongoose')
, path = require('path');
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@brikis98
brikis98 / BinaryModules.js
Created December 1, 2011 00:45
Node.js performance tips
// Use built in or binary modules
var crypto = require('crypto');
var hash = crypto.createHmac("sha1",key).update(signatureBase).digest("base64");
@jas-
jas- / _salt()
Created June 21, 2011 16:22
PHP salter
function _salt($string, $len=null)
{
return (!empty($len)) ?
hash('sha512', str_pad($string, (strlen($string) + $len),
substr(hash('sha512', $string),
round((float)strlen($string)/3, 0,
PHP_ROUND_HALF_UP),
($len - strlen($string))),
STR_PAD_BOTH)) :
hash('sha512', substr($string,
@staydecent
staydecent / hash_password.php
Created June 10, 2011 20:18
Django's password hashing ported to PHP
<?php
private function set_password($raw_password) {
/*
Sets the password to a string of random sha1 salt
and encrypted password.
Separated by '$'
*/
$salt = substr(sha1(genRandomString().genRandomString()), 0, 5);
$hash = sha1($salt.$raw_password);
@codepunkt
codepunkt / app.js
Created May 31, 2011 18:50
ExpressJS: set/delete cookies
// Dependencies.
var express = require('express')
app = module.exports = express.createServer(),
del = function(req, res) { res.clearCookie('login_token'); res.redirect('/'); },
set = function(req, res) { res.cookie('login_token', +new Date(), { maxAge: 3600000, path: '/' }); res.redirect('/'); };
// Config
app.configure(function() {
app.use(express.bodyParser());
app.use(express.cookieParser());