Skip to content

Instantly share code, notes, and snippets.

View ptgamr's full-sized avatar

Anh Trinh ptgamr

View GitHub Profile
#! /usr/bin/node
var MongoClient = require('mongodb').MongoClient
var Server = require('mongodb').Server;
var async = require('async');
var util = require('util');
// A simple linear congruence random number generator.
// This is anticipating doing a comparable test with the aggregation pipeline.
var randMod = 2 << 24;
@ptgamr
ptgamr / fixup-istvan.js
Created June 5, 2015 05:26
fixup-istvan
(function(){
'use strict';
function mdDataTableDirective($compile){
return {
restrict: 'E',
templateUrl: '/main/templates/mdDataTable.html',
transclude: true,
scope: {
tableCard: '=',
@ptgamr
ptgamr / dokku.sh
Last active August 29, 2015 14:22
dokku command
cat ~/.ssh/id_rsa.pub | ssh -i soundcloudify-ec2.pem ubuntu@52.11.128.104 "sudo sshcommand acl-add dokku catalystpc"
ssh dokku@52.11.128.104 logs backend
ssh -t dokku@backend.sportcontract.eu logs backend -t -f
@ptgamr
ptgamr / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ptgamr
ptgamr / tmux.md
Last active August 29, 2015 14:23 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

import Ember from 'ember';
export { dirtyHasMany, dirtyBelongsTo, dirtyMixin };
var dirty = 'relationshipIsDirty';
function dirtyMixin (obj) {
var args = Object.keys(obj);
var comp = Ember.computed;
args.push('isDirty');
obj[dirty] = comp.any.apply(comp, args);
@ptgamr
ptgamr / es-mongo-scripts
Last active August 29, 2015 14:24
elasticsearch-mongodb
7871* bin/plugin --install com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.9
7872* bin/plugin install elasticsearch/elasticsearch-mapper-attachments/2.6.0
7873* bin/plugin install mobz/elasticsearch-head
7874* bin/elasticsearch
7875* -XDELETE curl localhost:9200/_river
7876* curl -XDELETE localhost:9200/_river
7877* curl -XPUT "localhost:9200/_river/players/_meta" -d '\n{\n "type": "mongodb",\n "mongodb": { \n "db": "new_river", \n "collection": "players"\n }, \n "index": { \n "name": "players", \n "type": "playerIndexType"\n }\n}'
7878* sudo mongod --replSet rs0
7879* mongo
7880* curl -XPUT "localhost:9200/_river/players/_meta" -d '\n{\n "type": "mongodb",\n "mongodb": { \n "db": "new_river", \n "collection": "players"\n }, \n "index": { \n "name": "players", \n "type": "playerIndexType"\n }\n}'
@ptgamr
ptgamr / Conversation
Last active February 16, 2017 04:38
Facebook realtime update message
2017-02-16T04:34:36.492792086Z app[web.1]: Reveive RTU {
2017-02-16T04:34:36.492929663Z app[web.1]: "entry": [
2017-02-16T04:34:36.492952126Z app[web.1]: {
2017-02-16T04:34:36.492965720Z app[web.1]: "changes": [
2017-02-16T04:34:36.493015100Z app[web.1]: {
2017-02-16T04:34:36.493038866Z app[web.1]: "field": "conversations",
2017-02-16T04:34:36.493052780Z app[web.1]: "value": {
2017-02-16T04:34:36.493072140Z app[web.1]: "thread_id": "t_mid.1485225609263:e8e631c590",
2017-02-16T04:34:36.493097543Z app[web.1]: "page_id": 360498397447858
2017-02-16T04:34:36.493169916Z app[web.1]: }
@ptgamr
ptgamr / installation.md
Last active August 29, 2015 14:25
Installation guide

Install

  • MongoDB
  • NodeJS

###BACKEND

  • cd
  • sudo npm install
  • nodemon

backend endpoint is protected with JWT token, when using POSTMAN to test API, you'll need to include a token in the header

@ptgamr
ptgamr / fms-workflow.md
Last active August 29, 2015 14:26
FMS-workflow

FMS WORKFLOW

  • Every staffs has to register an account
  • Shop owner is also a normal user

===========================================

  • Shop owner create one more multiple TEAMS
  • Shop owner add USER to TEAMS
  • Shop owner add FACEBOOK PAGE to TEAMS