Skip to content

Instantly share code, notes, and snippets.

View lukaskonarovsky's full-sized avatar

Lukáš Konarovský lukaskonarovsky

View GitHub Profile
require 'faraday'
require 'multi_json'
# set API key in `MERK_API_TOKEN`
MerkSource.new('cz').find_by_registration_no('28897501')
MerkSource.new('sk').find_by_registration_no('31398871')
@lukaskonarovsky
lukaskonarovsky / check.sh
Created March 3, 2013 09:11
This is how to check dependencies for local development. Save as setup/check into rails app.
#!/usr/bin/env bash
function dependency {
$2 > /dev/null 2>&1
if [[ "$?" == "0" ]] ; then
echo "$1 installed"
else
echo "To install $1: '$3'"
fi
}
# Basic Settings
#
fontName = "Monaco"
fontSize = 11
# Extra files to include
#
myExtraIncludes = ".tm_properties,.htaccess,.gitignore"
fileBrowserGlob = "{*,$myExtraIncludes}"
include = "{$include,$myExtraIncludes}"
@lukaskonarovsky
lukaskonarovsky / gist:3924338
Created October 20, 2012 18:58
SSH SOCKS proxy script for OS X inspired by goulas
#!/bin/bash
# add yourself before use to sudoerrs
# Cmnd_Alias PROXY = /usr/sbin/networksetup -setsocksfirewallproxy*
# your_login ALL=NOPASSWD: PROXY
SSH_HOST="somehostname"
PORT=9999 # configured in System Preferences
NET_SERVICE="Wi-Fi" # on MacBook Air
SSH_OPTS="-C2qTnNfD"
# encoding: utf-8
module Trashable
extend ActiveSupport::Concern
included do
define_model_callbacks :trash, :only => [ :after, :before ]
default_scope where('trashed_at IS NULL')
scope :trashed, where('trashed_at IS NOT NULL')
end
cz:
numbers:
ones_male: [nula, jeden, dva, tři, čtyři, pět, šest, sedm, osm, devět]
ones_female: [nula, jedna, dva, tři, čtyři, pět, šest, sedm, osm, devět]
teens: [deset, jedenáct, dvanáct, třináct, čtrnáct, patnáct, šestnáct, sedmnáct, osmnáct, devatenáct]
tens: [nula, deset, dvacet, třicet, čtyřicet, padesát, šedesát, sedmdesát, osmdesát, devadesát]
hundreds: [nula, sto, dvěstě, třista, čtyřista, pětset, šestset, sedmset, osmset, devětset]
thousands:
one: tisíc
few: tisíce
@lukaskonarovsky
lukaskonarovsky / dynamicarray.cpp
Created April 6, 2009 21:33
C++ dynamic array implementation
#include "dynamicarray.h"
using namespace std;
DynamicArray::DynamicArray() {
DynamicArray::DynamicArray(5);
}
DynamicArray::DynamicArray(int initSize) {
size = initSize;
module Factory
def self.hash(name, attributes = {})
self.send("#{name}_hash").merge(attributes)
end
def self.build(name, attributes = {})
Kernel.const_get(name.to_s.capitalize).new(self.hash(name, attributes))
end
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char* argv[]) {
vector<string> lines;
string line;
@lukaskonarovsky
lukaskonarovsky / gist:67666
Created February 20, 2009 20:01
Nested attributes rocks!
<% if f.object.new_record? %>
<%= link_to_function "Smazat", "$(this).up('.line').remove(); " %>
<% else %>
<%= f.hidden_field(:_delete) %>
<%= link_to_function "Smazat", "$(this).previous().value = '1'; $(this).up('.line').hide(); " %>
<% end %>