Skip to content

Instantly share code, notes, and snippets.

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

crapthings crapthings

😎
🇰🇵我们晚上去
View GitHub Profile
@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
@crapthings
crapthings / destructuring.js
Created December 21, 2016 07:34 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@crapthings
crapthings / lodash.mergeUnionByKey.sample.js
Last active January 20, 2017 05:47
this is a fn that i've used to merge object from arrays
import _ from 'lodash'
const test1 = [
{ name: 'zhanghong', age: 32, money: 0, size: 12, },
{ name: 'wanghong', age: 20, size: 6 },
{ name: 'jinhong', age: 16, height: 172 },
]
const test2 = [
{ name: 'zhanghong', gender: 'male', age: 14 },
import { compose } from 'react-komposer'
function RV(component, states) {
const localStates = {}
const localValues = {}
for (let state in states) {
localStates[state] = new ReactiveVar(states[state])
}
import utils from '/server/utils';
/* eslint-disable prefer-arrow-callback */
import { check, Match } from 'meteor/check';
import Collections from '../../lib/collections';
import cacheManager from '../cache.js';
import {checkIssueMembership} from '../../lib/is-member.js';
import _ from 'lodash';
const { Issues, Activities, Users, IssueMembers, Groups, Tags, Documents } = Collections;
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
wget https://nginx.org/keys/nginx_signing.key -O - | sudo apt-key add -
echo "deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
apt update
apt install -y build-essential python mongodb-org nginx
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
echo LANGUAGE=en_US.UTF-8 >> /etc/default/locale
echo LC_ALL=en_US.UTF-8 >> /etc/default/locale
apt update
apt install -y mdadm xfsprogs
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
const _ = require('lodash')
const faker = require('faker')
console.time('make data')
const seed = 20000
const authors = _.times(seed, n => ({
id: 'a' + n,
name: faker.name.findName(),
@crapthings
crapthings / is.js
Created January 11, 2018 04:10
check type
function isString(target) {
return isType(target, 'String')
}
function isNumber(target) {
return isType(target, 'Number')
}
function isDate(target) {
@crapthings
crapthings / find.children.js
Created January 11, 2018 04:12
find children in items by root as array
module.exports = function findChildren(root, items = [], opts = {}) {
const { rootKey, foreignKey, withRoot } = opts
const bypass = {}
let children = [root]
let nextItems = []
recurse()
if (!withRoot)
children.shift()
return children