Skip to content

Instantly share code, notes, and snippets.

View dfang's full-sized avatar
🎯
Focusing

fang duan dfang

🎯
Focusing
View GitHub Profile
@dfang
dfang / gist:3168391
Created July 24, 2012 06:33
jquery snippets : to replace console.log
Snippets:
jQuery.logThis = function( text ){
if( (window['console'] !== undefined) ){
console.log( text );
}
}
@dfang
dfang / gist:3168404
Created July 24, 2012 06:36
IRepository<T> Interface
public interface IRepository<T>: IDisposable where T : class
{
/// <summary>
/// Gets all objects from database
/// </summary>
IQueryable<T> All();
/// <summary>
/// Gets objects from database by filter.
/// </summary>
@dfang
dfang / gist:3168409
Created July 24, 2012 06:38
nop 修改两行代码提高性能30%
public T Resolve<T>() where T : class
{
return ContainerManager.Container.IsRegistered<T>()?ContainerManager.Resolve<T>():null;
}
public object Resolve(Type type)
{
return ContainerManager.Container.IsRegistered(type)?ContainerManager.Resolve(type):null;
}
@dfang
dfang / .vimrc
Created August 2, 2012 02:05
My .vimrc.local file
set nocompatible " be iMproved
filetype off " required!
"--------------------
"" enable vundle
"--------------------
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
@dfang
dfang / gist:3781096
Created September 25, 2012 10:33
get url params
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
@dfang
dfang / capistrano deploy to local vagrant
Last active March 1, 2018 21:45
very very very basic guide for deploy rails application to local application
# assumptions: virtualbox, vagrant already installed
# and there is a box lucid32
1. rails new appdmeo , gem capistrano , then bundle
2. vagrant init lucid32
3. capify .
# !important
# vagrant ssh-config >> ~/.ssh/config
# vagrant ssh-config | grep IdentityFile | awk '{print $2}' that's where private key located
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CSS: source.css

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@dfang
dfang / gist:5813836
Created June 19, 2013 12:15
custom filter for jquery
$.expr[':'].external = function(elem,index,match) {
var url = elem.href || elem.src,
loc = window.location;
return !!url.match(new RegExp('^' + loc.protocol + '//' + '(?!' + loc.hostname + ')' ));
};
// You can now use it within your selectors:
// Find all external anchors:
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile