Skip to content

Instantly share code, notes, and snippets.

View hengkiardo's full-sized avatar

Hengki Sihombing hengkiardo

  • Jakarta, Indonesia
View GitHub Profile
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
var app = angular.module('validationExample', []);
app.controller('signupController', ['$scope', function($scope) {
$scope.submitted = false;
$scope.signupForm = function() {
if ($scope.signup_form.$valid) {
} else {
$scope.signup_form.submitted = true;
}
@benmj
benmj / geocoder-service.js
Created August 29, 2013 16:38
An AngularJS Service for intelligently geocoding addresses using Google's API. Makes use of localStorage (via the ngStorage package) to avoid unnecessary trips to the server. Queries Google's API synchronously to avoid `google.maps.GeocoderStatus.OVER_QUERY_LIMIT`
/*global angular: true, google: true, _ : true */
'use strict';
angular.module('geocoder', ['ngStorage']).factory('Geocoder', function ($localStorage, $q, $timeout) {
var locations = $localStorage.locations ? JSON.parse($localStorage.locations) : {};
var queue = [];
// Amount of time (in milliseconds) to pause between each trip to the
@jedi4ever
jedi4ever / nodejs-cluster-zero-downtime.md
Last active February 11, 2024 13:45
nodejs clustering, zero downtime deployment solutions

Clustering: The basics

The trick? pass the file descriptor from a parent process and have the server.listen reuse that descriptor. So multiprocess in their own memory space (but with ENV shared usually)

It does not balance, it leaves it to the kernel.

In the last nodejs > 0.8 there is a cluster module (functional although marked experimental)

@ryanhanwu
ryanhanwu / proxy.js
Created July 18, 2013 17:59
Node.js HTTP hostname redirect and proxy normal HTTP+WebSockets traffic
var http = require('http'),
_ = require('underscore'),
httpProxy = require('http-proxy');
var proxyOptions = {
router: {
"api.testAppX.com" : 'localhost:2041',
"dev.api.testAppX.com" : 'localhost:2042',
"www.testAppY.com" : 'localhost:10520',
"test.oldApps.com" : 'localhost:10520',
'bc.ryanwu.co' : 'localhost:8888'
@makotot
makotot / Gruntfile.js
Last active December 19, 2015 13:49
grunt-contrib-watchでlivereload
module.exports = function (grunt) {
'use strict';
// grunt-contrib-watchのlivereloadオプションでlivereload
grunt.initConfig({
watch: {
html: {
files: '**/*.html',
tasks: [],
@dolphin278
dolphin278 / README.md
Last active February 12, 2022 16:30
Pub/sub example for nodejs using mongodb

Uses capped collection, tailable cursors and streams.

What's here?

  • init.js recreates collection capped collection 'queue' on mongodb.
  • writer.js spams queue with new messages
  • worker.js processes all messages saved to queue,
  • onceWorker.js processes only unprocessed messages, so you can spawn several of them and each of your messages will be processed by only one worker.

Steps

@mcollina
mcollina / 1-NetworkButtonJSON.md
Last active December 15, 2015 23:00
NetworkButtonJSON

NetworkButtonJSON

NetworkButtonJSON is a forest of network enabled leds that switch on and off on simultaneosly. Join the forest, build a networked LED.

You should:

  • mount an Arduino Ethernet Shield.
  • build an Arduino-based prototype with the following schema:
@JamieMason
JamieMason / is_installed.sh
Last active February 17, 2024 10:12
Check if a program exists from a bash script.Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@TooTallNate
TooTallNate / mp3player.js
Created October 24, 2012 17:42
node.js command line MP3 player in 9 lines of code!
var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');
fs.createReadStream(process.argv[2])
.pipe(new lame.Decoder())
.on('format', function (format) {
this.pipe(new Speaker(format));
});