Skip to content

Instantly share code, notes, and snippets.

View casoetan's full-sized avatar
💯

Charles Soetan casoetan

💯
View GitHub Profile

Keybase proof

I hereby claim:

  • I am casoetan on github.
  • I am casoetan (https://keybase.io/casoetan) on keybase.
  • I have a public key whose fingerprint is 5ADD 841C 2CEB 6F33 BEA6 0AE6 71C3 25A9 19A7 B50E

To claim this, I am signing this object:

@casoetan
casoetan / html_for_international_calling coes.htm
Created November 2, 2016 12:10 — forked from andyj/html_for_international_calling coes.htm
HTML <select> international calling codes for each country
<!-- country codes (ISO 3166) and Dial codes. -->
<select name="countryCode" id="">
<option data-countryCode="GB" value="44" Selected>UK (+44)</option>
<option data-countryCode="US" value="1">USA (+1)</option>
<optgroup label="Other countries">
<option data-countryCode="DZ" value="213">Algeria (+213)</option>
<option data-countryCode="AD" value="376">Andorra (+376)</option>
<option data-countryCode="AO" value="244">Angola (+244)</option>
<option data-countryCode="AI" value="1264">Anguilla (+1264)</option>
<option data-countryCode="AG" value="1268">Antigua &amp; Barbuda (+1268)</option>
@casoetan
casoetan / gist:2c4795d650c4b0043643c1032bae443a
Created November 6, 2016 06:21 — forked from marty-wang/gist:5a71e9d0a6a2c6d6263c
Compile and deploy React Native Android app of Release version to device.
Disclaimer: The instructions are the collective efforts from a few places online.
Nothing here is my original. But I want to put them together in one place to save people from spending the same time as I did.
First off, bundle.
==================
1. cd to the project directory
2. Start the react-native packager if not started
3. Download the bundle to the asset folder:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
<?php
namespace App\Http\Middleware;
use Closure;
class CorsMiddleware
{
/**
* Handle an incoming request.
@casoetan
casoetan / fix-homebrew-npm.md
Created August 6, 2017 07:01 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@casoetan
casoetan / install_elasticsearch_osx.md
Created October 7, 2017 22:37 — forked from djonsson/install_elasticsearch_osx.md
OS X installation instructions for Elasticsearch + Kibana + Marvel

What is this?

Following this guide will set up a local Elasticsearch with Kibana and Marvel using Homebrew and Homebrew Cask

Prerequisites

If you already have Java installed on your system, skip steps Install Cask and Install Java

If you already have Java and Homebrew installed on your system, skip steps Prerequisites, start at Install Elasticsearch and Kibana after running $ brew update

Install Homebrew

  • $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@casoetan
casoetan / mongodb_lookup.go
Created November 30, 2017 09:49 — forked from sindbach/mongodb_lookup.go
A simple example of how to use $lookup in Golang using mgo.
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
func main() {
session, err := mgo.Dial("localhost")
if err != nil {
@casoetan
casoetan / log_request.go
Created November 30, 2017 18:35 — forked from hoitomt/log_request.go
Golang: Log HTTP Requests in Go
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
@casoetan
casoetan / ffmpeg_mkv_mp4_conversion.md
Created August 22, 2018 00:46 — forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@casoetan
casoetan / sqrt.js
Created August 28, 2018 17:48 — forked from animatedlew/sqrt.js
Here is an implementation of a square root function in JavaScript using Newton's method.
var sqrt = function(x) {
var isGoodEnough = function(guess) {
return Math.abs(guess * guess - x) / x < 0.001;
};
var improve = function(guess) {
return (guess + x / guess) / 2;
};
var sqrIter = function(guess) {