Skip to content

Instantly share code, notes, and snippets.

View andrewmarmion's full-sized avatar

Andrew Marmion andrewmarmion

  • Scotland, UK
  • 21:43 (UTC +01:00)
View GitHub Profile
@andrewmarmion
andrewmarmion / date.json
Created November 25, 2024 20:34
Just a date in JSON
{
date: "2024-09-03T10:15:00-04:00"
}
{
"name": "Val",
"age": 23,
"favourite_colors": [
"blue",
"yellow",
"green"
],
"fav_nums": [
1,
{
"name": "Movies",
"videos": [
{
"description": "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttps://www.bigbuckbunny.org",
"video": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
"subtitle": "By Blender Foundation",
"thumb": "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg",
"title": "Big Buck Bunny"
},
@andrewmarmion
andrewmarmion / AssertEquals+Diff.swift
Created June 10, 2021 21:01 — forked from mugbug/AssertEquals+Diff.swift
XCTestCase wrapper for asserting equatable structs with formatted error diff message
import XCTest
// Credits: https://github.com/pointfreeco/swift-composable-architecture
//swiftlint:disable empty_string force_cast force_unwrapping unused_closure_parameter function_body_length
class MyCustomTestCase: XCTestCase {
func assertEqual<T: Equatable>(
expected: T,
actual: T
) {
@andrewmarmion
andrewmarmion / dos2unix.sh
Created August 20, 2018 11:27 — forked from jappy/dos2unix.sh
Shell script to convert files with CRLF to LF (Mac/Linux)
#! /bin/sh
for x
do
echo "Converting $x"
tr -d '\015' < "$x" > "tmp.$x"
mv "tmp.$x" "$x"
done
@andrewmarmion
andrewmarmion / gist:df2118cc4d1284e367d57188761d3ad5
Created June 5, 2017 08:52
Using ImageMagick to create tiles for an image
convert myImage.jpg -crop 256x256 \
-set filename:tile "%[fx:page.x/256]-%[fx:page.y/256]" \
+repage +adjoin "Tile-%[filename:tile].png"
// converts an image into 256 tiles with the files named as Tile-row_num-column_num.png
@andrewmarmion
andrewmarmion / Parcelable.java
Created March 21, 2017 20:08
An example of a class that implements Parcelable
import android.os.Parcel;
import android.os.Parcelable;
public class Person implements Parcelable {
private String name;
private int age;
private String email;
private boolean hasPhone;
// Constuctor
@andrewmarmion
andrewmarmion / asynctask.java
Last active March 14, 2017 17:00
How to create a AsyncTask that is in it's own class
//Create an interface called AsyncResponse, AsyncResponse.java
public interface AsyncResponse {
void processFinish(String response);
}
// In the MainActivity.java override processFinish
// In processFinish put everything that you want to happen when you get a response from the AsyncTask
public class MainActivity extends Activity implements AsyncResponse {
protected void onCreate() {
@andrewmarmion
andrewmarmion / SomeFragment.java
Created February 13, 2017 23:22 — forked from joshdholtz/SomeFragment.java
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
@andrewmarmion
andrewmarmion / ItemClickSupport.java
Created February 5, 2017 21:19 — forked from nesquena/ItemClickSupport.java
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});