Skip to content

Instantly share code, notes, and snippets.

View catalsdevelop's full-sized avatar
🏠
Working from home

Z.Liu catalsdevelop

🏠
Working from home
View GitHub Profile
@catalsdevelop
catalsdevelop / hero.ts
Created May 9, 2018 09:20 — forked from brennanMKE/hero.ts
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
@catalsdevelop
catalsdevelop / Middleware.js
Created May 8, 2018 21:56 — forked from unbug/Middleware.js
Powerful Javascript Middleware Pattern Implementation, apply middleweares to any object. https://unbug.github.io/js-middleware/
'use strict';
/* eslint-disable consistent-this */
let middlewareManagerHash = [];
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
@catalsdevelop
catalsdevelop / Middleware.js
Created May 8, 2018 21:56 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5 & ES6) Middleware Pattern Implementation
var Middleware = function() {};
Middleware.prototype.use = function(fn) {
var self = this;
this.go = (function(stack) {
return function(next) {
stack.call(self, function() {
fn.call(self, next.bind(self));
});
@catalsdevelop
catalsdevelop / steps.md
Created May 7, 2018 22:19 — forked from cgcardona/steps.md
Steps for running a Bitcoin Cash (ABC) node on digital ocean. Forked from these steps: https://medium.com/signal-chain-weekly/how-im-running-a-bitcoin-full-node-on-digital-ocean-for-40-a-month-dfc328ba9604

Setup

  1. Ubuntu 16.04.3 x64
  2. 2 GB Memory / 60 GB Disk
  3. 200 GB block storage volume

Create user

get ip-address from digital ocean

@catalsdevelop
catalsdevelop / uninstall-mono.sh
Created August 25, 2017 03:26 — forked from AgiosAndreas/uninstall-mono.sh
This script removes Mono from an OS X System. It must be run as root
#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-*
for dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do
(cd ${dir};
@catalsdevelop
catalsdevelop / Enhanced NGINX logstash parser
Created August 15, 2017 09:37 — forked from csamsel/Enhanced NGINX logstash parser
Enhanced NGINX logstash parser to include upstream response time and request length fields
Enhanced NGINX logstash parser:
NGINX log format:
log_format enhanced '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_length "$http_referer" "$http_user_agent" $request_time $upstream_response_time';
access_log /var/log/nginx/access.log enhanced;
error_log /var/log/nginx/error.log;
logstash pattern (/opt/logstash/pattern/nginx):
@catalsdevelop
catalsdevelop / Instructions.md
Created August 15, 2017 09:32 — forked from shreyaskarnik/Instructions.md
Route Docker Logs to ELK Stack
  • With Docker 1.8.0 shipped new log-driver for GELF via UDP, this means that the logs from Docker Container(s) can be shipped directly to the ELK stack for further analysis.
  • This tutorial will illustrate how to use the GELF log-driver with Docker engine.
  • Step 1: Setup ELK Stack:
    • docker run -d --name es elasticsearch
    • docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
    • Note the config for Logstash can be found at this link
    • docker run --link es:elasticsearch -d kibana
  • Once the ELK stack is up now let's fire up our nginx container which ships its logs to ELK stack.
  • LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
  • `docker run -d --net=host --log-driver=gelf --log-opt gelf-address=u
@catalsdevelop
catalsdevelop / gist:1809d2280b575959c2a448a4a9de5803
Created August 13, 2017 23:25 — forked from cdnsteve/gist:5396612
Node.js: Restify and Passport for FB
// Based off example code from Hal Robertson
// https://github.com/halrobertson/test-restify-passport-facebook
// See discussion: https://groups.google.com/forum/?fromgroups#!topic/passportjs/zCz0nXB_gao
var restify = require('restify')
// config vars
var FB_LOGIN_PATH = '/api/facebook_login'
var FB_CALLBACK_PATH = '/api/facebook_callback'
var FB_APPID = '<<YOUR APPID HERE>>'
@catalsdevelop
catalsdevelop / elixirphoenix.bash
Created July 9, 2017 12:18 — forked from likethesky/elixirphoenix.bash
Installing Elixir & the Phoenix framework with Homebrew on OS X
$ brew update && brew doctor # Repeat, until you've done *all* the Dr. has ordered!
$ brew install postgresql # You'll need postgres to do this... you may also need to 'initdb' as well. Google it.
$ brew install elixir
$ mix local.hex # Answer y to any Qs
$ createuser -d postgres # create the default 'postgres' user that Chris McCord seems to like -- I don't create mine w/a pw...
# Use the latest Phoenix from here: http://www.phoenixframework.org/docs/installation -- currently this is 1.0.3
# ** Answer y to any Qs **
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v1.0.3/phoenix_new-1.0.3.ez
@catalsdevelop
catalsdevelop / sequelize-schema-file-generator.js
Created July 6, 2017 02:20 — forked from ahelord/sequelize-schema-file-generator.js
Automatically generates migration files from your sequelize models
'use strict';
//////////////////////////////////
// How to use?
// 1. Create `sequelize-schema-file-generator.js` in your app root
// 2. Make sure you've ran the `sequelize init` before (It should create `config`,`seeders`,`migrations` folders).
// 3. Update `DATABASE_DSN` below to match your connection string (works with any database adapter that Sequelize supports)
// 4. Run it with `node sequelize-schema-file-generator.js`
// 5. Review the generated migrations inside of the `migrations` folder.
//////////////////////////////////