Skip to content

Instantly share code, notes, and snippets.

View kirklewis's full-sized avatar
🙂
try { Positivity } catch { Negativity } finally { laugh() }

Kirk Lewis kirklewis

🙂
try { Positivity } catch { Negativity } finally { laugh() }
View GitHub Profile
function toCamelCase(str) {
//get the words from the string, would use \w but it includes underscores.
var words = str.match(/([a-zA-Z0-9]+)/g);
words = words.map(function(word, i){
//ignore the first word otherwise its first letter will be capitalised.
if(i == 0) return word;
//capitalise first letter in each word and concatenate it onto the rest of itself. E.g. C + ode
@kirklewis
kirklewis / install-couchdb.md
Created August 21, 2016 12:41
Install CouchDB and Futon

Installation

Linux (Ubuntu Distros)

# Get the latest package info
sudo apt-get update

# Fetch files for managing vendor source
sudo apt-get install software-properties-common -y
mkdir -p dbix-proj/{lib,scripts,t} && \
touch dbix-proj/{cpanfile,t/basic.t,scripts/{schema.sql,make_schema.pl}}
@kirklewis
kirklewis / Result-User.pm
Created February 4, 2017 12:02
learn-orm-perl-with-dbix
sub fullname {
my $self = shift;
return $self->firstname . ' ' . $self->lastname;
}

Keybase proof

I hereby claim:

  • I am kirklewis on github.
  • I am kirklewis (https://keybase.io/kirklewis) on keybase.
  • I have a public key whose fingerprint is D9FF 94AB C80F A0DA 0940 E7A8 6E02 7D52 9BAF A6BF

To claim this, I am signing this object:

#!/usr/bin/env perl
use v5.20.3;
use strict;
use warnings;
# Basic String Interpolation with Scalars and Lists
my $PI = 3.14;
my @nums = (3, 2, 1);
say "scalar: $PI - list: @nums";
@kirklewis
kirklewis / send-statsd-test-metrics.sh
Last active March 22, 2021 14:48
Generate and send StatsD test metrics
#!/bin/bash
DEFAULT='\033[0m'
HI_CYAN='\033[0;96m'
HI_WHITE='\033[0;93m'
STATSD_HOST=127.0.0.1
STATSD_PORT=8125
api_names=(orders invoice user)
@kirklewis
kirklewis / process-file.go
Created August 29, 2019 10:02
Template File Processing in Go
package main
import (
"os"
"text/template"
)
func main() {
// variables
vars := make(map[string]interface{})
@kirklewis
kirklewis / yaml-to-list.groovy
Created February 16, 2020 19:08
Groovy 3.0 YamlSlurper
import groovy.yaml.YamlSlurper
def yamlSlurper = new YamlSlurper()
def yaml = yamlSlurper.parseText('''\
- 100
- 50
- 1
''')
assert yaml instanceof List
@kirklewis
kirklewis / list-to-yaml.groovy
Created February 16, 2020 19:09
Groovy 3.0 YamlBuilder
import groovy.yaml.YamlBuilder
def counts = [ 1, 2, 3 ]
def yaml = new YamlBuilder()
yaml(counts)
assert yaml.toString() == '''\
---
- 1
- 2