Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@kevgathuku
kevgathuku / dummy_controller.rb
Created August 9, 2022 06:51 — forked from psobocinski/dummy_controller.rb
Asserting on a JSON response in a Rails controller test with MiniTest
class DummyController < ApplicationController
def do
render json: { balance: 50 }
end
end
@kevgathuku
kevgathuku / how-to-add-image-to-gist.md
Last active June 21, 2022 08:17 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@kevgathuku
kevgathuku / yarn.config
Created May 14, 2021 12:16 — forked from sealocal/yarn.config
Install Yarn and NodeJS on AWS Elastic Beanstalk EC2 Instance with Amazon Linux Ruby Platform, prior to precompiling assets for a Rails app
files:
# If this file is edited, it must be removed from EC2 instance prior to deploy.
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn_install.sh" :
mode: "000775"
owner: root
group: users
content: |
#!/usr/bin/env bash
set -xe
@kevgathuku
kevgathuku / iframechange.js
Created October 3, 2019 06:08 — forked from hdodov/iframechange.js
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
@kevgathuku
kevgathuku / EventComponent.spec.js
Created November 5, 2018 19:22 — forked from hartzis/EventComponent.spec.js
Touch Event Testing React Jest Enzyme
import React from 'react';
import EventComponent from './EventComponent';
import { mount } from 'enzyme';
import {
createStartTouchEventObject,
createMoveTouchEventObject
} from './EventHelpers.js';
describe('EventComponent', () => {
@kevgathuku
kevgathuku / Main.elm
Created October 1, 2018 16:37 — forked from sch/Main.elm
Minimum Elm boilerplate
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
type alias Model =
{ count : Int }
@kevgathuku
kevgathuku / circleci-heroku-continuous-deployment2.0.md
Created August 5, 2018 18:26 — forked from lauraturk/circleci-heroku-continuous-deployment2.0.md
instructions for deploying from circleci2.0 to heroku
@kevgathuku
kevgathuku / sort.ex
Created June 18, 2018 10:37 — forked from rylev/sort.ex
Sort Algorithms in Elixir
## Sort Algorithms in Elixir
# Selection Sort
defmodule Selection do
def sort(list) when is_list(list) do
do_selection(list, [])
end
def do_selection([head|[]], acc) do
@kevgathuku
kevgathuku / api.js
Created May 23, 2018 19:53 — forked from pshoukry/api.js
React / Redux fetch from rails server with CSRF token
import _ from 'underscore';
import fetch from 'isomorphic-fetch'
class API {
getCSRFToken() {
return _.find(document.getElementsByTagName('meta'), (meta) => {
return meta.name === 'csrf-token'
}).content
}
@kevgathuku
kevgathuku / docker_kill.sh
Created February 13, 2018 09:43 — forked from evanscottgray/docker_kill.sh
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt