Skip to content

Instantly share code, notes, and snippets.

Avatar

Viktor Eriksson vikeri

  • Stockholm, Sweden
View GitHub Profile
@vikeri
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
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/
# %%% SPECIFY THE NAME OF YOUR APP %%%
APPNAME="Pilloxa"
cd "$(dirname "$0")"
cd ..
@vikeri
vikeri / setup.sh
Created Apr 26, 2016
Setup highlight to work with clojure on mac
View setup.sh
#!/bin/bash
brew install highlight
sed -i '' 's/{ Lang="charmm"/{ Lang="clojure", Extensions={"clj", "cljs", "cljc"} },\
{ Lang="charmm"/g' /usr/local/etc/highlight/filetypes.conf
@vikeri
vikeri / pre-commit
Created Aug 25, 2015
Avoid commiting println in clojure
View pre-commit
#!/bin/sh
if git diff --cached | grep 'println';
then
tput setaf 1; echo "ERROR: You tried to commit a println statement"
tput bel
exit 1;
fi
@vikeri
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
vikeri / lamp
Created Jan 23, 2015
Shortcut to apache for terminal
View lamp
#!/usr/bin/env bash
sudo /etc/init.d/apache2 $1
@vikeri
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
vikeri / analytics.js
Created Jan 23, 2015
Send Viewport data to Google Analytics (Universal), based on example at http://viget.com/advance/upgrading-to-universal-analytics
View analytics.js
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-YOURIDHERE', 'auto');
ga('send', 'pageview');
var w = window,
d = document,