Skip to content

Instantly share code, notes, and snippets.

View tonetheman's full-sized avatar

Tony Colston tonetheman

View GitHub Profile
CmdUtils.CreateCommand(
{
name : "delicious",
author: { name : "Tonetheman", homepage: "http://tryexceptfinally.blogspot.com"},
license: "MPL",
execute : function() {
var doc = Application.activeWindow.activeTab.document;
var updateUrl = "https://api.del.icio.us/v1/posts/add";
var updateParams = {
url: doc.documentURI,
@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,
@tonetheman
tonetheman / gist:69652
Created February 24, 2009 16:37
read a pipe in python
import sys
while True:
next_line = sys.stdin.readline()
if not next_line:
break
# do something to the line
next_line = next_line.strip()
@tonetheman
tonetheman / gist:85815
Created March 26, 2009 01:33
urllib for java
import java.net.*;
import java.io.*;
class urllib {
public static StringBuffer urlopen(String url) {
try {
URL u = new URL(url);
StringBuffer sb = new StringBuffer();
BufferedReader in = new BufferedReader(
/*
* Copyright 2006 ThoughtWorks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#!/bin/bash
# tell me about this flv
# ffmpeg -i inputvideo.flv
# set the bit rate with this command
# ffmpeg -i inpuvvideofile.flv -ab 128k outputaudiofile.mp3
# no re encode with this command
/usr/bin/ffmpeg -i $1 -acodec copy $1.mp3
#include <iostream>
#include <signal.h>
#include <getopt.h>
using namespace std;
char * __PORT = 0;
int PORT = -1;
void dbg(const char * str) {
#include <iostream>
#include <cstring>
using std::cout;
using std::endl;
// convert string to double old school
double convert(char * s) {
int i=0;
double intPart = 0, fracPart = 0;
import java.util.Random;
public class Shuffler {
public static Random r = new Random();
public static void swap(int[] a, int i, int s) {
int tmp = a[i];
int tmp2 = a[s];
@tonetheman
tonetheman / websocketserver.py
Created August 3, 2011 00:23 — forked from mumrah/websocketserver.py
Simple WebSockets in Python
import time
import struct
import socket
import hashlib
import sys
from select import select
import re
import logging
from threading import Thread
import signal