Skip to content

Instantly share code, notes, and snippets.

import std.typecons;
import std.traits;
import std.typetuple;
import std.stdio : writeln;
struct Maybe(T) {
T value = void;
bool b = true;
@property static Maybe None() {
@dhrrgn
dhrrgn / RedisSession.php
Last active February 15, 2022 19:54
PHP 5.4 Redis Session Handler
<?php
use Predis\Client;
class RedisSession implements SessionHandlerInterface {
private $redis;
private $keyPrefix;
private $maxLifetime;
/**
@cou929
cou929 / detect-private-browsing.js
Last active May 1, 2024 21:07
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@betweenbrain
betweenbrain / gist:7798873
Created December 5, 2013 01:47
Disable VT-X in Vagrantfile
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
end
@starlightsys
starlightsys / load-utf8-html-into-dom.php
Last active December 30, 2015 06:29
How to load a UTF-8 HTML document into the PHP DOM.
<?
$dom = new DOMDocument('1.0', 'utf-8');
@$dom->loadHTML( mb_convert_encoding($htmldoc, 'HTML-ENTITIES', 'UTF-8') );
$x = new DOMXPath($dom);
@obscurerichard
obscurerichard / README.md
Created September 17, 2012 22:35
Simulates a low bandwidth, high-latency network connection

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency
slow dsl -b 1mbps         # Simulate DSL with a slower speed than the default

slow modem-56k -d eth0 # Simulate a 56k modem on the eth1 device. eth0 is unchanged.

@npryce
npryce / wip.py
Created May 28, 2011 20:17
Decorator to mark tests as work in progress for Python's Nose testing framework
from functools import wraps
from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
def fail(message):
raise AssertionError(message)
def wip(f):
@wraps(f)
@xantus
xantus / growl-libnotify-wrapper.pl
Created February 8, 2010 20:59
A simple wrapper for libnotify that takes growlnotify params
#!/usr/bin/env perl
use strict;
use warnings;
# TBD: locate these using env?
# mac
my $growl = '/usr/bin/growlnotify';
@endolith
endolith / Has weird right-to-left characters.txt
Last active October 26, 2024 13:55
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶