Skip to content

Instantly share code, notes, and snippets.

View dentarg's full-sized avatar
🌦️
=:D><!

Patrik Ragnarsson dentarg

🌦️
=:D><!
View GitHub Profile
@jjb
jjb / file.md
Last active April 30, 2024 11:26
Using Jemalloc 5 with Ruby.md

For years, people have been using jemalloc with ruby. There were various benchmarks and discussions. Legend had it that Jemalloc 5 didn't work as well as Jemalloc 3.

Then, one day, hope appeared on the horizon. @wjordan offered a config for Jemalloc 5.

Ubuntu/Debian

FROM ruby:3.1.2-bullseye
RUN apt-get update ; \
@chrisbloom7
chrisbloom7 / slack_ruby_client_websockets.rake
Last active August 21, 2023 08:33
Basic implementation of a websocket connector for Slack using slack-ruby-client and async-websockets gems
# frozen_string_literal: true
# Basic implementation of a websocket connector for Slack using the slack-ruby-client gem
#
# Run this rake task in a virtual container that is set to automatically restart on failure; this
# will help deal with disconnects from Slack since socket URLs are temporary.
# https://api.slack.com/apis/connections/socket-implement#disconnect
#
# This rake task can be called in multiple virtual containers to help with resilliancy and rolling restarts
# https://api.slack.com/apis/connections/socket-implement#connections
@dentarg
dentarg / .zshenv
Last active October 26, 2022 18:38
How to Ruby on Apple silicon
# Need to use ~/.zshenv, ~/.zprofile is not sourced when doing "arch -x86_64 /bin/zsh"
#
# From 'man zsh' (zsh 5.8.1 (x86_64-apple-darwin21.0))
#
# Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login
# shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile.
# Then, if the shell is interactive, commands are read from /etc/zshrc and
# then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell,
# /etc/zlogin and $ZDOTDIR/.zlogin are read.
class MyEnumerator
attr_reader :scope, :block, :opened, :headers
def initialize(scope, headers, &block)
@scope = scope
@block = block
@opened = false
@cursor = PostgreSQLCursor::Cursor.new(scope.send(:to_unprepared_sql))
@headers = headers
@headers_provided = false
# INFO: works well with Ruby 3.0.1
# hangs on any Ruby including https://github.com/ruby/ruby/commit/f9196de1dee6f5ab8b6fe115070b92775a3500fe
# since the yielding code in each method is running in different Fiber (due to be wrapped into Enumerator and next is used)
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
@otavioschwanck
otavioschwanck / install rails 7 m1.md
Last active April 26, 2022 19:44
Rails 7 on m1 mac

Why install in this way?

To fix some problems with the arm version, like puma SSL.

if you problem is only SSL, try it:

Remove gem puma: gem uninstall puma

And run bundle with DISABLE_SSL=1 bundle install

#!/usr/bin/env ruby
if %w(-h --help).include?(ARGV.first)
abort <<~USAGE
#{__FILE__} <FILE> to count IPs in given file
#{__FILE__} to count IPs using latest file on disk
DL=1 #{__FILE__} to download the AWS IP ranges
USAGE
end
@KoryNunn
KoryNunn / handshake-airdrop.md
Last active March 12, 2024 07:03
Handshake airdrop for github users.

Had 15 github followers in 2019? You can get about $4kAUD of crypto for minimal effort.

Explain this scam

That's legitimately a good default position to hold, however, in this case, the free money is a function of time, and not only charity.

In February 2020, in order to promote Handshake (HNS) to developers, an airdrop was offered to any Github user with more than 15 followers. The Airdrop would give you 4246HNS, at the time worth around at $0.08USD per coin, for a total of $339.68USD, pretty generous!

Today, 4246HNS is worth around $4000 dollarydoos, and there are plenty of github users who haven't claimed theirs.

@costela
costela / discussion_go_issue_16100.go
Created March 30, 2021 10:45
counter-example for the duscission in golang/go#16100
package main
import (
"context"
"log"
"net/http"
"sync/atomic"
"time"
)
@x-yuri
x-yuri / a. Rails < 4.2.5 and pg >= 12 don't mix well.md
Last active November 19, 2021 00:35
#rails #pg #client-min-messages