Skip to content

Instantly share code, notes, and snippets.

View hengkiardo's full-sized avatar

Hengki Sihombing hengkiardo

  • Jakarta, Indonesia
View GitHub Profile
@hengkiardo
hengkiardo / gist:f0ee23e91652e9cded68
Created February 2, 2016 09:53
remove all database mongodb
mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})'
@hengkiardo
hengkiardo / remove_brew-mongo_osx.sh
Created February 2, 2016 09:03 — forked from katychuang/remove_brew-mongo_osx.sh
remove mongodb that was installed via brew
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep mongo
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb
pkill -f mongod
@hengkiardo
hengkiardo / mongoose-connection-options.js
Created January 23, 2016 14:48
MongoLab recommended mongoose connection options. More supported connections for the underlying Node Native driver can be found here: http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html#mongoclient-connect-options
// mongoose 4.3.x
var mongoose = require('mongoose');
/*
* Mongoose by default sets the auto_reconnect option to true.
* We recommend setting socket options at both the server and replica set level.
* We recommend a 30 second connection timeout because it allows for
* plenty of time in most operating environments.
*/
var options = { server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
@hengkiardo
hengkiardo / elasticsearch-docker-script
Created January 23, 2016 10:07 — forked from mschoch/elasticsearch-docker-script
A script to fix ownership of Elasticsearch data directory (when mounted as a volume in docker), then switch to elasticsearch user and launch elasticsearch
#!/bin/sh
# fix permissions (wrong if docker mounted volume)
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
# now switch to elasticsearch user and run in foreground
echo Starting: /usr/share/elasticsearch/bin/elasticsearch -Des.default.config=$CONF_FILE -Des.default.path.home=/usr/share/elasticsearch -Des.default.path.logs=$LOG_DIR -Des.default.path.data=/var/lib/elasticsearch -Des.default.path.work=/tmp/elasticsearch -Des.default.path.conf=$CONF_DIR $@
su elasticsearch -s /bin/sh -c "/usr/share/elasticsearch/bin/elasticsearch -Des.default.config=$CONF_FILE -Des.default.path.home=/usr/share/elasticsearch -Des.default.path.logs=$LOG_DIR -Des.default.path.data=/var/lib/elasticsearch -Des.default.path.work=/tmp/elasticsearch -Des.default.path.conf=$CONF_DIR $@"
server {
listen 80;
server_name www.example.com;
root /var/www/vhosts/example.com/public/;
location /
{
index index.php index.html index.htm;
}
#!/bin/bash
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
# install homebrew-dupes (required to install zlib, php54's dependency)
brew tap homebrew/dupes
# install nginx + mysql + php 5.4 + php-fpm + apc + xdebug
brew install nginx mysql

Contributing

If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.

How to make a clean pull request

Look for a project's contribution instructions. If there are any, follow them.

  • Create a personal fork of the project on Github.
  • Clone the fork on your local machine. Your remote repo on Github is called origin.
#!/bin/bash
#---------------------------------------
# Node.JS Raspberry Pi Package builder
# Raspbian
# http://nodejs-news.com
#---------------------------------------
echo "-> Getting fpm (Effing package managers) Ruby gem"
sudo gem install fpm --no-ri --no-rdoc
@hengkiardo
hengkiardo / gist:7465436
Created November 14, 2013 11:42
Remove a directory that is not empty in NodeJS
var deleteFolderRecursive = function(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.statSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests