Skip to content

Instantly share code, notes, and snippets.

View terjesb's full-sized avatar

Terje Sten Bjerkseth terjesb

  • Outnordic
  • Norway
View GitHub Profile
@terjesb
terjesb / deserialize_php.clj
Created July 2, 2013 15:51
deserializing php in clojure - using instaparse and serialized-php-parser
(ns deserialize-php
(:require [instaparse.core :as insta]))
(def serialized-php-parser
(insta/parser
"
<S> = expr
<expr> = (string | integer | double | boolean | null | array)+
<digit> = #'[0-9]'
<number> = negative* (decimal-num | integer-num)
@terjesb
terjesb / outline.clj
Created November 30, 2012 15:02
Hierarchies in Datomic
(use 'datomic.samples.repl)
(easy!)
(def conn (scratch-conn))
(transact-all conn (io/resource "day-of-datomic/outline.dtm"))
(def rules
'[[(ancestors ?section ?ancestor) [?section :section/parent ?ancestor]]
[(ancestors ?section ?ancestor) [?section :section/parent ?parent]
(ancestors ?parent ?ancestor)]
@terjesb
terjesb / meraki-client-vpn-linux.md
Created January 27, 2021 11:28 — forked from clivetyphon/meraki-client-vpn-linux.md
Configuring Meraki Client VPN in Linux

Configuring Meraki Client VPN in Linux

You can try the official Meraki Configuring Client VPN in Linux article for GUI based setup. For terminal based configuration, see below.

Install packages

Install the following packages:

  • strongswan
  • xl2tpd
@terjesb
terjesb / how.md
Created January 27, 2021 11:28 — forked from Zemnmez/how.md
L2TP / ipsec VPN, Amazon Linux (EC2)
# adapted from http://spottedhyena.co.uk/centos-67-ipsecl2tp-vpn-client-unifi-usg-l2tp-server/
yum -y install epel # different on amazon linux
sudo yum -y install xl2tpd openswan
systemctl start ipsec.service
service ipsec start

# 'myserver.com' is just to help identify. these are all imported into /etc/ipsec.conf.

vim /etc/ipsec.d/myserver.com.conf # see next...
@terjesb
terjesb / excel_core.clj
Created August 16, 2012 09:57 — forked from jramb/excel_core.clj
Creating and updating Excel files with Clojure/poi.apache.org
((ns excel.core
(:import [org.apache.poi.hssf.usermodel HSSFWorkbook HSSFSheet HSSFRow
HSSFRichTextString HSSFFont HSSFDataFormat
HSSFCellStyle HSSFCell])
(:import [java.io FileOutputStream FileInputStream IOException])
#_(:import [org.apache.poi.ss.util CellRangeAdrress]))
(defn make-excel [file-name]
(let [wb (HSSFWorkbook.)
@terjesb
terjesb / latency.txt
Created May 4, 2017 15:06 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@terjesb
terjesb / core.clj
Created October 1, 2013 19:20
Google Analytics Core Reporting API v3 using Service Account from Clojure
(ns ga-exp.core
(:import
(com.google.api.client.googleapis.auth.oauth2 GoogleCredential$Builder)
(com.google.api.client.googleapis.javanet GoogleNetHttpTransport)
(com.google.api.client.json.jackson2 JacksonFactory)
(com.google.api.services.analytics Analytics$Builder AnalyticsScopes)))
(def HTTP_TRANSPORT (GoogleNetHttpTransport/newTrustedTransport))
(def JSON_FACTORY (JacksonFactory.))
@terjesb
terjesb / form_data.cljs
Created March 29, 2013 17:04
How to get form data in a ClojureScript app, other than getting values separately? I have a page with many instances of the same form, and a button to submit each form. I couldn't find anything obvious in Domina, Enfocus or Dommy. Then I found goog.dom.forms.getFormDataMap, but the goog.structs.Map it returns doesn't seem to be directly usable f…
(ns form-data
(:require [clojure.string :as str]
[goog.dom :as gdom]
[goog.string :as gstring]
[goog.dom.forms :as gforms]
[domina :refer [by-class]]
[domina.events :as ev]))
;; form-decode from ring.util.codec
(defn assoc-conj
@terjesb
terjesb / logicrels-fred.clj
Created July 26, 2012 08:39 — forked from jsmorph/logicrels-fred.clj
St. Louis Fed FRED relation for clojure.core.logic
(ns logicrels.fred
(:require [clojure.xml :as xml]
[clojure.core.logic :as logic]))
;; (config :fred-key (do "See http://api.stlouisfed.org/api_key.html" nil))
;; (clojure.pprint/pprint (sort-by :date (fred-test "DGS10" "2012-07-02")))
;; ({:target "1.61", :date "2012-05-31", :value "1.59"}
;; {:target "1.61", :date "2012-06-01", :value "1.47"}
@terjesb
terjesb / gist:4257641
Created December 11, 2012 10:38
iTerm2 emacs 24.2.1 -nw with paredit on OS X 10.8 Norwegian layout
iTerm2 emacs 24.2.1 -nw with paredit on OS X 10.8 Norwegian layout
Left Command is my Meta.
Left Alt used for inputting special characters.
Caps Lock is mapped to Control.
 > System Preferences > Keyboard > Keyboard > Special: Caps Lock: ^ Control
iTerm > Preferences > Keys: Left Command key mapped to Right Option
iTerm > Preferences > Profiles > Keys: Right option acts as: +Esc