Skip to content

Instantly share code, notes, and snippets.

View AshleyAitken's full-sized avatar

Ashley Aitken AshleyAitken

  • Perth, Australia
View GitHub Profile
@chengsokdara
chengsokdara / useStore.js
Last active June 20, 2024 10:09
React global state in 15 lines of code.
// Author: Sokdara Cheng
// Contact me for web or mobile app development using React or React Native
// https://chengsokdara.github.io
import React, { createContext, useContext, useReducer } from "react";
import initialState from "./initialState"; // object of initial states
import reducer from "./reducer"; // https://reactjs.org/docs/hooks-reference.html#usereducer
const Store = createContext({
dispatch: () => null,
state: initialState,
});
@adamw
adamw / workshop.md
Last active October 11, 2020 07:57

Functional Scala CRUD

We'll be adding a feature to Bootzooka, a skeleton Scala microservice/web application project.

This will involve using doobie, monix, tapir, http4s, circe and compile-time dependency injection.

If you'd like to follow along:

  1. make sure you have Java & sbt installed. You can use sdkman for Java and popular package manages for sbt (e.g. brew)
  2. git clone https://github.com/softwaremill/bootzooka.git
@izmailoff
izmailoff / ExpressionProblemWithImplicits.scala
Last active February 13, 2023 13:00 — forked from elnygren/expression_problem.clj
Solving the Expression Problem with Scala's Implicits
object Main extends App {
import math._
// The Expression Problem and my sources:
// http://stackoverflow.com/questions/3596366/what-is-the-expression-problem
// http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/
// http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/
// http://www.ibm.com/developerworks/library/j-clojure-protocols/
@pawelkaczor
pawelkaczor / ConfigExtensions.scala
Created September 27, 2017 07:19
Extension methods to Typesafe Config to support Docker Swarm secrets
package com.typesafe.config.impl
import com.typesafe.config.ConfigFactory.parseMap
import com.typesafe.config.{Config, ConfigFactory}
import scala.collection.JavaConverters._
import scala.io.Source
import scala.util.Try
// discussion: https://groups.google.com/forum/#!topic/play-framework-dev/t2g-TWbqtzY

I have been an aggressive Kubernetes evangelist over the last few years. It has been the hammer with which I have approached almost all my deployments, and the one tool I have mentioned (shoved down clients throats) in almost all my foremost communications with clients, and it was my go to choice when I was mocking my first startup (saharacluster.com).

A few weeks ago Docker 1.13 was released and I was tasked with replicating a client's Kubernetes deployment on Swarm, more specifically testing running compose on Swarm.

And it was a dream!

All our apps were already dockerised and all I had to do was make a few modificatons to an existing compose file that I had used for testing before prior said deployment on Kubernetes.

And, with the ease with which I was able to expose our endpoints, manage volumes, handle networking, deploy and tear down the setup. I in all honesty see no reason to not use Swarm. No mission-critical feature, or incredibly convenient really nice to have feature in Kubernetes that I'm go

@brianneisler
brianneisler / cheat-sheet.js
Last active November 27, 2022 08:23
Cheat sheet - es6 import/export mixed with require/modules.exports
require('./module.js') // { a: 1 }
import module from './module.js' // undefined
import { a } from './module.js' // 1
require('./module2.js') // { default: { a: 1 }, b: 2 }
import module2 from './module2.js' // { a: 1}
import { b } from './module2.js' // 2
require('./module3.js') // { default: { a: 1 }, b: 2 }
@realcr
realcr / machine_manager.py
Last active June 10, 2020 09:09
Manage docker machines between different hosts (Allows attaching to existing docker machine)
import os
import shutil
from sstash.sstash import SecureStash
from getpass import getpass
stash_path = "/my/path/to/stash/file"
def store_machine(machine_name):
"""
Export a docker-machine from to the machines dir.

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@schickling
schickling / _README.md
Last active January 4, 2024 09:37
Script to import and export docker-machine configurations to sync between hosts/collaborators

docker-machine import/export

Script to import and export docker-machine configurations to sync between hosts/collaborators

Export (on host A)

$ docker-machine ls
NAME       ACTIVE   DRIVER         STATE     URL                            SWARM   DOCKER    ERRORS
dev        -        digitalocean   Running   tcp://example.com:2376                 v1.10.1
@gnachman
gnachman / iterm.scpt
Last active April 8, 2023 23:42
Replace /Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/iterm.scpt with this.
set itermRunning to (application "iTerm" is running)
set scriptPath to quoted form of POSIX path of ((path to me as text) & "::" & "start.sh")
set user_shell to do shell script "dscl /Search -read /Users/$USER UserShell | awk '{print $2}'"
tell application "iTerm"
activate
if not (exists window 1) or (itermRunning = false) then
reopen
end if