Skip to content

Instantly share code, notes, and snippets.

View tonetheman's full-sized avatar

Tony Colston tonetheman

View GitHub Profile
@tonetheman
tonetheman / gist:56750
Created February 2, 2009 02:43
win32 security testing in python
import win32api
import win32security
import win32process
import pywintypes
def attempt_to_logon():
username = "junk"
password = "junk"
try:
hUser = win32security.LogonUser(username, None,
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name="viewport" />
<link rel="icon" href="data:,">
<title>String art</title>
<script type="text/javascript" src="jquery.min.js"></script>
<style>
html, body {
import collections
import math
import os
import cv2
import numpy as np
import time
MAX_LINES = 4000
N_PINS = 36*8
MIN_LOOP = 20 # To avoid getting stuck in a loop
@tonetheman
tonetheman / raytracer.js
Created June 25, 2013 03:32
javascript raytracer from typescript playground here http://www.typescriptlang.org/Playground/ this is the translated javascript that typescript pooped out
var Vector = (function () {
function Vector(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
Vector.times = function (k, v) {
return new Vector(k * v.x, k * v.y, k * v.z);
};
@tonetheman
tonetheman / aeb6243e
Created March 31, 2017 01:51
Python code showing Selenium script for http://www.yachtworld.com/. Running now, results in a minute...
#import our WebDriver object
from selenium import webdriver
import requests
def run_test():
try:
driver = None
#we need to use CBT capabilities
@tonetheman
tonetheman / seqsandarrays.nim
Created December 18, 2022 17:43
2d seq and some array examples for nim
# see here also for seq
# https://nimbyexample.com/sequences.html
# pretty print a seq
# or better than just echo it
proc pp(a: seq[ seq[int] ] ) =
for i in a:
echo(i)
@tonetheman
tonetheman / mut_evenodd.nim
Created November 1, 2022 19:59
Mutually recursive even and odd function in nim
# forward declarations
proc even(x: int) : bool;
proc odd(x: int) : bool;
proc odd(x : int) : bool =
if x==0:
return false
else:
return even(x-1)
@tonetheman
tonetheman / readfile.nim
Created September 24, 2019 12:27
read a file with nim line by line
proc readwholefile() =
let data = readFile("data.txt")
echo(data)
proc justoneline() =
let f = open("data.txt")
defer: f.close()
let firstline = f.readLine()
echo(firstline)
@tonetheman
tonetheman / mod.lua
Created August 29, 2022 22:54
lua code for a mod that works for 1 based numbers
--[[
saw this buried in this code
https://www.lexaloffle.com/bbs/?tid=49068
]]--
function mod(val,modulo)
--Mod for 1 based numbers.
--3%3=3. 4%3=1, 1%3=1
return (val-1)%modulo+1
@tonetheman
tonetheman / structtesting.py
Created August 14, 2022 00:18
python3 struct read bytes
import struct
data = open("test.bin","rb").read()
# all of these are unsigned
def read_single_byte(data,position):
return struct.unpack("B",data[position:position+1])
def read_single_word(data,position):
return struct.unpack("H",data[position:position+2])