Skip to content

Instantly share code, notes, and snippets.

View Loschcode's full-sized avatar
🌀
Probably coding

Laurent Schaffner Loschcode

🌀
Probably coding
View GitHub Profile
@Loschcode
Loschcode / stress_test_a_specific_user.rb
Created April 19, 2022 00:32
Stress test a specific user with Bloodbath (Ruby)
require "bloodbath"
scheduled_for = 5.minutes.from_now
100.times do
id = User.ids.sample
Bloodbath::Event.schedule(
scheduled_for: scheduled_for,
headers: { 'Content-Type': 'application/json' },
method: :get,
@Loschcode
Loschcode / stress_test_a_list_of_users.rb
Created April 19, 2022 00:29
Stress test a list of users with Bloodbath (Ruby)
require "bloodbath"
scheduled_for = 5.minutes.from_now
500.times do
Bloodbath::Event.schedule(
scheduled_for: scheduled_for,
headers: { 'Content-Type': 'application/json' },
method: :get,
body: { offset: rand(0..1000) },
endpoint: 'https://api.my-staging-project.com/users'
# frozen_string_literal: true
require "tempfile"
# catch various system process output
module Engines::Core::Infrastructure::Utils
class CaptureProcess
class << self
def error(&block)
capture($stderr, &block)
# report for each
# 0.010811 0.001804 0.012615 ( 0.013084)
# report for reduce
# 0.007351 0.001876 0.009227 ( 0.009232)
n=1000000
Benchmark.bm do |x|
x.report do
puts "report for each"
# report for each
# 0.007854 0.001874 0.009728 ( 0.010521)
# report for tally
# 0.782440 0.076243 0.858683 ( 0.858839)
n=100
Benchmark.bm do |x|
x.report do
puts "report for each"
@Loschcode
Loschcode / dokku.txt
Created February 15, 2018 18:31
Dokku no space left on device solution
1) Stop docker: service docker stop. Verify no docker process is running ps faux
2) Double check docker really isn't running. Take a look at the current docker directory: ls /var/lib/docker/
2b) Make a backup - tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
3) Move the /var/lib/docker directory to your new partition: mv /var/lib/docker /mnt/pd0/docker
4) Make a symlink: ln -s /mnt/pd0/docker /var/lib/docker
5) Take a peek at the directory structure to make sure it looks like it did before the mv: ls /var/lib/docker/ (note the trailing slash to resolve the symlink)
6) Start docker back up service docker start
# what it looks like after a while
<svg width="160px" height="39px" viewBox="0 0 160 39" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" font-family="Rancho-Regular, Rancho" font-size="50" font-weight="normal">
<g id="email_blue" transform="translate(-374.000000, -120.000000)" fill="#FFFFFF">
<text id="AskAlfred">
<tspan x="374.897461" y="154">AskAlfred</tspan>
</text>
</g>
</g>
</svg>
# MIGRATION
change_column :my_table, :status, :string
# LOGICS
module SafeEnumHelper
def self.ensure(resource:, column:, mapping:)
raw_status = resource.attributes_before_type_cast[column]
is_integer = /\A[-+]?\d+\z/ === raw_status
if is_integer
import gql from 'graphql-tag'
import EventsService from '@/services/EventsService'
import _ from 'lodash'
const CurrentIdentity = gql`
query CurrentIdentity {
currentIdentity {
id
role
token
import gql from 'graphql-tag'
import EventsService from '@/services/EventsService'
import _ from 'lodash'
const CurrentIdentity = gql`
query CurrentIdentity {
currentIdentity {
id
role
token