Skip to content

Instantly share code, notes, and snippets.

View AGresvig's full-sized avatar

Aksel G. Gresvig AGresvig

View GitHub Profile
var React = require('react');
module.exports = React.createClass({
render: function() {
return (
<div className="post">
<h2 className="postName">
AGresvig / JStoUTF8Converter.js
Created November 13, 2014 11:39
Javascript <-> UTF-8 conversion tool
var JStoUTF8Converter = {
encode: function(input) {
var output = '';
for (var i = 0; i < input.length; i++) {
var j = '\b\t\n\v\f\r"\'\\'.indexOf(input.charAt(i));
if (j != -1) {
output += '\\' + 'btnvfr"\'\\'.substr(j, 1);
} else if (input.substr(i, 2) == '</') {
output += '<\\/';
AGresvig /
Last active August 29, 2015 14:11
Description of Touch mixin for React. Fetched from:

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:

-- 300ms delay --
AGresvig / scroller.js
Last active August 29, 2015 14:14 — forked from Eyal-Shalev/scroller.js
Forked for Node compatibility
'use strict';
* Based on work done by Nikhil Nigade (@dezinezync)
var DEFAULT_ELEMENT = document.documentElement.scrollTop ? document.documentElement : document.body;
var REQUEST_ANIMATION_FRAME = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.oRequestAnimationFrame;
AGresvig / scroll.easing.js
Last active August 29, 2015 14:14 — forked from dezinezync/scroll.easing.js
NPM compat version
var scroller = module.exports = {
scrollTo(Y, duration, easingFunction, callback) {
var start =,
elem = document.documentElement.scrollTop?document.documentElement:document.body,
from = elem.scrollTop;
if(from === Y) {
return; /* Prevent scrolling to the Y point if already there */
AGresvig /
Last active August 29, 2015 14:26
Script to set up a brand new Debian install (or Raspbian) with some good software and sane defaults
# 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
# Update the system
apt-get update
# Install oh-my-zsh (
# sh -c "$(curl -fsSL"
# 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
[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:
AGresvig /
Last active December 2, 2015 13:31
Script to set up NodeJS on RPi
# 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
# Time this script
AGresvig /
Last active May 22, 2016 20:38
How to fix "nokogiri" gem releated dependency issues in OSX (El Capitan)

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 (, and Bundler cannot continue.

Scroll the logs and see:

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