Skip to content

Instantly share code, notes, and snippets.

@scudelletti
scudelletti / composite_pattern.js
Last active August 29, 2015 14:09
Composite Pattern
// How To Use
// var categories = CategoryModule.Category.all();
// var categoryComposite = new CategoryModule.CategoryComposite('CategoryComposite', categories.categorias, null);
//
// var categoryComposities = categoryComposite.findByName('Bar');
//
// var originalCategories = categoryComposities.map(function(item) {
// return item.original;
// });
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
aula. Ele pratica. Instrumentistas geniais nao aprendem a tocar tendo
aula. Eles praticam. Pratique. Chegue em casa depois do trabalho e da
@guilleiguaran
guilleiguaran / disable_framework.md
Created October 10, 2012 21:35
Disabling frameworks in Rails 3+

Disabling frameworks in Rails 3+###

Replace in your config/application.rb

require "rails/all"

with:

require "rails"
In celebration of Whyday: Rubyists always want to show others the beautiful code
they have created, hence the question: Has Anybody Seen My Code?
Has Anybody Seen My Code
(sung to the tune of Has Anybody Seen My Gal)
Clean and small, works for all,
Ruby is my all in all.
Has anybody seen my code?
@jtanium
jtanium / recognize_path.rb
Last active August 25, 2020 09:28
Ruby module that can recognize paths of the main Rails application as well as the engines.
module RecognizePath
def recognize_path(path, options)
recognized_path = Rails.application.routes.recognize_path(path, options)
# We have a route that catches everything and sends it to 'errors#not_found', you might
# need to rescue ActionController::RoutingError
return recognized_path unless recognized_path.slice(:controller, :action) == {controller: 'errors', action: 'not_found'}
# The main app didn't recognize the path, try the engines...
Rails.application.railties.engines.each do |engine|
@devonestes
devonestes / with_example.ex
Created February 8, 2020 16:55
Further refactoring of a with statement
# Step 1
def create_subscription(email, plan_id, payment_method_id) do
with %User{customer_id: nil, name: name} = user <-
Repo.get_by(User, email: email),
{:ok, %Stripe.Customer{id: customer_id}} <-
Stripe.Customer.create(%{
name: name,
email: email,
payment_method: payment_method_id,
@thiagofm
thiagofm / pattern_matching_magic.rb
Created September 5, 2022 11:11
Pattern Matching Magic
# Creating a complex hash, with nested keys
my_complex_hash = {
users: [
{name: "Yukihiro Matsumoto", age: 57},
{name: "Kabosu the Shiba Inu", age: 16},
{name: "Thiago Massa", age: 33}
]
}
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@morrolinux
morrolinux / gist:743aaa0ec933fa68a5b2f82e4308605e
Last active July 10, 2023 22:01
Schermo Wireless a bassa latenza
- Parzialmente ispirato a vari gist sparsi per il web
- Sto ancora facendo tuning dei parametri
# TRASMETTERE:
INTEL e AMD [VAAPI] (libva-mesa-driver):
ffmpeg -f x11grab -s 1920x1080 -framerate 60 -i $DISPLAY -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload,scale_vaapi=w=1920:h=1080' -c:v h264_vaapi -qp:v 26 -bf 0 -preset superfast -tune zerolatency -b:v 2000K -minrate 2000K -maxrate 2000K -bufsize 512k -f rawvideo udp://192.168.1.222:12345
NVIDIA (CUDA/NVENC/H264) STREAM:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -f x11grab -s 1920x1080 -i $DISPLAY -c:v h264_nvenc -zerolatency 1 -delay:v 0 -preset p1 -tune ull -b:v 2000k -bufsize 512k -maxrate 2000k -qmin 0 -temporal-aq 1 -rc-lookahead 0 -i_qfactor 0.75 -b_qfactor 1.1 -f rawvideo udp://192.168.1.222:12345
@rsp
rsp / GitHub-Project-Guidelines.md
Last active November 15, 2023 03:50
Git Strict Flow and GitHub Project Guidelines - setup rules and git flow for commercial and open-source projects by @rsp

Git Strict Flow and GitHub Project Guidelines

Or how to turn this:

into this: