Skip to content

Instantly share code, notes, and snippets.

View saman-taghavi's full-sized avatar

saman saman-taghavi

View GitHub Profile
@antfu
antfu / doc-table.md
Last active October 14, 2023 20:09
Doc Table in Markdown

Example

Name

Description


@LanceMcCarthy
LanceMcCarthy / UltimateListIds.md
Last active April 21, 2024 23:13
List of Package Ids
Name Package Id Version Source
7Zip 7zip.7zip 19.0.0 winget
Altap Salamander salamander choco
Alt-Tab Terminator alt-tab-terminator choco
AutoHotkey Lexikos.AutoHotkey 1.1.33.02 winget
AutoHotkey Store Edition HaukeGtze.AutoHotkeypoweredbyweatherlights.com Latest msstore (via winget)
Carnac
#!/bin/bash
source /home/project/myenv/bin/activate
cd /home/project/server
PID=$(ps aux | grep 'uvicorn myapp:app' | grep -v grep | awk {'print $2'} | xargs)
if [ "$PID" != "" ]
then
kill -9 $PID
sleep 2
echo "" > nohup.out
echo "Restarting FastAPI server"
@mattiaerre
mattiaerre / useLocalStorage.js
Created April 29, 2020 02:12
React hook useReducerWithLocalStorage
import { useState } from 'react';
// credit: https://usehooks.com/useLocalStorage/
function useLocalStorage(key, initialValue) {
const [storedValue, setStoredValue] = useState(() => {
try {
const item = window.localStorage.getItem(key);
return item ? JSON.parse(item) : initialValue;
} catch (error) {
console.log(error);
@LucasMallmann
LucasMallmann / EslintNodeJS.md
Created September 30, 2019 22:59
Eslint and Prettier configuration for NodeJS and Express projects

Eslint and prettier config for nodejs and express projects

Eslint and Libs

You need to install eslint and some other config libs.

yarn add eslint prettier eslint-config-prettier eslint-plugin-prettier -D

yarn eslint --init

.eslintrc.js

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@carltondickson
carltondickson / gist:28a90ccfed2f6b697aba
Created March 12, 2015 11:53
Undo commit and push to the wrong branch
# Credit to http://www.iarp.ca/hobby/computing/36-git-committed-and-pushed-to-the-incorrect-branch
# Ensure you're in the branch that you commited to by accident.
git checkout master
# Reset the branch back one commit.
git reset --soft HEAD^
# Stash the changes
git stash
@brianclements
brianclements / Commit Formatting.md
Last active April 28, 2024 11:35
Angular Commit Format Reference Sheet

Commit Message Format

This specification is inspired by and supersedes the [AngularJS commit message format][commit-message-format].

We have very precise rules over how our Git commit messages must be formatted. This format leads to easier to read commit history.

Each commit message consists of a header, a body, and a footer.

@jonlabelle
jonlabelle / string-utils.js
Last active October 30, 2023 20:33
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@rochacbruno
rochacbruno / 0_with_subprocess_and_password_as_function.py
Created June 3, 2011 06:29
Executar comando do OS (unix) como root usando sudo no Python - run a command as root using sudo from Python
import subprocess
echo = subprocess.Popen(['echo','123'],
stdout=subprocess.PIPE,
)
sudo = subprocess.Popen(['sudo','-S','iptables','-L'],
stdin=echo.stdout,
stdout=subprocess.PIPE,
)