Skip to content

Instantly share code, notes, and snippets.

View ma7dev's full-sized avatar
🏗️
say/do <<< 1/2

Mazen ma7dev

🏗️
say/do <<< 1/2
View GitHub Profile
@kepano
kepano / obsidian-web-clipper.js
Last active May 21, 2024 10:13
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@ashleyha
ashleyha / hf_helsinki-nlp_translation.py
Created December 16, 2020 17:57
example using the huggingface transformers library with the Helsinki-NLP/opus-mt-ru-en model
from transformers import MarianTokenizer, AutoModelForSeq2SeqLM
text = 'Рада познакомиться'
mname = 'Helsinki-NLP/opus-mt-ru-en'
tokenizer = MarianTokenizer.from_pretrained(mname)
model = AutoModelForSeq2SeqLM.from_pretrained(mname)
input_ids = tokenizer.encode(text, return_tensors="pt")
outputs = model.generate(input_ids)
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(decoded) #Nice to meet you
@leiteg
leiteg / back.html
Last active September 4, 2022 20:41
Anki theme with Dracula-inspired colors.
{{FrontSide}}
<div class="outside"> Answer</div>
<div class="card-back shadow">
<div class="back">{{Back}}</div>
{{#BackOpt}}
<hr />
<div class="backopt">{{BackOpt}}</div>
@TheCedarPrince
TheCedarPrince / .tmux.conf
Last active February 21, 2021 16:56
My tmux Configuration File
######################################################################
# START OF PLUGINS
######################################################################
# Plugin manager for tmux
set -g @plugin 'tmux-plugins/tpm'
# Simple tmux options for anyone
set -g @plugin 'tmux-plugins/tmux-sensible'
@TheCedarPrince
TheCedarPrince / .alacritty.yml
Created October 26, 2020 15:54
My Alacritty Configuration File
env:
TERM: xterm-256color
# Colors (Gruvbox dark)
colors:
# Default colors
primary:
# hard contrast: background = '#1d2021'
background: '#282828'
# soft contrast: background = '#32302f'
@TheCedarPrince
TheCedarPrince / init.vim
Last active November 17, 2022 09:28
My (neo)Vim Configuration File
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VIM SETTINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TURNS LINE NUMBERING ON
set nu
" TRIGGER `autoread` WHEN FILES CHANGES ON DISK
set autoread
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
@sgraaf
sgraaf / ddp_example.py
Last active April 23, 2024 11:13
PyTorch Distributed Data Parallel (DDP) example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
import torch
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
from torch.utils.data import DataLoader, Dataset
from torch.utils.data.distributed import DistributedSampler
from transformers import BertForMaskedLM
# Create 3 tunnels, each for different ports, with only https enabled
# This way the ngrok process stays bellow the Free plan limit (4 tunnels)
authtoken: ...
log: ngrok.log
tunnels:
first:
addr: 3000
proto: http
bind_tls: true
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@scarecrow1123
scarecrow1123 / dist_log.py
Created September 26, 2019 05:29
Example for handling multiprocess logging when using `torch.distributed`
import argparse
import logging
from logging import Filter
from logging.handlers import QueueHandler, QueueListener
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.multiprocessing import Queue