Skip to content

Instantly share code, notes, and snippets.

View niltonvasques's full-sized avatar
🎯
Focusing

Nilton Vasques niltonvasques

🎯
Focusing
View GitHub Profile
@niltonvasques
niltonvasques / adk-db-pull.sh
Created June 29, 2016 18:32
Pull databases from android application
#!/bin/bash
# USAGE
# apk-db-pull.sh com.package.example
adb backup -f data.ab -noapk $1
dd if=data.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -
@niltonvasques
niltonvasques / find_files_between_date.sh
Created April 6, 2016 05:07
Find all pdf files between some dates and move to current dir
#!/bin/bash
# FIND ALL PDF FILES THAT HAS BEEN ACCESSD BETWEEN SOME DATES AND MOVE TO CURRENT DIR
find ~/Documents -name \*.pdf -type f -newermt 2016-04-05 ! -newermt 2016-04-07 -exec mv -t ./ {} \+

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.

Install Jenkins Plugins

@niltonvasques
niltonvasques / .bashrc
Last active May 31, 2017 21:51
Bash functions to stream and play youtube video and audio
# Install: https://github.com/rg3/youtube-dl/
# USAGE:
# play_youtube https://www.youtube.com/watch?v=4HLaOmiwV5Q&list=PLsVoIP7pW8g984pIJuKXhY9tTG1DiJWY9
function play_youtube(){
mplayer -fs -quiet $(youtube-dl -g -t "$1")
}
# USAGE:
# play_youtube_audio https://www.youtube.com/watch?v=4HLaOmiwV5Q&list=PLsVoIP7pW8g984pIJuKXhY9tTG1DiJWY9
function play_youtube_audio(){
@niltonvasques
niltonvasques / pull_ssl_certificate.sh
Created March 7, 2016 21:17
Download SSL Certificate from Terminal
#!/bin/bash
# $1 - HOST
echo -n | openssl s_client -connect $1:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/$1.cert
@niltonvasques
niltonvasques / generate_roles.rb
Created February 16, 2016 07:02
Generate roles for all controllers
roles = Rails.application.routes.routes.map { |route| route.defaults[:controller] }.select { |i| not i.nil? }.uniq.select { |i| not i.match(/\//) }.reduce({}) { |h,i| h[i] = {index: true, new: false, create: false, edit: false, update: false, destroy: false }; h }
@niltonvasques
niltonvasques / rspec-syntax-cheat-sheet.rb
Created February 16, 2016 05:54 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@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)
@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 / 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