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 / .gitconfig
Created May 3, 2019 09:36
My .gitconfig file
[user]
# be sure to replace this
email = [email protected]
name = Ikechi Michael
[alias]
squash = !git reset $(git merge-base develop $(git rev-parse --abbrev-ref HEAD))
current-branch = !git rev-parse --abbrev-ref HEAD
publish = !git push --set-upstream origin $(git current-branch)
ignore = !curl https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore -O && mv Node.gitignore .gitignore
license-mit = !curl https://raw.githubusercontent.com/angular/angular.js/master/LICENSE -O

Compiling with optimisations

gcc -O3 -funroll-loops pascal.c && time ./a.out

@mykeels
mykeels / Random-Twitter-Bot.md
Last active November 29, 2021 23:27
A twitter bot that picks users at random, useful for giveaways.

An idea for a twitter bot

  • that picks users at random

I got this idea when I saw unicodeveloper's tweets about picking five twitter accounts, that indicate interest in an advanced JavaScript course, at random to gift the course to.

Syntax

Here's a list of correct syntax for such a bot, and meanings:

@mykeels
mykeels / ListNetworks.ino
Created February 26, 2019 13:18
Arduino -> ESP8266 Wifi Module program to list available WiFi networks
// See https://github.com/bportaluri/WiFiEsp
// See blog post https://medium.com/@mykeels/connect-to-wifi-with-arduino-9eee4b02d904
#include <WiFiEsp.h>
#ifndef HAVE_HWSERIAL1
#include <SoftwareSerial.h>
SoftwareSerial wSerial(6, 7);
#endif
void setup() {
@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).