Skip to content

Instantly share code, notes, and snippets.

@chrillo
chrillo / star.js
Created November 23, 2011 14:07
Draw a star in html canvas
/*
takes the x,y coordinates, the number of spikes, the inner and the outer radius of the spikes
*/
function drawStar(ctx,cx,cy,spikes,r0,r1){
var rot=Math.PI/2*3,x=cx,y=cy,step=Math.PI/spikes
ctx.strokeSyle="#000";
ctx.beginPath();
@chrillo
chrillo / recentposts.php
Created November 29, 2011 08:08
Get recent posts from Wordpress
// include in functions.php
function get_recent_posts($num=3){
$postsQuery = new WP_Query();
$args=array(
'showposts='=> $num,
'orderby'=>'posted',
'post_type'=>'post',
//'taxonomy'=>'category', uncomment to filter posts within a category
// 'term'=>'news', e.g.: news - could be anything
);
@chrillo
chrillo / mobilehtaccess
Created November 29, 2011 08:11
htaccess redirect all mobile traffic to specific landing page
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/landingpage/.$
RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\ wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r\ |s\ )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1\ u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(\ i|ip)|hs\-c|ht(c(\-|\ |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(\ |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|
@chrillo
chrillo / highResCanvas.js
Created December 6, 2011 09:17
Creates a dpi agnostic html canvas for high res images for mobile phones like iphone 4 retina display
/*
This method creates a html canvas and automatically scales it fit the mobile devices display dpi. You can code everything for 320 px and it still looks pixel perfect on high res displays like iPhone 4 or newer Android devices.
iPhone 3Gs has 320 x 480 devicePixelRatio = 1, Android phone has 480 x 800 devicePixelRatio=1.5, iPhone 4 has 480 x 960 devicePixelRatio = 2
code like this creates a circle of the same size on all devices without pixeling
*/
@chrillo
chrillo / soapheaders.js
Created April 15, 2012 13:19
SoapHeaders
Client.prototype.addSoapHeader=function(ns,tag,value){
if(!this.soapHeaders){
this.soapHeaders=[];
}
this.soapHeaders.push({ns:ns,tag:tag,value:value});
}
Client.prototype._getHeaders=function(){
if(!this.soapHeaders){
return;
}
@chrillo
chrillo / soapheaders.js
Created April 15, 2012 13:19
SoapHeaders
Client.prototype.addSoapHeader=function(ns,tag,value){
if(!this.soapHeaders){
this.soapHeaders=[];
}
this.soapHeaders.push({ns:ns,tag:tag,value:value});
}
Client.prototype._getHeaders=function(){
if(!this.soapHeaders){
return;
}
@chrillo
chrillo / vimeoPlayer.js
Created September 21, 2014 22:12
Vimeo Fullscreen Player
// This is here so we cann talk to the Vimeo Player Api,
// taken from here https://github.com/vimeo/player-api/tree/master/javascript
var Froogaloop=function(){function e(a){return new e.fn.init(a)}function h(a,c,b){if(!b.contentWindow.postMessage)return!1;var f=b.getAttribute("src").split("?")[0],a=JSON.stringify({method:a,value:c});"//"===f.substr(0,2)&&(f=window.location.protocol+f);b.contentWindow.postMessage(a,f)}function j(a){var c,b;try{c=JSON.parse(a.data),b=c.event||c.method}catch(f){}"ready"==b&&!i&&(i=!0);if(a.origin!=k)return!1;var a=c.value,e=c.data,g=""===g?null:c.player_id;c=g?d[g][b]:d[b];b=[];if(!c)return!1;void 0!==
a&&b.push(a);e&&b.push(e);g&&b.push(g);return 0<b.length?c.apply(null,b):c.call()}function l(a,c,b){b?(d[b]||(d[b]={}),d[b][a]=c):d[a]=c}var d={},i=!1,k="";e.fn=e.prototype={element:null,init:function(a){"string"===typeof a&&(a=document.getElementById(a));this.element=a;a=this.element.getAttribute("src");"//"===a.substr(0,2)&&(a=window.location.protocol+a);for(var a=a.split("/")
/**
* AWS Module: Action: Modularized Code
*/
var config = require('../../../config')
var Auth = require('../../../lib/auth')
var Toggl = require('../../../lib/toggl')
var TogglSync = require('../../../lib/togglSync')
var toggl = new Toggl(config.toggl)
var togglSync = new TogglSync({toggl: toggl})
'use strict'
var express = require('express')
class TogglController {
constructor(options){
this.toggl = options.toggl
this.togglSync = options.togglSync
this.auth = options.auth
{
"access_token":"MYAPIACCESSTOKEN"
}