Skip to content

Instantly share code, notes, and snippets.

View altbdoor's full-sized avatar
🐵

Ng Han Seng altbdoor

🐵
  • Kuala Lumpur, Malaysia
  • 12:31 (UTC +08:00)
View GitHub Profile
function getCodes (charset, codeLength, codeCount) {
var codeList = [],
codeListLength = 0,
charsetLength = charset.split('').length,
codePerCharset = charsetLength / codeLength,
collision = 0,
i, temp;
while (codeListLength < codeCount) {
var charsetCopy = charset.slice(0).split('');
@altbdoor
altbdoor / checkCircular.php
Created June 13, 2014 02:07
check circular referencing in flat array in PHP
private static function isHierarchyCircular ($hierarchy, $circularIdentifier, $nextIdentifier) {
if (!array_key_exists($nextIdentifier, $hierarchy)) {
$hierarchy[$nextIdentifier] = array();
}
$startHierarchy = $hierarchy[$nextIdentifier];
if (in_array($circularIdentifier, $startHierarchy)) {
return true;
}
@altbdoor
altbdoor / pre-commit.sh
Last active October 19, 2016 01:48
Script for Git pre-commit hook
#!/bin/bash
# to add a protected file, please open protected_file.txt and append a path into
# the file, relative to the project directory.
# ========================================
# defaults
# ========================================
abort_commit_msg="Aborting commit"
@altbdoor
altbdoor / powercfg.bat
Created February 27, 2016 13:48
Switch between High Performance and Energy Saver mode in Windows.
set HIGHPERF= 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
for /f "tokens=2 delims=:(" %%x in ('powercfg.exe -getactivescheme') do set ACTIVE=%%x
if /i %ACTIVE%==%HIGHPERF% (
powercfg.exe -s a1841308-3541-4fab-bc81-f71556f20b4a
) else (
powercfg.exe -s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
)
@altbdoor
altbdoor / shareLAN.bat
Created February 27, 2016 13:53
Small script to share LAN internet with WiFi
:: http://www.slideshare.net/vbdotnetnrew/0321210255-ch21
netsh wlan set hostednetwork mode=allow ssid=<wifi_display_name> key=<wifi_password> keyUsage=persistent
netsh wlan start hostednetwork
@altbdoor
altbdoor / gm_pdf.cs
Last active August 1, 2016 14:10
Scripts for combining PDF receipts into one
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
/*
Compiled with
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe /t:exe /out:gm_pdf.exe gm_pdf.cs
*/
#!/bin/bash
filename="$1"
parameter="$2"
if [[ ! -f "$filename" ]]; then
echo "Please specify the file"
exit 1
fi
@altbdoor
altbdoor / lib.ahk
Created August 22, 2016 02:45
Simple AHK GUI to display current battery percentage
; https://autohotkey.com/board/topic/7022-acbattery-status/
ReadInteger( p_address, p_offset, p_size, p_hex=true )
{
value = 0
old_FormatInteger := a_FormatInteger
if ( p_hex )
SetFormat, integer, hex
else
SetFormat, integer, dec
@altbdoor
altbdoor / vscape_dialog.py
Last active August 27, 2016 09:12
Python3 script to roughly convert the transcripts into method calls
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# http://odelvidyascape.blogspot.com/2016/07/dialogue-transcriptions_3.html
# http://vidyascape.no-ip.org/kanboard/?controller=board&action=readonly&token=12bc8837b3e20f675f747fda8fabb18052bb904db415bf88e59cd8416b28
# Requirements:
# - Python 3
# - BeautifulSoup4
@altbdoor
altbdoor / finkoma.sh
Created October 30, 2016 15:22
Bash script to finalize 4koma
#!/bin/bash
CURRENT_DIR=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
cd "$CURRENT_DIR"
hash gm 2>/dev/null || {
echo "Please install GraphicsMagick (Q8 win32 dll) first."
echo "Go get it at https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick-binaries/"
exit 1
}