Skip to content

Instantly share code, notes, and snippets.

@alfeg
alfeg / gist:3818602
Created October 2, 2012 12:21
SortBy
public static IQueryable<T> SortBy<T>(this IQueryable<T> source, string propertyName)
{
propertyName = propertyName.Trim();
if (source == null)
{
throw new ArgumentNullException("source");
}
// DataSource control passes the sort parameter with a direction
// if the direction is descending
int descIndex = propertyName.IndexOf(" DESC");
@alfeg
alfeg / Main.cs
Created October 18, 2012 13:50
GUIDs generation performance test JFF
private static void Main(string[] args)
{
Console.WriteLine("Will generate 70M of Guids.\n\r Flushing timestamps for each 100k guids in one thread");
long i = 0;
long max = 120 * 1000000;
long quant = max / 100l;
var list = new Guid[max];
@alfeg
alfeg / gist:4059091
Created November 12, 2012 12:29
RequiredIf
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace KI.Web.Admin.Common.Validation
{
public class RequiredIfGreaterValidator : DataAnnotationsModelValidator<RequiredIfGreaterAttribute>
{
public RequiredIfGreaterValidator(ModelMetadata metadata, ControllerContext context, RequiredIfGreaterAttribute greaterAttribute)
/*
Copyright (c) 2010 Microsoft Corporation. All rights reserved.
Use of this sample source code is subject to the terms of the Microsoft license
agreement under which you licensed this sample source code and is provided AS-IS.
If you did not accept the terms of the license agreement, you are not authorized
to use this sample source code. For the terms of the license, please see the
license agreement between you and Microsoft.
*/
@alfeg
alfeg / gist:4176397
Created November 30, 2012 15:23
Get file sizes by there extensions
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileHlpr
{
internal class FileInformation
#define WIN32_LEAN_AND_MEAN // just say no to MFC
#define INIT_GUID
#include "hge.h"
#include <hgesprite.h>
#include <hgefont.h>
#include <hgecolor.h>

Twitter公式クライアントのコンシューマキー

Twitter for iPhone

Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU

Twitter for Android

Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPad

Consumer key: CjulERsDeqhhjSme66ECg

@alfeg
alfeg / expand.cs
Created October 15, 2013 12:41
This tool were used to convert files from tabs to spaces. This file can be compiled with mono
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace expand
@alfeg
alfeg / pewpew.cs
Last active August 29, 2015 14:14
Atomic blocking queue
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Isam.Esent.Collections.Generic;
namespace Esent
{
class Storage
{
@alfeg
alfeg / disable_wake.ps1
Created July 26, 2015 06:22
Small powershell script to disable wake PC up for all scheduled tasks
$tasks = Get-ScheduledTask
ForEach ($task in $tasks)
{
if($task.settings.waketorun -eq 'True')
{
"$($task)"
$task.settings.WakeToRun = $false
Set-ScheduledTask -TaskName $task.TaskName -TaskPath $task.TaskPath -Settings $task.Settings
}