Skip to content

Instantly share code, notes, and snippets.

View MarkyMarkMcDonald's full-sized avatar

Mark McDonald MarkyMarkMcDonald

View GitHub Profile
@MarkyMarkMcDonald
MarkyMarkMcDonald / amend-ng
Last active March 5, 2019 21:01
Amending to an old commit
amend-ng () {
 SHA=$1
 git commit --fixup $SHA &&
 GIT_EDITOR="cat" git rebase --autosquash --interactive $SHA^
}
-- Read all about this program in the official Elm guide:
-- https://guide.elm-lang.org/architecture/user_input/text_fields.html
import Html exposing (Html, Attribute, beginnerProgram, text, div, input)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import List
import String
import Regex
import Result
@MarkyMarkMcDonald
MarkyMarkMcDonald / car_example.sh
Last active May 2, 2017 17:18
jq filter out children values
echo '{"logs": ["All the cars are really good"],"info": {"cars": [{"name": "another car","type": "big"},{"name": "my car","type": "small"},{"name":"sweet ride", "type":"small"}]}}' | jq '.info.cars |= map(select(.type == "small"))
@MarkyMarkMcDonald
MarkyMarkMcDonald / toggle.bookmark
Last active March 27, 2017 14:38
Bookmarklet for toggling github comments from code reviews of PRs
javascript:(function()%7Bvar elements %3D document.getElementsByClassName('js-toggle-file-notes')%3Bfor (i %3D 0%3B i < elements.length%3B i%2B%2B) %7B elements%5Bi%5D.click() %7D%7D)()
@MarkyMarkMcDonald
MarkyMarkMcDonald / FlattenedToReversedMutliImmutableMapTest.java
Created December 10, 2016 21:47
flattenedToReversedMutliImmutableMap collector for guava
package com.example;
import com.google.common.collect.*;
import org.junit.Test;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Stream;
@MarkyMarkMcDonald
MarkyMarkMcDonald / Card.elm
Last active September 21, 2016 17:07
Exposing list of attributes to be iterated over by validation check. See https://github.com/MarkyMarkMcDonald/elm-architecture-tutorial/commit/ede42b04414df3365dd6d7673dca9b6a6a32ab61?w=1 for full context
type Shape = Diamond | Oval | Squiggle
type Number = One | Two | Three
type Color = Red | Green | Blue
type Attribute = Color | Shape | Number
type alias Model = {
shape: Shape,
number: Number,
color: Color
@MarkyMarkMcDonald
MarkyMarkMcDonald / gist:876132a2c7deafe7a4f0
Last active December 15, 2015 12:35
Exposing Test Helpers across components in a gradle multi-module project

To produce a jar containing test sources and use it elsewhere in a Gradle multi-module project (component A depends on component B):

Create a new configuration in component A:

// components/A/build.gradle
configurations {
    test-helpers
}
@MarkyMarkMcDonald
MarkyMarkMcDonald / create_migration.sh
Last active August 24, 2020 22:21
Create Flyway migration versioned by timestamp: ./bin/create_migration.sh "Add_Unique_Constraint_To_User_Email"
#!/bin/bash
echo "-- New Migration" > "`dirname $0`/../src/main/resources/db/migrations/V`date +%s`__$1.sql"
@MarkyMarkMcDonald
MarkyMarkMcDonald / Bulbapedia Scrapper
Last active December 20, 2015 21:39
Populates a javascript object with data taken from this table at Bulbapedia: http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_base_stats You can run this in the chrome debugger to copy the object to your clipboard (Or just grab the results I saved in the second file).
var pokemons = {}; // We'll store what we scrap here
var raiseToLevel100 = true; // These stats are for level 1, we'll take into account normal growth
// The first td is the pokemon number, the second contains the sprite url, etc
var statOrder = {
0: 'number',
1: 'imageLocation',
2: 'name',
3: 'hp',
4: 'attack',