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">
ssdfsdf
{this.props.title}
@AGresvig
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 += '<\\/';
i++;
@AGresvig
AGresvig / ReactTouchMixin.md
Last active August 29, 2015 14:11
Description of Touch mixin for React. Fetched from: http://www.snip2code.com/Snippet/187682/React-js-Touch-Mixin

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
@AGresvig
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) 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;
@AGresvig
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 = 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 / raspberry-setup.sh
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
#!/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
#!/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 / node-rpi-setup-old.sh
Last active December 2, 2015 13:31
Script to set up NodeJS on RPi
#!/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
[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 / Fixing-nokogiri-in-El-capitan.md
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 (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.