Skip to content

Instantly share code, notes, and snippets.

View niltonvasques's full-sized avatar
🎯
Focusing

Nilton Vasques niltonvasques

🎯
Focusing
View GitHub Profile
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
<Button android:id="@+id/button"
android:layout_width="wrap_content"
@niltonvasques
niltonvasques / process-info.sh
Last active August 29, 2015 14:24
Logging infos about a process
gedit &
PID=$!
while :; do
sleep 3
ps -up $PID
echo "... get info about"$PID
done
@niltonvasques
niltonvasques / firefox-install-debian.sh
Created July 7, 2015 06:45
firefox-install-debian
#!bin/bash
#wget https://download.mozilla.org/?product=firefox-33.0.2-SSL&os=linux64&lang=en-US
cd ~/Downloads/
cp firefox-33.0.2.tar.bz2 /opt/
cd /opt/
tar -xvf firefox-33.0.2.tar.bz2
rm firefox-33.0.2.tar.bz2
@niltonvasques
niltonvasques / finances.rb
Created August 25, 2015 02:56
Update investments quotes in a libreoffice spreadsheet using ruby and yahoo finances gem
require 'yahoo-finance'
stocks = ["PETR3.SA"]
yahoo_client = YahooFinance::Client.new
data = yahoo_client.quotes( stocks, [:close])
File.open("quotes.csv", "w+") do |file|
stocks.size.times do |x|
file.puts "\"#{stocks[x]}\",#{data[x].close}"
vimdiff <(grep 'include Active$' -R . | awk '{ print $1 }' | cut -f1 -d: | cut -f2 -d/ | sort -u ) <(ls | sort -u)
@niltonvasques
niltonvasques / ident-all.viml
Last active November 25, 2015 12:05
Ident many files inside vim
:args *.rb | argdo execute "normal gg=G" | update
# http://stackoverflow.com/questions/3218528/indenting-in-vim-with-all-the-files-in-folder
@niltonvasques
niltonvasques / remove_line_in_many_files.sh
Created November 27, 2015 08:56
Remove one line following a pattern in many files, and open vimdiff to confirm.
#!/bin/bash
confirm () {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false ;;
@niltonvasques
niltonvasques / subtract_two_files.sh
Created January 18, 2016 12:54
List files in two directories, replace some string, subtract them and finaly copy result to clipboard.
#!/bin/bash
awk 'NR==FNR{a[$1];next}!($1 in a)' <(ls | sed 's/_spec.rb//g' | sort) <(ls ../../app/models/ | sed 's/.rb\|.bak//g' | uniq | sort) | awk '{ print "- [ ]",$1 }' | xclip -sel clip
@niltonvasques
niltonvasques / search_and_split.sh
Created January 25, 2016 15:12
Search and count a splited line in many files
for i in $(ls -d pfcm*); do echo -n "$i "; cat $i/discover.arff | grep "class " | cut -f2 -d{ | awk '{n=split($0,a,","); print n}'; done >> clusters_count.txt
@niltonvasques
niltonvasques / capybara.md
Created February 16, 2016 03:49 — forked from steveclarke/capybara.md
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)