Skip to content

Instantly share code, notes, and snippets.

View tadast's full-sized avatar

Tadas Tamošauskas tadast

View GitHub Profile
@tadast
tadast / json_api_to_graphviz.js
Created November 19, 2016 16:22
This is a script to take in a {json:api} document (jsonapi.org) and generate a visual graph (http://www.graphviz.org) representation of it
/*
This is a script to take in a {json:api} document (jsonapi.org)
and generate a graphviz (http://www.graphviz.org) representation of it.
Usage:
> node <this_file>
then copy and paste the output to some graphviz parser
e.g. http://www.webgraphviz.com or http://gravizo.com
*/
@tadast
tadast / dynamoid_reset.rb
Created September 8, 2016 15:02
Dynamoid test database cleaner
# Prevent wiping out data in non-test environments
raise "Test should be run in 'test' environment only" if Rails.env != 'test'
module DynamoidReset
def self.all
Dynamoid.adapter.list_tables.each do |table|
# Only delete tables in our namespace
if table =~ /^#{Dynamoid::Config.namespace}/
Dynamoid.adapter.delete_table(table)
end
@tadast
tadast / gist:6038585
Last active December 19, 2015 23:59
turbolinks sparkles
☆。★。☆。★
。☆ 。☆。☆
★。\|/。★
turbolinks
★。/|\。★
。☆。 。☆。
☆。 ★。 ☆
@tadast
tadast / sm-prototype-hierarchy-crawler.rb
Last active November 9, 2015 13:56
Service manual prototype hierarchy crawler
require 'nokogiri'
require 'open-uri'
require 'pry'
require 'yaml'
class Crawl
def initialize(start_url = "http://sm-11.herokuapp.com")
@start_url = start_url
@guides = []
end
@tadast
tadast / gist:4160627
Created November 28, 2012 11:34
Open the last migration file from shell
# stole this from Tor Erik Linenrud @telinnerud
alias olm='subl `ls -r db/migrate/* | head -n 1`'
# helpers
module PublicHelper
def router_attributes
{
"data-router-class" => "#{controller_name.to_s.titleize}Controller",
"data-router-action" => action_name.to_s
}
end
end
https://gist.github.com/1688857
=== 1.9.3-p0
✗ time (rails runner 'puts(1)')
6.33s user 0.69s system 99% cpu 7.027 total
✗ time (rspec spec)
1736/1736: 100% |==========================================| Time: 00:00:34
42.32s user 1.52s system 92% cpu 47.279 total
@tadast
tadast / gist:1569954
Created January 6, 2012 10:07
useful sublime text 2 stuff

== Key Bindings

[
  //https://github.com/alexstaubo/sublime_text_alternative_autocompletion
  { "keys": ["escape"], "command": "alternative_autocomplete", "context":
    [
      { "key": "num_selections", "operator": "equal", "operand": 1 },

{ "key": "overlay_visible", "operator": "equal", "operand": false },

@tadast
tadast / heroku_colors.sh
Created August 10, 2011 15:07
Colorize heroku production console for iTerm2 on OSX
# iTerm2, OS X
# 1. change 'your_app_production' to your application name
# 1a. Tune the colors by your taste
# 2. put these functions to your .bashrc, .zshrc
# or anywhere where it gets loaded for your iTerm session
# 3. restart iTerm or 'source ~/.zshrc' and use these functions
set_color() {
local HEX_FG=$1
local HEX_BG=$2
@tadast
tadast / terminal_color.sh
Created August 10, 2011 15:14
Colorize heroku production console for Terminal on OSX
# Terminal, OS X (iTerm version: https://gist.github.com/1137050)
# 1. change 'your_app_production' to your application name
# 1a. Tune the colors by your taste
# 2. put these functions to your .bashrc, .zshrc
# or anywhere where it gets loaded for your iTerm session
# 3. restart iTerm or 'source ~/.zshrc' and use these functions
set_color() {
local R=$1
local G=$2