Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jk3us's full-sized avatar

Jay Knight jk3us

View GitHub Profile
@jk3us
jk3us / .bash_profile
Last active May 19, 2017 19:23
My psql/tmux configuration
case "$TERM" in
screen*)
alias psql='PAGER=vim_psql_pager psql'
esac
@jk3us
jk3us / facets.sql
Created January 4, 2017 21:57
Facets from SQL
-- This will return your results as json, and the first row will be a json object containing counts for field
-- values that can be used to build a faceted search/filter UI.
with t as (
select * my_table where filter_field='value' -- this is your base query, everything else is based on it
),
field_counts as ( -- this gives you distinct values for your chosen fields from the result set from "t". Add more unions for more faceted fields
select json_agg(fc) from (
select json_build_object(field, json_agg(json_build_object(val, num))) fc
from (
/* Inspired by http://cpratt.co/twitter-bootstrap-callout-css-styles/ */
.bs-callout {
padding: 20px;
margin: 20px 0;
border: 1px solid #eee;
border-left-width: 5px;
border-radius: 3px;
}
http://snapshot.debian.org/archive/debian/20140101T042327Z/pool/main/l/linux-2.6/linux-image-2.6.32-5-amd64_2.6.32-48squeeze4_amd64.deb
@jk3us
jk3us / goodplaceholder.js
Created December 12, 2011 18:43
jquery placeholder plugin
(function($) { jQuery.fn.placeholder = function() {
var i = document.createElement('input'); if ('placeholder' in i) return;
$(this).filter('textarea').each(function(){
var placeholder = $(this).attr('placeholder');
$(this).html(placeholder);
$(this).css({color:'#999999'});
$(this).bind('focus', function(){
if($(this).html()==placeholder) {
@jk3us
jk3us / gist:1328964
Created October 31, 2011 21:09
Save images from data: url in an html submission
function save_images($object_id, $string) {
// This part could probably be better
$types = array(
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif',
);
$DOM = new DOMDocument;
$DOM->loadHTML($string);
// Find all the img tags
/*
Function: Set default values of input elements. Get the default value from associated label having class="default-value"
Author: Lasse Bunk (lassebunk@gmail.com - http://lassebunk.dk) with additions by Jay Knight (http://jk3.us/)
Demo: http://lassebunk.dk/demos/default-values/
Version: 1.0.1
License: Use as you wish :-)
*/
Event.observe(window,"load", function(event) {
$$("label.default-value").each(function(label) {
(function() {
//
// start of core hash functions
//
function b64_md5(p) {
return binl2b64(core_md5(str2binl(p),p.length*8));
}
function binl2b64(binarray) {
/*
* emptyText extension for Scriptaculous's Ajax.InPlaceEditor.
*
* based on http://codetocustomer.com/blog/2008/06/empty-text-for-ajaxinplaceeditor
* with some fixes suggested in the comments and some of mine.
*
*/
Ajax.InPlaceEditorWithEmptyText = Class.create(Ajax.InPlaceEditor, {
// ==UserScript==
// @name phpMyAdmin: Bigger SQL box
// @namespace http://jk3.us/gmns
// @description Enlarge SQL Boxes in phpMyAdmin
// @include http://svn2.cure4kids.net/padmin/*
// @include https://svn2.cure4kids.net/padmin/*
// @include https://www.cure4kids.org/padmin/*
// @exclude */querywindow.php*
// ==/UserScript==