This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File.expand_path(File.dirname(__FILE__)) | |
# If you want to require some files in different directory, in ruby 1.9, you may want to use: | |
require_relative "../xxxlib" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tests | |
SUBTESTS = %w(Abstract Decision Quantitative Verbal) | |
end | |
describe Tests do | |
describe "before assigning @ - " do | |
describe "this doesn't work because the loops are all at the same describe level (the befores override one another)" do | |
Tests::SUBTESTS.each do |test| | |
before(:each) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sidekiq/api' | |
Sidekiq::ScheduledSet.new.find_job("61374d5d51db323507376158") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> - In ruby 1.8.x, what is the functional difference between rb_thread_schedule and rb_thread_select? | |
rb_thread_schedule() is the guts of the thread scheduler, it traverses | |
over the linked list of threads (several times) to find the next one | |
to switch into. The function is long (250 lines) and messy, and covers | |
all the combinations of thread status (RUNNABLE, TO_KILL, STOPPED, | |
KILLED) and wait state (FD, SELECT, TIME, JOIN, PID). | |
If there are no threads doing i/o or waiting on a timeout, | |
rb_thread_schedule() picks another thread from the list (considering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import asyncio | |
import requests | |
domain = 'http://integralist.co.uk' | |
a = '{}/foo?run={}'.format(domain, time.time()) | |
b = '{}/bar?run={}'.format(domain, time.time()) | |
async def get(url): | |
print('start: ', url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAIL_LOG=${LOG_DIR:-/var/log}/mails.log | |
echo '== [' $(date +%Y-%m-%d_%H-%M-%S) '] ==' >> $MAIL_LOG | |
perl -MMIME::QuotedPrint -pe '$_=MIME::QuotedPrint::decode($_);' | tee -a $MAIL_LOG > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'sidekiq' | |
require 'sidekiq/cli' | |
# Default to running one process per core | |
def process_count | |
return ENV['SK_PROCESS_COUNT'].to_i unless ENV['SK_PROCESS_COUNT'].to_i == 0 | |
case RbConfig::CONFIG['host_os'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cpanm -l local https://github.com/<user_name>/<repo_name>/tarball/<branch_name> | |
e.g. | |
cpanm -l local https://github.com/issm/p5-Amon2-Plugin-Model/tarball/master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
This script attempts to reproduce poor glibc allocator behavior within Ruby, leading | |
to extreme memory fragmentation and process RSS bloat. | |
glibc allocates memory using per-thread "arenas". These blocks can easily fragment when | |
some objects are free'd and others are long-lived. | |
Our script runs multiple threads, all allocating randomly sized "large" Strings between 4,000 | |
and 40,000 bytes in size. This simulates Rails views with ERB creating large chunks of HTML | |
to output to the browser. Some of these strings are kept around and some are discarded. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Sidekiq workers | |
# start as many workers as you want here | |
Wants=sidekiq@1.service | |
Wants=sidekiq@2.service | |
# ... | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/true |
OlderNewer