Skip to content

Instantly share code, notes, and snippets.

/*
Copyright (c) 2010 Adam Duke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
/* Forces exclusive access to a database allowing a restore and subsequently restores the database from a backup file. This will interrupt any existing connections and rollback any in progress transactions. Use at your own risk. */
ALTER DATABASE [database_name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE [database_name]
FROM DISK = N'C:\path\to\backup\backupfile.bak'
WITH FILE = 1, KEEP_REPLICATION, NOUNLOAD, REPLACE, STATS = 10
GO
@adamvduke
adamvduke / gist:749493
Created December 21, 2010 04:34
Inline edits text files to add a newline between the start of a control block i.e. method declaration, if/else statement etc... and opening curly brace.
#gsed is the GNU version of sed
#OSX ships with the BSD version which is apparently not the same
gsed -i 's/\([[:space:]]*\)\([[:print:]]\{1,\}\){/\1\2\n\1{/' ./Classes/*.m
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class Dependencies {
Map <String, Collection <String>> dependencyMap = new HashMap <String, Collection <String>>();
set func_call_user NilOrNotNSNull
indent_align_string=false
indent_braces=false
indent_braces_no_func=false
indent_brace_parent=false
indent_namespace=false
indent_extern=false
indent_class=false
indent_class_colon=false
@adamvduke
adamvduke / AnalyticsRBelongToUs.php
Created February 24, 2011 16:41
A php file to register views in google analytics
<?php
$var_utmac='UA-XXXXX'; //enter the new urchin code
$var_utmhn='ihazdomain.com'; //enter your domain
$var_utmcs='UTF-8'; // character set?
$var_utmsr='800x600'; //screen resolution
$var_utmsc='24-bit'; // screen colors
$var_utmul='en-us'; // language
$var_utmn=rand(1000000000,9999999999);//random request number
$var_cookie=rand(10000000,99999999);//random cookie number
$var_random=rand(1000000000,2147483647); //number under 2147483647
@adamvduke
adamvduke / Git Cheat Sheet
Created March 12, 2011 15:01
Corey Floyd's git cheat sheet
via: http://groups.google.com/group/phillycocoa/browse_thread/thread/2d05f3eac5a7d260?hl=en
revert file:
git checkout HEAD path/to/file
OR
git checkout filename
pluck one file from another branch
git checkout Branch path/to/file
#!/usr/bin/env ruby
# Seems a bit silly to have a script to run redcloth considering you can just run
# $ redcloth inputfile.textile > outputfile.html
# but whatever
class Textilize
require 'rubygems'
require 'redcloth'
#!/bin/sh
#uncrustify -l OC -c ~/.uncrustify --no-backup $(find -x -E $SRCROOT -not -regex '.*/\.?External/*.*' -name "*.[mh]")
if [ $# -ne 1 ]; then
echo "Please pass the name of the directory to format"
exit 1;
fi
if [ ! -d $1 ]; then
echo "$1 is not a directory"
HttpURLConnection connection = (HttpURLConnection) requestTokenURL.openConnection(selectProxy(requestTokenURL));