Skip to content

Instantly share code, notes, and snippets.

View aruss's full-sized avatar
😎

Ruslan Akiev aruss

😎
  • Germany
View GitHub Profile
@aruss
aruss / CacheHelper.cs
Last active December 15, 2015 03:58
Cache Helper
public static class CacheHelper
{
public static string GetCachedResult(string key, Func<string> handle, int espiration = 86400)
{
var cache = HttpContext.Current.Cache;
var response = cache.Get(key);
if (response == null)
{
response = handle();
public static class HumanNameGenerator
{
public enum Gender
{
Unknown = 0,
Male = 1,
Female = 2
}
private static readonly Random Rand = new Random((int)DateTime.Now.Ticks);
@aruss
aruss / GuidGenerator.cs
Last active December 19, 2015 05:09
Sequential Guid Generator
using System;
using System.Runtime.InteropServices;
namespace eConduct.Extensions
{
public static class GuidGenerator
{
[DllImport("rpcrt4.dll", SetLastError = true)]
private static extern int UuidCreateSequential(out Guid guid);
@aruss
aruss / UUIDGenerator.cs
Last active December 19, 2015 05:49
Kooboo UUIDGenerator with IoC
public interface IUUIDGenerator
{
string Generate(ContentBase content);
}
public class GuidUIIDGenerator : IUUIDGenerator
{
[DllImport("rpcrt4.dll", SetLastError = true)]
private static extern int UuidCreateSequential(out Guid guid);
@aruss
aruss / tourl.js
Last active December 19, 2015 18:29
Generate URI with path and query http://jsfiddle.net/aruss/wfCLT/1/
if (!String.prototype.toUrl) {
String.prototype.toUrl = function(o) {
var r = this.replace(/\{([^{}]*)\}/g,function (a, b) {
var r = o[b];
delete o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
}
), p = [];
// paste it in your browsers console while surfing on facebook and you will like all things
(function (){
var d = [],
i = 0,
l = 0,
li = setInterval(function() {
if (i < l) {
console.log('like ' + i + ' out of ' + l);
public static class EnumerableExtensions
{
public static IEnumerable<IEnumerable<TSource>> SplitWithRest<TSource>(this IEnumerable<TSource> source, params Func<TSource, bool>[] predicates)
{
var taken = new List<TSource>();
for (int i = 0, l = predicates.Length; i < l; i++)
{
var take = source.Where(predicates[i]);
taken.AddRange(take);
@aruss
aruss / Preferences.sublime-settings
Created February 18, 2014 13:54
My Sublime Text 2 user settings
{
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_with_fields": true,
"bold_folder_labels": true,
"caret_style": "phase",
"detect_indentation": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
@aruss
aruss / DependencyController.cs
Last active August 29, 2015 13:56
Dependency Resolver Action
public class DependencyController : Controller
{
public ActionResult Index(string repositoryName, string assembyName, string typeFullName)
{
if (!String.IsNullOrWhiteSpace(assembyName) &&
!String.IsNullOrWhiteSpace(typeFullName))
{
var assembly = Assembly.Load(assembyName);
if (assembly != null)
{
@aruss
aruss / ng-template.js
Last active August 29, 2015 14:01
AngularJs snipptes
(function(app, $) {
app.directive('fooBar', function($timeout) {
return {
link: function(scope, elm, attrs) {
elm.on('public.action', function(e) {
// do stuff, call it by $('#elm').trigger('public.action');
});