Skip to content

Instantly share code, notes, and snippets.

View scaryghost's full-sized avatar

Eric Tsai scaryghost

View GitHub Profile
@scaryghost
scaryghost / App.java
Last active July 22, 2019 00:05
Sample code with groovy class loader
/*
* This Java source file was generated by the Gradle 'init' task.
*/
import groovy.lang.GroovyClassLoader;
import groovy.cli.commons.CliBuilder;
import groovy.cli.Option;
import java.io.File;
import java.io.IOException;
import java.nio.file.*;
@scaryghost
scaryghost / pascal.ll
Created June 10, 2019 10:31
random llvm-ir files
declare i32 @atoi(i8* nocapture)
declare i32 @printf(i8* noalias nocapture, ...) nounwind
@.result_fmt = private unnamed_addr constant [18 x i8] c"pascal(%d,%d)=%d\0A\00"
define i32 @pascal(i32 %n, i32 %k) {
%n_eq_0 = icmp eq i32 %n, 0
br i1 %n_eq_0, label %base_case_1, label %n_is_not_base
n_is_not_base:
@scaryghost
scaryghost / generic_list.cpp
Last active June 4, 2019 10:10
Nonhomogeneous list that stores its elements sequentially
#include "generic_list.hpp"
#include <algorithm>
#include <cstdlib>
using std::for_each;
using std::free;
using std::malloc;
using std::memcpy;
using std::memmove;
@scaryghost
scaryghost / CamelDemo.java
Created March 11, 2015 20:30
Apache camel demo taking data from a TCP connection and writing it to outbox/stream.txt. Requires camel-core and camel-mina2
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class CamelDemo {
public static void main(String[] args) throws Exception {
CamelContext cContext= new DefaultCamelContext();
RouteBuilder builder= new RouteBuilder() {
@scaryghost
scaryghost / fib_x64.s
Created April 1, 2014 03:41
fibanocci in x64
# compile: gcc -o fib_x64 fib_x64.s -m64
# run: ./fib <number>
.global main
.data
formatstr: .asciz "fib(%d)= %d\n"
main:
push %r12
movq 8(%rsi),%rdi
call atoi
@scaryghost
scaryghost / fib.s
Last active August 29, 2015 13:57
fibanocci in x86
# compile: gcc -o fib fib.s -m32
# run: ./fib <number>
.global main
.data
formatstr: .asciz "fib(%d)= %d\n"
main:
pop %ecx
movl 4(%eax),%edx
pushl %edx
@scaryghost
scaryghost / KFGameRules.uc
Created March 12, 2014 10:12
Initial functionality for expanded KF specific game rules
/**
* Expanded set of callbacks specific to Killing Floor events
* @author etsai
*/
class KFGameRules extends GameRules
abstract;
/**
* Determines if the perk change should be allowed or not
* @param player Controller of the player who wants to change perks
@scaryghost
scaryghost / querybuilder.groovy
Last active January 1, 2016 13:59
sql query builder examples
QueryBuilder() {
and() {
eq(col, val)
lt(col, val)
}
}
///< (c1 = v1 || c2 < v2
QueryBuilder() {
or() {
@scaryghost
scaryghost / jdnssd.java
Created October 16, 2013 10:33
Example of how to do a dnssd query in Java
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.ldap.InitialLdapContext;
/**
* Example of how to do a dnssd query in Java. Code based on answer from:
* http://stackoverflow.com/questions/738750/querying-the-dns-service-records-to-find-the-hostname-and-tcp-ip
* @author etsai
@scaryghost
scaryghost / win_dnssd.cpp
Last active December 23, 2015 02:29
How to do SRV and TXT query with windns.h
/**
* Compiled on VS2012
*/
#include <winsock2.h> //winsock
#include <windns.h> //DNS api's
#include <Rpc.h>
#include <iostream>
#include <functional>
#include <map>