Skip to content

Instantly share code, notes, and snippets.

@JustAdam
JustAdam / fruit_machine_ps1.sh
Last active October 1, 2015 07:29
Fruit machine PS1 prompt: origin. http://pastebin.com/dMFTr0Nk
# AUTHOR/Source : /u/Holger_Will
set_prompt (){
red="\[\033[38;5;1m\]"
green="\[\033[38;5;10m\]"
yellow="\[\033[38;5;11m\]"
grape="\[\033[38;5;92m\]"
strawberry="\[\033[38;5;9m\]"
mellon="\[\033[38;5;162m\]"
name="$red🍒$space$green🍏$space$red🍓$space$color4"
host="$color3\h$color4"
@JustAdam
JustAdam / rwmutex-no-blocking.go
Created November 4, 2014 20:18
Go: Read/Write variable locking - demo of Read locking without block with slow Write lock
package main
import (
"fmt"
"sync"
"time"
)
type C struct {
sync.RWMutex
@JustAdam
JustAdam / rwmutex.go
Created November 4, 2014 18:53
Go: Read/Write variable locking - demo showing the problem when accessing the variable directly and via a read lock when a slow write lock is running
package main
import (
"fmt"
"sync"
"time"
)
type C struct {
sync.RWMutex
@JustAdam
JustAdam / sighup.go
Last active January 12, 2020 02:15
Go: Handling HUP signal - reloading configuration settings while running
package main
import (
"bufio"
"fmt"
"log"
"os"
"os/signal"
"sync"
"syscall"
@JustAdam
JustAdam / drupal_taxonomy_content_type.php
Created August 2, 2012 09:49
Drupal 7 - Programmatically create a taxonomy and attach a field to it, then create a content type and attach that taxonomy to it.
<?php
// Machine name for our custom node
define('NODE_NAME', 'the_node_machine_name');
// Machine name for our custom taxonomy
define('TAXONOMY_NAME', 'the_taxonomy_machine_name');
function module_install() {
_create_taxonomy();
_create_content_type();
}