Skip to content

Instantly share code, notes, and snippets.

View sfilatov's full-sized avatar

Stepan Filatov sfilatov

View GitHub Profile
@sfilatov
sfilatov / ConcurrentDictLogicTest.cs
Last active June 11, 2018 16:10
ConcurrentDictionary execution test
namespace ConsoleApp1
{
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
public class Program
@sfilatov
sfilatov / setup-windows-machine.ps1
Last active September 15, 2017 18:33
Setup Windows Desktop
# run in elevated mode
Set-ExecutionPolicy Unrestricted -Force
# Install first http://boxstarter.org/
. { Invoke-WebRequest -useb http://boxstarter.org/bootstrapper.ps1 } | Invoke-Expression; get-boxstarter -Force
# temporary disable UAC
Disable-UAC
# Windows Settings
@sfilatov
sfilatov / Buildfile.rb
Created March 15, 2012 13:05
Netty example project
require 'buildr'
repositories.remote << 'http://repo2.maven.org/maven2/'
repositories.remote << 'https://repository.jboss.org/nexus/content/repositories/releases/'
define 'helloworld' do
project.group = 'example'
project.version = '1.0-SNAPSHOT'
compile.with "org.jboss.netty:netty:jar:3.2.7.Final"
@sfilatov
sfilatov / named_scopes.rb
Created August 11, 2011 12:55
Object#chain
# sort by price after sort by date if active projects listed
collection.sort_by_date_asc.chain(|c| c.active.sort_by_price_asc if params[:active]).sort_by_customer_name_desc
@sfilatov
sfilatov / gist:1109269
Created July 27, 2011 12:36
Migrate from Hoptoad to Airbrake
# Rails 2.3.5 - 2.3.11 environment settings (config/environment.rb)
config.gem 'airbrake', :version => '2.4.11', :require => "hoptoad_notifier"
# Rails 3 - bundler Gemfile(config/Gemfile)
gem 'airbrake', '2.4.11', require => "hoptoad_notifier"
# In Hoptoad initializer (config/hoptoad.rb)
HoptoadNotifier.configure do |config|
config.api_key = '<api key>'
config.host = 'airbrakeapp.com'
@sfilatov
sfilatov / nginx.conf
Created July 7, 2011 14:47
Rails 3 send_file on Nginx
http {
sendfile on;
}
@sfilatov
sfilatov / active_record_postgres_copy_1.rb
Created July 7, 2011 14:26
Active Record postgres copy
connection = ActiveRecord::Base.connection
query = "COPY ( SELECT '#{header}' UNION ALL #{sql_query}) TO 'file.csv' WITH DELIMITER AS ',' CSV"
connection.execute query