Skip to content

Instantly share code, notes, and snippets.

@petterik
petterik / largest_files_command
Created November 26, 2011 00:52
Where's my GBs at?
du -h / | sort -n | grep -P '^(\d+?| \d+?|\d,\d)G'
@petterik
petterik / filename.sed
Created December 7, 2011 07:48
Filename from path with sed
sed 's/.*\///'
@petterik
petterik / ding_when_done
Created December 19, 2011 19:41
Makes the computer say "DING!" after have executed a command
#!/bin/bash
$@
say "DIIING! executed $1"
@petterik
petterik / Time.java
Created February 19, 2012 08:15
Current time with Time.java
public class Time {
public static void main(String[] args) {
System.out.println(System.currentTimeMillis());
}
}
@petterik
petterik / lägenhetsprylar.txt
Created August 22, 2012 11:14
Petters: "Allt ska bort!"
Allt ska bort!
Skänkes mot hämtning:
Köksartiklar
- Bestick
- Tallrikar
- Stekpannor
- etc.
Hylla, vit: http://www.ikea.com/se/sv/catalog/products/50102157/#/00134052
Taklampa
(defn run-db-tests [db]
(fact "should get password that gets stored"
(.put-password db "email" "password")
(.get-password db "email") => "password"))
(fact "all db tests should be true"
(every? true? (map run-db-tests [(memory/get-instance)])) => true)
@petterik
petterik / shuttlCopyBucket.sh
Created December 4, 2013 19:23
Script to copy buckets using Shuttl and without the move needed in the warmToColdScript.sh
set -e
set -u
cd $SPLUNK_HOME/etc/apps/shuttl/bin
bucket="$1"
source java_executable.env
$JAVA -cp ./*:../lib/* com.splunk.shuttl.archiver.copy.ColdCopyEntryPoint "$bucket" &
;; Context: I'm using datascript and representing a Component as an entity.
;; Discovered a few problems when trying to nest components.
;; Problem 1:
;; When this EntityComponent is updated, it tries to read :db/id :person/name
;; and :person/likes.
;; Without context (like entity id in this case) those attributes may match many entries.
;;
;; Question:
;; Would it make sense to (assoc env :ident (ident c (props c))) in om/default-ui->props so
@petterik
petterik / react-kebab-case-css.cljs
Last active October 19, 2015 08:30
Wasn't impressed with react's camel case css...
;; Garden style css (just uses css properties as keywords as you'd expect):
[:style (css {:border-width "1px"})]
;; React cljs (camel cased css property names):
[:div {:style #js {:borderWidth "1px"}}]
;; Why camel case? "[...] This is consistent with the DOM style JavaScript property", see: https://facebook.github.io/react/docs/dom-differences.html
;; Problem: Cannot share code between inline css and react.
@petterik
petterik / gist:50779d8cf15d6b6443e4
Created February 22, 2016 14:47
Trying optimistic updates with om.next, datascript and datomic [Questions]
I'm trying to implement optimistic updates using om.next, datascript and datomic. Mutations should be visible instantly in the UI (the optimistic part) and synced with datomic once the mutation has been successfully transacted. Mutations should also be retryable.
I might be going about this all wrong, but here's the way I'm going about it:
Client:
0. Call om/transact with a mutation `[(my/mutation { ... }) :read/this...]
1. Transact update to datascript and save the optimistic transaction's tx number.
2. Pass the optimistic tx number in the remote's ast's :params (more on this later).
Server:
3. Transact update to datomic returning entities created in datomic and the optimistic tx number from :params, to client.
Client: