Skip to content

Instantly share code, notes, and snippets.

View johanbove's full-sized avatar
💭
Semper meliorem facio

Johan Bové johanbove

💭
Semper meliorem facio
View GitHub Profile
@johanbove
johanbove / .bash_colours
Last active May 2, 2023 08:21
TaskWarrior aliases and other stuff
# Inspired by Paul Fenwick (https://gist.github.com/pjf)
# See https://gist.github.com/pjf/051aa4ef326d493beec950823f7edfd8#file-bashrc
# Reset
Color_Off='\[\e[0m\]' # Text Reset
# Regular Colors
Black='\[\e[0;30m\]' # Black
Red='\[\e[0;31m\]' # Red
Green='\[\e[0;32m\]' # Green
Yellow='\[\e[0;33m\]' # Yellow
@johanbove
johanbove / swagger_JSONAPI_definitions.yaml
Last active December 3, 2018 09:23
JSONAPI Swagger definitions
definitions:
JSONAPI_BasicDoc:
title: JSONAPI_BasicDoc
type: object
description: |
A basic JSON API document.
The document MUST contain at least one of the following top-level members: `data`, `errors`, `meta`.
The members `data` and `errors` MUST NOT coexist in the same document.
The `Self Link` will open a view displaying all existing orders.
properties:
@johanbove
johanbove / localstorage_count.html
Last active September 27, 2016 12:18
localstorage counter
<!-- https://html.spec.whatwg.org/multipage/webstorage.html -->
<p style="font-size:0.7em;margin:5%">
You have viewed this page
<span id="count">an untold number of</span>
time(s).
</p>
<script>
if (!localStorage.pageLoadCount)
localStorage.pageLoadCount = 0;
@johanbove
johanbove / weather.php
Last active June 21, 2016 14:29
Get Weather through Aeris API in PHP
<?php
// http://www.aerisweather.com/support/docs/api/reference/endpoints/observations/
// fetch Aeris API output as a string and decode into an object
$CLIENT_ID = "";
$CLIENT_SECRET = "";
$location = "duesseldorf,germany";
$response = file_get_contents("http://api.aerisapi.com/observations/". $location ."?client_id=" . $CLIENT_ID . "&client_secret=" . $CLIENT_SECRET);
$json = json_decode($response);
if ($json->success == true) {
// create reference to our returned observation object
@johanbove
johanbove / git-php-webhook.php
Created December 15, 2015 13:59 — forked from marcelosomers/git-php-webhook.php
A basic webhook for deploying updates to repos on Github to your local server
<?php
/**
* This script is for easily deploying updates to Github repos to your local server. It will automatically git clone or
* git pull in your repo directory every time an update is pushed to your $BRANCH (configured below).
*
* Read more about how to use this script at http://behindcompanies.com/2014/01/a-simple-script-for-deploying-code-with-githubs-webhooks/
*
* INSTRUCTIONS:
* 1. Edit the variables below
* 2. Upload this script to your server somewhere it can be publicly accessed
@johanbove
johanbove / sinwave.js
Last active November 9, 2015 13:47
Sin Wave
// http://krazydad.com/tutorials/makecolors.php
// Sinwave
var frequency = 1;
for (var i = 0; i < 32; ++i) {
console.log(Math.sin(frequency * i));
}
// Rainbow colors
var frequency = .3;
@johanbove
johanbove / rounding.js
Created October 23, 2015 12:47
Rounding numbers
// Copied from http://stackoverflow.com/questions/10535817/javascript-round-up-and-down-to-the-nearest-5-then-find-a-common-denominator
// Rounding to nearest common denominator
x = 73;
x_rounded = 15 * Math.round( x / 15);
console.assert(x_rounded === 75, "Expecting x_rounded to be 75");
function sigfig(n, sf) {
sf = sf - Math.floor(Math.log(n) / Math.LN10) - 1;
@johanbove
johanbove / addMinutes.js
Last active October 21, 2015 10:54
Add minutes to a date stamp
/**
* @param {object} data
* @param {number} minutes
* @returns {object} date
*/
var addMinutes = function (date, minutes) {
return new Date(date.getTime() + minutes * 60000);
}
var now = new Date();
@johanbove
johanbove / getSecondsForTheDay.js
Created October 14, 2015 07:52
Get seconds for the current time for the current day
/**
* @function getSecondsForTheDay
* @param {Object} thetime
* @returns {Int} seconds
*/
getSecondsForTheDay = function (theTime) {
return theTime.getSeconds() + (60 * theTime.getMinutes()) + (60 * 60 * theTime.getHours());
};
var theTime = new Date(2015, 9, 14, 10, 0, 0);
@johanbove
johanbove / minutesBetweenEndStart.js
Created October 8, 2015 07:45
Minutes between end and start
var start = new Date(new Date().setMinutes(45));
var end = new Date(new Date().setMinutes(15));
minutesBetweenEndStart = Math.abs(end.getTime() - start.getTime()) / 1000 / 60;
console.assert(minutesBetweenEndStart === 30, "minutesBetweenEndStart should be 30");