Skip to content

Instantly share code, notes, and snippets.

View akiross's full-sized avatar
🥷
Ninja

Alessandro Re akiross

🥷
Ninja
View GitHub Profile
from line_profiler import LineProfiler
def do_profile(follow=[]):
def inner(func):
def profiled_func(*args, **kwargs):
try:
profiler = LineProfiler()
profiler.add_function(func)
for f in follow:
profiler.add_function(f)
@jstnlvns
jstnlvns / git: gitignore.md
Created November 16, 2018 19:42
a gitignore cheatsheet

Git sees every file in your working copy as one of three things:

  1. tracked - a file which has been previously staged or committed;
  2. untracked - a file which has not been staged or committed; or
  3. ignored - a file which Git has been explicitly told to ignore.

Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are:

  • dependency caches, such as the contents of /node_modules or /packages
  • compiled code, such as .o, .pyc, and .class files

Nix Flake MVP

Goals

  • To provide Nix repositories with an easy and standard way to reference other Nix repositories.

  • To allow such references to be queried and updated automatically.

  • To provide a replacement for nix-channel, NIX_PATH and Hydra

@dideler
dideler / bot.rb
Last active March 13, 2025 10:14
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
def train_network(samples, neural_network, nr_epochs=10, batch_size=64):
optimizer = optim.Adam(neural_network.parameters())
neural_network.train()
for epoch_nr in range(nr_epochs):
sample_ids = np.random.shuffle(range(len(samples)))
for start in range(0, len(samples) // batch_size, batch_size):
mini_batch = samples[sample_ids[start: start + batch_size]]
boards, pis, vs = zip(*mini_batch)
@manuel-delverme
manuel-delverme / zero.py
Last active June 11, 2018 14:31
zero code
environment = environments.GoEnvironment(board_size=19)
player_mcts = mcts.MCTS(
environment,
networks.NeuralNetwork(board_size=environment.getStateSize(), action_size=environment.getActionSize()),
)
training_samples = collections.deque(maxlen=opt.training_samples_buffer_size)
for iteration_number in range(opt.num_iters):
@parmort
parmort / tmux_tc.md
Created March 26, 2018 21:47
Tmux TrueColor Setup

Tmux TrueColor (a.k.a. 24-bit color) Support

Prerequisites

To enable TrueColor for Tmux, you must make sure that you have two things:

  1. Tmux version 2.2 or higher. You can find out your version by running tmux -V
  2. You have a terminal that supports TrueColor (it may also be referenced by 24 bit color. To check if you do, run
@PetrGlad
PetrGlad / dropbox_upload_large.py
Created March 6, 2018 23:21
Upload large files to dropbox
import dropbox
import dropbox.files
CHUNK_SIZE = 4 * 1024 * 1024
def upload_stream(dbx, readable, dest_path):
d = readable.read(CHUNK_SIZE)
offset = len(d)
@narate
narate / create-hotspot.md
Last active February 17, 2025 02:58
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"
@mattattui
mattattui / index.html
Last active October 24, 2020 11:28
Vue + Paper
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Shape selection</title>
<!-- Vue for doing stuff-->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- Paper for handling graphics -->
<script src="https://unpkg.com/[email protected]/dist/paper-full.min.js"></script>
<!-- Axios for making API calls -->