Skip to content

Instantly share code, notes, and snippets.

View okplanbo's full-sized avatar
🐢
Reminder: I need to walk more

Boris okplanbo

🐢
Reminder: I need to walk more
View GitHub Profile
@okplanbo
okplanbo / OneLineFizzBuzz.py
Created May 12, 2018 16:00
Yet another solution to FizzBuzz in one line (Python3)
for m in range(1,100): print("FizzBuzz" if (m%15==0) else"Fizz" if (m%3==0) else "Buzz" if (m%5==0) else m)
@okplanbo
okplanbo / getEquilibrium.java
Created May 14, 2018 14:26
Finding an equilibrium index in an int array
public int getEquilibrium(int[] array) {
long totalSum = sum(array);
long lowSum = 0L;
for (int i = 0; i < array.length; i++) {
totalSum -= array[i];
if (lowSum == totalSum) {
return i;
}
lowSum += array[i];
}
@okplanbo
okplanbo / snake.html
Last active April 20, 2024 16:06
snake game (javascript, canvas, setInterval)
<canvas id="gc" height="600" width="600" style="margin:auto; display: block;"></canvas>
<script type="text/javascript">
window.onload = function() {
canvas = document.getElementById('gc');
context = canvas.getContext('2d');
document.addEventListener('keydown', keyPush);
setInterval(game, 40);
}
let movX = 0;
@okplanbo
okplanbo / alarm.py
Created July 13, 2018 16:44
Simple silent alarm widget for windows using tkinter
# Simple silent alarm widget for windows
# Set time in seconds and text below or pass them in cmd like this: python timer 5 hello
import sys
import time
from tkinter import *
from tkinter.messagebox import showinfo
if (len(sys.argv) > 1):
delay = float(sys.argv[1])
@okplanbo
okplanbo / intersection.py
Created July 23, 2018 10:20
Find common characters in two strings
#Given two strings find characters present in both. E.g, for "harpoon" and "countryside", the answer is "nro".
#https://www.talentrider.com
def intersection(a, b):
return ''.join(set(a) & set(b))
@okplanbo
okplanbo / Fisher–Yates (Knuth) array shuffle
Created August 26, 2018 10:17
O(n) complexity, ES6 version
function shuffle(arr) {
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return arr;
}
ES7+ React/Redux/React-Native snippets:
dsznajder.es7-react-js-snippets
ESLint:
dbaeumer.vscode-eslint
More human-friendly TS errors:
https://github.com/yoavbls/pretty-ts-errors
Prettier - Code formatter:
Code:
VSCode, Git, Node, NVM, PuTTY
Notepad++, Sublime
Foobar, VLC, 7z, Steffen Gerlach Scanner
TG, Discord
FireFox, Chrome (OneTab, Adblock, React devtools, Grid Ruler, Measure dimensions, FullPage)
f.lux (or use built-in nightshift feature in win10)
Paint NET
Libre Office
@okplanbo
okplanbo / make_file_list.bat
Last active May 1, 2024 13:05
Win script for making file list. Recursively searches non-hidden, non-sys files in a current folder and makes a list of them with paths in txt format
@echo off
setlocal enabledelayedexpansion
set "outputFile=files_list.txt"
:: Change the code page to UTF-8 to handle Cyrillic characters
chcp 65001
if exist "%outputFile%" (
del "%outputFile%"
)
@okplanbo
okplanbo / mac_install_config.txt
Last active June 9, 2023 21:06
Webdev tools for mac install sequence in natural language
Homebrew
Git cli
Chrome + extensions
Sublime Text
VScode + Extensions
Node, NPM, nvm
Yarn
Serve - https://github.com/vercel/serve/
Openshift cli
Python