Skip to content

Instantly share code, notes, and snippets.

View bigsan's full-sized avatar

San Chen bigsan

  • LearningTech
  • Taiwan
View GitHub Profile
@bigsan
bigsan / CleanlyMigrateFromSvn.sh
Created January 17, 2010 08:00
Git: migrate from svn to git
# source: http://www.jonmaddox.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/
mkdir my_blog_tmp
cd my_blog_tmp
# --no-metadata, tells GIT to leave all the SVN details behind (not the commit log)
git-svn init http://code.yoursite.net/my_blog/trunk/ --no-metadata
# remap all the SVN users to GIT users when it sucks down the source and history
git config svn.authorsfile ~/Desktop/users.txt
@bigsan
bigsan / jquery.tree.datastores.asmx.js
Created January 26, 2010 16:48
JavaScript: add asmx support to jstree 0.99
(functioin($) {
$.extend($.tree.datastores, {
"asmx": function() {
// borrow datastore from "json"
var asmxds = $.tree.datastores.json();
// override "load" function:
// 1. serialize input data into string through JSON.stringify
// 2. add "contentType" attribute to $.ajax call
asmxds.load = function(data, tree, opts, callback) {
@bigsan
bigsan / HTML5 Offline Data.js
Created October 27, 2010 14:38
JavaScript: Checking for offline data functionality
// Key/value storage
if ('localStorage' in window) { ... }
if ('sessionStorage' in window) { ... }
// SQL API
if ('openDatabase' in window) { ... }
// Offline application cache
if ('applicationCache' in window) { ... }
@bigsan
bigsan / KillDatabaseProcess.sql
Created November 19, 2010 17:19
SQL: Kill processes related to some database
DECLARE @dbName nvarchar(max), @sql nvarchar(max)
SELECT @dbName = N'__DBNAME__', @sql = N''
SELECT @sql = @sql + N'KILL ' + CONVERT(nvarchar(max), spid) + ';'
FROM master..sysprocesses
WHERE dbid = DB_ID(@dbName)
--EXEC sp_executesql @sql
@bigsan
bigsan / dbinfo.sql
Created November 19, 2010 17:34
SQL: show databases info similar to sp_helpdb
SELECT
[name] database_name,
database_id,
SUSER_SNAME(owner_sid) owner_name,
recovery_model_desc,
collation_name,
[compatibility_level],
create_date
FROM sys.databases
@bigsan
bigsan / changedbowner.sql
Created November 19, 2010 17:39
SQL: Change dbowner like sp_changedbowner
-- change dbowner of __DBNAME__ to sa
ALTER AUTHORIZATION ON DATABASE::[__DBNAME__] TO sa
@bigsan
bigsan / casperjs.ps1
Created April 20, 2012 13:47
PowerShell: rewrite casperjs from python to powershell
$PHANTOMJS_NATIVE_ARGS =
'cookies-file',
'config',
'disk-cache',
'ignore-ssl-errors',
'load-images',
'load-plugins',
'local-to-remote-url-access',
'max-disk-cache-size',
'output-encoding',
@bigsan
bigsan / gist:3826192
Created October 3, 2012 10:06
Less: CSS3 Ribbon
@size: 150px;
@ribbon-width: 210px;
@ribbon-height: 28px;
@offset: 13px;
@ribbon-left: (@size - @ribbon-width) / 2 + @offset;
@ribbon-top: (@size - @ribbon-height) / 2 - @offset;
.ribbon {
width: @size;
height: @size;
@bigsan
bigsan / gist:3958016
Created October 26, 2012 10:17
TypeScript: readFile function in io.ts
readFile: function(path) {
try {
var file = fso.OpenTextFile(path);
var bomChar = !file.AtEndOfStream ? file.Read(2) : '';
var str = bomChar;
if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF)
|| (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) {
// Reopen the file as unicode
file.close();
file = fso.OpenTextFile(path, 1 /* IOMode.ForReading */, false /* Create */, -1 /* Format.TristateUseUnicode */);
@bigsan
bigsan / gist:4015910
Created November 5, 2012 07:58
Less: inset shadow on top/bottom side
.shadow-top-inset(@length: 15px, @color: gray) {
box-shadow: inset 0 @length @length -@length @color;
}
.shadow-bottom-inset(@length: 15px, @color: gray) {
box-shadow: inset 0 -@length @length -@length @color;
}
.shadow-top-bottom-inset(@length: 15px, @color: gray) {
box-shadow:
inset 0 @length @length -@length @color,
inset 0 -@length @length -@length @color;