Skip to content

Instantly share code, notes, and snippets.

View stania's full-sized avatar

Albert Hwang stania

View GitHub Profile
@stania
stania / setupVSEnv.py
Last active June 11, 2016 21:45
python implementation replacing "call vsvars32.bat"
from subprocess import Popen
import os, subprocess
def parseEnv(envoutput):
handle_line = lambda l: tuple(l.rstrip().split("=", 1))
pairs = map(handle_line, envoutput)
valid_pairs = filter(lambda x: len(x) == 2, pairs)
valid_pairs = [(x[0].upper(), x[1]) for x in valid_pairs]
return dict(valid_pairs)
@stania
stania / gist:4992670
Created February 20, 2013 03:39
GridMove .grid sample
[Groups]
NumberOfGroups = 4
[1]
TriggerTop = [Monitor1Top] + 400
TriggerRight = [Monitor1Right]
TriggerBottom = [Monitor1Bottom]
TriggerLeft = [Monitor1Left]
@stania
stania / gist:5274560
Created March 30, 2013 00:09
araqne batch script enhancement example.
# this is comment
logstorage.dropTable iis01
logstorage.createTable iis01 v3p
# lines before "EOF" will be used as inputstream. input lines are not trimmed and cannot commented.
logpresso-index.createIndex iis01 i1 <<EOF
delimiter
;/
@stania
stania / anonymous.py
Created April 3, 2013 11:28
prerequisite: gnu mpfr (may can be installed by distribution installer) pycrypto, pycryptopan (both can be installed by pip)
from cryptopan import CryptoPan
import re, sys
c = CryptoPan("".join([chr(x) for x in range(0, 32)]))
p = re.compile(r"^([^ ]+) ([^ ]+)")
def replace(mo):
try:
domain = mo.group(1)
package org.logpresso.misc;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class SignatureTesterMain {
@stania
stania / Perseids.txt
Last active December 20, 2015 23:29
Perseids
int main() {
/* *
. . * 0
0 . * .
. / *
. / *
. / . . .
/
. * / . *
/ *
@stania
stania / bitly.py
Created September 14, 2013 18:24
bitly commandline shortener
# -*- coding: utf-8 -*-
import traceback, sys
import bitly_api
from Tkinter import Tk
import tkMessageBox
access_token = ''
r = Tk()
@stania
stania / gist:3e03d1c1b29c94f3afbc
Created November 13, 2014 09:02
check if specified ip conflicts with others in same network
@echo off
setlocal
set IP=%1
arp -d %IP%
ping -4 -w 100 -n 1 %IP% > NUL
arp -a %IP% | findstr %IP% > NUL
exit /b %ERRORLEVEL%
@stania
stania / gist:99d6a416baa509d07aeb
Created November 13, 2014 09:03
wait for ip released from others in same network
@echo off
:chk
call ipconfl.bat %1
if errorlevel 1 goto exit
timeout /t 1 > nul
goto chk
exit /b 1
:exit
@stania
stania / gist:d3749d031301bdf48b11
Last active August 29, 2015 14:17
Thread pause/resume technique
package sandbox;
import java.util.Date;
import java.util.concurrent.Phaser;
import java.util.concurrent.atomic.AtomicBoolean;
public class PhaserTest implements Runnable {
private static AtomicBoolean paused = new AtomicBoolean(false);
private static Phaser p = new Phaser(1);