Skip to content

Instantly share code, notes, and snippets.

View aruss's full-sized avatar
😎

Ruslan Akiev aruss

😎
  • Germany
View GitHub Profile
@aruss
aruss / partial.js
Last active August 14, 2017 07:53
Partial Response Example
/*
Use case:
var map = parseFields('id,name,sub(name)');
var dto = map(obj, map);
*/
exports.parseFields = function(str) {
@aruss
aruss / consoleService.cs
Created December 8, 2014 09:29
Wrapped service in a console
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args)
{
var service = new Service();
var arguments = string.Concat(args);
@aruss
aruss / ui-dynamic-attr.js
Created December 3, 2014 09:00
Dynamicaly add attributes, or a directive that can add directives, yo dawg!
app.directive('uiDynamicAttr', function($compile, $parse) {
return {
restrict: 'A',
terminal: true,
priority: 100000,
link: function(scope, element, args) {
var expression = element.attr('ui-dynamic-attr');
if (expression) {
var attributes = $parse(element.attr('ui-dynamic-attr'))(scope);
/*
* ASP.NET ActionFilterAttribute to help implement EU Cookie-law
* MIT Licence (c) Maarten Sikkema, Macaw Nederland BV
*/
using System;
using System.Web;
using System.Web.Mvc;
namespace Auction.Web.Utility
@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');
});
@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 / 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":
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);
// 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);
@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 = [];