Skip to content

Instantly share code, notes, and snippets.

Avatar

Bolaji Olajide BolajiOlajide

View GitHub Profile
@BolajiOlajide
BolajiOlajide / aggregate.js
Created Dec 18, 2021
Delete your tweets from your account
View aggregate.js
const fs = require('fs');
const tweet_1 = require('./data/tweet.js');
const tweet_2 = require('./data/tweet-part1.js');
const totalTweets = [...tweet_1, ...tweet_2].map(({ tweet }) => ({
id: tweet.id_str,
createdAt: tweet.created_at
}));
@BolajiOlajide
BolajiOlajide / aggregator.js
Created Aug 16, 2021
2021 Delete Tweets Script using twitter's export tool
View aggregator.js
const fs = require('fs');
const tweet_1 = require('./data/tweet.js');
const tweet_2 = require('./data/tweet-part1.js');
const totalTweets = [...tweet_1, ...tweet_2].map(({ tweet }) => ({
id: tweet.id_str,
createdAt: tweet.created_at
}));
View delete_tweets.py
#!/bin/python3
"""
A Python script to delete tweets.
It uses tweet ids from a Twitter archive to bypass the Twitter API limit. Use this script if you need to delete more
than 3200 tweets and what's in your archive is a tweets.csv file.
If you have more than 3200 tweets but your archive has a tweets.json file use this:
https://gist.github.com/flesueur/bcb2d9185b64c5191915d860ad19f23f
@BolajiOlajide
BolajiOlajide / proton_vs_code.json
Created Jun 1, 2021
Proton's 2021 VSCode config (Last Updated: 1st June 2021)
View proton_vs_code.json
{
"editor.lineHeight": 25,
"editor.letterSpacing": 0.5,
"files.trimTrailingWhitespace": true,
"editor.renderWhitespace": "all",
"workbench.iconTheme": "material-icon-theme",
"editor.fontSize": 14,
"workbench.sideBar.location": "left",
"editor.fontLigatures": true,
"workbench.startupEditor": "none",
@BolajiOlajide
BolajiOlajide / fastapi-koii.py
Created May 22, 2021
sample of script to retrieve routes in a Fast API app
View fastapi-koii.py
from collections import namedtuple
from typing import List, Set
from fastapi import FastAPI
from fastapi.routing import APIRoute
from starlette.routing import BaseRoute
KOIIRoutes = List[BaseRoute]
Path = namedtuple("Path", ["path", "method"])
@BolajiOlajide
BolajiOlajide / fetch-wrapper.js
Created Apr 20, 2021
a wrapper around fetch for Asincole
View fetch-wrapper.js
const fetch = require('node-fetch');
const http = require('http');
const https = require('https');
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
const agent = (parsedUrl) => parsedUrl.protocol == 'http:' ? httpAgent : httpsAgent;
const client = {
async _createClient(method, url, payload = null, headers = {}) {
@BolajiOlajide
BolajiOlajide / git-fu.txt
Created Apr 19, 2021
some cool git tricks
View git-fu.txt
git blame file_name
git show commit_sha
git log -S "word/phrase to search for occurence" --reverse (get it in reverse order)
git push --force-with-lease # fail if someone pushed something to the same branch before this is about to happen
git config --global commit.verbose true # include the commit history when commiting stuff
git config --global core.editor "code"
View useInitialMount.js
/*
Sometimes we only want to run an effect the very first time the component mounts.
In my experience, the majority of these times have been firing off a tracking event.
Usually I’ll maintain a hasSent local variable that I flip from false to true after I’ve sent it the first time.
*/
import { useRef, useEffect } from 'react'
const useInitialMount = () => {
// refs exist across component re-renders, so
// we can use it to store a value for the
@BolajiOlajide
BolajiOlajide / useTraceUpdate.js
Created Apr 16, 2020
hook for tracing changed props
View useTraceUpdate.js
function useTraceUpdate(props) {
const prev = useRef(props);
useEffect(() => {
const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
if (prev.current[k] !== v) {
ps[k] = [prev.current[k], v];
}
return ps;
}, {});
@BolajiOlajide
BolajiOlajide / lol.sql
Created Feb 21, 2020
postgres replace dots and + sign in gmail email
View lol.sql
SELECT REGEXP_REPLACE('b.ol.aj.i+fafd@gmail.com', '(?!@)\+\w*|(?<!@gmail)\.', '', 'g'), 'b.ol.aj.i+fafd@gmail.com' as email;