Skip to content

Instantly share code, notes, and snippets.

View mucit's full-sized avatar
🎯
Focusing

mucit mucit

🎯
Focusing
View GitHub Profile
public class NeVar
{
//
}
A common requirement with an XML file is to find a particular node. If you are targeting the .NET framework 3.5 or higher, you can find the node using Linq to XML or by using Lambda expressions.
As with many of my prior XML examples, the XML string is as follows:
<States>
<State name="Wisconsin">
<Regions>
<Region name="Milwaukee">
<Area name="Mukwanago"/>
<Area name="Germantown"/>
@mucit
mucit / EfPocoGenerator.sql
Created May 4, 2011 09:02 — forked from anehir/EfPocoGenerator.sql
Generates POCO classes for entity framework for all the tables in current database. Considers primary keys, foreign keys, and writes object descriptions saved as extended properties to the comments of classes.
set nocount on
declare @namespace varchar(500)
set @namespace = 'PersonnelManagement.Common.DataModel'
declare @typeMap table(sqlName varchar(50), dotNetName varchar(50), isNullable bit)
insert into @typeMap values('image', 'byte[2147483647]', null)
insert into @typeMap values('text', 'string', null)
insert into @typeMap values('uniqueidentifier', 'Guid', 0)
insert into @typeMap values('uniqueidentifier', 'Guid?', 1)
@mucit
mucit / gist:976502
Created May 17, 2011 13:51
sql context_info data sharing across batchs
create proc dbo.setContextUser
@m varchar(15)
as
begin
declare @v varbinary(50) ; set @v = convert(varbinary(50), @m, 0)
SET CONTEXT_INFO @v
print @m + ' set edildi'
end
@mucit
mucit / gist:1236899
Created September 23, 2011 07:29 — forked from neoGeneva/gist:1234779
Detect Encoding in C#
public static Encoding GetFileEncoding(string path)
{
if (path == null)
throw new ArgumentNullException("path");
var encodings = Encoding.GetEncodings()
.Select(e => e.GetEncoding())
.Select(e => new { Encoding = e, Preamble = e.GetPreamble() })
.Where(e => e.Preamble.Any())
.ToArray();
@mucit
mucit / hack.sh
Created September 7, 2012 20:20 — forked from ahmetb/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@mucit
mucit / __init__.py
Last active August 18, 2016 15:13
opensubtitles plugin init_py (turkish encoding fix applied)
# opensubtitles.org
# Subtitles service allowed by www.OpenSubtitles.org
# Language codes: http://www.opensubtitles.org/addons/export_languages.php
import difflib
OS_API = 'http://plexapp.api.opensubtitles.org/xml-rpc'
OS_PLEX_USERAGENT = 'plexapp.com v9.0'
SUBTITLE_EXT = ['utf','utf8','utf-8','sub','srt','smi','rt','ssa','aqt','jss','ass','idx']
using Dapper;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
public class OracleDynamicParameters : Dapper.SqlMapper.IDynamicParameters {
private static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>( );