Skip to content

Instantly share code, notes, and snippets.

const queryStringToJSON = query => (
query.slice(1).split('&').map(d => d.split('=')).reduce(
(acc, [head, tail]) => ({ ...acc, [head]: tail }), 0)
)
@SadPandaBear
SadPandaBear / ROA.hs
Last active May 30, 2018 13:40
Haskell: Rotation of Axes
rotate :: (Double, Double) -> Double -> (Double, Double)
rotate (x, y) a = (x', y')
where
co = cos a
si = sin a
x' = x * co - y * si
y' = x * si + y * co
@SadPandaBear
SadPandaBear / Lib.hs
Last active May 20, 2018 22:39
Spotify Client Credentials Flow with Haskell
{-# LANGUAGE OverloadedStrings #-}
module Lib
( someFunc
) where
import Network.HTTP.Client
import Network.HTTP.Client.TLS
import qualified Data.ByteString.Char8 as B8 (pack)
import qualified Data.ByteString.Lazy.Char8 as L8
const throttle = (time, f) => (...args) => {
const now = Date.now()
return () => {
if ((now + time - Date.now()) < 0) {
f(...args)
now = Date.now()
}
}
}
const debounce = (time, f) => (...args) => (
Promise.race([
new Promise((_, reject) => setTimeout(reject, time, 'TIMEOUT')),
f(...args)
])
)
export default debounce
const prepareQueries = queryParams =>
`?${Object.entries(queryParams)
.map(kv => kv.join('='))
.join('&')}`;
export default prepareQueries;
@SadPandaBear
SadPandaBear / sort_algorithms.ex
Last active October 26, 2017 16:47
Sort Algorithms impl with Elixir
# Bubble sort
defmodule Bubble do
def sort([]), do: []
def sort(l) do
round = swap_itr(l)
cond do
round == l -> l
true -> sort(round)
end
end
defmodule Utils do
def value_at(list, 0), do: List.first(list)
def value_at(list, index) when index > length(list), do: raise "Index(#{index}) out of bounds on List"
def value_at(list, index) when index > 0 do
[_ | tail] = list
value_at(tail, index - 1)
end
end

Watir

What is WATIR?

Web Application Testing In Ruby

It's a library for the Ruby language which simulates users actions on major web browsers.

Examples: