Skip to content

Instantly share code, notes, and snippets.

View tonetheman's full-sized avatar

Tony Colston tonetheman

View GitHub Profile
@tonetheman
tonetheman / junk.clj
Created May 9, 2013 00:09
clojure junk on how to print primitive arrays
;; how to print primitive arrays
;; http://stackoverflow.com/questions/8390983/printing-primitive-arrays-in-clojure
(def a (range 10))
(println (seq a))
;; or use java.utils.Arrays
(java.util.Arrays/toString a)
@tonetheman
tonetheman / RT.java
Created May 9, 2013 00:31
Java ray tracer
/*
# original pastbin here
# http://pastebin.com/raw.php?i=F8f5GHJZ
from math import sqrt, pow, pi
import Image
class Vector( object ):
(ns test-clj-byte-chunk-seq
(:import (java.io InputStream OutputStream
FileInputStream FileOutputStream)))
(set! *warn-on-reflection* true)
(def ^:const ONE_MEG (* 1024 1024))
(deftype ByteArrayChunk [^bytes array ^int offset ^int end]
clojure.lang.IChunk
@tonetheman
tonetheman / JL.java
Created June 14, 2013 04:47
java program example to update menu on the fly
import javax.swing.*;
public class JL {
JFrame f = null;
JMenuBar mb = null;
JMenu fm = null;
JMenuItem mi = null;
private void sleep() {
@tonetheman
tonetheman / tests_20130618.py
Created June 18, 2013 21:31
CrossBrowserTesting.com sample for start/stopping and querying running live tests
import time, json
# we use python a lot
# to do api calls with api requests is a great way to go
# see here http://docs.python-requests.org/en/latest/
import requests
# put your own auth information here, login information
# for cbt
@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);
};
<html>
<head>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script>
var user = "USERNAME", pass = "PASSWORD";
function mycallback(data)
@tonetheman
tonetheman / Mysqldates.java
Created July 11, 2013 20:29
shows date interval effects in mysql, done in java, mainly how things bunch up when you choose INTERVAL MONTH
import java.sql.*;
public class Mysqldates {
Connection db =null;
public void run() throws Exception {
db = DriverManager.getConnection("jdbc:mysql://localhost/test");
PreparedStatement st = null;
PreparedStatement st2 = null;
@tonetheman
tonetheman / Clearer.java
Created August 11, 2013 04:04
How to clear a text field when a button is pressed
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
public class Clearer {
public static void main(String[] args) {
JFrame mainframe = new JFrame("test");
mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
#!/bin/bash
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2; tput bold)
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
function red() {
echo -e "$RED$*$NORMAL"
}