Skip to content

Instantly share code, notes, and snippets.

View ptgamr's full-sized avatar

Anh Trinh ptgamr

View GitHub Profile

Port Forwarding to a Dokku instance

dokku docker-options:add <container_name> run,deploy -p 127.0.0.1:<host_port>:<container_port>
@ptgamr
ptgamr / README.md
Created April 21, 2017 13:02 — forked from mik01aj/README.md
How to use Tether with React

Tether is a great library for positioning stuff (tooltips, modals, hints, etc) in your web app.

But, as I use React, it was pretty problematic for me, as Tether mutates the DOM and React breaks miserably when it sees mutated DOM. The solution is to have the tethered element outside the part of the DOM tree which is controlled by React (in this case, I use document.body).

That's why I created 2 helpers to use Tether with React.

The first one, TetheredElement is a plain JS helper to create a new element, attach it to some other one via Tether, and populate it with some React component.

The second one, TetherTarget is a React component and it uses TetheredElement to integrate it further with React, so that you can attach components to each other with Tether, without leaving the cozy React/JSX world and worrying about manual DOM operations. Just write:

@ptgamr
ptgamr / sc-mobile-app-version.json
Last active April 14, 2017 03:13
sc-app-version
{
"version": "1.0-debug.21"
}
@ptgamr
ptgamr / hoc.js
Last active January 11, 2017 04:17
hoc question
class MyComponent extends Component {
render() {
return (
<div>
<OutsideClick>
<button onClick={toggleModal}>Show modal 1</button>
{ isModalVisible && this.renderModal(1) }
</OutsideClick>
<OutsideClick>
@ptgamr
ptgamr / kudoo-noti-dev.txt
Last active September 29, 2016 11:17
kudoo-noti
# Nội dung thông báo DEV (Trung Anh dep zdai)
# http://kudoo.net
@ptgamr
ptgamr / get-with-default.js
Last active July 21, 2016 12:25
Ember get-with-default
import Ember from "ember";
export default Ember.Helper.helper(function([obj, path, defaultValue]){
if (Ember.isEmpty(path)) {
// or throw an error
return;
}
return obj ? Ember.get(obj, path) || defaultValue : defaultValue;
});
@ptgamr
ptgamr / vim-xterm
Created July 18, 2016 05:17
How to set correct VIM color in XTERM
export TERM="xterm-256color"
#TMUX
set -g default-terminal xterm-256color
@ptgamr
ptgamr / ember-offline-sync.md
Last active July 14, 2016 13:37
Ember-offline-sync Detailed Design

Detailed Design

# Add-on folder structure
- addon
  - mixins
    - offline-support-store.js
    - offline-support-adapter.js
- app
  - services
    - store.js
@ptgamr
ptgamr / Sharded mongodb environment on localhost
Created May 6, 2016 12:26 — forked from joewagner/Sharded mongodb environment on localhost
Bash shell script that sets up a sharded mongodb cluster on a single machine. Handy for testing or development when a sharded deployment is required. Notice that this will remove everything in the data/config and data/shard directories. If you are using those for something else, you may want to edit this...
# clean everything up
echo "killing mongod and mongos"
killall mongod
killall mongos
echo "removing data files"
rm -rf data/config
rm -rf data/shard*
# For mac make sure rlimits are high enough to open all necessary connections
ulimit -n 2048
@ptgamr
ptgamr / ngram-search.sh
Created May 5, 2016 13:33 — forked from avar/ngram-search.sh
ElasticSearch fuzzy ngram powered search
export http_proxy=
export https_proxy=
curl -XDELETE 'http://localhost:9200/test/'
echo "Creating the mapping"
curl -XPUT 'http://localhost:9200/test/?pretty=1' -d '
{
"mappings" : {
"member" : {