Skip to content

Instantly share code, notes, and snippets.

View ckalegi's full-sized avatar

Cameron Kalegi ckalegi

View GitHub Profile
@johndavidback
johndavidback / gist:fe17dc2a861fbf755691
Created July 17, 2014 14:38
Bootstrap Char Field for Django Form
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)
@blvkoblsk
blvkoblsk / ansi-colors.py
Created August 18, 2017 05:42
ANSI COLORS - PYTHON BASH SCRIPT + MODULE
#!/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** :
@tendoasan
tendoasan / bash_basics.sh
Last active June 5, 2018 06:08
[Bash 简要命令] #Bash
#!/bin/bash
##############################################################################
# BASH BASICS
##############################################################################
env # displays all environment variables
echo $SHELL # displays the shell you're using
echo $BASH_VERSION # displays bash version
@indolering
indolering / transmission-vpn-launcher.applescript
Last active September 21, 2019 13:42
Uses Private Internet Access REST API to set which port Transmission listens on, binds all Transmission traffic to the tun0 (typically OpenVPN) network interface, and then opens Transmission.
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
@IngmarBoddington
IngmarBoddington / shellScripting
Last active February 14, 2022 17:23
Notes on shell scripting in Linux. Should be used in conjunction with terminal notes: https://gist.github.com/IngmarBoddington/4226355
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 $#
@random-robbie
random-robbie / install_go_pi.sh
Created April 26, 2018 14:16
Install Go Lang 1.10.1 on Raspberry Pi 3
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
const countryCodes = {
US: 'United States',
CA: 'Canada',
NG: 'Nigeria',
GB: 'United Kingdom',
};
const sales = [
{ code: 'US', count: 233 },
@datchley
datchley / app.js
Last active September 20, 2022 01:22
"Getting Functional with Javascript" Blog post source files
/**
* 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
}
@ulisesantana
ulisesantana / .zshrc
Last active January 10, 2023 10:30
Raspberry Pi init script
# 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 {
@jbail
jbail / local-storage-with-json-parse-stringify.js
Created December 23, 2012 18:08
Local storage with JSON parse and stringify
var animal = {
name: 'Karl',
type: 'cat',
color: 'black',
age: 7
};
//convert JSON animal into a string
var dehydratedAnimal = JSON.stringify(animal);