Skip to content

Instantly share code, notes, and snippets.

Vegard Hanssen flogvit

View GitHub Profile
@flogvit
flogvit / slowmove.pl
Created Dec 3, 2016
Slow copy files to let Google Drive keep up
View slowmove.pl
#!/usr/bin/perl
#
# Created by Vegard Hanssen <Vegard.Hanssen@menneske.no>
# 2016-12-03
#
# The script will move the files recursive from one directory to another
# For each $sleepcount it will sleep for $sleepmin min so google drive
# can finish the syncjob
use File::Copy::Recursive qw(fmove);
@flogvit
flogvit / paramparser.js
Last active Aug 29, 2015
Little regexp magic to parse params
View paramparser.js
var text = 'Little brown="and yellow" fox=1 jumps over=lazy dog';
var res = text.match(/([^=\s]+="[^"]+")|\S+/g).map(function (p) {
return p.match(/^([^=\s]*)(?:="?([^"]*)"?)?$/).splice(1, 2);
})
console.log(res);
// Output
@flogvit
flogvit / sort.js
Created Jun 18, 2015
Speed test of sort variants in Node
View sort.js
var _ = require('underscore');
var async = require('async');
var sumTime = {};
var sortarray = [];
var ARRAYCOUNT = 100000;
var INNERITERATIONS = 10;
var OUTERITERATIONS = 5;
View Easter.java
/**
* Small class for getting Easter Sunday at a specific year
*/
public class Easter {
public static Calendar get(int year) {
int y = year;
int a = y % 19;
int b = y / 100;
int c = y % 100;
@flogvit
flogvit / vietnamese_snake.pl
Last active Aug 29, 2015
Perl solution to the Vietnamese pesky snake
View vietnamese_snake.pl
#!/usr/bin/perl
#
# Solution to the Vietnamese pesky snake in perl :)
# Calculates all 128 solutions
# http://www.theguardian.com/science/alexs-adventures-in-numberland/2015/may/21/how-to-solve-the-maths-puzzle-for-vietnamese-eight-year-olds-that-stumped-parents-and-teachers
#
# function: a+(13*b/c) + d + (12*e) - f - 11 + (g*h/i)-10;
# Setup the numbers to insert
@a = qw(1 2 3 4 5 6 7 8 9);
You can’t perform that action at this time.