Skip to content

Instantly share code, notes, and snippets.

View schovi's full-sized avatar
👁️

David Schovanec schovi

👁️
View GitHub Profile
@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 / keybase.md
Created February 8, 2017 08:51
keybase.md

Keybase proof

I hereby claim:

  • I am schovi on github.
  • I am schovi (https://keybase.io/schovi) on keybase.
  • I have a public key whose fingerprint is 8878 CAC3 5ECC CD60 3944 44E5 72C6 AEDF 3CE2 60A2

To claim this, I am signing this object:

@schovi
schovi / abortableFetch.js
Created January 16, 2017 14:38
Simple javascript fetch request with ability to be abort.
const abortableFetch(url, options) {
var abort;
const promise = new Promise((resolve, reject) => {
abort = reject
fetch(url, options).then(resolve, reject)
})
promise.abort = abort
@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 / 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
import React from 'react';
const IGNORE_CLASS = 'ignore-react-onclickoutside';
export default function clickOutside(BaseComponent) {
return class ClickOutside extends React.Component {
static displayName = `${BaseComponent.name}ClickOutside`;
@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