Skip to content

Instantly share code, notes, and snippets.

View oneEyedSunday's full-sized avatar
Working from home

Idiakose O. Sunday oneEyedSunday

Working from home
View GitHub Profile
oneEyedSunday / loops_variadic_arrays.js
Created July 2, 2022 22:45
A walkthrough loops and arrays for beginners
View loops_variadic_arrays.js
// declare function
// function <name> (firstParameter secondParameter, ...otherParaemters)
// Notice the `...` before otherParameters
// It means it can either be zero or more entries
// These entries will be collapsed into an array called whatever you named the parameter
function walkthrough(param1, param2, ...otherVariadicParams) {
// initialize sum to 0
let sum = 0;
// Here, this iteration varaibale is so you can track how many times the loop happened
// It can be different from the index of the loop itself
oneEyedSunday / gen-csv.js
Last active March 29, 2021 05:03
Gists for Blog post about logging and latency
View gen-csv.js
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const { promisify, format } = require('util')
const defaultOutputPath = path.join(__dirname, 'dump.csv')
const outPath = process.argv[3] ? path.resolve(process.argv[3]) : path.resolve(defaultOutputPath)
const entryCount = process.argv[2] ? Number(process.argv[2]) : 50000
oneEyedSunday / pre-push
Created January 14, 2021 10:05
Pre Push hook to run dotnet builds
View pre-push
branch="$(git rev-parse --abbrev-ref HEAD)"
## custom
BASEDIR=$(dirname "$0")
echo "Running Builds for DotNet Projects before Push for Branch: " $branch
oneEyedSunday / download.cs
Created December 21, 2020 06:40
Download individual files from a shared dropbox folder
View download.cs
using System;
using System.IO;
using System.Net;
using System.ComponentModel;
using Dropbox.Api;
using System.Threading.Tasks;
using Dropbox.Api.Files;
using System.Linq;
namespace DropboxDownload
oneEyedSunday / tuples.cpp
Last active July 11, 2020 13:57
C++ practice
View tuples.cpp
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
std::tuple<string, string> get_chars(const string&);
oneEyedSunday / logging.js
Created January 31, 2020 20:36
Better Logging JS
View logging.js
function customLog(message, color='black') {
let logType = 'log';
switch (color) {
case 'success':
color = 'Green';
case 'info':
color = 'Blue';
oneEyedSunday / replaceAll.js
Created January 25, 2020 20:21
Impleenting String.replaceAll by extending the String prototype
View replaceAll.js
String.prototype.replaceAll = function(candidate, replacement) {
let result = this;
let startIndex = result.indexOf(candidate);
if (startIndex < 0) {
return fullText;
oneEyedSunday / package.json
Created November 16, 2019 01:49
Reduce lambda size by stripping dev dependencies
View package.json
"scripts": {
"lint": "node node_modules/eslint/bin/eslint.js src --config ./.eslintrc.json",
"lint:fix": "npm run lint -- --fix",
"pre-package": "npm run lint && mv node_modules full_node_modules && npm prune --production",
"package": "npm run pre-package && npm run pack-publish && npm run post-package",
"post-package": "rm -rf node_modules && mv full_node_modules node_modules",
"pack-publish": "rm && zip -r src package.json node_modules",
"test": "npm run test"
oneEyedSunday / angular-usage.ts
Last active August 31, 2019 15:33
Describes how to use the basic formatter
View angular-usage.ts
import { Injectable } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
interface FormatterPatternAndReplacement {
pattern: RegExp;
replacement: string;
export class Formatter {