Skip to content

Instantly share code, notes, and snippets.


Viktor Eriksson vikeri

  • Stockholm, Sweden
View GitHub Profile
vikeri / analytics.js
Created Jan 23, 2015
Send Viewport data to Google Analytics (Universal), based on example at
View analytics.js
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', 'UA-YOURIDHERE', 'auto');
ga('send', 'pageview');
var w = window,
d = document,
vikeri / symbolicapache
Created Jan 23, 2015
create symbolic link serving as url (apache in linux)
View symbolicapache
# Useful way to manage urls in Apache, this creates a symbolic link in the /var/www folder
sudo ln -s /dir/with/files /var/www/yoururl
vikeri / lamp
Created Jan 23, 2015
Shortcut to apache for terminal
View lamp
#!/usr/bin/env bash
sudo /etc/init.d/apache2 $1
vikeri / gitcommands
Last active Aug 29, 2015
git commands
View gitcommands
# Clean .orig files with prompt
git clean -i
# Delete file from repo after it has been added to .gitignore
git rm --cached filename
# Search in commit messages for specific text
git log grep="Text to search for"
vikeri / pre-commit
Created Aug 25, 2015
Avoid commiting println in clojure
View pre-commit
if git diff --cached | grep 'println';
tput setaf 1; echo "ERROR: You tried to commit a println statement"
tput bel
exit 1;
vikeri /
Created Apr 26, 2016
Setup highlight to work with clojure on mac
brew install highlight
sed -i '' 's/{ Lang="charmm"/{ Lang="clojure", Extensions={"clj", "cljs", "cljc"} },\
{ Lang="charmm"/g' /usr/local/etc/highlight/filetypes.conf
vikeri / build-ios-offline
Last active Jun 7, 2016
Build script for deploying offline version to attached iOS device
View build-ios-offline
#! /bin/bash
# %%% Requires: ios-deploy (to install built app on device), terminal-notification (optional, to get a notification when build is done)
# %%% Put this file in <APPDIR>/script/
cd "$(dirname "$0")"
cd ..
vikeri / debug-re-frame-subs.clj
Last active Sep 3, 2016
re-frame debug sub macro
View debug-re-frame-subs.clj
;; A macro that replaces reg-sub, it inserts debug print statements into reg-sub if a flag of choice is set
;; Developed since 0.8.0 does not work with re-frame-tracer
;; Use it by replacing re-frame.core/reg-sub with this macro
(defmacro reg-sub [label & sub]
(let [fun (last sub)
arg (get-in (vec fun) [1 1 1])
[before after] (split-at 2 fun)
new-fun (concat before [`(js/console.log "Sub: " [~label ~arg])] after)]
(if (= "true" env/PRODUCTION) ;; Or whatever way you want to disable this, may also be done by replacing js/console.log above
vikeri / reload-android.scpt
Created Oct 12, 2016
Reload Android emulator Apple Script
View reload-android.scpt
do shell script "PATH=/usr/local/opt/android-sdk/platform-tools/ /Users/viktor/www/projects/pilloxa/script/reload-android"