Skip to content

Instantly share code, notes, and snippets.

View VladoMS's full-sized avatar

Vladislav Stoyanov VladoMS

View GitHub Profile
@VladoMS
VladoMS / build-zsh.sh
Created May 13, 2016 08:01 — forked from nicoulaj/build-zsh.sh
Build Zsh from sources on Ubuntu
#!/bin/sh​
# Build Zsh from sources on Ubuntu.
# From http://zsh.sourceforge.net/Arc/git.html and sources INSTALL file.
# Some packages may be missing
sudo apt-get install -y git-core gcc make autoconf yodl libncursesw5-dev texinfo
git clone git://zsh.git.sf.net/gitroot/zsh/zsh
cd zsh
@VladoMS
VladoMS / 1. infrastructure.php
Created May 3, 2016 14:53 — forked from Koc/1. infrastructure.php
Doctrine2 bulk inserts
<?php
use Doctrine\ORM\Persisters;
class DoctrineHelper
{
protected $entityManagers = array();
public function bulkCommit(EntityManager $em, array $entities)
{
@VladoMS
VladoMS / memoized-helper-methods.md
Created April 2, 2016 14:51 — forked from bloudermilk/memoized-helper-methods.md
Explaining the rationale behind using memoized helper methods for controller resources

Last year I started playing around with using memoized private helper methods in my controllers instead of the traditional instance variable assigns we see in RoR controllers. Here's an example:

class PostsController < ApplicationController
  helper_method :new_post, :post, :posts
  
  def new; end
  def show; end
  def edit; end
 def index; end
@VladoMS
VladoMS / enumerator_to_json.rb
Created March 25, 2016 09:08 — forked from brianhempel/enumerator_to_json.rb
Lazily convert an Enumerator or Enumerator::Lazy to a JSON array. Save as config/initializers/enumerator_to_json.rb
# Natively, Enumerators get JSONized like "#<Enumerator::Lazy:0x007f8714807080>", or they explode, either of which is a problem.
# We want them to make an array, and do it lazily so we don't have to keep the items in memory!
class Enumerator
def to_json(state)
state.depth += 1
string = "[\n"
first_item = true
self.each do |item|
@VladoMS
VladoMS / bench_rails_memory_usage.rb
Created March 25, 2016 08:21 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@VladoMS
VladoMS / config.json
Created March 6, 2016 09:09 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
<?php
namespace NoxLogic\DemoBundle\Form\Type;
use Doctrine\ORM\EntityManager;
use NoxLogic\DemoBundle\Entity\Province;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
buttonHTML = """<button type="button" class="attach" data-action="x-attach">Attach Files</button>"""
fileInputHTML = """<input type="file" multiple>"""
$(Trix.config.toolbar.content).find(".button_group.block_tools").append(buttonHTML)
$(document).on "trix-action-invoke", ($event) ->
if $event.originalEvent.actionName is "x-attach"
editorElement = $event.target
editorElement.focus()
@VladoMS
VladoMS / 00000000000000_CreateIdentitySchema.Designer.cs
Created December 2, 2015 17:54
Problem with migrations on MVC6 RC-1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
using WebApplication2.Models;
@VladoMS
VladoMS / SortSearchExtensions.cs
Created November 27, 2015 08:52 — forked from mombrea/SortSearchExtensions.cs
Extension Methods for table sorting and search query
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace My.App
{
public static class Extensions
{
/// <summary>