Skip to content

Instantly share code, notes, and snippets.

View SirPhemmiey's full-sized avatar
🎯
Focusing

Oluwafemi Akinde SirPhemmiey

🎯
Focusing
View GitHub Profile
@Gurey
Gurey / logListener.ts
Last active July 20, 2022 09:40
Wait for Firebase emulators to finish
import { client as Client, connection as Connection } from 'websocket'
export interface LogMessage {
type: string
utf8Data: string
}
export interface LogMessageContent {
level: string
data: Data
timestamp: number
@Sijibomii
Sijibomii / shuffleAlgo.py
Created May 15, 2021 10:11
ALGORITHM FIDAYS
def shuffleClass(pupilsList, noToBeMoved):
# validate inputs first
#check if pupils list is a valid list
if not isinstance(pupilsList, list):
return []
#check if noToBeMoved is a valid integer
if not isinstance(noToBeMoved, int):
return pupilsList
classSize = len(pupilsList)
#if pupils list contains just one element or noToBeMoved is zero return it
@Hafthor
Hafthor / floatradix.js
Created April 10, 2021 23:45
non-decimal non-integer stuff
// like parseFloat, but takes an optional radix
function parseFloatWithRadix(s, r) {
r = (r||10)|0;
const [b,a] = ((s||'0') + '.').split('.');
const l1 = parseInt('1'+(a||''), r).toString(r).length;
return parseInt(b, r) +
parseInt(a||'0', r) / parseInt('1' + Array(l1).join('0'), r);
}
// like Number..toFixed, but takes an optional radix
@mjclemente
mjclemente / 20190417131115_test-setup.ts
Created July 21, 2020 17:39 — forked from jukkatupamaki/20190417131115_test-setup.ts
Knex.js & TypeScript config example · How to setup Knex.js in a TypeScript project
import * as Knex from 'knex';
export async function up(knex: Knex): Promise<any> {
return knex.schema.createTable('test_setup', (table: Knex.TableBuilder) => {
table.integer('foobar');
});
}
export async function down(knex: Knex): Promise<any> {
return knex.schema.dropTable('test_setup');
// Run this script on this page https://www.worldometers.info/coronavirus/
const c = $$('#main_table_countries_today tr').map(el => ({
country: $(el).find('td:nth-of-type(2)').text(),
totalCases: $(el).find('td:nth-of-type(3)').text(),
testsPerMillion: $(el).find('td:nth-of-type(13)').text(),
tests: $(el).find('td:nth-of-type(12)').text(),
}))
const toNumber = ({ totalCases, tests, testsPerMillion, country }) => ({
country,
@agritheory
agritheory / hook_workflow_action.py
Last active January 16, 2021 11:51
Hook onto the workflow action API
# Overriding Whitelisted Methods (in my_app/hooks.py)
# ------------------------------
override_whitelisted_methods = {
"frappe.model.workflow.apply_workflow": "my_app.workflows.apply_workflow"
}
# in my_app/workflows.py
import frappe
from frappe.model.workflow import apply_workflow as model_apply_workflow
@zwily
zwily / expo-firestore-persistence-hack.js
Last active February 23, 2023 02:15
A fragile weaving of various modules together to convince the Firestore web SDK to use persistence in an un-ejected Expo app.
/*
expo-firestore-persistence-hack
A fragile weaving of various modules together to convince the Firestore
web SDK to use persistence in an un-ejected Expo app.
To use, first:
```
$ expo install expo-sqlite
/* The API
================== */
const noop = () => { };
// abstract matcher
const match = (field = '', delegate = noop) => {
return (data = []) => {
return data.filter(entry => delegate(entry[field]));
}
@gagarine
gagarine / fish_install.md
Last active May 3, 2024 08:11
Install fish shell on macOS Mojave with brew

Installing Fish shell on MacOS (Intel and M1) using brew

Fish is a smart and user-friendly command line (like bash or zsh). This is how you can instal Fish on MacOS and make your default shell.

Note that you need the https://brew.sh/ package manager installed on your machine.

Install Fish

brew install fish

@Samuelachema
Samuelachema / mysort.js
Created August 14, 2018 00:18
Write a mySort function which takes in an array integers, and should return an array of the inputed integers sorted such that the odd numbers come first and even numbers come last.
/*
JavaScript
Write a mySort function which takes in an array integers, and should return an array of the inputed integers sorted such that the odd numbers come first and even numbers come last.
For exampl1e:
mySort( [90, 45, 66, 'bye', 100.5] )
should return
[45, 66, 90, 100]