This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<!-- Base DOM markup and code logic here: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Closures --> | |
<p id="help">Helpful notes will appear here</p> | |
<p>E-mail: <input type="text" id="email" name="email"></p> | |
<p>Name: <input type="text" id="name" name="name"></p> | |
<p>Age: <input type="text" id="age" name="age"></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAPWIDGET = MAPWIDGET || {}; | |
// Constructor function for TripAdvisor's TypeAhead behavior. | |
MAPWIDGET.Autocomplete = function(domElement) { | |
// TypeAhead Source URL per documentation of TripAdvisor. | |
// See http://api.tripadvisor.com/api/partner/2.0/doc?key=TA_KEY. | |
// %QUERY is a wildcard needed by the suggestion engine. | |
var typeAheadUrl = TripAdvisor_API_BASE_URL + '/typeahead/%QUERY?key=' + tripAdvisorKey; | |
// Create a new suggestion engine dedicated for the specified category. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements COMMANDFILE_drush_command(). | |
*/ | |
function toolkit_drush_command() { | |
$items = array(); | |
// Command for Clear Cache All. | |
// The 'cca' array key is what you type in the terminal, like: drush cca. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get the node id from the current page's URL. | |
$nid = arg(1); | |
// Create a new EFQ object. | |
$query = new EntityFieldQuery(); | |
// Select the node entity with the target node id. | |
$query->entityCondition('entity_type', 'node'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hypothetical class for saving the Universe. | |
class Particle: | |
def __init__(self, name): | |
self.name = name | |
print self.name, 'created' | |
def __del__(self): | |
print self.name, 'deleted' | |
# Create new particle objects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$(function() { | |
// Artist's select option values will depend on | |
// the Genre's selected option. | |
var $genreSelectWidget = $('#id_genre'); | |
var $artistSelectWidget = $('#id_artist'); | |
var artistSelectWidgetInitial = $artistSelectWidget.val() | |
// Adjust Artists based on the selected Genre. | |
function adjustArtistOptions(preSelectedOption) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Workflow (Genre is the Parent Field, Artist is the Dependent Field): | |
// 1. user interacts w/ Genre select list widget via JS script. | |
// 2. JS script fetches the new Artist list in views.py | |
// 3. JSON response will be used as the new values/options for the Artist select list widget. | |
(function($) { | |
$(function() { | |
// Artist's select option values will depend on | |
// the Genre's selected option. | |
var $genreSelectWidget = $('#id_genre'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# Restricted symbols taken from https://en.wikipedia.org/wiki/Filename | |
symbols = ('/', '\\', '?', '%', '*', ':', '|', '"', '<', '>',) | |
symbols_replacements = {symbol: '_' for symbol in symbols} | |
space_replacement = {' ': '-'} # Dash instead of underscore | |
replacements = {} | |
replacements.update(symbols_replacements) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forms.py | |
class EventSessionFormSet(); | |
... | |
def save(self, commit=True): | |
sessions = [] | |
forms = self.forms | |
total_forms = len(forms) | |
for i, form in enumerate(forms): |
OlderNewer