Skip to content

Instantly share code, notes, and snippets.

View boxxxie's full-sized avatar
👙
disrupting absurdism

Paul Iannazzo boxxxie

👙
disrupting absurdism
View GitHub Profile
@boxxxie
boxxxie / gist:3170431
Created July 24, 2012 14:54
issue with bootstrap tabs having a delayed render
render:function(){
#('selector').html(my_tab_html);
_.defer(
function(){
view.$('.nav-tabs a'+selected_tab).tab('show');
view.delegateEvents(); //this smoothed out the user experience (somehow)
//need to do things related to tabs here, not right after being rendered to page ....
});
@boxxxie
boxxxie / gist:3162829
Created July 23, 2012 09:41
couchdb $.couch.db.save Error
[debug] [<0.1228.0>] 'PUT' /categorization/9aef603131112c1f3aba4efb090031cb {1,
1} from "127.0.0.1"
Headers: [{'Accept',"application/json, text/javascript, */*; q=0.01"},
{'Accept-Charset',"ISO-8859-1,utf-8;q=0.7,*;q=0.3"},
{'Accept-Encoding',"gzip,deflate,sdch"},
{'Accept-Language',"en-GB,en-US;q=0.8,en;q=0.6"},
{'Connection',"keep-alive"},
{'Content-Length',"417"},
{'Content-Type',"application/json"},
{'Host',"127.0.0.1:5984"},
#!/bin/bash
base_dir=$(dirname "$0")
echo basedir "$base_dir"
script=$(readlink -f "$0")
echo script "$script"
# Absolute path this script is in, thus /home/user/bin
script_path=$(dirname $script)
echo sript path" $script_path"
script_parent_path="$script_path"/..
@boxxxie
boxxxie / underscore.set.js
Created July 13, 2012 04:24
I love immutability
//requires underscore.js & JSON.js
/*
* This is a functional implementation of a SET
* adding and removing from sets do not overwrite previous values of the set
*/
function Set(initial_items){
if(initial_items && !_.isObject(initial_items)){
throw "the set must be given a list of initial items, or empty arguments"
}
function initialize_items(initial_items){
@boxxxie
boxxxie / gist:3060878
Created July 6, 2012 15:26
default build-couchdb config 1.2
{
"httpd_design_handlers": {
"_info": "{couch_httpd_db, handle_design_info_req}",
"_list": "{couch_httpd_show, handle_view_list_req}",
"_rewrite": "{couch_httpd_rewrite, handle_rewrite_req}",
"_show": "{couch_httpd_show, handle_doc_show_req}",
"_update": "{couch_httpd_show, handle_doc_update_req}",
"_view": "{couch_httpd_view, handle_view_req}"
},
"uuids": {
@boxxxie
boxxxie / gist:2984830
Created June 24, 2012 20:43
example of using csv show on couchdb
_export_csv:function(convert_to_array,file_name){
var export_db = 'export_requests_rt7';
var router = this;
var handler = {
success:function(resp){
var href = window.location.origin + '/'+ export_db +'/_design/app/_show/csv/' + resp.id;
window.location.href = href;
},
error:function(){
alert('there was an error exporting your data');
@boxxxie
boxxxie / template.js
Created April 25, 2012 21:08
extracted template engine from underscore
var _ = {};
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_.templateSettings = {
evaluate: /<%([\s\S]+?)%>/g,
interpolate: /<%=([\s\S]+?)%>/g,
escape: /<%-([\s\S]+?)%>/g
};
// When customizing `templateSettings`, if you don't want to define an
_.mixin({
toNumber:function(obj){
if(_.isNumber(obj)){
return obj
}
else if(_.isString(obj)){
return parseFloat(obj)
}
else{
return obj
@boxxxie
boxxxie / gist:2408730
Created April 17, 2012 20:16
backbone event driven example
var inventory_table_view =
Backbone.View.extend(
{
render:function(data){
var view = this,
template = view.options.template,
el = view.$el,
html = ich[template](data);
el.html(html)
}
@boxxxie
boxxxie / gist:2407693
Created April 17, 2012 17:37
futon's uploadAttachment function
//requires jquery.form.js
//<script src="/_utils/script/jquery.form.js"></script>
/*
<form action="" method="post" id="upload-form">
<h2>Upload Attachment</h2>
<fieldset>
<p class="help">
Please select the file you want to upload as an attachment to this
document. Please note that this will result in the immediate creation of
a new revision of the document, so it's not necessary to save the