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 / oop.js
Created November 19, 2018 16:06
Demonstration of the basic OOP principles
const getData = limit => {
const data = [];
let index = 0;
while(index < limit){
data.push(`Item ${index}`);
index++;
}
return data;
}
@oneEyedSunday
oneEyedSunday / closedLoopFix1.js
Created December 14, 2018 01:44
Fix for closed loops
function handler(index) {
alert(index)
}
function hookupevents() {
for (var i = 0; i < 3; i++) {
document.getElementById("button" + i).addEventListener("click", handler.bind(this,i));
}
}
function hookupevents(){
for(var i = 0; i < 3; i++){functon(index){
document.getElementsById("button" + index).addEventListener('click', function() {alert (index)})
}
}
}
function isMultiple(number, baseNumber) { return !(number % baseNumber); }
for (var i = 1; i < 101; i++) {
if (isMultiple(i,3)){
if (isMultiple(i,5)) {
console.log("FizzBuzz")
} else {
console.log("Fizz")
}
}else if(isMultiple(i,5)) {
@oneEyedSunday
oneEyedSunday / pushNotificationsExpressserver.ts
Created May 10, 2019 03:37
Express server to send push notifications using weboush
import * as express from 'express';
import {Application} from "express";
const webpush = require('web-push');
const bodyParser = require('body-parser');
const cors = require('cors');
const vapidKeys = {
"publicKey":...,
"privateKey":...
}
@oneEyedSunday
oneEyedSunday / Joins.sql
Created May 11, 2019 19:31
Mysql re-up
-- delete a customer
-- bcos of constraint
-- first turn off foreign_key_checks
SET foreign_key_checks = 0;
-- dorp customer(s)
SET foreign_key_checks = 1;
-- INNER JOIN
-- fetch details of customers and orders they made
-- wont show details of orders of customer 11
using System;
using System.Collections;
public class City
{
public int x, y;
public City(int p1, int p2)
{
x = p1;
@oneEyedSunday
oneEyedSunday / branches.sh
Created August 22, 2019 22:24
List git branches by last commit date
git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
@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 {
@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"
}