Skip to content

Instantly share code, notes, and snippets.

View NathanQ's full-sized avatar

Nathan Victor NathanQ

View GitHub Profile
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@paulsmith
paulsmith / verbatim_templatetag.py
Created October 25, 2011 19:03 — forked from ericflo/verbatim_templatetag.py
verbatim Django template tag
"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.
Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@IlianIliev
IlianIliev / fabfile.py
Created May 28, 2012 11:04
Fabric script that eases the creation of new Django Project
"""
This fabric script automates the creation of a virtual environment and a Django
project. The result will be virtual environtment with the name of the project.
The folder namer where the project code will be placed is specified in
SOURCE_DIRECTORY_NAME, a static root folder will be created and settings.py
will be updated.
"""
try:
from fabric.api import env, run, local
from fabric.context_managers import lcd, prefix
"""
Converts source video files in `sources` to mp4, ogv, and webm 640x360.
Edit `sources` (list of filenames) and adjust `source_dir`, `output_dir`,
and `new_path` as needed.
Reference: http://paulrouget.com/e/converttohtml5video/
"""
import os
import subprocess
@elidickinson
elidickinson / max_width_email.html
Created May 6, 2013 15:10
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
@ivanoats
ivanoats / slang.md
Last active February 23, 2021 00:58
slang for various symbols
!  = bang
.  = dot
$  = bling
{} = mustaches
[] = brackets
() = parens
^  = caret
&  = and
*  = asterik
@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet
@NathanQ
NathanQ / mySQL
Last active January 3, 2016 12:49
Reference for mySQL root user pw reset, backup of server database, get and use the database on mac.
The root password is gone. Shut off mySQL, restart, and set new password:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
mysql
>>>> UPDATE mysql.user SET Password=PASSWORD('new easy and memorable pw') WHERE User='root';
Create new one if needed:
mysql -u projectuser -p
mysql
>>>> create database projectdb;
@JedWatson
JedWatson / createItems.md
Last active September 17, 2019 02:41
Examples of how to use Keystone's createItems functionality

Populating Data in KeystoneJS

Keystone's createItems function is a simple but powerful way to populate your database with data.

It can be used to create test fixtures or initialise your database with default content / users / etc.

There's also a shorthand syntax that can be used within update files; if you are using the auto updates feature, any file that exports a create object will automatically be wrapped and the data will be created.

createItems takes two passes at the data it is passed, first creating the items and retaining references by key (if provided) that can be used to populate relationships in the second pass. This makes it easy to create related data without asynchronous nesting (which for data creation sometimes ends up in knots).