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 / index.html
Created March 31, 2017 15:32
jQuery Number Counter
<h1>JQUERY NUMBER ANIMATION</h1>
<h3>jQuery counter to count up to a target number</h3>
<div class="wrapper">
<div class="counter col_fourth">
<i class="fa fa-code fa-2x"></i>
<h2 class="timer count-title count-number" data-to="300" data-speed="1500"></h2>
<p class="count-text ">SomeText GoesHere</p>
</div>
@kevgathuku
kevgathuku / nginx.conf
Created December 18, 2014 05:28
Nginx configuration for serving phpMyAdmin in Arch Linux
user http http;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@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
(defn compute-collatz [num steps]
(cond
(= num 1) steps
(even? num) (compute-collatz (/ num 2) (inc steps))
(odd? num) (compute-collatz (+ 1 (* num 3)) (inc steps))))
(defn collatz [num]
; Check if the provided number is positive. If not throw an error
(if
type tree = Leaf | Node(int, tree, tree);
let rec sum = (item) => {
switch (item) {
| Leaf => 0
| Node(value, left, right) => value + sum(left) + sum(right);
}
};
let rec height = (root) => {
@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 / Main.elm
Last active June 25, 2019 06:49
Elm 0.19 Buttons example
-- Extracted from: https://guide.elm-lang.org
-- Read more about this program in the official Elm guide:
-- https://guide.elm-lang.org/architecture/buttons.html
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
@kevgathuku
kevgathuku / App.js
Created June 25, 2019 06:03
Embedding Elm 0.19 into a React app using react-elm-components
import React from 'react';
import logo from './logo.svg';
import './App.css';
// Add these two imports
import Elm from 'react-elm-components';
import Main from "./Main";
function App() {
return (