Skip to content

Instantly share code, notes, and snippets.

@anilex
anilex / gist:d8a304ff77bc382ed3fc918f049d84f8
Created November 27, 2016 20:28 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@anilex
anilex / .htaccess
Created November 6, 2016 19:04
Built-in filename-based cache busting. Will route requests for /css/all.20110203.css to /css/all.css
# ----------------------------------------------------------------------
# Built-in filename-based cache busting
# ----------------------------------------------------------------------
# If you're not using the build script to manage your filename version revving,
# you might want to consider enabling this, which will route requests for
# /css/all.20110203.css to /res/all.css
# To understand why this is important and a better idea than all.css?v1231,
# read: github.com/paulirish/html5-boilerplate/wiki/Version-Control-with-Cachebusting
@anilex
anilex / mysql_restart.sh
Created November 1, 2016 16:44
Restart your MySQL installed under macOS
#!/bin/bash
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
@anilex
anilex / unserialize-issues.php
Created October 29, 2016 18:05
Fox for PHP Notice: unserialize(): Error at offset 32738 of 32768 bytes in
//to safely serialize
$safe_string_to_store = base64_encode(serialize($multidimensional_array));
//to unserialize...
$array_restored_from_db = unserialize(base64_decode($encoded_serialized_string));
@anilex
anilex / nginx-static-files-cache-reinvalidate.conf
Created October 22, 2016 17:08
Cache invalidation for static files without the need of GET params to be added to the file.
location ~* ^/static/(\w+)/([^/]+)_\d+\.(js|css|png|jpg|jpeg|gif|ico)$ {
alias /srv/www/static/$1/$2.$3;
add_header Vary Accept-Encoding;
expires max;
}
ctrl + alt + shift + t = refactor this
alt + enter = allerlei shortcuts
ctrl + alt + l = reformat code
shift + f11 = show bookmarks
f11 = insert bookmark
alt + insert = file new
ctrl + n = navigate class
ctrl + shift + n = navigate file
ctrl + shift + f = find in path
ctrl + alt + shift + insert = commit file (eigen shortcut)
@anilex
anilex / font-system.css
Last active August 17, 2016 11:44
Using system fonts in Bootstrap 4 (beta)
body {
font-family: system, -apple-system, BlinkMacSystemFont,
"Helvetica Neue", "Lucida Grande";
font-family: -apple-system, BlinkMacSystemFont,
"Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell",
"Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
/* https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/#details-of-approach-a */
@anilex
anilex / cookie statement.txt
Created August 13, 2016 09:58
Cookie statement about the law ....
/*
From Marty Walker Pastie
Picturefill markup with ProcessWire image sizing
https://github.com/scottjehl/picturefill/
http://processwire.com/
*/
<div data-picture data-alt='{$page->title}'>
<div data-src='{$image->size(50,0)->url}'></div>
@anilex
anilex / load-css.js
Created March 22, 2016 13:07
add this at the bottom of the page
// add this at the bottom of the page
var cb = function() {
var l = document.createElement('link'); l.rel = 'stylesheet';
l.href = 'small.css';
var h = document.getElementsByTagName('head')[0]; h.parentNode.insertBefore(l, h);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(cb);
else window.addEventListener('load', cb);