Skip to content

Instantly share code, notes, and snippets.

Avatar

John Slegers jslegers

View GitHub Profile
@jslegers
jslegers / dynamics.odata.services.php
Last active Apr 16, 2020
A pretty basic but effective class that can be used to do CRUD operations on Microsoft Dynamics NAV's Odata service for the customer entity
View dynamics.odata.services.php
<?php
// A pretty basic but effective class that can be used for doing CRUD operations on Microsoft Dynamics NAV's Odata services
error_reporting(E_ALL);
ini_set("display_errors", 1);
class http_request {
protected $_handle = NULL;
@jslegers
jslegers / index.html
Last active Jan 16, 2020
Simple 2 player version of the "connect four" game. All code is MIT licenced.
View index.html
<body>
<span id="a">red</span>
<span id="b">yellow</span>
<span id="n">Are you sure you want to start a new game?</span>
<span id="w">The %s player won.
Do you want to play a new game?</span>
<div id="game">It's the <span id="c"></span>&nbsp;player's move.
<table id="gameboard">
<tr>
<td id="c-1-1"></td>
@jslegers
jslegers / gist:6562976
Created Sep 14, 2013
Hiding mobile specific content on IE6-8
View gist:6562976
/* Add the desktop-hidden class to any HTML tag that contains mobile specific content */
.desktop-hidden {
*display:none !important; /* IE6-7 */
}
@media \0 screen {
.desktop-hidden {
display:none !important; /* IE8 only */
View eat-sleep-code-repeat.js
(function repeat() {
eat();
sleep();
code();
repeat();
})();
View _generated-placeholders.scss
// This code will only work if you use Sass 3.3 (or higher)
// Configuration :
// -----------------------------------------
$screensizes : (
'default' : 0 infinity,
'mobile' : 0 767px,
'phone' : 0 480px,
'tablet' : 481px 767px,
@jslegers
jslegers / _clearfix.scss
Last active Oct 30, 2018
Clearfix code without duplication
View _clearfix.scss
%display-block-hacked {
display: block;
*zoom: 1;
}
%clear-both {
clear : both;
}
%blank-as-table {
@jslegers
jslegers / parsequery.js
Last active Apr 10, 2018
How to parse a query string
View parsequery.js
function parseQuery(str) {
var qso = {};
var qs = (str || document.location.search);
// Check for an empty querystring
if (qs == "") {
return qso;
}
// Normalize the querystring
qs = qs.replace(/(^\?)/, '').replace(/;/g, '&');
while (qs.indexOf("&&") != -1) {
@jslegers
jslegers / style.scss
Created Jul 26, 2013
A CodePen by Hugo Giraudel. Sass mixin for scrollbar styling - Because I can't ever remember the right syntax for scrollbars styling in WebKit, here is a little Sass mixin to do it for you.
View style.scss
@import "compass";
/**
* Mixin scrollbar
*/
@mixin scrollbar($size, $primary, $secondary: lighten($primary, 25%)) {
::-webkit-scrollbar {
width: $size;
height: $size;
}
View helper.string.js
var helper = {};
helper.string = {
contains : function (haystack, needle) {
return !!~haystack.indexOf(needle);
},
...
};
View contains.php
function contains($haystack, $needle, $caseSensitive = false) {
return $caseSensitive?
(strpos($haystack, $needle) === FALSE ? FALSE : TRUE):
(stripos($haystack, $needle) === FALSE ? FALSE : TRUE);
}
var_dump(contains('bare','are')); // Outputs : bool(true)
var_dump(contains('stare', 'are')); // Outputs : bool(true)
var_dump(contains('stare', 'Are')); // Outputs : bool(true)
var_dump(contains('stare', 'Are', true)); // Outputs : bool(false)
You can’t perform that action at this time.