Skip to content

Instantly share code, notes, and snippets.

View International's full-sized avatar
🪲
Debugging

George Opritescu International

🪲
Debugging
View GitHub Profile
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active April 19, 2024 04:06
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@FSX
FSX / script.lua
Last active December 21, 2023 15:34 — forked from chanks/script.lua
Lua script to delete/trim all processed messages from a Redis stream
-- The goal of this script is to trim messages that have been processed by
-- all extant groups from the a given Redis stream. It returns the number
-- of messages that were deleted from the stream, if any. I make no
-- guarantees about its performance, particularly if the stream is large
-- and not fully processed (so a simple XTRIM isn't possible).
-- First off, bail out early if the stream doesn't exist.
if redis.call("EXISTS", KEYS[1]) == 0 then
return false
end
@jalkoby
jalkoby / my_awesome_rspec_hacks.rb
Created September 29, 2018 13:05
My awesome RSpec hacks
## Context + metadata
shared_context 'Logged as a user', role: true do
let(:user) { |example| create :user, example.metadata[:role] }
before { login_as user }
end
scenario "Login as a client", role: :client
scenario "Login as a customer", role: :customer
scenario "Login as an admin", role: :admin
@andyyou
andyyou / rails_webpacker_bootstrap_expose_jquery.md
Last active August 9, 2022 07:38
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@random-robbie
random-robbie / install_go_pi.sh
Created April 26, 2018 14:16
Install Go Lang 1.10.1 on Raspberry Pi 3
wget https://storage.googleapis.com/golang/go1.10.1.linux-armv6l.tar.gz
sudo tar -C /usr/local -xvf go1.10.1.linux-armv6l.tar.gz
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
source ~/.bashrc
defmodule MyApp.Auth do
import Comeonin.Bcrypt, only: [checkpw: 2, dummy_checkpw: 0]
alias MyApp.Accounts.User
alias MyApp.Repo
def login(conn, user) do
conn
|> Guardian.Plug.sign_in(user)
end
# http://adventofcode.com/2017/day/1
defmodule Day1 do
def sum1(digits), do:
digits
|> Stream.concat(Enum.take(digits, 1))
|> Stream.chunk_every(2, 1, :discard)
|> Stream.filter(&match?([el, el], &1))
|> Stream.map(&hd(&1))
|> Enum.sum()
@kirankarki
kirankarki / Upgrading rails 5.0 to 5.1
Created October 30, 2017 13:19
Notes on upgrading rails 5.0 to 5.1
1. Change rails version in Gemfile
> gem 'rails', '~> 5.1', '>= 5.1.4'
2. Remove Gemfile.lock
> git rm Gemfile.lock
3. Run bundle install command
> bundle install --jobs=5
4. Run rails' app update to apply changes to app
@deadprogram
deadprogram / mqttdash.go
Last active September 20, 2017 21:43
Simple Golang dashboard to show MQTT server activity by subscribing to all messages.
// how to run:
// go run mqtt.go tcp://iot.eclipse.org:1883 /topic/name
package main
import (
"os"
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/gizak/termui"
)
@thisduck
thisduck / delayed_job.rb
Created May 20, 2017 16:45
delayed job profiling
# config/initializer/delayed_job.rb
module Delayed
module Plugins
class Flaming < Plugin
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, *args, &block|
HelperMethods.flaming(name: "DELAYEDJOB--#{job.name}") do
block.call(job, *args)
end