🏳️🌈
This file contains 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
var fs = require('fs') | |
var _ = require('lodash') | |
var async = require('async') | |
var GitHubApi = require('github') | |
// Token from your settings page on github | |
var token = 'YOURGITHUBTOKEN' | |
// Repository to migrate | |
var owner = 'upfrontIO' |
This file contains 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
#!/usr/bin/env node | |
// Embed semver module to make this script completely independent | |
// minified semver@5.1.0 | |
// https://github.com/npm/node-semver | |
var semver={};!function(r){function e(r,e){if(r instanceof i)return r;if("string"!=typeof r)return null;if(r.length>L)return null;var t=e?F[pr]:F[ar];if(!t.test(r))return null;try{return new i(r,e)}catch(n){return null}}function t(r,t){var n=e(r,t);return n?n.version:null}function n(r,t){var n=e(r.trim().replace(/^[=v]+/,""),t);return n?n.version:null}function i(r,e){if(r instanceof i){if(r.loose===e)return r;r=r.version}else if("string"!=typeof r)throw new TypeError("Invalid Version: "+r);if(r.length>L)throw new TypeError("version is longer than "+L+" characters");if(!(this instanceof i))return new i(r,e);B("SemVer",r,e),this.loose=e;var t=r.trim().match(e?F[pr]:F[ar]);if(!t)throw new TypeError("Invalid Version: "+r);if(this.raw=r,this.major=+t[1],this.minor=+t[2],this.patch=+t[3],this.major>U||this.major<0)throw new TypeError("Invalid major version");if(this.m |
This file contains 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 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 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 = [ |
This file contains 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 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 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 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 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'); |
NewerOlder