Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Oxley ianoxley

View GitHub Profile
@ianoxley
ianoxley / StringHelpers.cs
Created May 14, 2009
Some string extension methods for C# 3.0
View StringHelpers.cs
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>
View Web product guidelines
- 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
View ILogger.cs
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);
View diagnostics.py
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
View gist:217439
:⌉
=⌉
¦-) as opposed to |
⍥ om nom nom
@ianoxley
ianoxley / framebust.js
Created Jul 28, 2010
A JavaScript snippet for framebusting
View framebust.js
if (self != top) {
document.documentElement.style.visibility = 'hidden';
top.location = self.location;
}
View one-liners.sh
# Copy a file's contents to the clipboard
cat filename | xclip -sel clip
# Generate a random password
date | md5sum
@ianoxley
ianoxley / formutils.module
Created Dec 6, 2010
Removing the * to denote required fields and marking all optional fields as "optional" in Drupal
View formutils.module
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 Feb 7, 2011
Changes all varchar columns to nvarchar in SQL Server
View varchar2nvarchar.sql
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 / base58.py
Created Mar 11, 2011
base58 encoding in Python
View base58.py
""" base58 encoding / decoding functions """
import unittest
alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
base_count = len(alphabet)
def encode(num):
""" Returns num in a base58-encoded string """
encode = ''
You can’t perform that action at this time.