Skip to content

Instantly share code, notes, and snippets.

View klebervirgilio's full-sized avatar
🎯
Focusing

Kleber Correia klebervirgilio

🎯
Focusing
View GitHub Profile
@pelf
pelf / Anonymiser.py
Last active June 16, 2020 15:41
Sublime plugin for anonymising bank statement data
import sublime, sublime_plugin, random, string, re
class AnonymiseCommand(sublime_plugin.TextCommand):
def replacement(self, s):
# Figure out which chars to use
chars = []
if re.search("[a-z]", s):
chars += string.ascii_lowercase
if re.search("[A-Z]", s):
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@joshnuss
joshnuss / udp_server.exs
Last active October 9, 2023 09:11
Fault tolerant UDP Server in Elixir
# to run:
# > elixir --no-halt udp_server.exs
# to test:
# > echo "hello world" | nc -u -w0 localhost 2052
# > echo "quit" | nc -u -w0 localhost 2052
# Let's call our module "UDPServer"
defmodule UDPServer do
# Our module is going to use the DSL (Domain Specific Language) for Gen(eric) Servers
use GenServer
@marianogappa
marianogappa / ordered_parallel.go
Last active February 12, 2024 09:27
Parallel processing with ordered output in Go
/*
Parallel processing with ordered output in Go
(you can use this pattern by importing https://github.com/MarianoGappa/parseq)
This example implementation is useful when the following 3 conditions are true:
1) the rate of input is higher than the rate of output on the system (i.e. it queues up)
2) the processing of input can be parallelised, and overall throughput increases by doing so
3) the order of output of the system needs to respect order of input
- if 1 is false, KISS!
@briankung
briankung / docker-pry-rails.md
Last active December 12, 2023 10:40
Using pry-rails with Docker

First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails

gem 'pry-rails', group: :development

Then you'll want to rebuild your Docker container to install the gems

@schneems
schneems / command-line-only-objectspace-trace.sh
Last active December 19, 2022 13:54
trace where Ruby objects come from with this handy bash 3 liner
echo 'require "objspace"; ObjectSpace.trace_object_allocations_start; Kernel.send(:define_method, :sup) do |obj| ; puts "#{ ObjectSpace.allocation_sourcefile(obj) }:#{ ObjectSpace.allocation_sourceline(obj) }"; end' > tmp/tmp-gemfile
cat Gemfile >> tmp/tmp-gemfile
cat tmp/tmp-gemfile > Gemfile
# $ bundle exec irb
# irb(main):001:0> require 'rails'
# => true
# irb(main):002:0> sup(Rails)
# /Users/richardschneeman/.gem/ruby/2.4.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:3
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@akitaonrails
akitaonrails / upgrading-vagrant-fusion.mdown
Created October 24, 2013 17:40
Upgrading Vagrant from the default Virtualbox provider to VMWare Fusion on the Mac

I had some headaches yesterday while trying to upgrade to VMWare Fusion with Vagrant.

The steps that work are:

  • export your boxes from Virtualbox to OVA files
  • run 'vagrant destroy' on all your boxes
  • uninstall Virtualbox using the uninstaller script in the installer DMG
  • download VMWare Fusion
  • run 'vagrant plugin install vagrant-vmware-fusion' to install the provider plugin
  • run 'vagrant plugin license vagrant-vmware-fusion license.lic' to install the license you just bought
@willurd
willurd / web-servers.md
Last active April 26, 2024 18:00
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000