Skip to content

Instantly share code, notes, and snippets.

View mykeels's full-sized avatar
😄
faffing!

Michael Ikechi mykeels

😄
faffing!
View GitHub Profile
@mykeels
mykeels / GraphQLFormatter.cs
Last active July 8, 2017 22:10
ASP.NET WebAPI Custom Formatter for GraphQL Syntax
using System;
using System.Net.Http.Headers;
using System.Net.Http.Formatting;
using System.IO;
using System.Threading;
using System.Net.Http;
using GraphQL;
using GraphQL.Types;
namespace GraphQLWebAPI.Formatters
@mykeels
mykeels / clarg.md
Created July 28, 2017 15:15 — forked from pksunkara/clarg.md
Command Line Arguments Specification

Command Line Arguments Specification

This specification defines Command Line Arguments level 1 (CLARG 1.0). This document aims to direct development of command line tools conform to a set of rules while parsing options.

Arguments

The different type of arguments are:

  • Short Option
  • Long Option
@mykeels
mykeels / README.md
Last active August 25, 2017 15:31
A Simple Sort challenge

Write a program in any language of your choice that has a function that sorts the json data by Name in alphabetical order and Age and returns the result.

E.g.

  function sortData(arr) {
    // ... do stuff to sort the array
    return arr;
  }
@mykeels
mykeels / FriendsContainer.js
Last active October 6, 2017 14:25
The ultimate explanation for React's component lifecycle event handlers from https://tylermcginnis.com/reactjs-tutorial-a-comprehensive-guide-to-building-apps-with-react/
var FriendsContainer = React.createClass({
getInitialState: function(){
alert('In getInitialState');
return {
name: 'Tyler McGinnis'
}
},
// Invoked once before first render
componentWillMount: function(){
// Calling setState here does not cause a re-render
@mykeels
mykeels / README.md
Last active October 1, 2018 00:59
Kill Apache Service on Mac - bind() to 0.0.0.0:80 failed (48: Address already in use)

To find out the program interfering with port 80 on Mac,

sudo lsof -i:80

If it's httpd it's the Apache Service, so use the command in kill-apache.sh in your terminal to shut it down, then valet restart

If you get a 404, try valet link in your app directory.

@mykeels
mykeels / cast.php
Last active February 5, 2018 15:20
Cast an associative array or object in PHP to an instance of a class (uses a Laravel helper method)
<?php
function cast($object, $class) {
if( !is_object($object) )
throw new InvalidArgumentException('$object must be an object.');
if( !is_string($class) )
throw new InvalidArgumentException('$class must be a string.');
if( !class_exists($class) )
throw new InvalidArgumentException(sprintf('Unknown class: %s.', $class));
$ret = app($class);
@mykeels
mykeels / README.md
Last active February 19, 2018 09:06
Regex for Find & Replace in JavaScript Webpack Code Splitting

Regex for Find & Replace to convert

import MyComponent from './my-component'

to

const MyComponent = () =&gt; import(/* webpackChunkName: "chunk" */ './my-component')
@mykeels
mykeels / ApiClient.cs
Last active February 28, 2018 14:23
A helper class for working with most API requests
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Diagnostics;
using Newtonsoft.Json;
using System.Text;
@mykeels
mykeels / introrx.md
Created March 1, 2018 14:37 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing