Skip to content

Instantly share code, notes, and snippets.

Avatar

j youngblood hxgf

View GitHub Profile
@mollerse
mollerse / gulpfile-express.js
Last active Mar 28, 2021
Gulpfile for livereload + static server
View gulpfile-express.js
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 Aug 15, 2012
Basic express and mongoose CRUD application
View app.js
/**
* 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
US State Names & Abbreviations as PHP Arrays
View us-state-names-abbrevs.php
<?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 Dec 1, 2011
Node.js performance tips
View BinaryModules.js
// Use built in or binary modules
var crypto = require('crypto');
var hash = crypto.createHmac("sha1",key).update(signatureBase).digest("base64");
@jas-
jas- / _salt()
Created Jun 21, 2011
PHP salter
View _salt()
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 Jun 10, 2011
Django's password hashing ported to PHP
View hash_password.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
ExpressJS: set/delete cookies
View app.js
// 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());