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 / count-andela-jobs.js
Last active August 26, 2020 01:56
Shows an animation, when counting the jobs on Andela's job board.
/**
copy & paste into the browser console
on https://boards.greenhouse.io/andela
*/
(() => {
// create display box
if (!$('#count-popover').length) {
$('#footer').append(`<div style="position:fixed;height:200px;width:200px;left:calc(50% - 100px);top: calc(50% - 100px);border:2px solid black;background-color: white;font-size: 50px;text-align: center;line-height: 200px;" id="count-popover">0</div>`)
}
@mykeels
mykeels / A-JS-Fork-Bomb.md
Created November 29, 2018 07:53
Write a Fork Bomb in Browser JavaScript that keeps opening browser windows.

Write a Fork Bomb in Browser JavaScript that keeps opening browser windows.

@mykeels
mykeels / slack-day
Last active November 13, 2018 13:12
A shell script to change slack's colors
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
INTEROP_FOLDER="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static"
BACKUP_FILE="$DIR/backup/ssb-interop.js"
if [ -f "$BACKUP_FILE" ]
then
cp "$BACKUP_FILE" "$INTEROP_FOLDER"
@mykeels
mykeels / slack-night-mode.js
Created November 12, 2018 15:06
Append to ssb-interop.js for Slack Night Mode on a Mac
document.addEventListener('DOMContentLoaded', function() {
$.ajax({
url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
success: function(css) {
let overrides = `
code { background-color: #535353; color: #85c5ff; } /* Change color: to whatever font color you want */
.c-mrkdwn__pre, .c-mrkdwn__quote { background: #535353 !important; background-color: #535353 !important; }
`
$("<style></style>").appendTo('head').html(css + overrides);
}
@mykeels
mykeels / VueTemplate.json
Last active November 4, 2018 12:14
VS Code User Snippets for Vue templates
{
"Vue Template": {
"prefix": "VueTemplate",
"body": [
"<template>",
"\t$0",
"</template>",
"",
"<script>",
"\texport default {",
@mykeels
mykeels / GetCheapestPath.md
Last active November 1, 2018 12:15
Given the root node of a tree, write a function that calculates the minimal Sales Path cost in the tree

The car manufacturer Honda holds their distribution system in the form of a tree (not necessarily binary). The root is the company itself, and every node in the tree represents a car distributor that receives cars from the parent node and ships them to its children nodes. The leaf nodes are car dealerships that sell cars direct to consumers. In addition, every node holds an integer that is the cost of shipping a car to it.

Take for example the tree below:

honda-sales-tree

See SampleTree.json

A path from Honda's factory to a car dealership, which is a path from the root to a leaf in the tree, is called a Sales Path. The cost of a Sales Path is the sum of the costs for every node in the path. For example, in the tree above one Sales Path is 0→3→0→10, and its cost is 13 (0+3+0+10).

@mykeels
mykeels / Laravel-Content.md
Created August 5, 2018 11:25
Extending Models with Content and Content-Type

Extending Models with Content and Content-Type

Traditional relational databases have structure, so we use migrations to manage that structure in Laravel.

This is cool, until you find yourself creating tables for things that you don't need tables for, because none of the tables' columns act as foreign keys to keys on other tables.

E.g. a user_settings table would have a structure like

id user_id key value

Usage

  • For Laravel Applications
    • Place the PHP script in app/Console/Commands/ directory
  • Run php artisan make:filter {FilterName} where {FilterName} is the name of the filter you intend to create.
@mykeels
mykeels / array.prototype.js
Created April 22, 2018 19:14
taboo prototype functions you should NOT use
Array.prototype.paginate = function (length) {
var arr = this;
length = (length || 1);
return arr.reduce(function (a, b) {
if (!a[a.length - 1] || a[a.length - 1].length == length) a.push([]);
a[a.length - 1].push(b);
return a;
}, []);
}
@mykeels
mykeels / 2018_04_17_000000_sample_migration.php
Created April 17, 2018 09:54
A sample laravel migration class using the [SampleMigration](https://gist.github.com/mykeels/b6cc690012ca11063d0303ee2daa08bd) model that implements the [ModelTableNameTrait](https://gist.github.com/mykeels/df13807cf105d0f92d6d4eaa3fa22d5b)
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\SampleMigration;
class SampleMigration extends Migration
{
/**
* Run the migrations.