Skip to content

Instantly share code, notes, and snippets.

View zerolab's full-sized avatar
🖖
Live long and prosper

Dan Braghiș zerolab

🖖
Live long and prosper
View GitHub Profile
@zerolab
zerolab / qs.js
Created September 18, 2014 09:16
Parse query string
function parseQueryString(queryString) {
var params = {}, queries, temp, i, l;
// Split into key/value pairs
queries = queryString.split("&");
// Convert the array of strings into an object
for ( i = 0, l = queries.length; i < l; i++ ) {
temp = queries[i].split('=');
params[temp[0]] = temp[1];
@zerolab
zerolab / gist:f8eee46db9f1ff7019d7
Created November 4, 2014 15:26
Apache www to non-www redirect
<IfModule mod_rewrite.c>
RewriteEngine On
# redirect to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>
@zerolab
zerolab / robots.txt
Created November 13, 2014 16:44
Isaac Asimov would be proud
Disallow: /humans/harm
Disallow: /orders/ignore_human
Disallow: /admin/self_harm
<?php
/**
* Implements hook_entity_view_alter()
*
* Task: change child field_collection view mode depending on parent
* field_block_layout value
*
* Solution: Screw that. Instead change the image style for
* field_collection_imagecaption in the field_collection_content_block
@zerolab
zerolab / tunnel.sh
Created December 29, 2014 00:09
ssh proxy tunnel script
#!/bin/bash
# http://richardkmiller.com/925/script-to-enabledisable-socks-proxy-on-mac-os-x
disable_proxy()
{
networksetup -setsocksfirewallproxystate Wi-Fi off
networksetup -setsocksfirewallproxystate Ethernet off
echo "SOCKS proxy disabled."
}
@zerolab
zerolab / SublimeLinter.sublime-settings
Last active August 29, 2015 14:14
SublimeLinter config
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"pep8": {
@zerolab
zerolab / event_swap.js
Last active August 29, 2015 14:14
DOM events listing and hotswapping
(function ($) {
$(document).bind('MY_EVENT', function() {
console.log('Original event');
// STRING FROM EVENT FUNCTION
});
// List all events and bound functions
$.each($._data(document, 'events'), function(i, e) {
console.log(i, e);
});
@zerolab
zerolab / gist:f2b0480efd67f5896f22
Created March 18, 2015 16:25
iframe autoresize
<script>
// Parent
function onMessage (event) {
if (event.source != document.getElementById('iframe').contentWindow) return;
eval('var message = ' + event.data);
resizeIframe(message.height);
}
if (typeof(window.attachEvent) != "undefined") {
window.attachEvent('onmessage', onMessage);
} else if (typeof(window.addEventListener) != "undefined") {
From 30a31eae993d24aa5e4887e6ae8a0dab026f5c5d Mon Sep 17 00:00:00 2001
From: Dan Braghis <zerolab@354424.no-reply.drupal.org>
Date: Mon, 20 Apr 2015 09:14:37 +0100
Subject: [PATCH] Fix content access issues on first login
---
shib_auth.module | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/shib_auth.module b/shib_auth.module
@zerolab
zerolab / gist:2127f3179e5f6469932d
Last active August 29, 2015 14:22
gnuplot recipe to plot uwsgi's load time logs as a histogram
scp user@server:/var/log/uwsgi/site.log .
gnuplot
gnuplot> bin(x) = 5*(floor(x/5)+0.5)
gnuplot> set boxwidth 5
gnuplot> plot "site.log" using (bin($33)):(1.0) smooth freq with boxes