Skip to content

Instantly share code, notes, and snippets.

View altbdoor's full-sized avatar
🐵

Ng Han Seng altbdoor

🐵
View GitHub Profile
@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;
}
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 / 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 / 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 / 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 / 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
}
@altbdoor
altbdoor / img_to_html_css_pixels.html
Created November 9, 2016 10:03
This kills the Firefox
<!doctype html>
<html>
<head>
<style>
/* default css */
#output {box-shadow:0 0 5px red; position:relative}
.output-block {width:1px; height:1px; position:absolute}
</style>
<style id="stylesheet"></style>
</head>
@altbdoor
altbdoor / imageset.bat
Created March 3, 2017 10:49
Compiles all PNG images in folder into a JPG image set
@echo off
:: set path to the graphicsmagick folder, get gm from
:: https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick-binaries/
set graphicsmagick_path=C:\Program Files (x86)\GraphicsMagick-1.3.25-Q8\
:: the maximum width of the image set
set image_set_width=1200
:: the resize filter, please check