Skip to content

Instantly share code, notes, and snippets.

@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
@jtsagata
jtsagata / 0_reuse_code.js
Created November 1, 2016 20:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jtsagata
jtsagata / update_lvm_alternatives.sh
Created November 4, 2016 07:54
update llvm and clang alternatives fix
#!/usr/bin/env bash
#!/usr/bin/env sh
sudo update-alternatives --install \
/usr/bin/llvm-config llvm-config /usr/bin/llvm-config-3.6 200 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-3.6 \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-3.6 \
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-3.6 \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-3.6 \
@jtsagata
jtsagata / update_lvm_alternatives.sh
Last active December 4, 2016 22:04
Update alternatives for lvm/clang versions
#!/usr/bin/env bash
sudo update-alternatives --install \
/usr/bin/llvm-config llvm-config /usr/bin/llvm-config-3.6 200 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-3.6 \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-3.6 \
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-3.6 \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-3.6 \
--slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-3.6 \
--slave /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-3.6 \
$ echo "id:${UID}/${SUDO_UID} user:${USER}/${SUDO_USER} home: ${HOME}"
➡ id:1000/ user:talos/ home: /home/talos
$ sudo bash -c 'echo "id:${UID}/${SUDO_UID} user:${USER}/${SUDO_USER} home: ${HOME}"'
➡ id:0/1000 user:root/talos home: /home/talos
$ sudo -H bash -c 'echo "id:${UID}/${SUDO_UID} user:${USER}/${SUDO_USER} home: ${HOME}"'
➡ id:0/1000 user:root/talos home: /root
@jtsagata
jtsagata / check_sudo.sh
Last active March 7, 2017 07:58
Checking how sudo works
#!//usr/bin/env bash
set -e
function iColor() {
echo -n "'$(tput setaf $1)"; shift; echo -n "${@}$(tput sgr0)'"
}
function print_info() {
function iColor() {
printf "'$(tput setaf $1)"; shift; printf "${@}$(tput sgr0)'"
#!/bin/bash
#Heith Seewald 2012
#Feel free to extend/modify to meet your needs.
#Maya on Ubuntu v.1
#This is the base installer... I’ll add more features in later versions.
#if you have any issues, feel free email me at heiths@gmail.com
#### Lets run a few checks to make sure things work as expected.
#Make sure we’re running with root permissions.
if [ `whoami` != root ]; then