Skip to content

Instantly share code, notes, and snippets.

View catrielmuller's full-sized avatar

Catriel Müller catrielmuller

View GitHub Profile
@catrielmuller
catrielmuller / diff_dates_array.php
Created March 14, 2019 10:45
Get an Array of dates between 2 dates, one element per day
<?php
function diffDatesArray($from, $to, $formatInput, $formatOutput) {
$out = [];
$fromDate = DateTime::createFromFormat($formatInput, $from);
$toDate = DateTime::createFromFormat($formatInput, $to);
$interval = date_diff($fromDate, $toDate);
$daysInterval = intval($interval->format('%d'));
for ($i = 0; $i <= $daysInterval; $i++) {
$nextDay = clone $fromDate;
if($i >= 1){
@catrielmuller
catrielmuller / app.json
Created September 8, 2016 14:27
PM2 Sails
{
"apps" : [{
"name": "sails",
"script": "app.js",
"watch": true,
"ignoreWatch" : [".tmp",".idea","views","node_modules"],
"node_args": ["--debug=5860"]
}]
}
function is_border(posx, posy, relieve){
var current = relieve[posy][posx];
var maxx = relieve[0].length;
var maxy = relieve.length;
/* TODO: I dont know but */
if(current == 9){
return 0;
}
/* TODO: I dont know but */
relieve = [[9, 2, 2, 2, 3, 5],
[9, 8, 3, 2, 4, 5],
[9, 7, 2, 2, 4, 3],
[9, 9, 2, 4, 4, 3],
[9, 2, 3, 4, 3, 5]];
function is_border(posx, posy, relieve){
var current = relieve[posy][posx];
var maxx = relieve[0].length;
var maxy = relieve.length;
@catrielmuller
catrielmuller / controllers.js
Created November 13, 2015 23:59
AngularJs Token Auth Demo - Metro 2015 Prog4
.controller('EntrarCtrl', function($rootScope, $scope, $stateParams, $http, $ionicPopup, $location ) {
$rootScope.userToken = '';
$scope.user={};
$scope.user.email='';
$scope.user.password ='';
$scope.doLogin = function() {
$http.post('http://api-prog4.herokuapp.com/login',$scope.user).then(function(resp) {
console.log(resp.data);
@catrielmuller
catrielmuller / gist:bfd0edc29b6b1b1f64bb
Created July 6, 2015 19:27
hook_webform_select_options_info
/**
* Private implementation of hook_webform_select_options_info().
*
* @see webform_webform_select_options_info()
*/
function general_webform_select_options_info()
{
$items = array();
$items['people'] = array(