Skip to content

Instantly share code, notes, and snippets.

View pboling's full-sized avatar
🏓
Ping me if you need me!

Peter Boling pboling

🏓
Ping me if you need me!
View GitHub Profile
@liamwh
liamwh / +page.svelte
Last active March 27, 2024 14:33
SvelteKit Otel
<script lang="ts">
import type { UserView } from '$lib/stubs/auth';
import { getContext, onMount } from 'svelte';
import { goto } from '$app/navigation';
import { getContacts } from '$lib/repositories/contacts';
import { browser } from '$app/environment';
import { CONTACTS_STORE_KEY, USER_STORE_KEY } from '$lib/store-keys';
import type { Writable } from 'svelte/store';
import AddContactButton from '$lib/components/Contacts/AddContact/AddContactButton.svelte';
import { db } from '$lib/surrealdb';
@eric-hemasystems
eric-hemasystems / hash_delegate.rb
Created August 16, 2021 16:43
Rails `delegate to:` for hashes
module HashDelegate
# Like `delegate :foo, to: :bar` only for hashes instead
# of objects. So these are the same:
#
# def foo
# bar[:foo]
# end
#
# hash_delegate :foo, to: :bar
@sastan
sastan / $layout.svelte
Last active January 15, 2023 00:15
sveltekit + urql (extended version)
<script context="module">
import { get, readable } from 'svelte/store'
import { createClient, operationStore } from '@urql/svelte'
import { browser, dev } from '$app/env'
/**
* @type {import('@sveltejs/kit').Load}
*/
@GuilleLeopold
GuilleLeopold / generate_engines.rb
Created March 11, 2020 18:51
generate_engines
task :generate_engine do
# Get name sent from console
name = ENV['name'].downcase
# Store useful paths
engine_path = "engines/#{name}"
dummy_path = 'spec/dummy'
lib_files_path = 'lib/tasks/files'
dummy_relative_path = "#{engine_path}/#{dummy_path}"
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@schovi
schovi / sidekiq.rb
Created March 17, 2017 22:38
Configure sidekiq via ENV variables
Sidekiq.configure_server do |config|
ENV["SIDEKIQ_NAMESPACE"] && config.options[:namespace] = ENV["SIDEKIQ_NAMESPACE"]
ENV["SIDEKIQ_CONCURRENCY"] && config.options[:concurrency] = ENV["SIDEKIQ_CONCURRENCY"].to_i
ENV["SIDEKIQ_VERBOSE"] && config.options[:verbose] = ENV["SIDEKIQ_VERBOSE"] === 'true'
ENV["SIDEKIQ_LOGFILE"] && config.options[:logfile] = ENV["SIDEKIQ_LOGFILE"]
ENV["SIDEKIQ_PIDFILE"] && config.options[:pidfile] = ENV["SIDEKIQ_PIDFILE"]
config.options[:strict] = true
if ENV["SIDEKIQ_QUEUES"]
@marcotc
marcotc / sidekiq_retry_time.csv
Created February 14, 2017 18:16
Sidekiq retry exponential backoff formula times
Retry count Retry Time Total Cumulative Time Total Cumulative Days
0 0:00:00 0:00:00 0.0
1 0:00:16 0:00:16 0.0
2 0:00:31 0:00:47 0.0
3 0:01:36 0:02:23 0.0
4 0:04:31 0:06:54 0.0
5 0:10:40 0:17:34 0.0
6 0:21:51 0:39:25 0.0
7 0:40:16 1:19:41 0.1
8 1:08:31 2:28:12 0.1

Long story short, Celluloid versions 0.17+ have a memory leak.

The Reason behind this is that completed Celluloid threads are never cleaned up.

We have discovered that our Sidekiq process is leaking memory when we have a lot of tasks that were failed because of exceptions. Unfortunately, having a lot of failed tasks is specific for our application — we do have a lot of small queued jobs to work with social network APIs and other external services.

You can reproduce the problem with this: https://gist.github.com/gazay/3aa78e515ab05cb79f76

@nateberkopec
nateberkopec / gist:11dbcf0ee7f2c08450ea
Last active March 24, 2023 21:59
RubySpec is dead, long live RubySpec!

Last night, Brian Shirai unilaterally "ended" the RubySpec project, a sub-project of Rubinius (the alternative Ruby implementation which Brian was paid to work on full-time from 2007 to 2013). The blog post describing his reasons for "ending" the project led to a big discussion on Hacker News.

When a single, competing Ruby implementation tells that you its test suite is the One True Way, you should be skeptical. Charles Nutter, Ruby core committer and JRuby head honcho, spent a lot of time last night on Twitter talking to people about what this decision means. He's probably too busy and certainly too nice of a guy to write about what is a political issue in the Ruby community, so I'm going to do it on behalf of all the new or intermediate Rubyists out there that are confused by Brian's decision and what it me