Skip to content

Instantly share code, notes, and snippets.

{
"shell_cmd" : "gcc $file_name -o ${file_base_name} && ${file_base_name}",
"working_dir" : "$file_path",
"variants":
[
{
"name": "Run",
"shell_cmd": "gcc $file_name -o ${file_base_name} && ${file_path}/${file_base_name}"
}
]
# require gems, installs dependencies
def __import__(*lib)
lib.each do |i|
begin
require i
rescue LoadError
system "gem install #{i}"
Gem.clear_paths
retry
end
@b-coimbra
b-coimbra / spam.rb
Last active September 6, 2017 23:20
generates random text files
Thread.new{loop{open(rand(0..10e3).to_s+'.txt','w+'){|f|f<<rand(4000**2000).to_s(36)*10e2}}}.join rescue Errno::EACCESS abort 'Run as admin.'
@b-coimbra
b-coimbra / p.apl
Created August 22, 2017 01:16
elementary propositional logic in APL
⍝ ex. 1
~((1 ∧ 0) ∨ (0 ↔ 1)) → ~(1 ∨ 0)
⍝ ~(0 ∨ 0) → ~(1 ∨ 0)
⍝ 1 → ~1
⍝ 1 → 0
⍝ 0
⍝ ex. 2
⍝ considering:
⍝ v(p) = 0
@b-coimbra
b-coimbra / google.rb
Created August 25, 2017 16:01
opens google and types something
#!/usr/bin/env ruby
# encoding: UTF-8
# USAGE: ruby google.rb <anything you want to search>
require 'win32ole'
shell = WIN32OLE.new("Wscript.Shell")
link = "www.google.com"
link =~ /www\.(.*)\.com/i
title = $1.capitalize
@b-coimbra
b-coimbra / vivaldi.css
Last active December 7, 2017 17:25
vivaldi custom CSS
/* focus debugging
#browser *:focus {
background-color:rgba(200,0,0,.2) !important;
outline: 2px solid rgba(200,0,0,.5) !important;
visibility: visible !important;
display: initial !important;
transform: scale(1), translate3D(0,0,0) !important;
}
*/
@b-coimbra
b-coimbra / pyrb.rb
Created September 10, 2017 20:44
python methods inside ruby
# TODO: lambda expressions
class String
define_method(:format) { |*args| self.tr('{}', '%s') % args }
end
module Kernel
alias_method :__init__, :initialize
alias_method :import, :require
end
Dir['*'].each { |f| File.rename(f, f.gsub(/\-|\_/m, ' ')) if f != $0 } rescue Errno::ENOENT abort 'INVALID DIRECTORY'
@b-coimbra
b-coimbra / yt.rb
Last active December 16, 2017 21:55
mpv script - youtube search on the terminal
#!/usr/bin/env ruby
require 'eat'
abort "Usage: yt.rb <search> <max>" if ARGV[0].nil?
class String
{ :reset => 0,
:bold => 1,
:dark => 2,
function fun(){if(aZ=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],document.getElementById("animator")){var t=document.getElementById("animator");t.parentNode.removeChild(t)}f=document.createElement("style"),f.setAttribute("id","animator");for(var e=0;e<aZ.length-1;e++)h=Math.floor(Math.random()*(window.screen.width/Math.floor(8*Math.random())-1)),k=Math.floor(Math.random()*(window.screen.height/Math.floor(8*Math.random())-1)),g="@keyframes ${from{left:"+a[0]+"px; top:"+a[1]+"px}to{left:"+h+"px; top:"+k+"px}} @-webkit-keyframes ${from{left:"+a[0]+"px; top:"+a[1]+"px}to{left:"+h+"px; top:"+k+"px}}",a[0]=h,a[1]=k,f.innerHTML+=g.replace(/[\$]/g,aZ[e]);document.head.appendChild(f);for(var n=0;n<document.getElementsByTagName("*").length-1;n++){var o=document.getElementsByTagName("*")[n];-1==v.indexOf(o.tagName)&&(o.style.webkitAnimationName=aZ[Math.floor(Math.random()*(aZ.length-1))],o.style.webkitAnimationDuration=Math.floor(8*Math.random())+"s",o.style.