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 / 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)
@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 :("
#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])); }
# encoding: UTF-8
module Kernel
alias_method :λ, :lambda
end
Y = λ { |f|
λ { |x| x.(x) }.(
λ {|x| f.(
λ {|v| x.(x).(v)}) }
@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`))
@b-coimbra
b-coimbra / template.css
Created July 9, 2017 17:11
model for flexible UI
@charset "UTF-8";
@import "https://fonts.googleapis.com/css?family=Roboto";
@import "https://fonts.googleapis.com/css?family=Raleway";
@import "https://fonts.googleapis.com/css?family=Open-Sans";
:root { --y-axis: 200px }
_:-ms-lang(x), @supports (not (--var: 0)) {
[class$='\66\78' i]:not(:empty):nth-child(-4+3n)::after, section { width: calc(var(--y-axis) * 100)) }
@b-coimbra
b-coimbra / locker.rb
Last active July 26, 2017 19:28
flash drive folder locker script
#/usr/bin/env ruby
# encoding: UTF-8
require 'io/console'
BEGIN {
FOLDER = "\u{00a0}"
PASSWORD = "12345"
$> << %{\e[35m
@b-coimbra
b-coimbra / virus-fix.bat
Created July 24, 2017 19:05
flash drive malware cleaner
attrib -R -S -H /S /D
del *.lnk
rd /s /q RECYCLER
del /f autorun.inf
del /q /f /s 1j038que.exe
del /q /f /s 2ul.exe
del /q /f /s 9rfpp.exe
del /q /f /s fcphol.exe/csrcs.exe
del /q /f /s killVBS.vbs
del /q /f /s t2hjo0.exe
define_method(:calc) { |c| return eval(c.gsub(/\[/,"(").gsub(/\]/,")").gsub(/(modulus|mod)/i,"%").gsub(/(subtract|minus)/i,"-").gsub(/(add|plus)/i,"+").gsub(/(\^|power by)/i,"**").gsub(/(×|∙|multiplied by)/i,"*").gsub(/(divided by|÷)/i,"/").gsub(/[^0-9\s\-\(\)^*+\/]/,"")) rescue return false }
#include <stdio.h>
int main()
{
for (int i=0;++i<101;puts("")) {
char f[] = "FizzBuzz%d";
f[8-i%5&12]=0;
printf (f+(-i%3&4+f[8]/8), i);
}
}