Skip to content

Instantly share code, notes, and snippets.

View vikeri's full-sized avatar

Viktor Eriksson vikeri

  • Stockholm, Sweden
View GitHub Profile
@vikeri
vikeri / debug-re-frame-subs.clj
Last active September 3, 2016 15:35
re-frame debug sub macro
;; 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 June 7, 2016 11:17
Build script for deploying offline version to attached iOS device
#! /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 April 26, 2016 16:11
Setup highlight to work with clojure on mac
#!/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 August 25, 2015 13:36
Avoid commiting println in clojure
#!/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 August 29, 2015 14:15
git commands
# 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"
textarea
box-sizing border-box
@vikeri
vikeri / lamp
Created January 23, 2015 22:05
Shortcut to apache for terminal
#!/usr/bin/env bash
sudo /etc/init.d/apache2 $1
@vikeri
vikeri / symbolicapache
Created January 23, 2015 22:03
create symbolic link serving as url (apache in linux)
# 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 January 23, 2015 21:59
Send Viewport data to Google Analytics (Universal), based on example at http://viget.com/advance/upgrading-to-universal-analytics
(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,