Skip to content

Instantly share code, notes, and snippets.

View glaucocustodio's full-sized avatar
🇧🇷

Glauco Custódio glaucocustodio

🇧🇷
View GitHub Profile
@jerodsanto
jerodsanto / firebug_logger.rb
Created December 9, 2009 16:23 — forked from simonjefford/firebug_logger.rb
Rack::FirebugLogger
module Rack
class FirebugLogger
def initialize(app, options = {})
@app = app
@options = options
end
def call(env)
status, headers, orig_response = @app.call(env)
return [status, headers, orig_response] unless (headers["Content-Type"] =~ /html/ && env['firebug.logs'])
@mattetti
mattetti / gist:1015948
Created June 9, 2011 02:44
some excel formulas in Ruby
module Excel
module Formulas
def pmt(rate, nper, pv, fv=0, type=0)
((-pv * pvif(rate, nper) - fv ) / ((1.0 + rate * type) * fvifa(rate, nper)))
end
def ipmt(rate, per, nper, pv, fv=0, type=0)
p = pmt(rate, nper, pv, fv, 0);
ip = -(pv * pow1p(rate, per - 1) * rate + p * pow1pm1(rate, per - 1))
(type == 0) ? ip : ip / (1 + rate)
@jbjornson
jbjornson / SwitchToFile.py
Last active October 29, 2015 19:45
Show a input panel to switch to a currently open file
import sublime_plugin
import os
# -------------------------------------------
# You will need to create a key mapping for this, something like:
# { "keys": ["alt+e"], "command": "switch_to_file" }
# -------------------------------------------
class SwitchToFileCommand(sublime_plugin.WindowCommand):
def run(self):
self.display_list = []
self.views = []
@hotchpotch
hotchpotch / .pryrc
Created March 5, 2012 13:26
pry clipboard copy utility
def pbcopy(str)
IO.popen('pbcopy', 'r+') {|io| io.puts str }
output.puts "-- Copy to clipboard --\n#{str}"
end
Pry.config.commands.command "hiscopy", "History copy to clipboard" do |n|
pbcopy _pry_.input_array[n ? n.to_i : -1]
end
Pry.config.commands.command "copy", "Copy to clipboard" do |str|
Pry.config.editor = "vim --noplugin"
if defined?(PryByebug)
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
Pry.commands.alias_command 'b', 'break'
Pry.commands.alias_command 'bda', 'break --disable-all'
end

Crystal vs Node.js Websocket Benchmark

Crystal 0.9.1 with Kemal

require "kemal"

ws "/" do |socket|
  socket.on_message do |message|
 end
@fimkap
fimkap / gist:565d97a6a57a7b9283c8663ae8c9eab1
Created January 12, 2017 09:25
NeoVim, FZF and termpix setup
install termpix from https://github.com/fimkap/termpix (currently alpha blending done with white background)
-- init.vim (along with usual FZF setup, change path to termpix)
let g:fzf_layout = { 'down': '~60%' }
let g:fzf_files_options =
\ '--preview "(~/dev/termpix/bin/termpix --width 50 --true-color {} || cat {}) 2> /dev/null "'
@bl4ck5un
bl4ck5un / responsive-semantic-ui.css
Created May 12, 2017 03:20
Responsive helpers (mobile-only etc.) for semantic-ui
/* Semantic UI has these classes, however they're only applicable to*/
/* grids, containers, rows and columns.*/
/* plus, there isn't any `mobile hidden`, `X hidden` class.*/
/* this snippet is using the same class names and same approach*/
/* plus a bit more but to all elements.*/
/* see https://github.com/Semantic-Org/Semantic-UI/issues/1114*/
/* Mobile */
@media only screen and (max-width: 767px) {
[class*="mobile hidden"],
@primaryobjects
primaryobjects / react-confirm.js
Created November 1, 2017 19:03
A simple example of a confirm alert dialog in ReactJs / React.
<div className='delete-button' onClick={() => { if (window.confirm('Are you sure you wish to delete this item?')) this.onCancel(item) } } />
@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active May 7, 2024 11:31
crack activate Office on mac with license file