Skip to content

Instantly share code, notes, and snippets.

View goFrendiAsgard's full-sized avatar

Go Frendi Gunawan goFrendiAsgard

View GitHub Profile
@goFrendiAsgard
goFrendiAsgard / normalizeChainElse.js
Last active October 4, 2017 07:09
discussion in devRant with @plugsut
function createIfChain(chain){
let ifChain = {} // ifChain should has everything chain has, except 'else' property
for(let key in chain){
if(key != 'else'){
ifChain[key] = chain[key]
}
}
return ifChain
}
@goFrendiAsgard
goFrendiAsgard / test.js
Created August 30, 2017 15:18
test exec and execFile. The result is similar
const childProcess = require('child_process')
console.time('testExecFilePHP')
childProcess.execFile('php', ['tests/programs/add.php', '5', '6'], function(err, stdout, stderr){
console.timeEnd('testExecFilePHP')
})
console.time('testExecPHP')
childProcess.exec('php tests/programs/add.php 5 6', function(err, stdout, stderr){
console.timeEnd('testExecPHP')
@goFrendiAsgard
goFrendiAsgard / php-black-magic.php
Created August 26, 2017 09:29
greek-question-mark
<?php
echo "hello world";
echo "hello world";
@goFrendiAsgard
goFrendiAsgard / biarBerhentiBerantem.js
Created May 28, 2017 10:39
Biar mahasiswaku berhenti berantem
/* Instruksi: Buka tab baru, tekan ctrl + shift + i, klik tab "console", lalu copy-paste kan kode berikut */
let kalimatKonyol = "Tono adalah programmer yang sempurna. Jika program buatan Tono salah, salahkan programnya, jangan salahkan Tono. Tono itu sempurna, tapi program buatan Tono tidak";
window.alert("Contoh kalimat konyol: " + kalimatKonyol);
/* Contoh penggunaan regex di javascript: */
kalimatKonyol = kalimatKonyol.replace(/program buatan Tono/g, 'saya').replace(/Tono/g, 'Agama saya').replace(/programmer/g, 'agama').replace(/program/g, 'saya');
window.alert("Kalimat dengan pola yang sama: " + kalimatKonyol);
/* Apa yang bikin anda baper? */
@goFrendiAsgard
goFrendiAsgard / php-magic.php
Created December 31, 2016 14:52
Some magic on PHP to celebrate 2017 new year eve
<?php
/* Created on Mudawikawi's laptop on 2017 new year eve, to show you miracle */
class Mutant{
function __get($property)
{
if($property == 'a')
{
if(property_exists($this, 'get_a'))
{
#include <iostream>
#include <math.h>
using namespace std;
int get_digit(int angka, int digit){
int divider = 1;
for(int i=0; i<digit; i++){
divider *= 10;
}
@goFrendiAsgard
goFrendiAsgard / gomodorokanbanreminder.py
Last active March 4, 2017 14:03
Go Frendi's pomodoro, kanban, and reminder application. Work on terminal, written by using Python
#!/usr/bin/env python
'''
Kanban + Pomodoro + Reminder
If you use linux please install sox first (sudo apt-get install sox)
You can use these formats in order to remind you of the tasks:
* Y:m:d H:M:S
* Y:m:d H:M
* everyday H:M[:S]
* every [monday|tuesday|wednesday|thursday|friday|saturday] H:M[:S]
* *:m:d H:M[:S]
@goFrendiAsgard
goFrendiAsgard / gosolarized.vim
Created August 4, 2016 05:06
solarized colorscheme for vim with higher contrast and without red
" Vim color file - gosolarized
" Generated by http://bytefluent.com/vivify 2016-08-03
set background=dark
if version > 580
hi clear
if exists("syntax_on")
syntax reset
endif
endif
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Description of Manage_purchase_invoice
*
* @author No-CMS Module Generator
*/
class Manage_purchase_invoice extends CMS_CRUD_Controller {
protected $URL_MAP = array();
@goFrendiAsgard
goFrendiAsgard / manhattan_distance_a_star.pas
Created March 15, 2016 23:27
Manhattan Distance implementation for A * algorithm in grid map
Uses sysutils;
type
integer_array = array of integer;
integer_array_2d = array of integer_array;
var
closed_row, openned_row, closed_col, openned_col : integer_array;
map, previous_rows, previous_cols, fs, gs : integer_array_2d;
height, width, row, col, current_row, current_col, start_row, end_row, start_col, end_col, up_row, bottom_row, left_col, right_col, f, g, h, i, best_f, prev_row, prev_col, counter : integer;
solution_found : boolean;