Skip to content

Instantly share code, notes, and snippets.

@davidrenne
davidrenne / gist:9646574
Created March 19, 2014 17:18
Greatest Headache Preventer ONLOAD
if (window.location.hostname == 'localhost') {
$('[id]').each(function(){
var ids = $('[id="'+this.id+'"]');
if(ids.length>1 && ids[0]==this)
alert('Dev Err: Multiple IDs #'+this.id);
});
}
@davidrenne
davidrenne / gist:1cc1b8db2ad0388c47b5
Created December 29, 2014 19:05
Python log Django Queries
from django.db import connection
for query in connection.queries :
print "\033[1;31m[%s]\033[0m \033[1m%s\033[0m" % (query['time'],
" ".join(query['sql'].split()))
@davidrenne
davidrenne / gist:db6896137a31791b3df6
Created February 2, 2015 23:57
Excel formula for wget grep image source
IF column A is an ID, and column C is a URL. Request the URL and get the single image on the page. Then create a new CSV off of this with the source of the image
=CONCATENATE("random_shit=`tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1`;wget -O /tmp/html$random_shit ",C2655,"; grep '<img' /tmp/html$random_shit | grep -v 'beach-logo' | grep -oP 'src=""([^""]*)' | cut -b 6- > /tmp/html_$random_shit; value=`cat /tmp/html_$random_shit`; echo """,A2655,",$value"" >> /tmp/all; rm /tmp/html_$random_shit; rm /tmp/html$random_shit;")
#-*-coding:utf-8-*-
# This script requires an existing SQLite DB for output from Facebook Graph API, it should be stored in the same folder of this script if you do not specify the path to DB
"""
Facebook Graph API Explorer (http://developers.facebook.com/tools/explorer)
GO HERE FOR DEFINITIONS OF VARIABLES RETURNED BY API:
https://developers.facebook.com/docs/reference/api/post/
JSON Viewer (http://jsonviewer.stack.hu/)
@davidrenne
davidrenne / gist:6f04054aeadffea496ee
Last active August 29, 2015 14:16
Git Branch Management for multiple repositories in a project
#Repeat these scripts if you want to do branch management across similar repos in the same project obviously change your path /usr/local/repository & /usr/local/repository2 and copy more as needed
alias switch_branch='echo -n "Git branch name?>" && read response && cd /usr/local/repository && git fetch origin && git checkout $response && cd /usr/local/repository2 && git fetch origin && git checkout $response'
alias create_branch='echo -n "Git branch name?>" && read response && cd /usr/local/repository/ && git branch $response && git push origin $response && git checkout $response && cd /usr/local/repository2/ && git branch $response && git push origin $response && git checkout $response'
alias delete_branch='echo -n "Git branch name?>" && read response && cd /usr/local/repository/ && git checkout $response && git checkout master && git branch -d $response && git push origin :$response && cd /usr/local/repository2/ && git checkout $response && git checkout master && git branch -d $response && git push origi
@davidrenne
davidrenne / gist:a84937a091c7cf3084a7
Created March 18, 2015 20:27
Setup mandrillapp on ubuntu with postfix
sudo apt-get install mailutils
sudo apt-get install libsasl2-modules
sudo echo "[smtp.mandrillapp.com] YOURUSER:YOURPASSWORD" > /etc/postfix/sasl_passwd
sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo vim /etc/postfix/main.cf
delete relay host line
// Detect CSS mask support and hack it into Modernizr
if ( document.body.style[ '-webkit-mask-box-image' ] !== undefined ) {
Modernizr.cssmasks = true;
$('html').addClass('cssmasks');
} else {
Modernizr.cssmasks = false;
$('html').addClass('no-cssmasks');
}

Share this. If I had the below HTML in my DOM:

<a class="st_sharethis_custom button share-track tiny radius secondary share player-share">Share</a>

and it already gets bound, I cannot easily dynamically set the st_url unless I completely delete this from the DOM. So the below code is the only way I could figure out how to dynamically change URLs in the same button. I tried to unset st_processed. And also had issues using jquery's prop function. It seems somehow you guys will only pick up when the function attr() is called.

This is very frustrating of a work around to try to dynamically create a button! Please make developer experience better by producing some kind of article to swap out url's on the fly.

(function(artoo) {
// Artoo Spider for http://www.immobiliare.it/info/ufficio-stampa
var scrape = {
iterator: '#wrapTestoStatiche',
data: {
'id': function() {
var id = artoo.$(this).find('.text-align_left a:last-child').attr('href');
if (id) {
id = id.match(/ImmoNews\-(\d+)\.pdf$/);
mount c c:\ -t cdrom
c:\