Skip to content

Instantly share code, notes, and snippets.

View tjoskar's full-sized avatar

Oskar Karlsson tjoskar

View GitHub Profile
import time, os
size = 25
b = [[0 for x in xrange(size)] for x in xrange(size)]
a = [[0 for x in xrange(size)] for x in xrange(size)]
b[10][10] = 1
b[11][11] = 1
<!DOCTYPE html>
<html>
<head>
<title>Snake</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="snake.js"></script>
<style type="text/css">
.snake_piece {
position:fixed;
left:50%;
@tjoskar
tjoskar / vt-offline.htm
Created April 12, 2015 07:06
Demonstrate bad internet connection
<!DOCTYPE html>
<html>
<head>
<title>VT</title>
<style>
* {
margin: 0;
padding: 0;
}
html, body, #view {
@tjoskar
tjoskar / start.py
Created April 26, 2015 08:43
Unrar
import subprocess
import sys
download_base_path = sys.argv[1]
final_destination = sys.argv[2]
"""
Start unrar script in a new process.
This will cause an exit code of 0, even if unrar.py hangs.
"""
@tjoskar
tjoskar / install-all-components.js
Created June 18, 2015 13:52
run "npm install" in all folders under a certain folder
var fs = require('fs');
var path = require('path');
var childProcess = require('child_process');
var dir = './components';
var nodeComand = 'npm install';
var packageFile = 'package.json';
var nodeVersion = process.versions.node.split('.');
if (!(nodeVersion[0] >= 0 && nodeVersion[1] >= 12 && nodeVersion[2] >= 4)) {
@tjoskar
tjoskar / copy.js
Created June 22, 2015 20:42
Copy files recursive and replace strings
var fs = require('fs');
var path = require('path');
function copyRecursive(src, dest) {
var copyPromises = [];
var copy = function copy(src, dest) {
var exists = fs.existsSync(src);
var stats = exists && fs.statSync(src);
@tjoskar
tjoskar / register.js
Created July 31, 2015 07:19
Register Hapi routers
var path = require('path');
var routePrefix = '_router';
var exports = module.exports;
/**
* Register all sections routes
* @param {exports.Server} server
*/
exports.registerRouts = function(server: hapiServer) {
var sections = ['movies', 'auth', 'series'];
@tjoskar
tjoskar / mock-knex.js
Created August 12, 2015 19:39
Mocking knex with mock-knex
'use strict';
var mockKnex = require('mock-knex');
var knex = require('knex')({
client: 'mysql',
connection: {
host: 'localhost',
user: 'user',
password: 'password',
database: 'database',
@tjoskar
tjoskar / ApiController.cs
Last active October 21, 2015 16:09
PainlessHttp bug #1
namespace Demo.Controllers
{
public static class HttpSingleton
{
private static PainlessHttp.Client.HttpClient instance;
public static PainlessHttp.Client.HttpClient Instance
{
get
@tjoskar
tjoskar / angular2-vs-react.js
Last active January 31, 2016 14:00
Angular 2 vs react
const angular = 1 * '🍎';
const react = 1 * '🍐';
angular > react // false
angular < react // false
angular === react // false