Skip to content

Instantly share code, notes, and snippets.

View elchroy's full-sized avatar

Elisha-Wigwe Chijioke O. elchroy

  • Richardson, Texas
View GitHub Profile
@elchroy
elchroy / config-editor.md
Created September 13, 2018 17:41 — forked from nnja/config-editor.md
Configure git editor

Set which editor git should use.

This is the program that will open during a commit with no -m flag, a merge, a rebase, etc...

Select from any installed editor. Examples:

  • emacs: emacs
  • vi: vi or vim
@elchroy
elchroy / git-log2json.sh
Created September 13, 2018 18:58 — forked from textarcana/git-log2json.sh
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features :) UPDATED 2017: Today I would just use https://github.com/tarmstrong/git2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
# import packages
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
from os import path, makedirs
import numpy as np
import matplotlib.pyplot as plt
import torch
from torch import nn, optim
import torch.nn.functional as F
@elchroy
elchroy / sorting_algos.js
Created July 3, 2019 12:15
Implementations of common sorting algorithms
/**
* Naive sort - Quadratic time, nested loops
* Divide & Comquer - O(nlogn)
*/
module.exports = {
bubbleSort () {
},
@elchroy
elchroy / some_algos.js
Created July 3, 2019 12:24
Factorial, Fibonacci, Search Algorithms, etc. See sorting.js for sorting algorithms
module.exports = {
isUnique (arr) {
let result = true;
let count = 0;
for (let i = 0; i < arr.length; i++) {
console.log(`OUTER LOOP ~~~~ i === ${i}`);
for (let j = 0; j < arr.length; j++) {
console.log(`INNER LOOP ~~~~ j ==== ${j}, and ${++count}`);
// apart from the current index where i and j are equal
@elchroy
elchroy / make_change.js
Created July 3, 2019 12:32
Different implementations of `makeChange` problem.
// Write a function, makeChange, that returns an integer
// that represents the least number of coins that add up
// to an amount where the amount is always divisible by 5
const availableCoins = {
5: 0,
10: 0,
25: 0
}
<?php
function reverseArray($a) {
$len = count($a);
$i = 0;
$res = [];
while ($i < $len) {
$j = abs($i - $len) - 1;
$res[] = $a[$j];
$i++;
<?php
$arr = [1, 2, 3, 4, 5];
function rotLeft($a, $d) {
$res = [];
$count = count($a);
array_walk($a, function ($e, $i) use (&$a, $d, $count, &$res) {
$res[$i] = $a[($i+$d)%$count];
@elchroy
elchroy / cs-bin-gists.js
Created August 14, 2019 18:53
Will Sentance FEMasters CS Bin Promises - http://csbin.io/promises
// Challenge 1
function sayHello() {
setTimeout(() => console.log('Hello'), 1000);
}
// Uncomment the line below when ready
sayHello(); // should log "Hello" after 1000ms
@elchroy
elchroy / scss-color-names.scss
Created June 9, 2020 16:46
CSS color names as SCSS variables
$aliceblue: #f0f8ff;
$antiquewhite: #faebd7;
$aqua: #00ffff;
$aquamarine: #7fffd4;
$azure: #f0ffff;
$beige: #f5f5dc;
$bisque: #ffe4c4;
$black: #000000;
$blanchedalmond: #ffebcd;
$blue: #0000ff;