Skip to content

Instantly share code, notes, and snippets.

Tore Darell toretore

Block or report user

Report or block toretore

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View location.elm
module Location
type Location
= None
| SelectCountry (List Country)
| CountrySelected Country
| SelectRegion Country (List Region)
| RegionSelected Country Region
| SelectCity Country Region (List City)
| Complete Country Region City
View elm-tips.elm
--------------------------------------------------------------------------------
-- The `msg` in `Html msg` and `Cmd msg` can be anything
--------------------------------------------------------------------------------
-- Most Elm apps will have a `Msg` type at the top lever describing the messages
-- that can be processed by `update`:
type Msg
= UserLoaded (Maybe User)
| UserSelected User
View Customers.elm
module Customers exposing (Error, Customers, init, toLoading, toFailure, toSuccess)
type alias Error = String
type Customers
= NotAsked
| Loading (Maybe Error) (Maybe (List Customer))
| Failure Error (Maybe (List Customer))
| Success (List Customer)
View logging.rb
require 'logger'
require 'fileutils'
require 'time'
require 'fiber'
module Logging
class Logger
View lb.rb
require 'thread'
state = {time: Time.now, status: "Flux Capacitor running"}
messages = Queue.new
class TimeChange
attr_reader :time
def initialize(t)
@time = t
end
View chrome_sockets_link.rb
View chrome_sockets.rb
require 'socket'
def log(s)
puts "#{Time.now.strftime('%H:%M:%S')}: #{s}"
end
server = TCPServer.new('', 1337)
loop do
socket = server.accept
View t.rb
require 'thread'
class WorkerPool
def initialize
@num = 10
@jobs = Queue.new
@results = Queue.new
@stopped = false
View now.rb
PIPELINE = %w[booked collected ironed delivered]
def state
PIPELINE[@pipeline_position]
end
def advance
@pipeline_position += 1
end
View sockets.rb
require 'socket'
server1 = TCPServer.new('0.0.0.0', 1337)
server2 = TCPServer.new('0.0.0.0', 1338)
servers = [server1, server2]
clients = []
loop do
readables, * = IO.select(servers+clients)
You can’t perform that action at this time.