Skip to content

Instantly share code, notes, and snippets.

View nicksen's full-sized avatar
🦅

Nicklas Moberg nicksen

🦅
View GitHub Profile
@nicksen
nicksen / readme.md
Created March 10, 2022 18:35 — forked from hansonkd/readme.md
Redis vs HTTP benchmark

Redis vs HTTP Benchmarks

See the original blog post

Results:

Name                           ips        average  deviation         median         99th %
redix_pool                   70.44       14.20 ms    ±36.07%       13.30 ms       50.60 ms
run_redix_pipeline 30.56 32.73 ms ±65.74% 47.26 ms 91.99 ms

Keybase proof

I hereby claim:

  • I am nicksen on github.
  • I am nicksen (https://keybase.io/nicksen) on keybase.
  • I have a public key ASDQ4sBMkgGNq3Zdqd7MDzq2qYaNcx6tTUnrV5fwm3sQBAo

To claim this, I am signing this object:

// iFrameBuster™
if (top.location !== self.location) {
top.location = self.location.href;
}
@nicksen
nicksen / Pagination.php
Created December 4, 2013 14:45
Laravel Pagination for REST JSON
<?php
use \Illuminate\Pagination\Paginator as Orig;
use \Illuminate\Support\Contracts\JsonableInterface;
class Paginator extends Orig implements JsonableInterface
{
public function toJson($options = 0)
{
$json = array(
@nicksen
nicksen / selection.less
Created November 22, 2013 14:40
Selection mixin
.selection(@color, @img-color) {
background-color: @color;
img& {
background-color: @img-color;
}
}
@nicksen
nicksen / cache.php
Created November 21, 2013 13:50
PHP Cache control
<?php
//get the last-modified-date of this very file
$lastModified = filemtime(__FILE__);
//get a unique hash of this file (etag)
$etagFile = md5_file(__FILE__);
//get the HTTP_IF_MODIFIED_SINCE header if set
$ifModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
@nicksen
nicksen / scrollbar.less
Created November 15, 2013 18:43
Always show scrollbar (webkit)
::-webkit-scrollbar {
width: 7px;
-webkit-appearance: none;
}
::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: rgba(0, 0, 0, .5);
-webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
}
@nicksen
nicksen / index.html
Last active December 28, 2015 08:09
Jade version of html5bp's index.html
//if lt IE 7
<html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="sv" xmlns:fb="http://ogp.me/ns/fb#">
//if IE 7
<html class="no-js lt-ie9 lt-ie8 ie7" lang="sv" xmlns:fb="http://ogp.me/ns/fb#">
//if IE 8
<html class="no-js lt-ie9 ie8" lang="sv" xmlns:fb="http://ogp.me/ns/fb#">
//[if gt IE8|!(IE)]><!
html.no-js(lang="sv", xmlns:fb="http://ogp.me/ns/fb#")
//<![endif]
uniqueId = (length=8) ->
id = ""
id += Math.random().toString(36).substr(2) while id.length < length
id.substr 0, length
uniqueId() # => n5yjla3b
uniqueId(2) # => 0d
uniqueId(20) # => ox9eo7rt3ej0pb9kqlke
uniqueId(40) # => xu2vo4xjn4g0t3xr74zmndshrqlivn291d584alj
@nicksen
nicksen / mixOf.coffee
Last active December 28, 2015 08:09
You have a few utility methods that you want to include in a number of different classes. http://coffeescriptcookbook.com/chapters/classes_and_objects/mixins
mixOf = (base, mixins...) ->
class Mixed extends base
for mixin in mixins by -1 #earlier mixins override later ones
for name, method of mixin::
Mixed::[name] = method
Mixed