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
from django import forms | |
class BootstrapCharField(forms.CharField): | |
def __init__(self, *args, **kwargs): | |
# Grab the placeholder from the kwargs if it exists | |
placeholder = kwargs.pop('placeholder') if 'placeholder' in kwargs else u'' | |
# Build all the defaults | |
super(BootstrapCharField, self).__init__(*args, **kwargs) |
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
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
""" An efficient and simple ANSI colours module (and also a powerfull script), with functions to print text using colours. | |
About the convention for the names of the colours : | |
* for the eight colours black, red, green, yellow, blue, magenta, cyan, white: | |
* the name in minuscule is for colour **with bold** (example 'yellow'), | |
* the name starting with 'B' is for colour **without bold** (example 'Byellow'), | |
* the name starting with a capital letter is for the background colour (example 'Yellow').* for the special effects (blink, italic, bold, underline, negative), **not always supported** : |
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
#!/bin/bash | |
############################################################################## | |
# BASH BASICS | |
############################################################################## | |
env # displays all environment variables | |
echo $SHELL # displays the shell you're using | |
echo $BASH_VERSION # displays bash version |
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
set user to "USERNAME" | |
set pass to "PASSWORD" | |
--set token automatically based on macaddress | |
set macAddHash to do shell script "/sbin/ifconfig en0 | /usr/bin/awk '/ether / {print $2}' | /usr/bin/tr -d ':' | md5 " | |
try | |
set vpn_ip to do shell script "ifconfig tun0 | grep inet | awk '{print $2}'" | |
--hack: must delete property before writing it but first run 'defaults delete' fails |
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
Basics | |
====== | |
Expansion (special symbols replaced by values) and word splitting (arguments being split into several aruments) must have attemtion paid or pain will follow. | |
- # for comments | |
- Lots of internal variables available to bash scripts, see: http://tldp.org/LDP/abs/html/internalvariables.html#ARGLIST | |
- Name of script will be $0 | |
- Parameters passed to script will be in $1, $2, $3.... vars and count in $# |
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
wget https://storage.googleapis.com/golang/go1.10.1.linux-armv6l.tar.gz | |
sudo tar -C /usr/local -xvf go1.10.1.linux-armv6l.tar.gz | |
cat >> ~/.bashrc << 'EOF' | |
export GOPATH=$HOME/go | |
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin | |
EOF | |
source ~/.bashrc |
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
const countryCodes = { | |
US: 'United States', | |
CA: 'Canada', | |
NG: 'Nigeria', | |
GB: 'United Kingdom', | |
}; | |
const sales = [ | |
{ code: 'US', count: 233 }, |
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
/** | |
* Primary application logic for our Functional Programming blog example | |
* See related blog series at: http://www.datchley.name/tag/functional-programming/ | |
* Version: 2.0 | |
*/ | |
// A simple, resuable comparison for '>=' | |
function greaterThanOrEqual(a, b) { | |
return a >= b | |
} |
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
# Prevent from using the custom alias on 3rd party scripts. Must be at the top of the file | |
[ -z "$PS1" ] && return | |
# alias | |
alias blog='cd ~/projects/blog' | |
alias blog-posts='cd ~/projects/blog/content/blog' | |
alias .zshrc='nvim ~/.zshrc' | |
alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
alias wifi='nmcli device show wlan0' | |
function cd { |
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
var animal = { | |
name: 'Karl', | |
type: 'cat', | |
color: 'black', | |
age: 7 | |
}; | |
//convert JSON animal into a string | |
var dehydratedAnimal = JSON.stringify(animal); |
OlderNewer