Skip to content

Instantly share code, notes, and snippets.

@itgelo
itgelo / nodejs-basic-server.js
Last active August 31, 2016 02:40
Nodejs Basic Server
var http = require("http");
http.createServer(function (req, res){
res.writeHead(200, {"Content-Type":"text/plain"});
res.end("Hello world!!");
}).listen(3000);
console.log("Server is running ...");
@itgelo
itgelo / nodejs-basic-route.js
Last active August 31, 2016 02:39
Nodejs Basic Route
var http = require("http");
http.createServer(function(req, res){
var getUri = req.url;
var code = "";
var template = "";
if(getUri != "/favicon.ico"){
if(getUri == "/"){
code = 200;
template = "Index page";
@itgelo
itgelo / image_autorotate.php
Created August 31, 2016 10:19 — forked from codee/image_autorotate.php
CodeIgniter: Automatic image rotation library
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* @file application/libraries/Image_autorotate.php
*/
class Image_autorotate
{
function __construct($params = NULL) {
if (!is_array($params) || empty($params)) return FALSE;
@itgelo
itgelo / enc_decrypt.php
Created January 23, 2017 03:27
Simple Encrypt/Decrypt PHP
echo encrypt("itgelo");
echo decrypt("B9mFi5BNEhL0kbSdBauFq+L1MEDCmfnoSfUjQ3moAvw=");
function encrypt($string){
$key = "secret-key";
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM);
$encrypted = base64_encode($iv.mcrypt_encrypt(MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), $string, MCRYPT_MODE_CBC, $iv));
return $encrypted;
}
@itgelo
itgelo / hideOnScroll.js
Created December 27, 2018 15:40 — forked from mmazzarolo/hideOnScroll.js
react-native-action-button hide on scroll
// 1. Define a state variable for showing/hiding the action-button
state = {
isActionButtonVisible: true
}
// 2. Define a variable that will keep track of the current scroll position
_listViewOffset = 0
// 3. Add an onScroll listener to your listview/scrollview
<ListView
@itgelo
itgelo / curl.sh
Created March 23, 2020 11:13
Test CORS with cURL
curl -I -X OPTIONS \
-H "Origin: http://localhost" \
-H "Access-Control-Request-Method: POST" \
"http://domain.com" 2>&1 | grep -i "Access-Control-Allow-Origin\|Access-Control-Allow-Methods"
@itgelo
itgelo / http2_apache2_ubuntu18.04.md
Created September 16, 2020 13:37 — forked from GAS85/http2_apache2_ubuntu18.04.md
How to Enable HTTP/2 in Apache 2.4 on Ubuntu 18.04

Based on https://gist.github.com/GAS85/990b46a3a9c2a16c0ece4e48ebce7300

Requirements

  • A self-managed VPS or dedicated server with Ubuntu 18.04 running Apache 2.4.xx.
  • A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.

Step 1: Install Apache2

Per default it will be apache2 version 2.4.29 what is enought for http2 support.

@itgelo
itgelo / Javascript Format NPWP
Created September 30, 2020 02:39 — forked from yudapc/Javascript Format NPWP
Javascript Format NPWP. NPWP is ID tax each people of indonesian. Specificly in frontend need to format NPWP before render to user
//
// Javascript Format NPWP
//
function formatNpwp(value) {
if (typeof value === 'string') {
return value.replace(/(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})/, '$1.$2.$3.$4-$5.$6');
}
}
@itgelo
itgelo / problem.md
Created December 7, 2020 14:35 — forked from tomanistor/problem.md
Multi-tap Keypad Text Entry on an Old Mobile Phone

Prior to having fancy iPhones, teenagers would wear out their thumbs sending SMS messages on candybar-shaped feature phones with 3x4 numeric keypads.

------- ------- -------
|     | | ABC | | DEF |
|  1  | |  2  | |  3  |
------- ------- -------
------- ------- -------
| GHI | | JKL | | MNO |
| 4 | | 5 | | 6 |

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.