Skip to content

Instantly share code, notes, and snippets.

Avatar

Aksel G. Gresvig AGresvig

View GitHub Profile
@AGresvig
AGresvig / slackstatus.sh
Last active Jun 5, 2018 — forked from samervin/slackstatus.sh
A command line utility for changing your Slack status.
View slackstatus.sh
#!/bin/bash
# Usage: slackstatus "My new status"
function slackstatus() {
slacktoken=$SLACK_OAUTH_TOKEN
apiurl="https://slack.com/api/users.profile.set?token="$slacktoken"&profile="
emoji=":mag:"
if [ $# -eq 0 ]
@AGresvig
AGresvig / Bleeding-edge-kodi-mesa-setup.sh
Created Jun 23, 2017
Installing bleeding edge Kodi with latest Mesa on Ubuntu
View Bleeding-edge-kodi-mesa-setup.sh
#!/bin/bash
# Script to set up bleeding edge Kodi with bleeding edge VAAPI/Mesa drivers on Ubuntu. Tested on 16.10 with Kodi
# First complete step 0 of Fritsch's guide here: http://forum.kodi.tv/showthread.php?tid=231955
# This guide takes over on step 1
# based on https://forum.kodi.tv/showthread.php?tid=231955&pid=2543877#pid2543877
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
@AGresvig
AGresvig / Fixing-nokogiri-in-El-capitan.md
Last active May 22, 2016
How to fix "nokogiri" gem releated dependency issues in OSX (El Capitan)
View Fixing-nokogiri-in-El-capitan.md

I tried setting up a nice Jekyll-based site (or theme, rather) Indigo on my up-to-date Mac today, and ran into a host of issues. I spent quite some time resolving it all, to the extent I thought this would be valuable for others to get recapped.

My experience setting up "Indigo" Jekyll theme

First, I clone repo. Install Jekyll, NodeJS and Bundler. Do bundle install, and get hit in the face:

An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.

Scroll the logs and see:

libxml2 is missing. Please locate mkmf.log to investigate how it is failing.

View funcTests.log
[11:03:01] Requiring external module babel-core/register
[11:03:02] Using gulpfile ~/Workspace/Plyo/_platform/web/gulpfile.babel.js
[11:03:02] Starting 'selenium'...
[11:03:04] Finished 'selenium' after 1.94 s
[11:03:04] Starting 'serve-functional'...
[11:03:04] spawn wdio with these attributes:
/Users/aksel/Workspace/Plyo/_platform/web/wdio.conf.js
=======================================================================================
@AGresvig
AGresvig / node-rpi-setup-old.sh
Last active Dec 2, 2015
Script to set up NodeJS on RPi
View node-rpi-setup-old.sh
#!/bin/bash
# Script to set up NodeJS on RPi
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Time this script
View setup-zsh.sh
#!/bin/bash
# FIRST
# Install oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh)
# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# Set up Zsh config
sed -i '/ZSH_THEME="robbyrussell"/c\ZSH_THEME="af-magic"' .zshrc
sed -i '/plugins=(git)/c\plugins=(git debian dircycle tmux autojump command-not-found)' .zshrc
echo "export EDITOR='vim'" >> .zshrc
@AGresvig
AGresvig / raspberry-setup.sh
Last active Aug 29, 2015
Script to set up a brand new Debian install (or Raspbian) with some good software and sane defaults
View raspberry-setup.sh
#!/bin/bash
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Update the system
apt-get update
@AGresvig
AGresvig / scroll.easing.js
Last active Aug 29, 2015 — forked from dezinezync/scroll.easing.js
NPM compat version
View scroll.easing.js
var scroller = module.exports = {
scrollTo(Y, duration, easingFunction, callback) {
var start = Date.now(),
elem = document.documentElement.scrollTop?document.documentElement:document.body,
from = elem.scrollTop;
if(from === Y) {
callback();
return; /* Prevent scrolling to the Y point if already there */
@AGresvig
AGresvig / scroller.js
Last active Aug 29, 2015 — forked from Eyal-Shalev/scroller.js
Forked for Node compatibility
View scroller.js
'use strict';
/*
* Based on work done by Nikhil Nigade (@dezinezync) https://gist.github.com/dezinezync/5487119
*/
var DEFAULT_ELEMENT = document.documentElement.scrollTop ? document.documentElement : document.body;
var REQUEST_ANIMATION_FRAME = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.oRequestAnimationFrame;
View ReactTouchMixin.md

Handling both touch and click events in JS has always been a pain, thanks to the way these events interact. Importantly, since there are now many devices where users can both touch AND click, we can't simply switch all events over to touch events if we detect a touch. Here is the sequence these events fire:

touchstart
touchmove
touchend
-- 300ms delay --
mousedown
mousemove
mouseup