Skip to content

Instantly share code, notes, and snippets.

View sholfen's full-sized avatar

Peter Liang sholfen

View GitHub Profile
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
@sholfen
sholfen / Check 64 bit OS and process
Created November 13, 2013 09:51
you can use this code to check OS is 64 bit or 32 bit.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
@sholfen
sholfen / gist:b3c40c7c64721b94c778
Last active August 29, 2015 14:02
AutoMapper demo code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
namespace AutoMapperConsoleAP
{
class Program
@sholfen
sholfen / gist:4580ce39968a57cca0f9
Created September 18, 2014 07:41
Check OS Version
OperatingSystem OS = Environment.OSVersion;
if (OS.Platform == System.PlatformID.MacOSX)
{
Console.WriteLine("It's not Windows OS.");
}
else
{
Console.WriteLine(OS.Platform.ToString());
}
@sholfen
sholfen / gist:3b3938ecbf958978f3b7
Created September 25, 2014 02:55
Lucene.Net demo: IndexItems function
static void IndexItems(List<Product> list)
{
Lucene.Net.Store.Directory directory = FSDirectory.Open(new DirectoryInfo(@"D:\Index"));
IndexWriter indexWriter = new IndexWriter(
directory,
new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30),
true,
IndexWriter.MaxFieldLength.LIMITED);
foreach (Product product in list)
@sholfen
sholfen / gist:ecbf4e44f1fc701bf9a2
Created October 21, 2014 14:57
C# 6.0 - Auto Properties
public class Foo
{
//auto property
public int x { get; set; } = 1;
public int y { get; set; } = 2;
}
@sholfen
sholfen / gist:0bf1b2411f42028b9110
Last active August 29, 2015 14:11
Sinatra Test
# myapp.rb
require 'sinatra'
require 'yajl'
require 'json'
encoder = Yajl::Encoder.new
get '/' do
'Hello world!'
end
@sholfen
sholfen / gist:eb53cfd53bd7382e56bb
Created February 17, 2015 10:19
Print Expression Information
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace ExpressionTreeConsoleApplication
{
class Program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsyncConsoleApplication
{
class Program
{
@sholfen
sholfen / gist:513ed73ab68af578191e
Created July 12, 2015 10:15
Attribute Class Tip: AttributeUsage
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AttributeTestConsoleApplication
{
class Program
{