Skip to content

Instantly share code, notes, and snippets.

View fakenickels's full-sized avatar
💭
hello this is a mic test, are you listening

Gabriel Rubens Abreu fakenickels

💭
hello this is a mic test, are you listening
View GitHub Profile
@fakenickels
fakenickels / projectlines.rb
Created September 16, 2012 00:57
Count lines of a project. It scans folder( and subfolders ) files and count total lines
#!/usr/bin/ruby
require 'find'
if ARGV[0]
puts "Wait..."
Find.find( ARGV[0] ) do |f|
totalLength += IO.readlines(f).size if File.file? f
end
end
@fakenickels
fakenickels / matavogais.rb
Created September 18, 2012 16:03
Pega um arquivo de texto, e cria um novo arquivo de texto retirando todas as vogais e trocando-as por -
#!/usr/bin/ruby
# Troca vogais e coloca um hifen no lugar das mesmas
# passe como argumento o arquivo de texto i.e. ->
# matavogais.rb /home/masterboss/vogais.txt
File.open("#{File.dirname(ARGV[0])}/noVogals.txt",'w') do |f|
f << File.read( ARGV[0] ).gsub(/[aeiou]/i, '-')
end
@fakenickels
fakenickels / wordor.rb
Created September 22, 2012 21:02
Organiza arquivos com um nome que contem um mesmo trecho de uma palavra
#!/usr/bin/ruby
# Example: wordor /anything/ ruby
# Found: anythingruby.pdf and rubynotify.rb, after put they in ruby/ folder
require 'find'
require 'fileutils'
if !ARGV.empty?
path = "#{ARGV[0]}/#{ARGV[1]}"
reg = /#{ARGV[1]}/
Dir.mkdir( path,0755 ) unless File.exists? path
@fakenickels
fakenickels / simple_animation_engine.js
Last active December 19, 2015 10:29
Simple JavaScript Animation Engine
function now(){
return ( new Date ).getTime();
}
function animate( time, fn, fps ){
var start = now(),
intrval = fps ? 1000/fps : 20,
id = setInterval(function(){
var diff = now() - start, p = diff/time;
@fakenickels
fakenickels / frequently_words.sh
Created October 5, 2013 21:08
A simple shell script that shows and enumerates the most frequently words used in a file
# Show and enumerate the most frequently words in a file
# Use:
# $ chmod a+x frequently_words.sh
# $ ./frequently_words file_path
cat $1 | tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn
@fakenickels
fakenickels / frequently_words.js
Last active December 25, 2015 01:09
The same algorithm of frequently_words.sh in JavaScript
function analyse( text ){
var words = {},
text = text.toLowerCase()
.replace(/[.,]+/g, '')
.replace(/[^\w\s\t\n]+/, '')
.split(' ');
for( var i in text ){
if( words[ text[i] ] == undefined )
words[ text[i] ] = 1;
@fakenickels
fakenickels / ytdownload.js
Created October 21, 2013 23:48
Just put this script to execute on a YouTube video page, and download it!
!function( ytplayer ){
var url = ytplayer.config.args["url_encoded_fmt_stream_map"],
videoFormats = url.split(','),
videos = [],
props = ['quality', 'type'];
setFormats();
askToUser();
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@fakenickels
fakenickels / simpleED.js
Created December 5, 2013 03:22
Simple Encrypt-Decrypt Algorithm
var key = 'heuehueheubrbrbrprasswithlasers333';
/*
* Simple Encrypt-Decrypt Algorithm
* mode = 1 or -1
* 1 -> Encrypt mode
* -1 -> Decrypt mode
*/
function simpleED( str, mode ){
@fakenickels
fakenickels / frequently_words.rb
Created January 17, 2014 05:39
Frequently used words scanner in Ruby
module Analiser
extend self
def parse(text)
originalArray = text.split(/\s/).reject {|x| x.empty?}
repeatedWords = {}
originalArray.each do |word|
word.downcase!
if repeatedWords.has_key?(word.to_sym)