Skip to content

Instantly share code, notes, and snippets.

View superhero's full-sized avatar
💭
oɹǝɥɹǝdns

Erik Landvall superhero

💭
oɹǝɥɹǝdns
View GitHub Profile
@superhero
superhero / shift.log.js
Last active August 29, 2015 13:57
Shift.Log
Shift.Log = function()
{
this.router =
{
'error.*': 'error'
};
this.view =
{
error: function(e)
@superhero
superhero / docker.nodejs
Created September 18, 2015 08:35
NodeJS docker file
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN ln -snf /usr/share/zoneinfo/Europe/Madrid /etc/localtime && echo "Europe/Madrid" > /etc/timezone
RUN apt-get -y update && apt-get -y install \
build-essential git python
RUN git clone git://github.com/nodejs/node.git /tmp/nodejs \
@superhero
superhero / docker.phanomjs
Created September 18, 2015 08:38
PhantomJS docker file
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN ln -snf /usr/share/zoneinfo/Europe/Madrid /etc/localtime && echo "Europe/Madrid" > /etc/timezone
RUN apt-get -y update && apt-get -y install \
build-essential g++ flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev \
libfreetype6 libssl-dev libpng-dev libjpeg-dev python libx11-dev libxext-dev git
@superhero
superhero / shift.event-attacher.js
Last active December 20, 2015 01:59
This is a module for the shift framework that allows interaction between the view layer of the DOM to trigger events in the framework.jQuery dependent..
Shift.EventAttacher = function(sl)
{
this.router =
{
'shift.ready' : 'attachEvents',
'attach-events': 'attachEvents'
};
this.view =
{
<!DOCTYPE html>
<html dir="ltr" lang="sv-SE">
<head>
<title>Flipper</title>
<meta charset="utf-8">
<style>
.thumb
{
@superhero
superhero / action-by-bit.php
Last active January 29, 2016 09:45
Do an action by bit
<?php
function actionByBit($actions, $dec, $bits)
{
for($i = 0, $count = count($actions); $bits > 0; $i++)
if($dec & 1 << --$bits && $i < $count)
$actions[$i]();
}
$hex = '70 0C 00 00';
@superhero
superhero / auto-expand-textarea.js
Last active March 2, 2016 14:56
Expands the textarea depending on content
(function($)
{
$(document).on('input', 'textarea', function()
{
var $this = $(this);
var padTop = parseInt($this.css('padding-top'), 10);
var padBot = parseInt($this.css('padding-bottom'), 10);
$this.height(0);
var scroll = $this.prop('scrollHeight');
$this.height(scroll - padTop - padBot);
@superhero
superhero / math.random.seed.js
Created November 25, 2016 10:49
A seeded random generator
(seed) =>
{
const n = Math.sin(seed);
return n - Math.floor(n);
};
@superhero
superhero / npm-publish.sh
Created December 22, 2016 16:25
run in root folder of multiple npm packages to publish them all with 1 command
#!/bin/bash
docker run \
-it \
--rm \
--volume /etc/localtime:/etc/localtime:ro \
--volume `pwd`/.npmrc:/root/.npmrc \ # notice the login credentials that needs to be mounted
--volume `pwd`:/app \
--workdir /app \
node /bin/bash -c "
@superhero
superhero / git-commit-push.sh
Created December 22, 2016 16:28
run in root of multiple projects to commit and push them all at once
#!/bin/bash
# note that all commits will have the same commit message
if [ $# -eq 1 ]; then
MSG=$1
else
read -p "commit message: " MSG
fi
for d in */ ; do