Skip to content

Instantly share code, notes, and snippets.

View KANekT's full-sized avatar

Пронин Андрей KANekT

View GitHub Profile
@KANekT
KANekT / DeclensionGenerator
Created May 3, 2018 13:02
Склонение числительных в C#
public class DeclensionGenerator
{
/// <summary>
/// Возвращает слова в падеже, зависимом от заданного числа
/// </summary>
/// <param name="number">Число от которого зависит выбранное слово</param>
/// <param name="nominativ">Именительный падеж слова. Например "день"</param>
/// <param name="genetiv">Родительный падеж слова. Например "дня"</param>
/// <param name="plural">Множественное число слова. Например "дней"</param>
/// <returns></returns>
@KANekT
KANekT / QueryableExtensions.cs
Created February 3, 2017 13:33
QueryableExtensions C#
public static class QueryableExtensions
{
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler");
private static readonly PropertyInfo NodeTypeProviderField = QueryCompilerTypeInfo.DeclaredProperties.Single(x => x.Name == "NodeTypeProvider");
private static readonly MethodInfo CreateQueryParserMethod = QueryCompilerTypeInfo.DeclaredMethods.First(x => x.Name == "CreateQueryParser");
split -l 20000 /Users/kanekt/KANekT/sql/_.sql
public static class AccessorCache
{
private static readonly Hashtable Accessors = new Hashtable();
private static readonly Hashtable CallSites = new Hashtable();
private static CallSite<Func<CallSite, object, object>> GetCallSiteLocked(string name)
{
var callSite = (CallSite<Func<CallSite, object, object>>)CallSites[name];
if (callSite == null)
Подскажите плиз как можно выполнить определенную функцию несколько раз с разными промежутками времени между запусками.
Типа сначала короткие просежутки потом больше больше.
Rx.Observable.range(1,3)
.delayWhen((i) => Rx.Observable.interval(i * 5000))
.subscribe(console.log.bind(console))
Или если нужен Random (от 0 до 5 секунд)
Rx.Observable.range(1,3)
.delayWhen((i) => Rx.Observable.interval(Math.random() * 5000))
var watch = System.Diagnostics.Stopwatch.StartNew();
watch.Stop();
var elapsedMs = watch.ElapsedMilliseconds;
@KANekT
KANekT / BootStrapSpinner
Last active August 29, 2015 14:07
BootStrap Spinner
<div class="input-group spinner">
<input type="text" class="form-control" value="@Model">
<div class="input-group-btn-vertical">
<span class="btn btn-default"><i class="glyphicon glyphicon-chevron-up"></i></span>
<span class="btn btn-default"><i class="glyphicon glyphicon-chevron-down"></i></span>
</div>
</div>
@KANekT
KANekT / gist:4018083
Created November 5, 2012 16:21
PunBB Sub
// Get any subscribed users that should be notified (banned users are excluded)
$query = array(
'SELECT' => 'u.id, u.email, u.notify_with_post, u.language, u.username',
'FROM' => 'users AS u',
'JOINS' => array(
array(
'INNER JOIN' => 'subscriptions AS s',
'ON' => 'u.id=s.user_id'
),
array(
@KANekT
KANekT / gist:1292961
Created October 17, 2011 16:04
jQuery UI punBB
$ext_jQuery_UI->add_jQuery_UI("Button");