Skip to content

Instantly share code, notes, and snippets.

View postnati's full-sized avatar

Greg Pattison postnati

View GitHub Profile
@postnati
postnati / test_radio_module_communication.rb
Created January 5, 2011 14:27
Test Radio Module Communication
def test_radio_module_communication
total_reads = 20
overall_result = "SUCCESS"
# get the current study table first so it can be reset after test
original_serial_numbers = get_serial_numbers_from_study_table
# ---------------------------------------------------------------
# clear out the current study table
send_set_study_table_command([])
@postnati
postnati / survey_scoring_code.cs
Created January 13, 2011 21:31
Survey Scoring Code
int points = 0;
int unpoints = 0;
RadioButton[] radiolist = new RadioButton[] { RadioButton11, RadioButton12, RadioButton13, RadioButton14, RadioButton15, RadioButton21, RadioButton22, RadioButton23, RadioButton24, RadioButton25, RadioButton31, RadioButton32, RadioButton33, RadioButton34, RadioButton35, RadioButton51, RadioButton52, RadioButton53, RadioButton54, RadioButton55, RadioButton71, RadioButton72, RadioButton73, RadioButton74, RadioButton75, RadioButton81, RadioButton82, RadioButton83, RadioButton84, RadioButton85, RadioButton91, RadioButton92, RadioButton93, RadioButton94, RadioButton95, RadioButton101, RadioButton102, RadioButton103, RadioButton104, RadioButton105, RadioButton121, RadioButton122, RadioButton123, RadioButton124, RadioButton125 };
for (int i = 0; i < radiolist.Length; i++)
{
if (i % 5 == 0 && radiolist[i].Checked)
unpoints += 1;
if (i % 5 == 1 && radiolist[i].Checked)
@postnati
postnati / send_google_email.rb
Created January 20, 2011 02:14
Send email from Ruby using google's smtp server
require 'net/smtp'
def send_email(from, from_alias, to, to_alias, subject, message)
msg = <<END_OF_MESSAGE
From: #{from_alias} <#{from}>
To: #{to_alias} <#{to}>
Subject: #{subject}
#{message}
END_OF_MESSAGE
@postnati
postnati / jwplayer.html
Created January 27, 2011 07:55
JWPlayer Code
<script type='text/javascript' src='http://YOUR-CLOUDFRONT-SPECIFIC-SUBDOMAIN.cloudfront.net/video/swfobject.js'></script>
<div id='mediaspace'>This text will be replaced</div>
<script type="text/javascript">
// see http://blog.deconcept.com/swfobject/ for documentation on SWFObject function
var so = new SWFObject('http://YOUR-CLOUDFRONT-SPECIFIC-SUBDOMAIN.cloudfront.net/video/player.swf','mpl',"640","360",'9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
@postnati
postnati / gist:995432
Created May 27, 2011 15:05
Create MySQL CSV using SELECT's INTO OUTFILE
mysql --user=root --password='' -e "SELECT GROUP_CONCAT(COLUMN_NAME SEPARATOR '\t') FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='phineas_and_ferb' and table_name='characters' INTO OUTFILE '~/tmp/output.txt' FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '' ESCAPED BY '' LINES TERMINATED BY '\n';"
mysql --user=root --password='' phineas_and_ferb -e "SELECT * FROM characters INTO OUTFILE '~/tmp/data.txt' FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n';"
cat ~/tmp/data.txt >> ~/tmp/output.txt
@postnati
postnati / gist:995440
Created May 27, 2011 15:09
MySQL CSV using SELECT
mysql --user=root --password='' --column-names=TRUE phineas_and_ferb -e "SELECT * from characters;" > ~/tmp/output.txt
@postnati
postnati / gist:995445
Created May 27, 2011 15:10
MySQL CSV using mysqldump
mysql --user=root --password='' -e "SELECT GROUP_CONCAT(COLUMN_NAME SEPARATOR '\t') FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='phineas_and_ferb' and table_name='characters' INTO OUTFILE '~/tmp/output.txt' FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '' ESCAPED BY '' LINES TERMINATED BY '\n';"
mysqldump --single-transaction --user=root --password='' -T ~/tmp/ phineas_and_ferb --fields-enclosed-by=\"
cat ~/tmp/characters.txt >> ~/tmp/output.txt
@postnati
postnati / gist:995457
Created May 27, 2011 15:17
Database setup for MySQL CSV creation examples
mysql --user=root --password='' -e 'DROP DATABASE phineas_and_ferb;'
mysql --user=root --password='' -e 'CREATE DATABASE phineas_and_ferb;'
mysql --user=root --password='' phineas_and_ferb -e 'CREATE TABLE characters (id INT, name VARCHAR(100), bio VARCHAR(100));'
mysql --user=root --password='' phineas_and_ferb -e 'INSERT INTO characters VALUES (1, "Phineas", "Thinking up ways to squeeze more fun out of every summer day helps Phineas stay entertained.");'
mysql --user=root --password='' phineas_and_ferb -e 'INSERT INTO characters VALUES (2, "Ferb", "Ferb is the brains behind the gadgets and contraptions.");'
mysql --user=root --password='' phineas_and_ferb -e 'INSERT INTO characters VALUES (3, "Perry the Platypus", "This pet platypus hides a secret life as crime-fighting agent P!");'
@postnati
postnati / gist:995513
Created May 27, 2011 15:42
Result from MySQL CSV using mysqldump
id name bio
"1" "Phineas" "Thinking up ways to squeeze more fun out of every summer day helps Phineas stay entertained."
"2" "Ferb" "Ferb is the brains behind the gadgets and contraptions."
"3" "Perry the Platypus" "This pet platypus hides a secret life as crime-fighting agent P!"
@postnati
postnati / gist:995518
Created May 27, 2011 15:44
Result from MySQL CSV using SELECT's INTO OUTFILE
id name bio
1 "Phineas" "Thinking up ways to squeeze more fun out of every summer day helps Phineas stay entertained."
2 "Ferb" "Ferb is the brains behind the gadgets and contraptions."
3 "Perry the Platypus" "This pet platypus hides a secret life as crime-fighting agent P!"