Skip to content

Instantly share code, notes, and snippets.

@ianoxley
ianoxley / StringHelpers.cs
Created May 14, 2009 14:59
Some string extension methods for C# 3.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace GitHub.Gist {
/// <summary>
/// Extension methods for working with strings
/// </summary>
- simple
- public over private
- personal vanity
- internet is global
- permalinks
- one important item per page
- don't break the browser
- don't wanker in technology
- a medium is not a grande
- break convention for your users
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Github.Gist.Logging {
public interface ILogger {
void Warn(string s);
void Warn(string s, Exception ex);
import System
def is_assembly_debug_build(filename):
"""Returns true if filename appears to have been built in debug mode"""
result = False
dll = System.Reflection.Assembly.LoadFile(filename)
customAttribs = dll.GetCustomAttributes(False)
for att in customAttribs:
if att.GetType() == System.Type.GetType("System.Diagnostics.DebuggableAttribute"):
result = att.IsJITTrackingEnabled
:⌉
=⌉
¦-) as opposed to |
⍥ om nom nom
@ianoxley
ianoxley / framebust.js
Created July 28, 2010 11:30
A JavaScript snippet for framebusting
if (self != top) {
document.documentElement.style.visibility = 'hidden';
top.location = self.location;
}
# Copy a file's contents to the clipboard
cat filename | xclip -sel clip
# Generate a random password
date | md5sum
@ianoxley
ianoxley / formutils.module
Created December 6, 2010 13:59
Removing the * to denote required fields and marking all optional fields as "optional" in Drupal
function formutils_form_alter(&$form, &$form_state, $form_id) {
if (is_array($form['submitted'])) {
foreach ($form['submitted'] as $field) {
if (!$field['#required']) {
$currentTitle = $field['#title'];
$field['#title'] = $currentTitle . ' (optional)';
}
}
}
}
@ianoxley
ianoxley / varchar2nvarchar.sql
Created February 7, 2011 16:48
Changes all varchar columns to nvarchar in SQL Server
SELECT 'ALTER TABLE [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] ALTER COLUMN [' + COLUMN_NAME + '] nvarchar(' + CAST(CHARACTER_MAXIMUM_LENGTH As NVARCHAR) + ');'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE = 'VARCHAR';
@ianoxley
ianoxley / example.html.haml
Created August 15, 2011 20:06
Example code for my Introduction to Haml article on RubySource.com
!!! 5
%html
%head
%title Example HAML
/[if IE]
%link{ :rel => "stylesheet", :href => "/css/ie.css" }
%body
#container
%header
%h1 Our Awesome HTML5 Template