Skip to content

Instantly share code, notes, and snippets.

View localhots's full-sized avatar

Gregory Eremin localhots

View GitHub Profile
@localhots
localhots / theme_desktop.plist
Created October 20, 2012 12:16
Twitterrific theme config with Lucida Grande
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compose</key>
<dict>
<key>characterCounterFont</key>
<string>11 LucidaGrande-Bold</string>
<key>font</key>
<string>13 LucidaGrande</string>
@localhots
localhots / example_response.js
Last active August 20, 2018 13:39
VK.com stored procedure that gets user info and location info if present
response: {
user: {
uid: 1,
first_name: 'Павел',
last_name: 'Дуров',
nickname: '',
screen_name: 'durov',
sex: 2,
bdate: '10.10.1984',
city: '2',
#!/usr/bin/env ruby
last_commit = `git rev-parse HEAD`.chomp
system 'git pull --rebase'
news = `git whatchanged #{last_commit}..HEAD`
files = Hash.new do |hash, key|
hash[key] = { :status => [], :author => [] }
end
@localhots
localhots / deploy.rb
Last active December 18, 2015 15:19
Keep your deploy.rb clean! Move all customs tasks to config/deploy/recipes/. Define triggers only in deploy.rb file.
require 'bundler/capistrano'
logger.level = Logger::DEBUG # Logger::IMPORTANT
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
server 'example.com', :web, :app, :db, :sidekiq, primary: true
set :application, 'example'
@localhots
localhots / install.sh
Last active December 29, 2015 15:29
OSX Launch agent that shuts Transmission.app down on weekdays at 12 noon
cd ~/Library/LaunchAgents
wget https://gist.githubusercontent.com/localhots/c224b49f4f70b937e2d1/raw/2b60ee2593310fa89aea4396dc7e5c2ada37b608/ru.aviasales.notorrents.plist
launchctl load xxx.localhots.notorrents.plist
cd -
[
{
"weight": "400",
"style": "italic",
"family": "ABeeZee"
},
{
"weight": "400",
"style": "normal",
"family": "ABeeZee"
@localhots
localhots / config.ru
Created January 27, 2014 13:01
Tiny static serving server written in Ruby
%w[ logger yaml rack eventmachine ].each(&method(:require))
log = Logger.new(STDOUT)
config = YAML.load_file('config.yml')
Thread.new{ EM.run }
templates = config['storage']['templates'].map{ |tpl| config['storage']['root'] + tpl }
cache = templates.map{ |tpl| Dir[tpl] }.inject(:+).keep_if{ |f| File.file?(f) }
cache = Hash[cache.map do |f|
l = config['storage']['root'].length
@localhots
localhots / application_controller.rb
Created March 6, 2014 16:15
Clear impersonation logic in Rails
def session_user
@session_user ||= if current_user.admin? && params[:user_id].present?
User.find(params[:user_id])
else
current_user
end
end
DELIMITER $$
CREATE FUNCTION angle_point(lat double, lon double, deg double, dist double) RETURNS POINT DETERMINISTIC
BEGIN
DECLARE dist2 double;
DECLARE rdeg double;
DECLARE rlat1 double;
DECLARE rlon1 double;
DECLARE rlat2 double;
DECLARE rlon2 double;
<?php
$config_file = "default.json";
$config = json_decode(file_get_contents($config_file));
$host = $config["default_host"];
$uri = $_SERVER["QUERY_STRING"];
if ($config["ab_enabled"]) {
if (in_array($_COOKIE["ab"], $config["ab_hosts"])) {
$host = $_COOKIE["ab"];