Skip to content

Instantly share code, notes, and snippets.

View merqlove's full-sized avatar

Alexander Merkulov merqlove

View GitHub Profile
@merqlove
merqlove / README.md
Last active September 29, 2015 11:26
Sberbank Address Book Cleanup
@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 / 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 / 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 / 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 / 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 / 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 / woocommerce-yandex.php
Last active September 17, 2015 08:02
WooCommerce - Yandex Market XML Example
<?php
/*
Template name: Для яндекс маркета
*/
header('Content-Type: text/xml; charset=utf-8');
preg_match('|http://(.*)|', get_option('siteurl'), $m);
$shop_name = $m[1];
@merqlove
merqlove / stackTrace.coffee
Created September 7, 2014 00:36
StackTrace with NodeJS
'use strict';
angular.module('vc.messages')
.factory "stackTrace", () ->
stackTrace = require('stack-trace')
getStack: (level) ->
stack = stackTrace.get()
for i in [0..level-1]
stack.shift()
@merqlove
merqlove / logger.coffee
Last active August 29, 2015 14:06
AngularJS / NodeWebkit logger service.
'use strict';
angular.module('vc.messages')
.factory "logger", ['$log', '$location', '$timeout', 'NwService', 'stackTrace', ($log, $location, $timeout, NwService, stackTrace) ->
log4js = require('log4js')
airbrake = require('airbrake').createClient('SOMEKEY')
airbrake.protocol = 'http'
airbrake.serviceHost = 'api.airbrake.io'
airbrake.env = 'production' if NwService.isProduction()