Skip to content

Instantly share code, notes, and snippets.

@isidzukuri
isidzukuri / ruby_csv_from_hash.rb
Created October 6, 2022 11:20
ruby generate csv from hash
require 'csv'
CSV.open('name.csv', "wb") do |csv|
csv << data.first.keys
data.each do |row|
csv << row.values
end
end
- describe NameOfClass
-- describe 'constantants'
-- describe '.method_a'
-- describe '#method_b'
--- let!(:a)
--- let(:b)
--- before
--- after
--- subject
--- shared_examples
@isidzukuri
isidzukuri / js promises experiments.js
Last active February 5, 2021 10:07
js promises experiments
new Promise(function(resolve, reject) {
console.log(1)
resolve()
})
.then(() => console.log(2))
.then(() => {
return new Promise(function(resolve, reject) {
reject(new Error('Polling failure'));
})
.then(() => console.log(21))
@isidzukuri
isidzukuri / Class descendants
Created January 13, 2021 17:31
Ruby. Get descendants of the class
class GRPC::BadStatus
def self.descendants
ObjectSpace.each_object(Class).select { |klass| klass < self }
end
end
GRPC::BadStatus.descendants
RSpec::Matchers.define :be_url do |expected|
match do |actual|
actual =~ URI::regexp
end
end
@isidzukuri
isidzukuri / redis-autostart-osx.md
Created December 18, 2020 17:39 — forked from subfuzion/redis-autostart-osx.md
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)

{
"font_size": 10,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
120
],
check host website.com with address 0.25.118.0
if failed
port 443
protocol https
request "/search?word=black"
status = 200
then exec "/bin/bash -c '/var/www/lib_agregator/import_elastic.sh'"
@isidzukuri
isidzukuri / write_temporary_file.rb
Created July 20, 2020 12:09
creates temporary file with name without randomizing
class WriteTemporaryFile
class Remover
def initialize(tmpfile)
@pid = Process.pid
@tmpfile = tmpfile
end
def call(*args)
return if @pid != Process.pid
@isidzukuri
isidzukuri / thoughts_about_module_callable.md
Last active June 21, 2020 07:40
Thoughts about `module Callable`.

Thoughts about module Callable.

Lets assume that we have a service:

class SomeService
  include Callable

  def initialize(parameter)
    @parameter = parameter
 end