Skip to content

Instantly share code, notes, and snippets.

View nathan-osman's full-sized avatar

Nathan Osman nathan-osman

View GitHub Profile
@nathan-osman
nathan-osman / CMakeLists.txt
Created March 28, 2016 19:43
Lookup an icon by name and size
cmake_minimum_required(VERSION 2.8.9)
project(gtktest LANGUAGES C)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
add_executable(gtktest main.c)
target_link_libraries(gtktest ${GTK3_LIBRARIES})
@nathan-osman
nathan-osman / CMakeLists.txt
Created January 27, 2016 05:04
Add to %PATH% before starting another process
cmake_minimum_required(VERSION 2.8.9)
project(printpath)
add_executable(printpath path.cpp)
set(ENV{PATH} "C:/Some/Path;$ENV{PATH}")
add_custom_target(show "$<TARGET_FILE:printpath>")
add_dependencies(show printpath)
@nathan-osman
nathan-osman / version_compare.py
Created November 5, 2015 06:21
Sort a list of version numbers
#!/usr/bin/env python2
from argparse import ArgumentParser
from apt_pkg import init_system, version_compare
if __name__ == '__main__':
parser = ArgumentParser(description="Sort a list of version numbers")
parser.add_argument(
@nathan-osman
nathan-osman / exepath.go
Last active October 26, 2015 17:46
Retrieve path to executable in Go on Windows
// +build windows
package main
import (
"fmt"
"syscall"
"unicode/utf16"
"unsafe"
)
@nathan-osman
nathan-osman / timeout.js
Created October 19, 2015 21:28
Simple class for managing timeouts in JavaScript
/**
* Simplify the process of setting and resetting timeouts.
* @param fn callback to invoke
* @param delay time in MS
*
* Any additional parameters are passed to the callback when invoked.
*/
function Timeout(fn, delay) {
var timeout = null,
args = $.map(arguments, function(v, i) {
@nathan-osman
nathan-osman / twitter.txt
Last active August 22, 2018 03:30
Check Twitter for available usernames
test1
test2
...
@nathan-osman
nathan-osman / dnsupdate.go
Created September 9, 2015 20:48
Update a DNS record via an HTTP GET request
// Compile for the current platform with:
// go build dnsupdate.go
// Cross-compile for Windows with:
// GOOS=windows GOARCH=amd64 go build dnsupdate.go
package main
import (
"fmt"
"net/http"
@nathan-osman
nathan-osman / peimportlist.cpp
Created August 26, 2015 04:01
Display a list of imports in a PE file
// Copyright (c) 2011 Nathan Osman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@nathan-osman
nathan-osman / CMakeLists.txt
Last active April 8, 2016 06:23
Enumerate OpenCL platforms available
cmake_minimum_required(VERSION 2.8.11)
project(cltest)
find_package(OpenCL REQUIRED)
add_executable(cltest cltest.cpp)
include_directories(cltest ${OpenCL_INCLUDE_DIRS})
target_link_libraries(cltest ${OpenCL_LIBRARIES})
@nathan-osman
nathan-osman / httpstress.py
Created July 13, 2015 19:32
Stress test an HTTP server
#!/usr/bin/env python2
"""
HTTP Stress Tester
Copyright 2015 - Nathan Osman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or