Skip to content

Instantly share code, notes, and snippets.

View spoeken's full-sized avatar

Mathias Madsen Stav spoeken

View GitHub Profile
[
{
"action": "talk",
"text": "Simon, Simon, Simon, Simon, Simon, Simon. What have you done. You are getting seriously old. Almost as old as you jokes. Ha ha ha ha. Pause for dramatic effect. Life is great. Don’t you think? Happy birthday, we all love you just the way you are. End of message."
}
]
@spoeken
spoeken / isPhone.js
Created December 21, 2016 13:51
Is this a phone number?
const isNumeric = num => {
return !isNaN(num)
}
const isPhone = function(number){
if(number.length >= 8 && isNumeric(number) ){
return true
}
@spoeken
spoeken / gist:7338502
Last active December 27, 2015 14:09
Angular AngularFire Obj to Array so that one can filter them objects Thank you https://github.com/finalclass // https://github.com/angular/angular.js/issues/1286#issuecomment-22193332
// To Array Filter
// https://github.com/angular/angular.js/issues/1286#issuecomment-22193332
$scope.toArray = function () {
return function (obj) {
if (!(obj instanceof Object)) {
return obj;
}
return Object.keys(obj).map(function (key) {
@spoeken
spoeken / post-receive
Created October 31, 2013 13:47
Git post-receive hook for deploying with --bare repo
#!/bin/bash
## Remember to change /var/www/ to the right dir and chmod +x post-receive
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
GIT_WORK_TREE=/var/www/ git checkout -f
fi
done
@spoeken
spoeken / .htaccess
Last active December 26, 2015 21:29
Angular.js .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Remember to define subdir or remove it
RewriteRule ^((?:[a-z0-9-_]+/){0,7})([a-z0-9-_]+)$ /subdir/#/$2/ [NE,R,L]
</IfModule>
@spoeken
spoeken / Accurate Human Logical Time Difference Javascript Function
Last active June 17, 2023 12:55
A time difference function in javascript, logical to humans. Outputs the difference of two dates in years, months, days, hours, minutes and seconds.
// Time difference function
function timeDiff(start, end) {
//today, now!
//Get the diff
var diff = end - start;
//Create numbers for dividing to get hour, minute and second diff
var units = [
1000 * 60 * 60 *24,
1000 * 60 * 60,
1000 * 60,