Skip to content

Instantly share code, notes, and snippets.

@davidrenne
davidrenne / gist:c55a3de5c5014b239095
Last active August 29, 2015 14:21
startapp extras
PROJECT_NAME=XXXXXXXXXXXXXX
APP_NAME=api
BASE_DIR=$PROJECT_NAME/apps/$APP_NAME
mkdir -p $BASE_DIR
django-admin.py startapp $APP_NAME $BASE_DIR
mkdir -p $BASE_DIR/static/$APP_NAME/{css,js,img}
echo '' > $BASE_DIR/static/$APP_NAME/css/.gitkeep
echo '' > $BASE_DIR/static/$APP_NAME/js/.gitkeep
echo '' > $BASE_DIR/static/$APP_NAME/img/.gitkeep
<span class="fa-stack fa-lg danger">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-times fa-stack-1x fa-inverse"></i>
</span>
@davidrenne
davidrenne / gist:9471ba9b7a1f52e5199a
Created May 26, 2015 14:32
Be safe out there kids...
def tester(insert=False, value={}):
if insert:
value['insert'] = True
print(value)
tester(insert=False)
tester(insert=True)
tester(insert=False)
@davidrenne
davidrenne / Dumper.py
Last active August 29, 2015 14:24 — forked from passos/Dumper.py
"""
A perl Data.Dumper clone for Python
Author: simon@log4think.com
2011-07-08
"""
#!/bin/env python
import sys
from types import *
@davidrenne
davidrenne / gist:c427cee31a4665089e7d
Last active August 29, 2015 14:28
MAGIC CSS CROP
#sectionFeatures p img, #sectionDining p img {
width: 100%;
background-position: center;
background-size: cover;
}
#sectionDining p {
width: 306px;
height: 219px;
@davidrenne
davidrenne / Show Process List HTML
Created October 24, 2011 22:00
Show Process List HTML because pressing UP + ENTER in shell is annoying
<?php
$conn = mysql_connect('yourserver','yourusername','yourpassword');
echo "<html><head><META HTTP-EQUIV='Refresh' CONTENT='2; URL=".$_SERVER['PHP_SELF']."'><body>";
echo "<table><th>ID</th><th>DATABASE</th><th>QUERY</th><th>EXECUTION TIME</th><th>STATE</th>";
$res = mysql_query("show processlist");
while($row = mysql_fetch_assoc($res))
{
if (stristr($row['State'],"Has sent all binlog to slave"))
{
continue;
@davidrenne
davidrenne / gist:1330885
Created November 1, 2011 15:48
The most amazing mysql flags ever - multiple queries in one mysql_query
<?php
define('CLIENT_LONG_PASSWORD',1); /* new more secure passwords */
define('CLIENT_FOUND_ROWS',2); /* Found instead of affected rows */
define('CLIENT_LONG_FLAG',4); /* Get all column flags */
define('CLIENT_CONNECT_WITH_DB',8); /* One can specify db on connect */
define('CLIENT_NO_SCHEMA',16); /* Don't allow database.table.column */
define('CLIENT_COMPRESS',32); /* Can use compression protocol */
define('CLIENT_ODBC',64); /* Odbc client */
define('CLIENT_LOCAL_FILES',128); /* Can use LOAD DATA LOCAL */
define('CLIENT_IGNORE_SPACE',256); /* Ignore spaces before '(' */
@davidrenne
davidrenne / gist:1351309
Created November 9, 2011 12:34
Dumb script that will download a repository to your server
<?php
if (array_key_exists('user',$_REQUEST))
{
if (!is_dir($_REQUEST['repo']))
{
system("mkdir {$_REQUEST['repo']} && cd {$_REQUEST['repo']} && git init && git pull git://github.com/{$_REQUEST['user']}/{$_REQUEST['repo']}.git master");
}
else
{
@davidrenne
davidrenne / gist:1479507
Created December 15, 2011 02:07
Seriously Is It this much code to support case insensitive post/get keys? There has got to be a better way...
<?php
$caseInsensitivePosts = array('your_desired_cleaned_lower_case_post_var');
foreach($_GET as $k=>$v)
{
$lower = strtolower($k);
foreach ($caseInsensitivePosts as $requestVal)
{
if ($requestVal == $lower && $k !== $requestVal)
{
@davidrenne
davidrenne / gist:1903668
Created February 24, 2012 20:51
Nice utility to scan real-time all your php fatals and parse errors in production
Edit cron tab to point to this file and run php script every one minute:
*/1 * * * * php /yourpath/phpFatals.php web01
*/1 * * * * php /yourpath/phpFatals.php cron01
*/1 * * * * php /yourpath/phpFatals.php etcetc
Edit the below variables: