Skip to content

Instantly share code, notes, and snippets.

Avatar
☢️
mentally unavailable

Fahad Hossain fa7ad

☢️
mentally unavailable
View GitHub Profile
@fa7ad
fa7ad / mpvc.sh
Created Mar 30, 2020
Cast Youtube to MPV
View mpvc.sh
#!/bin/sh
#
# fyr - 2019 (c) MIT | /bin/sh mpvc
# control mpv remotely using JSON ipc
# https://mpv.io/manual/master/#json-ipc
SOCKET=${MPVC_SOCKET:-/tmp/mpvsocket}
MPVOPTIONS="--no-audio-display"
usage() {
View example_filter_1.js
const data = ['apple', 'banana', 'orange', 'strawberry']
const isNotBerry = fruit => !/berry/i.test(fruit)
const fruitsThatArentBerries = data.filter(capitalizeFirst)
View stringIntAdd.js
function add(a, b) {
let c = 0;
let n = a.length > b.length ? a : b
let m = n === a ? b.padStart(a.length, 0) : a.padStart(b.length, 0)
let r = []
for(let i = n.length - 1;i >= 0; i--){
let s = c > 0 ? c-- : 0;
s += +n[i] + +m[i]
if (s > 9) c++
r.unshift((s%10)+"")
@fa7ad
fa7ad / countryToEmoji.js
Last active Oct 12, 2019
ISO Country code to Emoji Flag
View countryToEmoji.js
function countryToEmoji (code) {
code = code.toUpperCase()
const [e1, e2] = [code.codePointAt(0) + 127397, code.codePointAt(1) + 127397]
return String.fromCodePoint(e1) + String.fromCodePoint(e2)
}
View countryToEmoji.js
function countryToEmoji (code) {
code = code.toUpperCase()
const [e1, e2] = [code.codePointAt(0) + 127397, code.codePointAt(1) + 127397]
return String.fromCodePoint(e1) + String.fromCodePoint(e2)
}
View 8puzzle.py
import math
from random import randrange
from copy import deepcopy
class Puzzle:
def __init__(self):
self.board = [
[1, 2, 3],
[4, 5, 6],
@fa7ad
fa7ad / main.cc
Last active Nov 8, 2018
MatrixChainMult.cpp
View main.cc
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;
template <int T>
void multMatrix(array<array<int, T>, T> a, array<array<int, T>, T> b,
array<array<int, T>, T> &res) {
int i, j, k;
@fa7ad
fa7ad / code.js
Created May 3, 2018
Generate all possible 10 digit base-3 combinations
View code.js
const fs = require('fs')
var combination = Array.from({length: 59049}, (_, num) => (
('0000000000' + Number(num).toString(3)).slice(-10)
))
fs.writeFileSync('combos.txt', combination.join('\n'))
View operator-overloading.cc
#include <iostream>
using namespace std;
class Distance {
int feet;
int inches;
public:
Distance(): feet(0), inches(0){}
Distance(int f, int i): feet(f), inches(i){
if (feet < 0 && inches < 0) {
View mirrorlist
##
## Manjaro Linux default mirrorlist
## Generated on 2018-03-15 16:20
##
## Please use 'pacman-mirrors -f [NUMBER] NUMBER' to modify mirrorlist
## (Use 0 for all mirrors)
##
## Country : Bangladesh