Skip to content

Instantly share code, notes, and snippets.

View boutros's full-sized avatar

Petter Goksøyr Åsen boutros

  • Oslo Public Library
  • Oslo
View GitHub Profile
@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@ztellman
ztellman / gist:66ba4e65558a064920e9
Created October 31, 2014 10:07
reading list from PolyConf 2014

Fiction

  • Fictions and The Aleph by Borges
  • Invisible Cities by Calvino

More Technical

  • An Introduction to General Systems Thinking by Weinberg
  • Data and Reality by Kent
  • Patterns of Software by Gabriel
@ptaoussanis
ptaoussanis / transducers.clj
Last active December 17, 2021 13:54
Quick recap/commentary: Clojure transducers
(comment ; Fun with transducers, v2
;; Still haven't found a brief + approachable overview of Clojure 1.7's new
;; transducers in the particular way I would have preferred myself - so here goes:
;;;; Definitions
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as:
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation
;; (The `[]` arity is actually optional; it's only used when calling
;; `reduce` w/o an init-accumulator).
@loganlinn
loganlinn / history.cljs
Last active November 19, 2017 20:13
history.cljs
(ns history
"Light wrappers and utils for js/history")
(defn back! [] (.back js/history))
(defn forward! [] (.forward js/history))
(defn go! [idx] (.go js/history idx))
(defn replace-state!
@steeve
steeve / _readme.md
Last active March 7, 2024 12:38
How to cross compile Go with CGO programs for a different OS/Arch

How to cross compile Go with CGO programs for a different OS/Arch

It is possible to compile Go programs for a different OS, even though go build says otherwise.

You'll need:

@scttnlsn
scttnlsn / queue.go
Last active July 5, 2023 14:30
Queue server in Go
package main
import (
"bufio"
"flag"
"fmt"
"net"
"strconv"
"strings"
"time"
(defn postfix [& e]
(reduce #(if (fn? %2)
(let [[l r & m] %]
(cons (%2 r l) m))
(cons %2 %)) [] e))

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?

@martintrojer
martintrojer / rdf-cl.clj
Created August 16, 2012 18:36
RDF graph core.logic
;; http://www.infoq.com/presentations/core-logic
(ns rdf
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
(def g
[[:a1 :rdf/type :sdx/FederationService]
[:a1 :rdf/type :sdx/name "movies"]
[:a1 :rdf/exposedServices :_syscoll1]
@ptaoussanis
ptaoussanis / smart_memoize.clj
Created June 14, 2012 11:19
More powerful memoize for Clojure
(def ^:private gc-sm-cache!
"Maintains maximum cache size by intelligently pruning less valuable items."
(let [gc-running? (atom false)]
(fn [cache ttl max-items now]
(when-not @gc-running?
(reset! gc-running? true)
(let [snapshot @cache