Skip to content

Instantly share code, notes, and snippets.

View cstrap's full-sized avatar
🐍

Christian Strappazzon cstrap

🐍
View GitHub Profile
@cstrap
cstrap / workbook.md
Created July 31, 2023 08:09 — forked from leisurelicht/workbook.md
Export queryset to Excel workbook
from django.http import HttpResponse
from .utils import queryset_to_workbook

def download_workbook(request):
    queryset = User.objects.all()
    columns = (
        'first_name',
        'last_name',
        'email',
@cstrap
cstrap / how-to-connect-an-iOS-device-to-your-computer-using-SOCKS.md How to connect an iOS device to your computer via a SOCKS proxy. Say you're running a virtual machine on your work computer. Say this machine, for whatever reason, can only connect to the internet over NAT - as in, it does not get it's own IP address. Say this VM is running a webserver, and you need a device outside of your computer to connect t…

How to connect an iOS device to your computer via a SOCKS proxy

Say you're running a virtual machine on your work computer. Say this machine, for whatever reason, can only connect to the internet over NAT - as in, it does not get it's own IP address. Say this VM is running a webserver, and you need a device outside of your computer to connect to it.

If only there was a way to get your work computer to 'share' it's network, so that you could get at that VM… Here's how you do it!

For all instructions, I assume your work computer is a mac

  1. Get your computer's IP address:
@cstrap
cstrap / ubuntu_agnoster_install.md
Created June 30, 2023 09:45 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

@cstrap
cstrap / gist:f33e2763e898ae70184969f7a950ad60
Created April 6, 2022 09:17 — forked from fael/gist:1212446
Javascript Easter Egg - Konami Code
var kkeys = [],
konami = "38,38,40,40,37,39,37,39,66,65";
easterEgg = function (e) {
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(konami) == 0) {
var ee = $('<div id="ee">TROLOLOL</div>');
ee.css({
@cstrap
cstrap / latency.txt
Created November 15, 2021 13:17 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@cstrap
cstrap / fix_virtualenv
Last active December 3, 2019 08:55 — forked from tevino/fix_virtualenv
Fix python virtualenv after python update
#!/bin/bash
sh <(curl -sL https://gist.githubusercontent.com/cstrap/39459fdc0ffab9405166596c8969d3be/raw/e5932f9923e57dcb41db32fe5bed9acc6d584be4/fix_virtualenv)
@cstrap
cstrap / nginxproxy.md
Created May 20, 2019 14:45 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cstrap
cstrap / packtpub_get_your_library_books.js
Created November 24, 2017 14:56 — forked from tuxskar/packtpub_get_your_library_books.js
Create wget commands for all claimed books on packtpub
/*
== Adapted from the code over at https://gist.github.com/graymouser/a33fbb75f94f08af7e36 ==
Log into your account at packtpub.com and save the cookies with the "cookies.txt" Chrome extension or the "Export cookies" Firefox extension into the file cookies.txt.
Then open the console in your browsers dev tools and paste the following code.
You will get a list of wget commands that you can copy and paste as a whole into a terminal to download all books.
Example: wget --load-cookies=cookies.txt --content-disposition "https://packtpub.com//ebook_download/20217/mobi" -O "R Data Visualization Cookbook.mobi"
If you only want some filetypes, edit the "pattern" vaiable accordingly.
@cstrap
cstrap / copy-from-time-machine.sh
Created October 31, 2017 13:06 — forked from vjt/copy-from-time-machine.sh
Copy data from a Time Machine volume mounted on a Linux box.
#!/bin/bash
#
# Copy data from a Time Machine volume mounted on a Linux box.
#
# Usage: copy-from-time-machine.sh <source> <target>
#
# source: the source directory inside a time machine backup
# target: the target directory in which to copy the reconstructed
# directory trees. Created if it does not exists.
#