Skip to content

Instantly share code, notes, and snippets.

@graste
graste / php_datetime.md
Created February 2, 2015 10:21
PHP DateTime and DateTimeImmutable

From PHP 5.5 onwards there's DateTimeImmutable which implements the same DateTimeInterface as DateTime and thus should be interchangeable in implementations. The DateTimeImmutable returns new instances with the requested changes when calling modifying functions like modify.

now with microseconds precision instead of seconds

When creating a DateTime instance for the current moment in time (e.g. with the string now) the precision is seconds. Unix timestamp might help. Another option to create a valid NOW value is:

$dti = DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', microtime(true)));
(function(window){
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,
_eventStack,
_findByName,
stackEvent,
removeEvent,
eventListener,
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
/// Since the current way to qualify a class from within its ruleset is quite
/// ugly, here is a mixin providing a friendly API to do so.
/// @author Hugo Giraudel
/// @param {String} $element-selector - Element selector
@mixin qualify($element-selector) {
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
// @crazyrohila
// Global colors.
$colors: (
dark-gray: rgb(153, 153, 153),
hulk: rgb(119, 167, 109),
// intl/spoofchecker/spoofchecker.c
void spoofchecker_register_constants(INIT_FUNC_ARGS)
{
#define SPOOFCHECKER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long(Spoofchecker_ce_ptr, ZEND_STRS( #x ) - 1, USPOOF_##x);
SPOOFCHECKER_EXPOSE_CLASS_CONST(ASCII)
SPOOFCHECKER_EXPOSE_CLASS_CONST(SINGLE_SCRIPT_RESTRICTIVE)
SPOOFCHECKER_EXPOSE_CLASS_CONST(HIGHLY_RESTRICTIVE)
SPOOFCHECKER_EXPOSE_CLASS_CONST(MODERATELY_RESTRICTIVE)
A comparison of Collection+JSON, HAL, JSON-LD and SIREN media types.
Discussion at
http://sookocheff.com/posts/2014-03-11-on-choosing-a-hypermedia-format/
.listing--events {
display: flex;
}
.event {
box-sizing: border-box;
padding: 1.25rem; /* 20px padding */
margin: 0 0 1.25rem 0; /* 20px bottom margin */
flex: 0 0 100%;
}

Collection+JSON application/vnd.collection+json

{ "collection" :
  {
    "version" : "1.0",
    "href" : "http://example.org/friends/",
    
    "links" : [
 {"rel" : "feed", "href" : "http://example.org/friends/rss"}
@graste
graste / dot-cat.sh
Last active August 29, 2015 14:20 — forked from abelsonlive/dot-cat.sh
#!/bin/sh
curl http://cat.www.$1.com.meowbify.com/ > index.html
s3cmd put index.html s3://$1.cat/
@graste
graste / bling.js
Last active August 29, 2015 14:23 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn)
}
NodeList.prototype.__proto__ = Array.prototype