Skip to content

Instantly share code, notes, and snippets.

trait Reader<A>
where
Self: Sized,
{
type Out;
fn apply(&self, a: &A) -> Self::Out;
fn map<'a, G>(&'a self, g: &'a G) -> Map<Self, G> {
Map(self, g)
@zobar
zobar / backoff.scala
Last active September 22, 2017 21:57
import java.util.{Timer, TimerTask}
import org.joda.time.Duration
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
import scala.concurrent.duration.Duration.Inf
import scala.math.min
import scala.util.Random
def withBackoff[A](maxRetry: Int,
baseDelay: Duration,
maxBackoffTime: Duration)
:paste
implicit class Reader[-A, +B](f: A => B) {
def contramap[C](g: C => A): C => B = f compose g
def flatMap[C <: A, D](g: B => C => D): C => D = { c => g(f(c))(c) }
def map[C](g: B => C): A => C = f andThen g
def zip[C <: A, D](g: C => D): C => (B, D) = { c => (f(c), g(c)) }
}
require 'bigdecimal'
require 'csv'
require 'date'
lo = hi = nil
CSV.foreach('temp-2016.csv') do |station, valid, tmpc|
next if station.start_with?('#') || station == 'station' || tmpc == 'M'
valid = DateTime.strptime valid, '%Y-%m-%d %H:%M'
value_type fixed_length nullable data_type simple_type GType type_parameter x
ArrayType true _vala_array_destroy(value, length, (GDestroyNotify) element_destroy_func)
DelegateType if (delegate_target_destroy_notify != NULL) delegate_target_destroy_notify(delegate_target)
ValueType false Struct true destroy_func(value)
ValueType false Struct false destroy_func(&value)
ValueType false Enum N/A destroy_func(&value) // ??
ValueType false Struct false value if (G_IS_VALID(&value)) g_value_unset(&value);
ValueType false Struct false mutex etc _vala_clear_mutex(&value)
sshpass -p raspberry ssh pi@raspberrypi mkdir .ssh
sshpass -p raspberry scp ~/.ssh/id_rsa.pub pi@raspberrypi:.ssh/authorized_keys
ssh pi@raspberrypi '
set -e
sudo chgrp staff /usr/src
sudo chmod g+ws /usr/src
sudo usermod --append --groups staff pi
sudo passwd -l pi'
ssh -t pi@raspberrypi sudo raspi-config
ssh pi@raspberrypi '

Never follow any guidelines without understanding their concrete benefits. Clarity is more important than structure. If code is left ugly but straightforward, it's easy enough to refactor it. If an inappropriate structure is imposed on code, it will need to be detangled first.

You will never know less about a project than you do at the very beginning. You know more about your project today than you have ever known, but you will know even more tomorrow.

  • Think about the future, but defer final decisions until the time is right.
  • 299839 Single-Gang Drawn Handy Box 1-7/8 in. Deep with 1/2 in. KO's
  • 342576 Husky 9 ft. 14/3 Power Tool Replacement Cord
  • 630692 Ideal 33 Orange In-Sure 3-Port Connector (10-Pack)
  • 698646 Leviton 15 Amp Tamper Resistant Duplex Outlet, Black
  • 839647 3/8 in. Non-Metallic (NM) Twin-Screw Cable Clamp Connectors (5-Pack)
  • 908401 Romex 15 ft. 14/2 Soild SIMpull NM-B Cable
  • 1001091470 Gardner Bender 1/2 in. Plastic Staple, White (25-Pack)
module Nfa where
import Control.Applicative
import Control.Monad
data State i o
= Reject
| Accept o
| Transition (i -> State i o)
module Iter = struct
type 'a t = {
fold: 'b. ('b -> 'a -> 'b) -> 'b -> 'b
}
let empty = {
fold = fun f accu -> accu
}
let pure a = {