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
oneEyedSunday / loops_variadic_arrays.js
Created July 2, 2022 22:45
A walkthrough loops and arrays for beginners
// 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
oneEyedSunday / gen-csv.js
Last active March 29, 2021 05:03
Gists for Blog post about logging and latency
#!/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
oneEyedSunday / pre-push
Created January 14, 2021 10:05
Pre Push hook to run dotnet builds
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
## custom
BASEDIR=$(dirname "$0")
echo "Running Builds for DotNet Projects before Push for Branch: " $branch
@oneEyedSunday
oneEyedSunday / download.cs
Created December 21, 2020 06:40
Download individual files from a shared dropbox folder
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
oneEyedSunday / tuples.cpp
Last active July 11, 2020 13:57
C++ practice
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
std::tuple<string, string> get_chars(const string&);
@oneEyedSunday
oneEyedSunday / logging.js
Created January 31, 2020 20:36
Better Logging JS
// https://dev.to/wangonya/better-consolelogs-448c?utm_source=additional_box&utm_medium=internal&utm_campaign=regular&booster_org=
function customLog(message, color='black') {
let logType = 'log';
switch (color) {
case 'success':
color = 'Green';
break
case 'info':
color = 'Blue';
@oneEyedSunday
oneEyedSunday / replaceAll.js
Created January 25, 2020 20:21
Impleenting String.replaceAll by extending the String prototype
String.prototype.replaceAll = function(candidate, replacement) {
let result = this;
let startIndex = result.indexOf(candidate);
if (startIndex < 0) {
return fullText;
}
@oneEyedSunday
oneEyedSunday / package.json
Created November 16, 2019 01:49
Reduce lambda size by stripping dev dependencies
{
"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 code.zip && zip -r code.zip src package.json node_modules",
"test": "npm run test"
}
@oneEyedSunday
oneEyedSunday / angular-usage.ts
Last active August 31, 2019 15:33
Describes how to use the basic formatter
import { Injectable } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
interface FormatterPatternAndReplacement {
pattern: RegExp;
replacement: string;
}
@Injectable()
export class Formatter {