Skip to content

Instantly share code, notes, and snippets.

View sidonath's full-sized avatar
🐈
Petting cats

Damir Zekic sidonath

🐈
Petting cats
View GitHub Profile
@sidonath
sidonath / install-chromedriver.sh
Last active May 31, 2019 11:24
Install latest compatible ChromeDriver on SemaphoreCI
#!/bin/bash
set -e
INSTALLED_CHROME_VERSION=$(apt-cache policy google-chrome-stable | grep Installed | egrep -o '[[:digit:]]+' | head -n1)
CHROMEDRIVER_VERSION=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$INSTALLED_CHROME_VERSION)
# Download ChromeDriver into Semaphore's cached directory if it doesn't exist already
if ! [ -e $SEMAPHORE_CACHE_DIR/chromedriver-$CHROMEDRIVER_VERSION ]; then
mkdir -p $SEMAPHORE_CACHE_DIR/chromedriver-$CHROMEDRIVER_VERSION
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="rspec" tests="9" failures="6" errors="0" time="0.001972" timestamp="2017-06-13T18:46:48+09:00">
<properties>
<property name="seed" value="12345"/>
</properties>
<testcase classname="spec.example_spec" name="some example specs should be pending" file="./spec/example_spec.rb" time="0.000106"><skipped/></testcase>
<testcase classname="spec.example_spec" name="some example specs escapes &lt;html tags=&apos;correctly&apos; and=&quot;such &amp;amp; such&quot;&gt;" file="./spec/example_spec.rb" time="0.000458"><failure message="
expected: &quot;&lt;p&gt;This is &lt;strong&gt;very&lt;/strong&gt; important&lt;/p&gt;&quot;
got: &quot;&lt;p&gt;This is important&lt;/p&gt;&quot;
#!/usr/bin/env ruby
require 'benchmark'
def add_methods_to_a_module(m)
1_000.times.map do |i|
method_name = "method_#{i}"
m.__send__(:define_method, method_name) {}
method_name
end
@sidonath
sidonath / README.md
Last active August 29, 2015 14:20
Generate reports from Slack logs

Put JSON files with Slack logs into the data directory and save the Ruby script outside that directory.

Open Terminal and cd into the directory with the Ruby script. Now type:

ruby parse_logs.rb

You should get output directory with reports in CSV.

@sidonath
sidonath / keybase.md
Created October 27, 2014 07:10
My identity proof @ Keybase

Keybase proof

I hereby claim:

  • I am sidonath on github.
  • I am sidonath (https://keybase.io/sidonath) on keybase.
  • I have a public key whose fingerprint is 4717 804E 7261 B3B0 670F 2C60 7D14 BE56 5E2F 6DCA

To claim this, I am signing this object:

// is the other bird within a certain distance
def within(dist: Float) = { other: Boid =>
val d = loc distance other.loc
d > 0 && d < dist
}
// Sum, and divide by size
def avg(l: List[Vector]) = (l :\ new Vector)(_ + _) / (l.size max 1)
// Separation
lines = [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Sed vitae sapien dignissim, volutpat leo consectetur, iaculis magna.",
"In quis lacus tincidunt, vehicula ipsum in, euismod elit.",
"Quisque a elit in odio consequat mattis.",
"Fusce condimentum eros in mauris pharetra, vel accumsan mi vehicula.",
"Phasellus tincidunt neque eget lobortis fringilla.",
"In sit amet mi ut turpis dapibus commodo.",
"Sed non tellus non libero hendrerit iaculis.",
"Ut dictum dolor nec lectus cursus, at eleifend urna varius.",
#r "/Users/damir/packages/MathNet.Numerics.3.0.2/lib/net40/MathNet.Numerics.dll";;
#r "/Users/damir/packages/MathNet.Numerics.FSharp.3.0.2/lib/net40/MathNet.Numerics.FSharp.dll";;
open MathNet.Numerics.LinearAlgebra
let splitRows (matrix:string) =
matrix.Split([|'\n'|])
|> List.ofArray
let parseRow (row:string) =
class Create
include Lotus::Action
expose :booking, :errors
def call(params)
@booking = Booking.new
# BookingForm validates datetime entered and converts the values into a single Time object
form = BookingForm.new(booking)
# Syncs the form values to the entity
@sidonath
sidonath / initialize-instance-method-example.rb
Last active August 29, 2015 14:01
Why is it bad to call instance method in initializers
class Logger
def info(*args)
puts(*args)
end
end
class Auditor
def log(action)
puts "Following action was performed: #{action}"
end