Skip to content

Instantly share code, notes, and snippets.

View mheap's full-sized avatar
🦋
Follow me on Bluesky @mheap.dev

Michael Heap mheap

🦋
Follow me on Bluesky @mheap.dev
View GitHub Profile
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('{"success":true}');
}).listen(9615);
# Install it
Add to composer:
"symfony/dependency-injection": "2.4.2",
"symfony/yaml": "2.4.2",
# Configure it
<?php
func oddNumberGenerator(n int) []int {
vals := make([]int, n);
origN := n;
// In PHP I'd do while count($arr) < $n, but as we initialise
// an array of size n that won't work in go
for i := 0; n > 0; i++ {
if (i % 2 == 1) {
@mheap
mheap / gist:9f95d57492e7a85fda11
Created December 15, 2014 11:16
Mermaid/Graphviz

Graph

Mermaid

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
kilo% ls ~/.zsh/completions
_hub
kilo% echo $fpath
/home/michael/.zsh/completion /usr/local/share/zsh/site-functions /usr/share/zsh/vendor-functions /usr/share/zsh/vendor-completions /usr/share/zsh/functions/Calendar /usr/share/zsh/functions/Chpwd /usr/share/zsh/functions/Completion /usr/share/zsh/functions/Completion/AIX /usr/share/zsh/functions/Completion/BSD /usr/share/zsh/functions/Completion/Base /usr/share/zsh/functions/Completion/Cygwin /usr/share/zsh/functions/Completion/Darwin /usr/share/zsh/functions/Completion/Debian /usr/share/zsh/functions/Completion/Linux /usr/share/zsh/functions/Completion/Mandriva /usr/share/zsh/functions/Completion/Redhat /usr/share/zsh/functions/Completion/Solaris /usr/share/zsh/functions/Completion/Unix /usr/share/zsh/functions/Completion/X /usr/share/zsh/functions/Completion/Zsh /usr/share/zsh/functions/Completion/openSUSE /usr/share/zsh/functions/Exceptions /usr/share/zsh/functions/MIME /usr/share/zsh/functions/Misc /usr/share/zsh/functions/Newuser /usr/share/zsh/functi
<?php
// Interestingly, a null value in an isset() check will return false
$r = array(
"a" => 1,
"b" => null
);
echo "a: ".(isset($r['a']) ? 'Yes' : 'No').PHP_EOL;
@mheap
mheap / .start-session.sh
Created February 24, 2015 15:34
Session startup script for a Dell XPS 15. Enables/disables screens automatically
# Set up some variables we need
test -z "`xrandr | grep '^HDMI1 connected'`" && HDMI_ON=1
test -z "`xrandr | grep '^DP1 connected'`" && DP_ON=1
# Both on, I'm probably at work
if [[ -z "$HDMI_ON" ]] && [[ -z "$DP_ON" ]]; then
bash ~/.screenlayout/work-desk.sh
# Only the HDMI on
elif [[ -z "$HDMI_ON" ]]; then
@mheap
mheap / Abstract.md
Created April 13, 2015 20:14
HTTP is your friend

We’ve all used HTTP before - we use it every time we go to Google or Facebook, every time we refresh our Twitter client on our phone.

HTTP is a very well defined protocol that we can use to build our own apps. It guarantees a response if you make a request, it has predefined error codes that everyone implements and it’s a very simple format to read if you need to inspect what’s going on by looking at it.

This talk takes you through HTTP, starting at the beginning with how a connection is established, parsed and how the response is formatted. We’ll also cover things like status codes, common headers and some advanced topics such as HTTP streaming and web sockets.

@mheap
mheap / Abstract.md
Created April 13, 2015 20:16
Continuous delivery with GoCD

Move over Jenkins, there’s a new kid on the block and it’s called GoCD.

GoCD is a continuous integration system developed by Thoughtworks and open sourced in 2014. At it’s core, it’s a pipeline based build system that takes an input (or multiple inputs) and runs commands that you define on it.

This talk is a basic introduction to application packaging and continuous delivery, along with an overview of GoCD and how it can be used to ship continuously.

@mheap
mheap / Abstract.md
Created April 13, 2015 20:16
NIH Syndrome

Not Invented Here Syndrome is a big problem in a lot of companies that believe that what’s out there isn’t suitable for them. They believe that they can do a better job writing something custom than adapting open source products.

This talk covers a lot of common problems that emerge in day to day development and takes a look at the available solutions that have been adopted by hundreds of companies. From things like logging and metrics to database access, this is a whistle stop tour of all the technologies out there that you could be using today.