This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class LinqExtension | |
{ | |
public static void ForEach<T>(this IEnumerable<T> dataSource, Action<T> act) | |
{ | |
if (dataSource != null) | |
{ | |
foreach (var item in dataSource) | |
{ | |
act(item); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*start from local*/ | |
//create repository in github and add .gitignore/readme.md | |
//init the local folder | |
git init myfolder | |
//add created remote repository | |
git remote add origin https://github.com/liujin/test.git | |
git fetch origin | |
//commit local changes | |
git add . | |
git commmit -m "init commit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Used for configuration when different user use different settings e.g. db connection string | |
/// </summary> | |
public static class ConfigurationUtil | |
{ | |
static NameValueCollection appSettings = ConfigurationManager.AppSettings; | |
static ConnectionStringSettingsCollection connectionStrings = ConfigurationManager.ConnectionStrings; | |
public static string GetAppSetting(string name) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Foo | |
#this class is in Foo:: | |
class Bar | |
end | |
#this class is not in Foo:: but in global scope | |
class ::FooBar | |
#class method | |
def self.method1 | |
'method1' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
def outer11(&bl) | |
inner1(&bl) | |
end | |
def outer12(&bl) | |
inner2(&bl) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "socket" | |
class Client | |
def initialize(ip="127.0.0.1",port=3333) | |
@ip, @port = ip, port end | |
def send_message(msg) connection do |socket| | |
socket.puts(msg) | |
socket.gets end | |
end |