View settings.json
{ | |
"window.zoomLevel": -1, | |
"terminal.integrated.fontFamily": "MesloLGS NF", | |
"terminal.integrated.cursorBlinking": true, | |
"terminal.integrated.cursorStyle": "line", | |
"editor.fontFamily": "Monaco, Menlo, 'Courier New', monospace", | |
"code-runner.fileDirectoryAsCwd": true, | |
"terminal.integrated.cwd": ".", | |
"terminal.integrated.shell.osx": "/usr/local/bin/zsh", | |
"atomKeymap.promptV3Features": true, |
View karabiner.json
{ | |
"global": { | |
"check_for_updates_on_startup": true, | |
"show_in_menu_bar": true, | |
"show_profile_name_in_menu_bar": false | |
}, | |
"profiles": [ | |
{ | |
"complex_modifications": { | |
"parameters": { |
View django-formset--custom-kwarg--formset-save--model-save.py
# forms.py | |
class EventSessionFormSet(); | |
... | |
def save(self, commit=True): | |
sessions = [] | |
forms = self.forms | |
total_forms = len(forms) | |
for i, form in enumerate(forms): |
View multiple_replace.py
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) |
View django-dependent-field.js
// 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'); |
View dependent-field.js
(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) { |
View issues_with_deleting_objects.py
# 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. |
View drupal_image_with_caption_block.php
<?php | |
// HOW TO USE: | |
// Create a MY_MODULE.info file. See https://www.drupal.org/node/542202. | |
// Create a MY_MODULE.module file. | |
// Put the codes below in MY_MODULE.module file | |
// THE BIG PICTURE: | |
// For a block to work in Drupal, you have to do a minimum of 3 things: | |
// 1. Declare the block in hook_block_info(). |
View drupal_get_node_type.php
<?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'); |
View toolkit.drush.inc.php
<?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. |
NewerOlder