Skip to content

Instantly share code, notes, and snippets.

View amkisko's full-sized avatar
😺
Hymyillen suora selkä!

Andrei GitHub Makarov amkisko

😺
Hymyillen suora selkä!
  • Kisko Labs
  • Helsinki, Finland
View GitHub Profile
@gysel
gysel / integrate.rb
Created August 4, 2012 12:45
Simple Integral implementation in Ruby
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)
@simplay
simplay / Ruby_Lambda_Fun_Numerical _Integration_Trapezoid.rb
Last active April 22, 2022 15:23
# Numerical Integraion over real domain of real 1d valued functions using Newton-Cotes approximation. # NB1: Error of approximation in O(f'' * (b-a)^3 ) # NB2: In practice quite usable for many common functions, like affine, trigonomatric function
# 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
@Denommus
Denommus / integral.hs
Last active April 22, 2022 15:24
Numeric integral implementation (Simpson method) in different languages
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
@usmanakram232
usmanakram232 / WolfieTools.md
Last active January 25, 2021 10:30
An Aggregated list of useful tools. #tools #kb

Wolfie's List

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.

Volunteer

@ChuckJHardy
ChuckJHardy / example_activejob.rb
Last active July 20, 2024 12:15
Example ActiveJob with RSpec Tests
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
@wvengen
wvengen / README.md
Last active March 25, 2024 07:53
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

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
@ansulev
ansulev / install-arch-linux-on-btrfs-subvolume-inside-luks
Last active June 30, 2024 03:07
Install Arch Linux with full encrypted btrfs subvolume inside luks
# 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
@kgilles
kgilles / generate_pin.rb
Last active March 15, 2022 09:10
Generate Random Finnish, Norwegian and Swedish Personal Identification Numbers
# 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)