Skip to content

Instantly share code, notes, and snippets.

Avatar

Will Boyd lonekorean

View GitHub Profile
@lonekorean
lonekorean / gist:8755458
Last active Aug 29, 2015
Multiple passes regex
View gist:8755458
(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*\d).*
@lonekorean
lonekorean / gist:8757510
Last active Aug 29, 2015
Old Twitter feed code
View gist:8757510
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
public class TweetLoader
{
const string ATOM_NAMESPACE = "http://www.w3.org/2005/Atom";
const string SCREEN_NAME = "lonekorean"; // TODO: your twitter name goes here
const int NUM_TWEETS = 5;
const int MAX_ATTEMPTS = 3;
@lonekorean
lonekorean / gist:8757255
Last active Aug 29, 2015
Suckerfish dropdown doctype
View gist:8757255
<!DOCTYPE html>
<html>
<!-- the rest of your HTML -->
@lonekorean
lonekorean / gist:8759053
Last active Aug 29, 2015
SyntaxHighlighter per snippet config
View gist:8759053
<pre class="brush: c#; tab-size: 2; toolbar: false;">
...
</pre>
@lonekorean
lonekorean / gist:8756498
Last active Aug 29, 2015
Still bad image preloader
View gist:8756498
// better, but still not good
function imageLoaded(i) {
alert(i);
}
for (var i = 0; i &lt; max; i++) {
var image = new Image();
image.onload = function () { imageLoaded(i) };
// more irrelevant stuff here
@lonekorean
lonekorean / gist:8755736
Last active Aug 29, 2015
JavaScript Date object
View gist:8755736
var date = new Date();
alert('Day of month: ' + date.getDate());
alert('Month: ' + date.getMonth());
alert('Day of week: ' + date.getDay());
@lonekorean
lonekorean / gist:8756258
Last active Aug 29, 2015
SQL query for column information
View gist:8756258
SELECT
C.name AS ColumnName,
T.name As DataType,
C.max_length AS Length
FROM sys.columns AS C JOIN sys.types AS T ON C.user_type_id = T.user_type_id
WHERE c.object_id = OBJECT_ID('YOUR_TABLE_NAME_HERE')
ORDER BY c.column_id;
@lonekorean
lonekorean / gist:8755747
Last active Aug 29, 2015
JavaScript function parameters
View gist:8755747
function f(a, b) {
alert(a);
alert(b);
}
f(1); // a gets 1, while b is undefined
f(1, 2, 3); // the 3 is ignored
@lonekorean
lonekorean / gist:8759079
Last active Aug 29, 2015
SyntaxHighlighter default snippet config
View gist:8759079
SyntaxHighlighter.defaults['tab-size'] = 2;
SyntaxHighlighter.defaults['toolbar'] = false;
@lonekorean
lonekorean / gist:8756268
Last active Aug 29, 2015
SQL query for column information output
View gist:8756268
ColumnName DataType Length
========== ======== ======
ID int 4
Title varchar 255
Blurb varchar 255
IsActive bit 1
Created datetime 8