Skip to content

Instantly share code, notes, and snippets.

@sgraaf
sgraaf / ddp_example.py
Last active November 7, 2024 05:39
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
@sshleifer
sshleifer / tweet.md
Last active July 15, 2020 13:36
Tweet Translations using Marian MTModels

See Model List, Docs

en_tweet = ["Today we are releasing 1,008 machine translation models, covering combinations of 140 different languages.",
            "They were trained by @jorgtiedemann with @marian, and converted by @sam_shleifer.", 
            "Find your language here"]

en-da: I dag frigiver vi 1.008 maskinoversættelsesmodeller, der dækker kombinationer af 140 forskellige sprog. De blev uddannet af @jorgtiedemann med @marian, og konverteret af @sam_shleifer. Find dit sprog her:

@andreyryabtsev
andreyryabtsev / backmatting.ipynb
Last active June 5, 2024 04:56
BackMatting.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mpodriezov
mpodriezov / express_i18n_nunjucks.js
Created August 9, 2019 11:12
Internationalization and localization example using express + i18n and nunjucks
// usual requirements
const express = require('express');
const cookieParser = require('cookie-parser');
const i18n = require('i18n');
const nunjucks = require('nunjucks');
const app = module.exports = express();
i18n.configure({
// setup some locales - other locales default to en silently
locales: ['en', 'fr', 'de', 'ru'],
# python3 version, derived from python2 version https://gist.github.com/dergachev/7028596
#
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python3 simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
@maxim5
maxim5 / pretrained_word2vec_lstm_gen.py
Last active July 2, 2023 10:40
Text generator based on LSTM model with pre-trained Word2Vec embeddings in Keras
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
__author__ = 'maxim'
import numpy as np
import gensim
import string
@luciopaiva
luciopaiva / _Full-socketio-client-and-server-example.md
Last active January 24, 2025 14:53
Full socket.io client and server example

Full socket.io client and server example

Last updated: 2021-02-21, tested with socket.io v3.1.1

This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.

To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.

If you're looking for examples using frameworks, check these links:

@kawanet
kawanet / material-colors.json
Last active March 23, 2025 04:07
Material Design Style Color Palette as JSON
{
"red": {
"50": "#ffebee",
"100": "#ffcdd2",
"200": "#ef9a9a",
"300": "#e57373",
"400": "#ef5350",
"500": "#f44336",
"600": "#e53935",
"700": "#d32f2f",
@ZAYEC77
ZAYEC77 / fabricJS history
Created September 12, 2015 10:30
History implementation for fabricJS
function (canvas, container) {
var history = {state: [], lock: true, mods: 0};
app.history = history;
canvas.on('history.lock', function () {
history.lock = true;
});
canvas.on('history.unlock', function () {
history.lock = false;
@denji
denji / nginx-tuning.md
Last active April 17, 2025 07:26
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.