Skip to content

Instantly share code, notes, and snippets.

View eristoddle's full-sized avatar

Stephan Miller eristoddle

View GitHub Profile
@eristoddle
eristoddle / tune.sql
Created March 26, 2014 18:45
Oracle tune queries
DECLARE
l_sql VARCHAR2(2000) := '';
l_sql_tune_task_id VARCHAR2(400) ;
recommendations VARCHAR2(2000) ;
RetVal CLOB;
MAXBUFSIZE NUMBER := 32767;
BEGIN
dbms_output.enable(1000000) ;
l_sql_tune_task_id := dbms_sqltune.create_tuning_task(
sql_text => l_sql,
@eristoddle
eristoddle / drupal7_sql.sql
Created March 30, 2014 20:02
Drupal 7 comment related queries
/* Delete all unapproved comments */
delete from comment where status = 0;
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@eristoddle
eristoddle / fix_udev.sh
Created July 10, 2014 02:30
Fix for node-webkit on Ubuntu 14.04 error while loading shared libraries: libudev.so.0
sudo ln -sf /lib/x86_64-linux-gnu/libudev.so.1 /lib/x86_64-linux-gnu/libudev.so.0
@eristoddle
eristoddle / watch
Created August 8, 2014 16:11 — forked from exogen/watch
#!/bin/bash
#
# Author: Brian Beck <exogen@gmail.com>
# Usage: watch PATH COMMAND...
#
# This script watches PATH and runs COMMAND whenever PATH or a descendent
# of PATH is modified. COMMAND is everything after the first argument.
#
# If PATH is "-", then the list of paths comes from standard input.
#
/*
Loads http://github.com/geuis/helium-css for testing without modifying the source pages
Crunched by http://ted.mielczarek.org/code/mozilla/bookmarklet.html to:
javascript:(function(){(function(msg,target){var loader=function(){if(arguments.callee._executed)return;arguments.callee._executed=true;if(typeof target==="function"){target();}else{jQuery.getScript(target);}var el=document.createElement('div');el.style.position='absolute';el.style.height='30px';el.style.width='200px';el.style.margin='0 auto 0 auto';el.style.top='0';el.style.left='40%';el.style.padding='5px 10px';el.style.backgroundColor='#F00';el.style.fontWeight="bold";el.style.textAlign="center";el.innerHTML=msg;document.body.appendChild(el);window.setTimeout(function(){jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});},2500);};if(typeof jQuery!=='undefined'){loader();}else{var s=document.createElement('script');s.type="text/javascript";s.setAttribute('src',document.location.protocol+'//ajax.googleapis.com/ajax/libs
@eristoddle
eristoddle / scaled-centered-image.scss
Created October 3, 2014 15:00
To scale and center an image based on wrapper size
.field-items {
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 60%;
height: 60%;
.field-item {
@eristoddle
eristoddle / Application.php
Created March 13, 2015 16:39
Multiple database connections in Phalcon PHP Framework
<?php
//...
foreach ($config->databases as $db => $cred) {
$this->di->set($db, function () use ($cred) {
$adaptor = "\\Phalcon\\Db\\Adapter\\Pdo\\{$cred->adapter}";
return new $adaptor([
'host' => $cred->host,
'username' => $cred->username,
'password' => $cred->password,
'dbname' => $cred->dbname
@eristoddle
eristoddle / Application.php
Created March 13, 2015 16:45
Phalcon PHP Framework environment switching
<?php
//...
protected function _setEnvironment($config)
{
$env = new \stdClass();
if (array_key_exists('ENV', $_SERVER) && isset($_SERVER['ENV'])) {
$env->name = $_SERVER['ENV'];
} else {
$env->host = $_SERVER['HTTP_HOST'];
foreach ($config['domains'] as $k => $v) {
@eristoddle
eristoddle / pre-render.js
Last active August 29, 2015 14:20 — forked from mef/pre-render.js
// pre-render d3 charts at server side
var d3 = require('d3')
, jsdom = require('jsdom')
, fs = require('fs')
, htmlStub = '<html><head></head><body><div id="dataviz-container"></div><script src="js/d3.v3.min.js"></script></body></html>'
jsdom.env({
features : { QuerySelector : true }
, html : htmlStub
, done : function(errors, window) {