Skip to content

Instantly share code, notes, and snippets.

View merqlove's full-sized avatar

Alexander Merkulov merqlove

View GitHub Profile
@merqlove
merqlove / optimization.rake
Created January 9, 2015 13:55
PostgreSQL optimization tasks for ActiveRecord
namespace :optimization do
desc "Provide DB vacuum for production environment"
task :vacuum => :environment do
begin
tables = ActiveRecord::Base.connection.tables
tables.each do |table|
ActiveRecord::Base.connection.execute("VACUUM FULL ANALYZE #{table};")
end
rescue Exception => exc
Rails.logger.error("Database VACUUM error: #{exc.message}")
@merqlove
merqlove / Gemfile
Last active August 29, 2015 14:14
Importing Apple Notes with Ruby
# A sample Gemfile
source "https://rubygems.org"
gem 'sqlite3'
gem 'pony'
@merqlove
merqlove / sidekiq
Last active August 29, 2015 14:22
Sidekiq init script
#!/bin/bash
#
# Alexander Merkulov sasha@merqlove.ru
# Contributors : @merqlove
# App Version : 6.x
# chkconfig: 2345 82 55
# processname: sidekiq_some_service
# description: Runs sidekiq for some_service.
@merqlove
merqlove / scraper.js
Last active August 29, 2015 14:24
Droplr Export Uids
var dropList = [];
for(var i in Droplr.DropList.models) {
// Find the drop ID in the list
var dropID = Droplr.DropList.models[i].id,
dropTitle = Droplr.DropList.models[i].attributes.title;
if(dropList.indexOf(dropID) == -1) { // If ID is not on the list, add it to the list
dropList.push({id: dropID, title: dropTitle});
}
@merqlove
merqlove / do_snapshot_gli_crap.rb
Created July 21, 2015 22:38
GLI binary scaffold
#!/usr/bin/env ruby
# -*- encoding : utf-8 -*-
Signal.trap('INT') { exit 1 }
# resolve bin path, ignoring symlinks
require 'pathname'
bin_file = Pathname.new(__FILE__).realpath
# add self to libpath
@merqlove
merqlove / Dockerfile
Last active August 29, 2015 14:28 — forked from mokevnin/Dockerfile
hexlet.io: configuration management and deploy
FROM ruby:2.2.1
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ENV RAILS_ENV production
ENV REFILE_CACHE_DIR /var/tmp/uploads
RUN curl -sL https://deb.nodesource.com/setup | bash -
@merqlove
merqlove / README.md
Last active September 29, 2015 11:26
Sberbank Address Book Cleanup
@merqlove
merqlove / swig.rb
Last active October 23, 2015 22:37
Swig
require 'formula'
class Swig < Formula
url 'http://downloads.sourceforge.net/project/swig/swig/swig-2.0.4/swig-2.0.4.tar.gz'
homepage 'http://www.swig.org/'
sha256 '763a117730d26f8e5ed67f5718c6c0761fbb8461680fc20269db8c0839e1ec8a'
depends_on 'pcre'
def install
@merqlove
merqlove / dynamic.java
Created November 2, 2015 12:08
Dynamic methods in java
class Logger {
private BiConsumer<Object, Integer> logger = null;
// ...
private Logger(Object logger) {
this.akkaLogger = (LoggingAdapter) logger;
this.logger = (message, level) -> {
switch (level) {
case INFO: akkaInfo(message);
@merqlove
merqlove / osx_fix.sh
Created December 7, 2015 11:45
OSX Preferences
# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
# Set a shorter Delay until key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 12
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0
# Disable window animations ("new window" scale effect)