Skip to content

Instantly share code, notes, and snippets.

# 100mil 'entities'
# need to be able to check from a random subset if 'something' is TRUE or FALSE
# set booleans in a redis bitmap where the ID for the entities are the offset
$ redis-cli
> SETBIT mybitmap 100000000 1 # 8ms
> SETBIT mybitmap 99999999 1 # 2ms
> SETBIT mybitmap 10000000 1 # 2ms, etc
class Utils
def self.merge_by_id(arr1, arr2)
arr = arr1 + arr2
arr = arr.group_by { |h| h[:id] }
arr.map do |kk, value|
value[1].each_key do |k|
value[0][k] = value[1][k]
end
value[0]
end
sudo apt-get update
sudo apt-get remove vim-common
sudo apt-get install -y ubuntu-restricted-extras
sudo apt-get install -y vim
@c80609a
c80609a / KEYS REMAPPING
Created March 15, 2018 11:21
20180315 NEW UBUNTU x64
xmodmap -e "keycode 83 = Left"
xmodmap -e "keycode 85 = Right"
xmodmap -e "keycode 88 = Down"
xmodmap -e "keycode 80 = Up"
xmodmap -e "keycode 89 = Next"
xmodmap -e "keycode 81 = Prior"
xmodmap -e "keycode 79 = Home"
xmodmap -e "keycode 87 = End"
videos = [
{ id: 'video1' },
{ id: 'video2' },
{ id: 'video3' },
{ id: 'video6' }
]
response = {
'rows' => [
['video1', 1, 2],
@c80609a
c80609a / nginx
Last active June 30, 2018 11:16
Подойдёт для centos 6.9 x32 с пассажиром и ngix на борту
#!/bin/sh
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
[ "$NETWORKING" = "no" ] && exit 0
nginx="/opt/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf"
@c80609a
c80609a / test_rails.md
Last active April 16, 2019 05:04
test_rails.md
#
# get-boat -> GetBoat
#
module ConvertStringToCamelCase
# split-based-solution #1
#
# critical:
#
# 1) лишнее действие - может быть и не нужно было capitalize самое первое слово
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
require 'csv'
require 'time'
headers = { 'PRIVATE-TOKEN' => ENV['GL_TOKEN'] }
issues = Enumerator.new do |result|
@c80609a
c80609a / am_dry_validation_1.rb
Created December 11, 2018 14:51 — forked from solnic/am_dry_validation_1.rb
dry-validation vs activemodel
require 'benchmark/ips'
require 'active_model'
require 'virtus'
require 'dry-validation'
require 'dry/validation/schema/form'
class User
include ActiveModel::Validations
include Virtus.model