Replace in your config/application.rb
require "rails/all"
with:
require "rails"
// 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 |
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? |
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| |
# 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, |
# 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} | |
] | |
} |
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 |
- 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 |