Quick and dirty https://www.purescript.org/ sample.
create a directory and enter it.
mkdir sample
cd sample
Use npm to install purescript
and it's package manager spago
.
qty, size, bonus = "3d6-1" | |
.match(/^(\d+)d(\d+)([+-]\d+)?/) | |
.captures | |
.map(&:to_i) |
RSpec.configure do |config| | |
config.before(:suite) do | |
ActiveRecord::Base.establish_connection database['one'] | |
DatabaseCleaner.strategy = :deletion | |
ActiveRecord::Base.establish_connection config.database['two'] | |
DatabaseCleaner.strategy = :deletion | |
end | |
config.before(:each) do |
class Record | |
class MissingField < Error; end | |
class << self | |
def build(hash) | |
new(*members.map{|m| hash[m.to_s] }) | |
end | |
end | |
def initialize(*values) | |
self.class.members.zip(values).each do |member, value| | |
raise MissingField, "Unable to initialize #{self.class}, missing field: '#{member}'." if value.nil? |
Quick and dirty https://www.purescript.org/ sample.
create a directory and enter it.
mkdir sample
cd sample
Use npm to install purescript
and it's package manager spago
.
select | |
* | |
from | |
tables | |
join ( | |
select table_id | |
from books | |
where rating = 1 | |
) as t1 on t1.table_id = tables.table_id | |
join ( |
class Job | |
def self.fetch | |
return new if rand(100) > 85 # only return a job 15% of the time | |
end | |
attr_reader :count | |
def initialize | |
@count = rand(5) # some random data | |
end |
#!/bin/sh | |
# $1 is session/window name | |
# $2 is command to run in that session | |
mk_tmux_session() { | |
if [ -z "$1" ]; then | |
echo 'usage: startdev NAME' | |
exit 1 | |
fi |
Process.setproctitle("foo-parent") | |
ppid = Process.pid | |
fork do | |
exit if fork # You can only setsid if you're in a child process so first we fork | |
Process.setsid # and exit the parent then setsid in the child. Now that we have a | |
exit if fork # new session create a child process in it and exit the parent again. | |
Dir.chdir("/") # Finally, change directory to one that can't be deleted or moved. | |
Process.setproctitle("foo-child") |
{-# LANGUAGE RecordWildCards #-} | |
import Data.Maybe | |
import Data.List | |
-- this defines the data type that will be read from the config file, all of the values are optional | |
data Proxy = Proxy | |
{ proxyKey :: Maybe String | |
, proxyUser :: Maybe String |
# The point is that only functions and function application are required to create all | |
# higher level language abstractions. You can use church encoding to turn functions | |
# into numbers, boolean values, logical operators, math operators, and in this case | |
# data structures. | |
fst = -> (a,_) { a } # no matter what 2 values are passed in return the 1st | |
snd = -> (_,b) { b } # no matter what 2 values are passed in return the snd | |
# a tuple is a function, that takes a function as an argument and applies it to the constant values of the tuple | |
tuple1 = ->(f){ f.('alpha', 'omega') } |