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 python3 | |
import asyncio | |
import iterm2 | |
THEME_LIGHT = "serendipity-light-iTerm2" | |
THEME_DARK = "serendipity-dark-iTerm2" | |
class AutoSwitchTheme: |
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
# Use Let's Encrypt certbot to order a free certificate | |
certbot certonly --non-interactive --manual \ | |
--manual-auth-hook "./auth-hook.sh UPSERT your_domain.com" \ | |
--manual-cleanup-hook "./auth-hook.sh DELETE your_domain.com" \ | |
--preferred-challenge dns \ | |
--config-dir "./letsencrypt" \ | |
--work-dir "./letsencrypt" \ | |
--logs-dir "./letsencrypt" \ | |
--agree-tos \ | |
--manual-public-ip-logging-ok \ |
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
// here i'm thinking i needed to use `reduce` twice for some reason | |
const perms = (str) => { | |
const words = str.split(' ') | |
return words.reduce((p, _, i) => { | |
return p.concat([words.reduce((s, word, j) => { | |
return j >= i ? s + ` ${word}` : s | |
}, '').trim()]) | |
}, []) | |
} |
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
// @flow | |
import express from 'express' | |
import myRoute from './myroute' | |
const app = express() | |
app.use('/my-route', myRoute()) |
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 views = require('co-views') | |
var merge = require('deepmerge') | |
var path = require('path') | |
module.exports = function () { | |
return function *(next) { | |
var render = views(path.join(__dirname, './../'), {default: 'jade'}) | |
this.render = function *(file, locals) { | |
var seg = file.split('/') | |
return yield render(path.join('/modules', seg[0], '/views', seg[1]), merge(locals || {}, this.locals)) |
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 mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, async = require('async') | |
, _ = require('underscore') | |
, bcrypt = require('bcrypt'); | |
var UserSchema = new Schema(require('./schema')); | |
UserSchema.pre('save', function (next) { | |
var user = this; |
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
### Keybase proof | |
I hereby claim: | |
* I am artcommacode on github. | |
* I am artcommacode (https://keybase.io/artcommacode) on keybase. | |
* I have a public key whose fingerprint is F8BA 239B 18CB DB19 F8EC 3BF0 E267 820A EDC7 4FA8 | |
To claim this, I am signing this object: |
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 express = require('express') | |
, admin = require('./admin/app') | |
, client = require('./client/app') | |
, app = module.exports = express(); | |
app.use('/admin', admin); | |
app.use(client); | |
app.listen(3009); |
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
sUser.pre('save', co(function *(next) { | |
if (!this.isModified('password')) return next(); | |
this.password = yield this.encryptPassword(this.password) | |
return next() | |
})) | |
sUser.methods.encryptPassword = function *(password) { | |
var salt = yield thunkify(bcrypt.genSalt)(10) | |
return yield thunkify(bcrypt.hash)(password, salt, null) | |
} |
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
// first | |
// render is set on this in app.use(), vPath (view path) is set at top of file | |
// locals sit in `this.locals` and can be easily merged | |
this.body = yield this.render(vPath + 'index', {users: users}) | |
// second | |
// render is required at the top of the file with the view path, | |
// need to pass in `this` to merge `this.locals` | |
this.body = yield render.call(this, 'index', {users: users}) |
NewerOlder