Skip to content

Instantly share code, notes, and snippets.

@askaidau
askaidau / update-geoip.sh
Created April 5, 2017 11:04
Update GeoIP data files automatically
#!/bin/bash
cd /usr/share/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz || { echo 'Could not download GeoLiteCountry, exiting.' ; exit 1; }
#wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz || { echo 'Could not download GeoLiteCity, exiting.' ; exit 1; }
gunzip -f GeoIP.dat.gz
#gunzip -f GeoLiteCity.dat.gz
echo "y"
#|mv GeoLiteCity.dat GeoIPCity.dat
@askaidau
askaidau / image-compactr
Last active April 1, 2017 09:55
Image Compactr (PHP), requires pngquant
#!/usr/bin/php
<?php
if( "cli"!==php_sapi_name() ) exit;
if( !isset($argv,$argv[1]) ){
cli_error("usage: ./".basename(__FILE__)." <path>");
cli_error("example: ./".basename(__FILE__)." /data/sites/example.com/fat-images/");
exit;
}
@askaidau
askaidau / php7-memcached-session-fix.php
Created October 10, 2016 08:46
PHP 7 Memcached session_regenerate_id() E_RECOVERABLE_ERROR Fix
<?php
// affects (but not limited to) stock PHP 7.0x on Ubuntu 16.04.3
// source: https://bugs.php.net/bug.php?id=71187
// assuming we are using memcached for session store
ini_set("session.save_handler", "memcached");
ini_set("session.save_path", "localhost:11211");
// we need to extend and override the read method to force it to return string value
// in order to comply with PHP 7's more strict type checking
@askaidau
askaidau / redirect-http-to-https.conf
Created January 30, 2016 05:22
NGINX Sample Site Configs
server {
listen 80;
server_name some-example-domain.com;
return 301 https://some-example-domain.com$request_uri;
}
@askaidau
askaidau / port80to3k.sh
Created July 24, 2014 03:50
Node.js HTTP Port Enabler
#!/bin/bash
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
<meta name="viewport" content="width=device-width, minimal-ui, user-scalable=no, initial-scale=1">
<meta name="format-detection" content="telephone=no">
/* basic reset */
html,body,p,ul,ol,dl,li,dt,dd,h1,h2,h3,h4,h5,h6 {
margin:0;padding:0;
}
html {
-webkit-text-size-adjust: none;
}
ul,ol {
list-style:none
}
.fifty{
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";/*IE8*/
filter:alpha(opacity=50);/*IE5-7*/
opacity:.5;/*good browsers*/
}
@askaidau
askaidau / social-sharing.txt
Last active May 5, 2022 03:32
Social sharing URL with all parameters listed
Facebook
========
https://www.facebook.com/dialog/feed?app_id=458358780877780
&link=https://developers.facebook.com/docs/reference/dialogs/
&picture=http://fbrell.com/f8.jpg
&name=Facebook%20Dialogs
&caption=Reference%20Documentation
&description=Using%20Dialogs%20to%20interact%20with%20users.
&redirect_uri=https://mighty-lowlands-6381.herokuapp.com/
@askaidau
askaidau / osx_dedupe_launcher.sh
Created June 4, 2013 16:26
Fixes duplicates in OS X "open file with..." launcher.
#!/bin/sh
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\
LaunchServices.framework/Versions/A/Support/\
lsregister -kill -r -domain local -domain user