Skip to content

Instantly share code, notes, and snippets.

View dekart's full-sized avatar

Aleksey Dmitriev dekart

View GitHub Profile
javascript:setTimeout(function(){
var m = window.location.href.match(/trello.com\/c\/[A-z\d]+\/(\d+)/);
if(m){
var text = new Date().toLocaleDateString("en-US") + "\t" +
'=HYPERLINK("'+m[0]+'","'+m[1]+'")' + "\t" +
document.querySelector('div.window-title>textarea').value;
navigator.clipboard.writeText(text);
@dekart
dekart / .gitignore
Created February 25, 2019 05:44
Unity Gitignore
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
# Visual Studio cache directory
.vs/
@dekart
dekart / README
Last active August 29, 2015 14:01
Iptables setup for port forwarding on local dev machine.
Should be added to /etc/network/if-pre-up.d/iptable_rules
Don't forget to run
chmod +x /etc/network/if-pre-up.d/iptable_rules
class Object
def self.my_decorator(method_name)
alias_method "#{method_name}_without_my_decorator", method_name
define_method method_name do
puts "My decorator logic starts"
result = send("#{method_name}_without_my_decorator")
puts "My decorator logic ends"
result
end
@dekart
dekart / convert_to_webp
Created August 9, 2013 09:18
A script to convert JPEG and PNG images in desired folders to WebP
#!/usr/bin/env ruby
def process_folders(message, *folders, &block)
root = File.expand_path('../..', __FILE__)
puts message
puts
total_old = 0
total_new = 0
ffmpeg -i input.mkv -map 0:0 -map 0:2 -c:v copy -c:a:0 copy output.mp4
CLAN_ID = 1
clan = Clan.find(CLAN_ID)
character_ids = ClanMember.connection.select_values(
ClanMember.send(:sanitize_sql, ["SELECT character_id FROM clan_members WHERE clan_id = :clan", :clan => clan.id])
)
position = 0
@dekart
dekart / backup.rb
Created May 28, 2013 09:02
Redis backup & restore script
def backup(path, redis)
keys = redis.keys
puts "#{ keys.size } keys to dump"
File.open(path, 'w+') do |f|
keys.each_with_index do |key, i|
next unless dump = redis.dump(key)
f.puts JSON.dump([key, dump.force_encoding('utf-8')]).force_encoding('utf-8')
[mysql]
# CLIENT #
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
# GENERAL #
user = mysql
cd ~
curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
export PATH="$HOME/.rbenv/bin:$PATH"
echo '
export RBENV_ROOT="${HOME}/.rbenv"
if [ -d "${RBENV_ROOT}" ]; then