Skip to content

Instantly share code, notes, and snippets.

View booyaa's full-sized avatar
🏠
Dayjob

Mark Sta Ana booyaa

🏠
Dayjob
View GitHub Profile
@booyaa
booyaa / FillDataTablefromSqlTable.cs
Last active December 18, 2015 09:49
Fill datatable from SQL table source #oledb #csharp
DataTable dt = new DataTable();
OleDbConnection conn = new OleDbConnection(@"Provider=OraOLEDB.Oracle;Data Source=FOO.WORLD;user id=fubar;password=snafu;PLSQLRSet=1;");
string sql = @"select foo, bar from snafu";
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
// you'll automatically get the columns from the select, wildcards work too. also don't go past 16M rows
@booyaa
booyaa / Benchmarking.cs
Last active December 18, 2015 09:49
Benchmarking in C#
// Source: http://www.blackwasp.co.uk/SpeedTestWithStopwatch_2.aspx
// Use it to compare things like da.Fills vs iterating over an OleDbDataReader.
using System;
using System.Diagnostics;
namespace StopWatchExample
{
class Example
{
@booyaa
booyaa / LinqDataTable.cs
Created June 12, 2013 11:04
Linq A DataTable
// sources: http://stackoverflow.com/a/11593/105282
var results = from r in dt.AsEnumerable()
select r.Field<string>("foo");
foreach(var item in results.ToList())
{
Console.WriteLine(item);
}
@booyaa
booyaa / SProcsNamedParams.cs
Created June 12, 2013 14:52
Running Stored Procedures with named parameters in C# #CSharp #AdoNet
// pro-tip: don't believe anyone who says you can use OleDbCommmand to achieve this. You can specify parameters,
// but ultimately everything is dependant on parameter order e.g.
// exec usp_Foo @p1=1, @p2=2 - if you use OleDbCommand you need to specify each OleDbParameter.Add in sequence i.e.
//
// cmd.Parameter.AddWithValue("@p1", 1);
// cmd.Parameter.AddWithValue("@p2", 2);
//
// also you need to null any values you don't want to pass e.g. if you had @p0 you would need include it otherwise
// @p0 would get the value of @p1, @p1 would get the value of @p2.
//
@booyaa
booyaa / SingleHandedCoder.md
Last active December 18, 2015 11:08
Single handed coder

###background

this is my journal of my temporary disability. i hope to share lessons learnt from my experience. my primary focus will be on coding using the following ides: visual studio 2010 (windows xp - yes i know) and vim (osx).

###benchmark

i used the following on-line touch typing test: http://www.typingtest.com/ to assess before my temporary disability and here are the results:

left handed: 20 words per minute full use of both hands: 60 words per minute

@booyaa
booyaa / README.md
Last active December 19, 2015 09:39
Hello world
@booyaa
booyaa / timesheet.js
Created July 5, 2013 14:35
timesheet
function parseTime(timeString) {
return timeString.split(":");
}
function process() {
console.log($('input[name="start"]'));
var data = {};
data["start"] = parseTime($('input[name="start"]').val());
data["end"] = parseTime($('input[name="end"]').val());
data["lunch"] = $('input[name="lunch"]').val();
@booyaa
booyaa / blackMagicks.mkd
Last active December 19, 2015 13:49
data uri + contenteditable = crazy delicious

borrowed from http://www.fizerkhan.com/blog/posts/Use-your-browser-as-Notepad.html

paste into your browser's address bar (won't work on ie and may need base64ing on ffx)

hello world: data:text/html, <html contenteditable>

bad acid: data:text/html, <html><head><link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'><style type="text/css"> html { font-family: "Open Sans" } * { -webkit-transition: all linear 1s; }</style><script>window.onload=function(){var e=false;var t=0;setInterval(function(){if(!e){t=Math.round(Math.max(0,t-Math.max(t/3,1)))}var n=(255-t*2).toString(16);document.body.style.backgroundColor="#ff"+n+""+n},1e3);var n=null;document.onkeydown=function(){t=Math.min(128,t+2);e=true;clearTimeout(n);n=setTimeout(function(){e=false},1500)}}</script></head><body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;">

bit of js flair: ```data:text/html,<title>DoJS</title><style type="text/css">#e{font-size

@booyaa
booyaa / dabblet.css
Created July 10, 2013 09:01
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
/* test */
@booyaa
booyaa / editorMuscleMemory.md
Last active December 19, 2015 15:19
editors muscle memory

##editors muscle memory

###select a block

  • vim ``v|V``` (block/line)
  • visual studio shift and arrow keys
  • emacs

###copy