Skip to content

Instantly share code, notes, and snippets.

@DanielHemmati
DanielHemmati / settings.json
Created February 22, 2022 12:01 — forked from jayphelps/settings.json
Modifications on top of "Community Material Theme Palenight" Before and after: https://twitter.com/_jayphelps/status/1259321038728560642?s=20
// Modify your settings.json to add these. Customize further how you prefer.
{
"workbench.editor.highlightModifiedTabs": true,
"workbench.editor.tabCloseButton": "off",
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#ffffff06",
"editor.foreground": "#acb3db",
"selection.background": "#89DDFF",
"progressBar.background": "#89DDFF",
"textLink.foreground": "#89DDFF",
@DanielHemmati
DanielHemmati / generateAdjacencyLst.py
Last active January 22, 2022 00:15
Generate adjacency list for undirected graph
# source: https://towardsdatascience.com/search-algorithm-breadth-first-search-with-python-50571a9bb85e
def generateAdjacencyLst(edges):
adjacencyList = defaultdict(list)
for u, v in edges:
adjacencyList[u].append(v)
adjacencyList[v].append(u)
return adjacencyList
edges = [['A', 'B'], ['A', 'C'], ['B', 'D'], ['B', 'E'], ['C', 'F'], ['C', 'G'], ['D', 'H'], ['D', 'I'], ['E', 'J'], ['E', 'K'], ['F', 'L'], ['F', 'M']]
@DanielHemmati
DanielHemmati / textButtonRadius.dart
Created June 15, 2021 16:01
remove textButton border radius
Expanded(
child: TextButton(
// this is my solution didn't find it anywhere
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.red),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(borderRadius: BorderRadius.zero),
),
),
onPressed: () {
@DanielHemmati
DanielHemmati / checkbox with react.js
Created April 21, 2021 11:54
why write checkbox again
import React, { useReducer, useState } from "react";
const initialTodos = [
{
id: "a",
task: "Learn React",
complete: false,
},
{
id: "b",
@DanielHemmati
DanielHemmati / about.md
Created March 20, 2021 16:00 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@DanielHemmati
DanielHemmati / command-line-color.js
Last active February 27, 2021 16:59
change color in command line with node js
// here is the source
// https://stackoverflow.com/a/41407246/7516735
console.log("\x1b[36m%s\x1b[0m", "I am cyan"); //cyan
console.log("\x1b[33m%s\x1b[0m", stringToMakeYellow);
const Reset = "\x1b[0m";
const Bright = "\x1b[1m";
const Dim = "\x1b[2m";
const Underscore = "\x1b[4m";
@DanielHemmati
DanielHemmati / listAllDocIndb.js
Created February 24, 2021 21:13
if you want to list all of the documents in your db, use this code
const res = await client
.db("daniel_is_here")
.collection("test")
.find({})
.toArray();
console.log(res);
@DanielHemmati
DanielHemmati / flattenArray.js
Created February 8, 2021 13:58
flat array like a boss LOL
const arrays = [[10], 50, [100, [2000, 3000, [40000]]]];
console.log(arrays.flat(Infinity));
@DanielHemmati
DanielHemmati / find odd int
Created February 1, 2021 20:17
if you want to find the number in array which repeated odd number of times you can use this
let input1 = [1, 2, 3, 3, 3, 2, 3, 1, 5];
const findOdd2 = (xs) => xs.reduce((a, b) => a ^ b);
console.log(findOdd2(input1));
@DanielHemmati
DanielHemmati / tmux.conf
Created January 27, 2021 13:51 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000