Skip to content

Instantly share code, notes, and snippets.

View b-coimbra's full-sized avatar
馃尩

Bruno Coimbra b-coimbra

馃尩
View GitHub Profile
@b-coimbra
b-coimbra / commit.rb
Created June 8, 2017 01:37
daily commit script
#!/usr/bin/env ruby
# encoding: UTF-8
cmds = <<CMDS
git add file.txt
git commit -m "update"
git push -u origin master
CMDS
cmds.each_line(&(c=[]).method(:<<))
test(?e, '.git') ? ->(*cmds) {cmds.map(&method(:system)); sleep(1)}.(c.to_s) : \
(File.open('file.txt', 'w'){|f| f << '( 汀掳 蜏蕱 汀掳)'} && (`git init`;`git remote add origin <repository-name>.git`))
# encoding: UTF-8
module Kernel
alias_method :位, :lambda
end
Y = 位 { |f|
位 { |x| x.(x) }.(
位 {|x| f.(
位 {|v| x.(x).(v)}) }
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[0]) { static int (*self)(int) = [](int i)->int { return i <= 1 ? i : self(i-1) + self(i-2); };
std::cout << self(atoi(argv[1])); }
@b-coimbra
b-coimbra / sort.rb
Last active June 3, 2017 20:55
sort files numerically in increasing order
#!/usr/bin/env ruby
->(i) {->(_) {Dir[$_=(_.nil? ? '.' : _) + '/*'].each_with_index {|f,i| f.to_enum(:scan, /(?<type>\.(png|jpg|jpeg|gif|webm|mp4|pdf))$/im). \
map {p "[#{-~i}/#{Dir["#{_}/*"].length}] "+f;$_=f; test(?e, ($_) + i.to_s + $1) ? next : \
File.rename(f, File.dirname(f) + File::SEPARATOR + (-~i).to_s + $~[:type])}}} \
::(ARGV[0])}.(0) && at_exit {system "echo Done! && explorer #{$_.gsub(/\/[(\w|\d)\.\w\d]+$/i,'')}"} \
rescue Errno::EACCESS abort "Cant sort this folder :("
@b-coimbra
b-coimbra / passcrypt.rb
Last active April 11, 2017 02:24
Store encrypted passwords locally
#!/usr/bin/env ruby
# encoding: utf-8
require 'aes'
require 'fileutils'
system 'title Password Manager'
at_exit { puts 'See ya!' }
def check(key)