Skip to content

Instantly share code, notes, and snippets.

View nomaster's full-sized avatar
🐧
Chaos Penguin

Mic Szillat nomaster

🐧
Chaos Penguin
View GitHub Profile
@nomaster
nomaster / sendfile.php
Last active August 29, 2015 14:02
X-Sendfile in PHP
<?php
sendfile() {
header( 'X-Sendfile: '.$file ); // Apache webserver
header( 'X-Accel-Redirect: '.$file ); // Nginx webserver
header( 'Content-Type: application/octet-stream' ); // set correct mime type here
header( 'Content-Disposition: attachment; filename='.$filename );
exit;
}
@nomaster
nomaster / streamfile.php
Last active August 29, 2015 14:02
Stream file in PHP
<?php
streamfile() {
header( 'Content-Length: '.filesize($file) );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename='.$filename );
readfile( $file );
exit;
}
@nomaster
nomaster / nginx.conf
Last active August 29, 2015 14:02
Nginx configuration for X-accel
http {
server {
listen 80;
server_name example.com;
location / {
rewrite ^/download/(.*) /sendfile.php?path=$1 last;
}
location /files {
Normalise your URLs!
Bad
/opt/db/functions.php&session=5698136136
/forum.php?user=21515&group=134&mode=table
Good

Keybase proof

I hereby claim:

  • I am nomaster on github.
  • I am nomaster (https://keybase.io/nomaster) on keybase.
  • I have a public key whose fingerprint is 3A89 632F 26CD 19CA 4A1A 9C30 1348 A0EF 87C3 D99A

To claim this, I am signing this object:

PING google-public-dns-a.google.com (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=54 time=13.8 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=8.63 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=7.99 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=54 time=8.23 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=54 time=8.86 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=54 time=8.77 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=54 time=9.09 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=54 time=8.94 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=54 time=9.34 ms
@nomaster
nomaster / .fonts.conf
Created July 12, 2012 09:38
Droid family default fonts
<!--?xml version="1.0"?>-->
<!--DOCTYPE fontconfig SYSTEM "fonts.dtd">-->
<!-- ~/.fonts.conf for per-user font configuration -->
<fontconfig>
<alias>
<family>serif</family>
<prefer>
<family>Droid Serif</family>
</prefer>
</alias>
@nomaster
nomaster / mplayer
Created August 20, 2012 20:37
mplayer wrapper to temporarily disable redshift
#!/bin/sh
killall -USR1 redshift
mplayer $1
killall -USR1 redshift
@nomaster
nomaster / ds9.conf
Created October 22, 2012 14:52
OpenVPN configuration for Freifunk node uplink
client
dev tun
auth-user-pass /etc/openvpn/ds9.txt
remote 78.47.11.70
ca /etc/openvpn/ds9.ca
remote-cert-tls server
script-security 1
@nomaster
nomaster / ds9.ca
Created October 22, 2012 14:54
OpenVPN authority certificate for Freifunk Rheinland
-----BEGIN CERTIFICATE-----
MIID7DCCA1WgAwIBAgIJAOXdetqNHHq8MA0GCSqGSIb3DQEBBQUAMIGrMQswCQYD
VQQGEwJERTEMMAoGA1UECBMDTlJXMRQwEgYDVQQHEwtEdWVzc2VsZG9yZjEgMB4G
A1UEChMXRnJlaWZ1bmsgUmhlaW5sYW5kIGUuVi4xFDASBgNVBAsTC1ZQTiB0ZXN0
aW5nMQwwCgYDVQQDEwNkczkxDDAKBgNVBCkTA2RzOTEkMCIGCSqGSIb3DQEJARYV
bm9tYXN0ZXJAY2hhb3Nkb3JmLmRlMB4XDTEyMDgxNTEyMjIxN1oXDTIyMDgxMzEy
MjIxN1owgasxCzAJBgNVBAYTAkRFMQwwCgYDVQQIEwNOUlcxFDASBgNVBAcTC0R1
ZXNzZWxkb3JmMSAwHgYDVQQKExdGcmVpZnVuayBSaGVpbmxhbmQgZS5WLjEUMBIG
A1UECxMLVlBOIHRlc3RpbmcxDDAKBgNVBAMTA2RzOTEMMAoGA1UEKRMDZHM5MSQw
IgYJKoZIhvcNAQkBFhVub21hc3RlckBjaGFvc2RvcmYuZGUwgZ8wDQYJKoZIhvcN