Skip to content

Instantly share code, notes, and snippets.

View crapthings's full-sized avatar
😎
🇰🇵我们晚上去

crapthings crapthings

😎
🇰🇵我们晚上去
View GitHub Profile
var id = crypto.randomBytes(20).toString('hex');
//=> bb5dc8842ca31d4603d6aa11448d1654
var seed = crypto.randomBytes(20);
var id = crypto.createHash('sha1').update(seed).digest('hex');
//=> 06eb06693508052c950cf6d915e6f70a8419baac
//=> http://stackoverflow.com/questions/9407892/how-to-generate-random-sha1-hash-to-use-as-id-in-node-js
exports = @
@App = {}
App.login = App.signin = Meteor.loginWithPassword
App.logout = App.signout = Meteor.logout
App.isLoggedIn = -> return true if Meteor.user()
class App.Collection
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
@crapthings
crapthings / gist:b7c74b81a672be8dd5a6
Last active April 5, 2016 17:09
linux cheat sheet
http://devo.ps/blog/troubleshooting-5minutes-on-a-yet-unknown-box/
http://devo.ps/blog/basic-setup-for-a-new-linux-server/
echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
netstat -plutn
iptables -F
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
#!/bin/bash
#
# Starts up a MongoDB replica set
#
# There is a lot of documentation about replica sets:
#
# http://docs.mongodb.org/manual/reference/replica-configuration/
# http://docs.mongodb.org/manual/administration/replica-sets/
#
# To read data from a SECONDARY, when in the client, use:
To have launchd start mongodb at login:
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod --config /usr/local/etc/mongod.conf
@crapthings
crapthings / gist:f49ab3b838b41555a8c8
Last active August 29, 2015 14:22
ubuntu lemp setup
https://collegetimes.co/lemp-server/
https://www.littlebizzy.com/nginx-configuration
https://www.littlebizzy.com/nginx-server-block
To have launchd start redis at login:
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
redis-server /usr/local/etc/redis.conf
==> Summary
🍺 /usr/local/Cellar/redis/3.0.3: 9 files, 892K
To have launchd start rethinkdb at login:
ln -sfv /usr/local/opt/rethinkdb/*.plist ~/Library/LaunchAgents
Then to load rethinkdb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.rethinkdb.plist
==> Summary
🍺 /usr/local/Cellar/rethinkdb/2.2.2: 6 files, 37.3M
WARNING: checksums are currently disabled for node.js v4.0 and later
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local/Cellar/nvm/0.30.1/versions/node/v5.4.0"
Run `npm config delete prefix` or `nvm use --delete-prefix v5.4.0` to unset it.