Skip to content

Instantly share code, notes, and snippets.

Avatar

Aksel G. Gresvig AGresvig

View GitHub Profile
View post.jsx
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 Nov 13, 2014
Javascript <-> UTF-8 conversion tool
View JStoUTF8Converter.js
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++;
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
@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;
@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 / 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
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 / 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 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 / 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.