Skip to content

Instantly share code, notes, and snippets.

View schovi's full-sized avatar
👁️

David Schovanec schovi

👁️
View GitHub Profile
@schovi
schovi / 1-shallow
Created December 8, 2016 17:48
shallow vs render vs mount
exports[`Datepicker works 1`] = `
<div
className="datepicker datepicker-active">
<EventListener
onClick={[Function]}
onKeyUp={[Function]}
target="document" />
<div
className="datepicker-prev"
onClick={[Function]} />
@schovi
schovi / Dockerfile
Last active March 9, 2017 15:11
Dockerfile for crystal playground
FROM debian:jessie
##########
# Install utils
RUN apt-get update && \
apt-get install -y \
git \
make \
dh-autoreconf \
apt-transport-https
@schovi
schovi / cleanup.rb
Last active October 18, 2016 18:49
Ruby script for cleaning trailing spaces and add new line to the end
counter = 0
def drop_empty_from_start lines
lines.drop_while do |line|
!(line =~ /[^\s\t\n]+/)
end
end
def fix content
lines = content.split("\n")
@schovi
schovi / employee.rb
Last active September 14, 2016 18:04
# migration
def up
execute "CREATE TYPE roles AS ENUM ('worker', 'manager', 'boss');"
end
# model
class Employee < ActiveRecord::Base
include PostgresEnum
postgres_enum :role
end
@schovi
schovi / commands.sh
Created September 2, 2016 10:23
Cleanup merged git branches
# Remove local merged branches
git branch --merged master | grep -v '\Wmaster$' | xargs -n 1 git branch -d
# Remove remote origin merged branches
git branch -a --merged remotes/origin/master | grep 'remotes/origin/' | grep -v '\Wmaster$' | awk '{gsub(/remotes\//, ""); print}' | xargs -n 1 git branch -d -r
@schovi
schovi / active_translation.yml
Created June 17, 2016 13:22
Rails translate activerecord and activemodel same way
de:
models: &models
user: 'Benutzer'
attributes: &attributes
user:
email: 'E-Mail'
errors: &errors
@schovi
schovi / better-nodejs-require-paths.md
Created May 31, 2016 07:37 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@schovi
schovi / OSX cleanup.md
Last active February 8, 2024 01:58
My collection of resources how to keep your mac fresh, fast and with lot of disk space. Still **WORK IN PROGRESS**. If you have any comments and tips, give me comment. Like how to clean after python, clojure, etc etc
[7] pry(main)> search = Advert::Search.search()
=> #<Elasticsearch::DSL::Search::Search:0x007f81aa5e02f8 ...>
[8] pry(main)> print search.to_json
{"query":{"match_all":{}},"aggregations":{"price":{"nested":{"path":"price"},"aggregations":{"min":{"min":{"field":"price.price"}},"max":{"max":{"field":"price.price"}}}}},"size":0}
[9] pry(main)> result = Advert.search(search)
=> #<Elasticsearch::Model::Response::Response:0x007f81aa537518 ...>
[10] pry(main)> result.aggregations
=> {"price"=>{"doc_count"=>9428, "min"=>{"value"=>1.0}, "max"=>{"value"=>260000.0}}}
[11] pry(main)> result.aggregations.price
=> {"doc_count"=>9428, "min"=>{"value"=>1.0}, "max"=>{"value"=>260000.0}}
@schovi
schovi / README.markdown
Created January 9, 2016 17:04 — forked from karmi/README.markdown
echo 'Přečti mi něco, prosím!' | ruby dictator.rb

A simple dictation robot.

echo 'Přečti mi něco, prosím!' | ruby dictator.rb

cat data.txt | ruby dictator.rb

cat data.txt | SPEED=1.5 ruby dictator.rb