Skip to content

Instantly share code, notes, and snippets.

View cstrap's full-sized avatar
🐍

Christian Strappazzon cstrap

🐍
View GitHub Profile
/*
Source code from this gist: https://gist.github.com/javilobo8/097c30a233786be52070986d8cdb1743
Thanks also and other contributors with their comments.
https://medium.com/@drevets/you-cant-prompt-a-file-download-with-the-content-disposition-header-using-axios-xhr-sorry-56577aa706d6
https://stackoverflow.com/questions/41938718/how-to-download-files-using-axios
*/
/************************
@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 / resizer-text
Created September 6, 2021 08:17
From article: [3 easy CSS tricks for responsive websites I use for every project](https://sjorswijsman.medium.com/3-easy-css-tricks-for-responsive-websites-i-use-in-every-project-68ec334a1522)
html {
font-size: calc(60% + 0.8vmin);
}
main {
max-width: 40rem;
margin: 0 auto;
}
* {
font-size: 1rem;
}
#!/bin/bash
ZDOCKER_IMAGE=zuppalalambda
ZCOMMAND=$1
ZENV=$2
if [ $# -eq 0 ] ; then
echo -e "\033[0;31mNo arguments supplied\033[0m"
echo "Usage: ./zuppa <zappa command> <zappa environment>"
exit 1
fi
attrs = {'some_property': 'some_value'}
Obj = type('ObjectClassName', (object,), attrs)
obj = Obj()
print(obj.some_property)
# >>> some_value
@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)