My firends said along with sharing all these tools all the time, maintain a list. So, they don't have to search in old chats. :/ I will populate it slowly with time.
IMPORTANT❗ List is not endorsments. If you use any of these, you are on your own.
require 'bigdecimal' | |
def integrate (a, b, n) | |
a = a.to_f; b = b.to_f; n = n.to_i | |
result = 0.0 | |
dx = (b - a) / n | |
dx_half = dx / 2 | |
for i in 0 ... n | |
result += yield a + (i * dx) |
# D subset |R Domain over which we integrate - sample D = [1,10] | |
D = (1..10).to_a | |
# f:|R->|R function - sample x |-> f(x) := x^2 | |
f = lambda {|x| x*x} | |
# summation of function values over our domain | |
summator = lambda {|function, domain| domain.inject(0){|x,y| x += function.call(y)} } | |
# Integrations Driver (for real valued 1d functions only) - assumption: integration steps equidistant |
integral :: (Fractional a, Ord a) => (a -> a) -> Integer -> a -> a -> a | |
integral f p a b | |
| a==b = 0 | |
| otherwise = total 0 a | |
where dx = (b-a)/fromInteger p | |
total t x | x2>b = t | |
| otherwise = total (t+(dx*(f x+(4*f ((x+x2)/2))+f x2)/6)) x2 | |
where x2 = x+dx |
My firends said along with sharing all these tools all the time, maintain a list. So, they don't have to search in old chats. :/ I will populate it slowly with time.
IMPORTANT❗ List is not endorsments. If you use any of these, you are on your own.
class MyJob < ActiveJob::Base | |
queue_as :urgent | |
rescue_from(NoResultsError) do | |
retry_job wait: 5.minutes, queue: :default | |
end | |
def perform(*args) | |
MyService.call(*args) | |
end |
When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.
There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'memory_profiler' | |
gem 'redis', ENV['RVERSION'] | |
require 'redis' | |
puts Process.pid | |
puts Redis::VERSION |
# Install Arch Linux with full encrypted btrfs subvolume inside luks | |
# Hardware: BIOS system, Intel GPU, Nvidia Optimus, Toshiba SSD, Wifi | |
# Please adjust for your needs. | |
# filename: install-arch-linux-on-btrfs-subvolume-inside-luks.txt | |
# The official guide: https://wiki.archlinux.org/index.php/Installation_Guide | |
# Download the archiso image from https://www.archlinux.org/download/ | |
# Copy to a usb-drive | |
dd bs=4M if=archlinux.iso of=/dev/sdx status=progress oflag=sync # on linux |
# NOTE: Gender is something these countries use to calculate the serial/individual number(making them even or odd) | |
# It is not taken into consideration in this snippet but the generated numbers are still valid | |
require 'date' | |
age = 21 # Whatever you want it to be | |
# Randomize month and day equal to, or lower, than the current month | |
# to make sure the generated birth month and day has occurred in <current_year> | |
t = Time.new | |
year = t.year - age |
1) Setup Server on Vultr | |
Select “create New Server(e.g. 123.123.123.123)”, select “Ubuntu 14.04 LTS” | |
Once your server has been created, wait for installation to complete. | |
SSH into your Server as root and run the following commands: | |
# login server by SSH | |
ssh root@dokku.me | |
# Updating apt-get | |
sudo apt-get update # Fetches the list of available updates | |
sudo apt-get upgrade # Strictly upgrades the current packages | |
sudo apt-get dist-upgrade # Installs updates (new ones) |