🏳️🌈
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passport.use(new LocalStrategy( | |
function(username, password, done) { | |
if (username.indexOf('@') == -1) { | |
username = username + '@example.com'; | |
} | |
User.findOne({ 'email': username.toLowerCase()}, function(err, user) { | |
if (err) { return done(err); } | |
if (!user) { | |
var error = new Error('User not found or wrong Credentials'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function postLogin(req, res, next){ | |
req.assert('username', 'username is required').notEmpty(); | |
req.assert('password', 'password is required').notEmpty(); | |
var username = (req.body.username)? req.body.username: ''; | |
var password = (req.body.password)? req.body.password: ''; | |
var errors = req.validationErrors(true); | |
if (errors) { | |
res.render('login.jade', {locals: { title: 'Login Error', username: username, password: password, errors: errors}}); | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://jsperf.com/in-vs-hasownproperty-vs-has/2 | |
fs = require('fs') | |
_ = require('lodash') | |
async = require('async') | |
nodehun = require('nodehun') | |
redis = require("redis") | |
cache = redis.createClient() | |
affbuf = fs.readFileSync('/Users/marcbachmann/Desktop/de-NZZ.aff'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongodb_url = require('../../config').get('mongodb:url') | |
MongoClient = require('mongodb').MongoClient | |
exports.db = null | |
exports.connect = (callback) -> | |
exports.client = new MongoClient() | |
MongoClient.connect mongodb_url, (err, db) -> | |
return callback(err) if err | |
exports.db = db | |
return callback(null, db) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db = require('knex')(yourConfig) | |
Migration = require('../../lib/db').Migration | |
upgrade = new Migration(db) | |
upgrade.createTable 'documents', (t) -> | |
t.uuid('id') | |
t.text('title') | |
upgrade.createTable 'users', (t) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM elasticsearch | |
RUN sed -i.bak -e "s|^varname:.*$|varname: \"value"|;" /data/elasticsearch.yml | |
RUN plugin -i elasticsearch/marvel/latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Preferences" to activate | |
tell application "System Events" | |
get properties | |
tell application "System Preferences" | |
reveal anchor "output" of pane id "com.apple.preference.sound" | |
end tell | |
tell process "System Preferences" | |
set theRows to every row of table 1 of scroll area 1 of ¬ | |
tab group 1 of window "sound" | |
repeat with aRow in theRows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on https://gist.github.com/2206527 | |
echo -e "Backup MySQL Databases to S3" | |
# Basic variables | |
host="localhost" | |
mysqlpass="rootpass" | |
bucket="s3://bucketname" | |
accesskey="awsaccesskey" | |
secretkey="awssecretkey" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ = require('lodash') | |
module.exports = | |
populate = (mapName, fromCollection, toCollection, fromId, toId='id') -> | |
indexed = _.indexBy(toCollection, toId) | |
for doc in fromCollection || [] | |
doc[mapName] = indexed[doc[revision_id]] | |
docs = [ |
OlderNewer