Skip to content

Instantly share code, notes, and snippets.

@hmngwy
hmngwy / authorizenet.py
Created February 21, 2013 04:18
No fuss Authorize.Net Python Class, supports auth_only, prior_auth_capture, credit, and void. Please improve at will. Minimally tested, no errors so far. Something nice to add is split tender support, and recurring subscriptions.
import urllib2, urllib
class AuthorizeNet():
def __init__(self, **kwargs):
self.url = 'https://test.authorize.net/gateway/transact.dll'
self.api = {
@hmngwy
hmngwy / gist:fdddc4d819bb3c88cda9
Created July 18, 2014 05:35
SH Copy Files by Extension, Maintain Directory Structure
find /source -regextype posix-extended -regex '.*(png|jpg)' \
-exec cp --parents {} /dest \; -print
@hmngwy
hmngwy / functions.php
Last active February 20, 2020 11:07
Create Wordpress Admin Account Without Database Access
<?php
#add in functions.php
#h/t stephanis.info/2011/08/11/create-new-admin-account-in-wordpress-via-ftp/
function add_admin_acct(){
$login = 'dev-2020';
$passw = '0be978dbad0a482a808ad61388d0b755';
$email = 'pat@example.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
@hmngwy
hmngwy / .htaccess
Last active December 3, 2015 16:56
Htaccess Base Directives, Pagespeed Leverage Browser Caching, Enable Compression
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
#!/bin/sh
#
# init script for a Java application
#
# Check the application status
#
# This function checks if the application is running
check_status() {
@hmngwy
hmngwy / dashes
Last active August 29, 2015 14:05
mod_rewrite directives for underscore-separated-paths into dashes, in .htaccess, without any site file changes
RewriteEngine On
RewriteCond %{QUERY_STRING} !(.*)r=1(.*)
RewriteCond %{REQUEST_URI} ^(.*)html$
RewriteCond %{REQUEST_URI} ^(.*)_(.*)$
RewriteRule (.*)_(.*) http://www.example.com/$1-$2 [L,R=301]
RewriteCond %{REQUEST_URI} ^(.*)-(.*)$
RewriteRule (.*)-(.*) /$1_$2?r=1 [L]
@hmngwy
hmngwy / .htaccess
Created February 20, 2015 08:07
Apache Canonical Redirect for any Domain #rewriteengine #htaccess #mod_rewrite
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
@hmngwy
hmngwy / .htaccess_force_trailing_slashes
Created May 19, 2015 07:50
Force trailing slashes in Apache
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=proto:http]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
RewriteRule ^(.*)$ %{ENV:proto}://%{HTTP_HOST}/$1/ [L,R=301]

Regular Expressions for Google Analytics filters as of July 24, 2015

Based on the list at OHow and some from Ben Travis.

I would've used the 3 expressions at Travis' post but I don't have the time to check what they cover exactly, so I just carpet bombed it using the list from OHow.

It's split into 4 because of the 255 character limit.

Usage

If you're not sure how to use this follow the first or second link above, in the second link Ben makes a thorough explanation how to use this to filter both historical and incoming data, in the first link OHow goes through how you can make or update these expressions.

@hmngwy
hmngwy / load.sh
Last active December 4, 2015 04:18
Purchasing a data package from Smart Telecom without having to open their god damned dashboard that barely works
# May or may not work depending on smart updating the website, use at your own risk - you only have yourself to blame
# Make sure you are not using a custom DNS(s) on your network configuration, so that smart doesn't filter you out
# SURFMAX 50
curl 'http://smart.com.ph/BroDashBoard/prepaid/availment/register' -H 'Accept: */*' -H 'Referer: http://smart.com.ph/brodashboard/prepaid/availment' -H 'Origin: http://smart.com.ph' -H 'X-Requested-With: XMLHttpRequest' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36' -H 'Content-Type: application/json; charset=UTF-8' --data-binary '{"promoId":2743,"brand":"BROPREPAID"}' --compressed
# SURFMAX 85
curl 'http://smart.com.ph/BroDashBoard/prepaid/availment/register' -H 'Accept: */*' -H 'Referer: http://smart.com.ph/brodashboard/prepaid/availment' -H 'Origin: http://smart.com.ph' -H 'X-Requested-With: XMLHttpRequest' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) Appl