Skip to content

Instantly share code, notes, and snippets.

View wizo06's full-sized avatar

wizo wizo06

View GitHub Profile
@wizo06
wizo06 / asyncJS-test
Created May 19, 2018 15:19
snippet to test if a function has async calls inside it
var work = process._getActiveHandles().length + process._getActiveRequests().length;
foo();
var newWork = (process._getActiveHandles().length + process._getActiveRequests().length) - work;
if(newWork > 0) {
console.log("asynchronous work took place.");
}
@wizo06
wizo06 / getLongestSubstring.js
Last active June 9, 2018 22:30
To run: "node getLongestSubstring.js <string>". Get longest substring in alphabetical order from a string. Javascript-specific methods were avoided as much as possible. Complexity is O(n).
/*
* Assume s is a string of lower case characters.
*
* Write a program that prints the longest substring of s
* in which the letters occur in alphabetical order.
*
* For example, if s = 'azcbobobegghakl', then your program should print
* "Longest substring in alphabetical order is: beggh"
*
* In the case of ties, print the first substring.
@wizo06
wizo06 / collatz.js
Last active June 22, 2018 00:06
To run: "node collatz.js <integer>". Collatz Conjecture in Javascript. Left column is the number of steps to get to 1.
// Warning: maximum value for a variable of type Number (no bitwise or shift operators allowed): 9,007,199,254,740,991
let x = parseInt(process.argv[2]);
if(isNaN(x)) process.exit(1);
else{
if(x < 1){
process.exit(1);
}
else{
let n = 0; console.log(`${n} ${x}`);
while (x !== 1){
@wizo06
wizo06 / collatz.cpp
Last active June 22, 2018 00:02
To run: Compile and "./collatz <integer>". Collatz Conjecture in C++. Left column is the number of steps to get to 1.
// Warning: maximum value for a variable of type int: 2,147,483,647
#include <stdio.h>
int main(int argc, char *argv[]){
if(argc == 2){
int x = atoi(argv[1]); int n = 0; printf("%i %i\n",n,x);
if(x < 1){
exit(1);
}
else{
while(x != 1){
@wizo06
wizo06 / Your push would publish a privaate email address
Created February 5, 2020 21:34
If you made some commits with a privated email and THEN changed git's email, you will still get the error. Follow these steps to fix the error.
git config --global user.email "526473+gb96@users.noreply.github.com"
git rebase -i
git commit --amend --reset-author
git rebase --continue
git push
@wizo06
wizo06 / dot.sh
Last active April 25, 2022 09:04
#!/bin/bash
sudo apt-get install curl zsh git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
cd ~/.oh-my-zsh/custom/plugins && \
git clone https://github.com/zsh-users/zsh-syntax-highlighting && \
curl -s https://gist.githubusercontent.com/wizo06/3dce572a8ba5ff7ddbf120829f541b7c/raw/d9ebbd0a3935264bf9cc2777a62aa887bf57d9a9/wizo-min.zsh-theme > ~/.oh-my-zsh/custom/themes/wizo-min.zsh-theme && \
sed 's/^ZSH_THEME="robbyrussell"/ZSH_THEME="wizo-min"/' ~/.zshrc > ~/.zshrc_new && mv ~/.zshrc_new ~/.zshrc && \
sed 's/^plugins=(git)/plugins=(git zsh-syntax-highlighting)/' ~/.zshrc > ~/.zshrc_new && mv ~/.zshrc_new ~/.zshrc && \
source ~/.zshrc
@wizo06
wizo06 / nginx101.md
Last active February 25, 2021 23:29
@wizo06
wizo06 / wizo.zsh-theme
Last active May 4, 2021 05:50
My personal oh-my-zsh theme
local date='%F{008}%D{%Y.%m.%d}%f'
local time='%F{008}%*%f'
local timezone='%F{008}%D{%Z}%f'
local user='%B%F{129}%n%f%b'
local machine='%B%F{045}%m%f%b'
local current_dir='%B%F{147}%~%f%b'
local git_info='%B$(git_prompt_info)%b'
PROMPT="${user}@${machine} in ${current_dir} ${git_info}
%F{015}$%f "
@wizo06
wizo06 / kana_to_kanji.py
Created April 15, 2021 20:50
Python script that converts kana to their original kanji character
kana_dict = {
'あ': '安',
'ア': '阿',
'い': '以',
'イ': '伊',
'う': '宇',
'ウ': '宇',
'え': '衣',
'エ': '江',
'お': '於',
@wizo06
wizo06 / gist:95fa89c11e8cdf20fbde9800b574a0b4
Created June 12, 2021 17:58
razer keyboard caps lock crash fix for ubuntu
sudo add-apt-repository ppa:openrazer/stable
sudo apt update
sudo apt install openrazer-meta
sudo modprobe razerkbd
xinput set-prop "AT Raw Set 2 keyboard" "Device Enabled" 0
cd /etc/X11/
sudo mkdir xorg.conf.d
cd xorg.conf.d/
sudo touch 20-razer.conf
sudo nano 20-razer.conf