Skip to content

Instantly share code, notes, and snippets.

@jtsagata
jtsagata / install_sublime_text_handler.sh
Last active August 29, 2015 13:59
Sublime Text 3, livereload, railsPanel, better_errors, linux
#!/bin/bash
echo "Installing Sublime text handler"
sudo cp sublime-handler /usr/local/bin
sudo cp sublime-handler.desktop /usr/share/applications/
echo "Updating desktop database"
sudo update-desktop-database
cat <<THE_END
Not done yet!
#!/bin/bash
#information
echo "
Popcorn-Time Beta 2 for Ubuntu-Linux
------------------------------------
WARNING: Popcorn Time streams movies from Torrents. Downloading copyrighted material may be illegal in your country. Use at your own risk.
"
#verify awareness
@jtsagata
jtsagata / ci-tool.py
Last active August 29, 2015 14:08
Poor mens CI. Continious Integration with Zeus, RSpec, tmux/tmuxinator like clone. Autotest and autoreload functionality (Work in progress)
#!/usr/bin/env python
# filename <app>/ci_tool
# Zeus CI IDE
# Created by talos aka Giannis Tsagatakis
# --color
# --require spec_helper
# --format documentation
# --format html -o "tmp/rspec.html"
@jtsagata
jtsagata / Readme
Created December 28, 2014 10:09
Add column definitions to a migration
rails g model user name:string avatar:attached
create_table :users do |t|
t.string :name
t.string :avatar_identifier
t.string :avatar_extension
t.integer :avatar_size
end
For more info look
@jtsagata
jtsagata / database_tasks.rake
Created December 29, 2014 13:21
Database tasks for postgress
namespace :tools do
desc 'Clear the database'
task :clear_db => :environment do |t,args|
ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.tables.each do |table|
next if table == 'schema_migrations'
ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
end
end
@jtsagata
jtsagata / README
Last active August 29, 2015 14:12
Translation fallbacks and logging in the helpers
Rails I18n helper
@jtsagata
jtsagata / apt-linux-mint
Created February 7, 2015 20:21
apt completion
#
# Bash completion file for Linux Mint apt utility.
#
have apt &&
_apt()
{
local cur opt
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@jtsagata
jtsagata / pause.sh
Created June 10, 2015 03:19
universal pause key
#!/bin/bash
# https://github.com/ryanries/UniversalPauseButton
# https://news.ycombinator.com/item?id=9686854
currentProcess=$(xprop -id $(xprop -root | grep -F '_NET_ACTIVE_WINDOW(WINDOW)' | awk '{print $5}') | grep -F '_NET_WM_PID(CARDINAL)' | awk '{print $3}')
state=$(grep 'State:' /proc/$currentProcess/status | awk '{print $2}')
if [[ "$state" == "T" ]]
then
require 'htmlentities'
require 'i18n/backend/active_record'
module I18n
module Backend
require 'i18n/core_ext/object/meta_class'
# Just to enhance the I18n.
module JustALoader
include Metadata
module TranslationHelper
# foo = ActionView::Base.new.extend TranslationHelper
# TODO: If translation is missing
# get a translation from google
# and then add it to database, marked as dirty (how?)
def translate(key, options = {})
key = scope_key_by_partial(key)
options[:raise] = true
options[:request_locale] = options.has_key?(:locale) ? options[:locale] : I18n.locale