Skip to content

Instantly share code, notes, and snippets.

View angch's full-sized avatar

Ang Chin Han angch

  • Kuala Lumpur, Malaysia
View GitHub Profile
<?php // Use proper tags, not everyone is coding in PHP!
// Use proper, *working* code please. Not everyone wants to retype your homework.
$tahun = array(2011, 2012, 2013);
$nama = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I');
// Homework: Go read and understand:
// http://php.net/manual/en/ref.array.php
// Formatted for readability
@angch
angch / xrandr_ftw
Created May 9, 2014 04:42
Manually adding and setting 1920x1200 mode on monitor
angch@stryfe:$ cvt 1920 1200 60
# 1920x1200 59.88 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz
Modeline "1920x1200_60.00" 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync
angch@stryfe:$ xrandr --newmode "1920x1200_60.00" 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync
angch@stryfe:$ xrandr --addmode VGA1 "1920x1200_60.00"
angch@stryfe:$ xrandr --output VGA1 --mode "1920x1200_60.00"
<?php
// https://forum.lowyat.net/topic/3230448/
$name = "Kajuta Re'lian";
if (preg_match_all("/\b(\w)/", str_replace("'", "", $name), $initials)) {
$initials = strtoupper(implode(". ", $initials[0]).".");
print $initials;
}
#!/bin/bash
# https://forum.lowyat.net/topic/3331860/+0
# Hope you don't have files begining with ___
# Usage ./pivot.sh inputfile.txt
rm -f ___*
split $1 -l1 ___
sed -i -r -e's/(..)../\1\n/g' ___*
paste ___* | tr -d '\n' | sed -r -e's/[\t \.]+/ /g'
rm -f ___*
package main
import "fmt"
func spiral(max_x int, max_y int) {
var n, x, y, xdir, ydir int
xdir = 1
var matrix = make([][]int, max_y)
for i := range matrix {
def spiral(max_x, max_y):
matrix = []
for i in range(0, max_y):
matrix.append([0] * max_x)
x, y, n, xdir, ydir = 0, 0, 0, 1, 0
while 1:
n = n + 1
matrix[y][x] = n
package main
import "fmt"
func main() {
var n, max_x, max_y, x, y, xdir, ydir int
max_x, max_y = 5, 5
var matrix = make([][]int, max_y)
P:
@angch
angch / btree.go
Last active August 29, 2015 14:07
golang: Just a quick test of a using github.com/google/btree using mixed types: string and int
// Just a quick test of a using github.com/google/btree using
// mixed types (string) and (int)
package main
import (
"fmt"
"github.com/google/btree"
"strconv"
)
@angch
angch / fetch_url_with_cookiejar.go
Created October 30, 2014 14:55
Some snippet golang code for excalibr to retrieve/reuse sessions using cookies.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
)
@angch
angch / persist_cookies.go
Last active August 29, 2015 14:08
excalibr's request for a golang version of first example in http://docs.python-requests.org/en/latest/user/advanced/
//usr/bin/env go run $0 $@ ; exit
// excalibr (from Freenode's #myoss)'s request for a golang version of
// the first example in http://docs.python-requests.org/en/latest/user/advanced/
package main
import (
"fmt"
"io/ioutil"