Skip to content

Instantly share code, notes, and snippets.

View nbrochu's full-sized avatar
🐍
Snek

Nicholas Brochu nbrochu

🐍
Snek
View GitHub Profile
@nbrochu
nbrochu / browser.py
Last active June 9, 2019 17:13
Python Pseudo-Electron Boilerplate (Windows)
import os
import sys
import math
import time
import threading
import webbrowser # To launch the remote debugging page
import win32api #
import win32con # pip install pywin32
import win32gui #
@nbrochu
nbrochu / ocr.ipynb
Created July 11, 2017 23:50
OCR Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

EC2/Ubuntu OpenVPN server config

  • open UDP port 1194 using EC2 security groups
sudo apt-get install openvpn
sudo openvpn —genkey —secret /etc/openvpn/openvpn-key.txt
sudo modprobe iptable_nat
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -s 10.8.0.1/2 -o eth0 -j MASQUERADE
@nbrochu
nbrochu / gist:2008952
Created March 9, 2012 22:03 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p0
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1333785)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p194 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
# Generating a unique passkey for each user(to use with XBT Tracker) and injecting it in the torrent file.
# This is for Rails.
require 'bencode' # sudo gem install bencode
require 'digest/sha1'
class TorrentsController < ApplicationController
def download_example_torrent
# Decode the torrent file using the bencode gem
# Generating the info_hash from a torrent file (binary & urlencoded)
require 'bencode' # sudo gem install bencode
require 'digest/sha1'
require 'cgi' # Not needed in rails
decoded_torrent = BEncode.load_file("public/files/example.torrent")
info_hash = ([Digest::SHA1.hexdigest(decoded_torrent["info"].bencode)].pack("H*")).downcase
url_encoded_info_hash = CGI.escape(info_hash)
<?php
// Much simpler, no? I could be wrong, PHP isn't my primary language!
$data=bdecode('example.torrent');
$user=mysql_fetch_row(mysql_query("SELECT torrent_pass_version FROM xbt_users WHERE uid={$uid}"));
$torrent_pass_version=$user[0];
$config=mysql_fetch_row(mysql_query("SELECT value FROM xbt_config WHERE name='torrent_pass_private_key'"));
$torrent_pass_private_key=$config[0]