Skip to content

Instantly share code, notes, and snippets.

View ljinke's full-sized avatar

Jinke Liu ljinke

  • Autodesk
  • Shanghai, China
View GitHub Profile
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);
}
/*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"
/// <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)
{
@ljinke
ljinke / ruby namespace ::.rb
Last active December 24, 2015 01:29
:: in Ruby
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
@ljinke
ljinke / proc.rb
Last active December 26, 2015 20:29
performance of Ruby Proc and block
require 'benchmark'
def outer11(&bl)
inner1(&bl)
end
def outer12(&bl)
inner2(&bl)
end
@ljinke
ljinke / gist:0b4a7a506d32f36a8cf8
Created November 11, 2014 01:15
use codeblock for pre/post processing
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