Skip to content

Instantly share code, notes, and snippets.

View NegarMirgati's full-sized avatar
⚔️
The game is on

Negar NegarMirgati

⚔️
The game is on
View GitHub Profile
@sbailliez
sbailliez / vagrant-vmware-tech-preview-apple-m1-pro.md
Last active April 10, 2024 07:51
Vagrant and VMWare Tech Preview 21H1 on Apple M1 Pro

Vagrant and VMWare Tech Preview 21H1 on Apple M1 Pro

UPDATE November 20, 2022: VMWare Fusion 13

VMWare Fusion 13 is now released. Read Vagrant and VMWare Fusion 13 Player on Apple M1 Pro for the latest.

Summary

This document summarizes notes taken while to make the VMWare Tech preview work on Apple M1 Pro, it originated

@AFAgarap
AFAgarap / autoencoder-pytorch.ipynb
Last active April 28, 2024 12:30
PyTorch implementation of an autoencoder.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jetnew
jetnew / lstm_autoencoder.py
Last active September 16, 2022 02:49
LSTM Autoencoder using Keras
from keras.layers import LSTM, Dense, RepeatVector, TimeDistributed
from keras.models import Sequential
class LSTM_Autoencoder:
def __init__(self, optimizer='adam', loss='mse'):
self.optimizer = optimizer
self.loss = loss
self.n_features = 1
def build_model(self):
@MarvinT
MarvinT / black_code_prettify.json
Last active January 16, 2023 15:41
json you can paste into jupyter notebook's code prettify configuration that makes it use black to reformat your code instead of yapf.
{
"python": {
"library": "import json\ndef black_reformat(cell_text):\n import black\n import re\n cell_text = re.sub('^%', '#%#', cell_text, flags=re.M)\n try:\n reformated_text = black.format_str(cell_text, 88)\n except TypeError:\n reformated_text = black.format_str(cell_text, mode=black.FileMode(line_length=88))\n return re.sub('^#%#', '%', reformated_text, flags=re.M)",
"prefix": "print(json.dumps(black_reformat(u",
"postfix": ")))"
},
"r": {
"library": "library(formatR)\nlibrary(jsonlite)",
"prefix": "cat(toJSON(paste(tidy_source(text=",
"postfix": ", output=FALSE)[['text.tidy']], collapse='\n')))"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
From KERAS package
Fairly basic set of tools for real-time data augmentation on image data.
Can easily be extended to include new transformations,
new preprocessing methods, etc...
"""
@rluts
rluts / token_auth.py
Last active October 13, 2023 20:56
Token authorization middleware for Django Channels 2
from channels.auth import AuthMiddlewareStack
from rest_framework.authtoken.models import Token
from django.contrib.auth.models import AnonymousUser
from django.db import close_old_connections
class TokenAuthMiddleware:
"""
Token authorization middleware for Django Channels 2
"""
@Shourai
Shourai / Allowing SSH on a server with an active OpenVPN client.md
Last active October 5, 2023 06:32
Allowing SSH on a server with an active OpenVPN client

If you want to SSH to a VPS which is running openVPN do the following:
source: https://serverfault.com/questions/659955/allowing-ssh-on-a-server-with-an-active-openvpn-client

Enable

The problem is that the default gateway gets changed by OpenVPN, and that breaks your current SSH connection unless you set up appropriate routes before you start OpenVPN.

What follows works for me. It uses iptables and ip (iproute2). Below, it is assumed that the default gateway interface before OpenVPN is started is "eth0". The idea is to ensure that when a connection to eth0 is made, even if eth0 is not the default gateway interface anymore, response packets for the connection go back on eth0 again.

You could use the same number for the connection mark, firewall mark and routing table. I used distinct numbers to make the diffences between them more apparent.

Upload images to GitHub

  1. Create a new issue on GitHub.

  2. Drag an image into the comment field.

  3. Wait for the upload process to finish.

  4. Copy the URL and use it in your Markdown files on GitHub.

@aparrish
aparrish / understanding-word-vectors.ipynb
Last active May 10, 2024 14:19
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.