Skip to content

Instantly share code, notes, and snippets.

View Gabelbombe's full-sized avatar

Till Eulenspiegel Gabelbombe

  • The Deep Darkness, WA
View GitHub Profile
@Gabelbombe
Gabelbombe / gist:9277462
Last active August 29, 2015 13:56
Filtering Filmaker Pro for bad dates
<?php
$result = json_decode(file_get_contents('data_raw.json'), 1);
/**
* Array filtering by force
*/
$jacked = [];
foreach ($result AS $key => $obj) // creates a reduction of array parts
/**
* contravariance required so Empty can be used with Nodes ( Nothing <: T )
*/
class Tree[+T]
case object Empty extends Tree[Nothing]
case class Node[T](val elem: T, val left: Tree[T], val right: Tree[T]) extends Tree[T]
def inOrder[T](t: Tree[T]): List[T] = t match {
case Empty => Nil
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "GET, POST, OPTIONS"
@Gabelbombe
Gabelbombe / index.php
Created August 26, 2014 19:27
Mobile Redirect
<script type='text/javascript'>
(function(){
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
var mobile = (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\
@Gabelbombe
Gabelbombe / .bash_aliases
Created September 8, 2014 23:37
VPN connect and run setup commands in under osx
function tab ()
{
osascript 2>/dev/null <<EOF
tell application "System Events"
tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
activate
do script with command "cd \"$PWD\"; $*" in window 1
end tell
@Gabelbombe
Gabelbombe / redeemer.js
Last active December 14, 2015 18:46
Destiny promo code redeemer
/**
* ehime :: Jd Daniel
*
* Goto: http://www.bungie.net/en/User/coderedemption
* Paste/Run script in Firebug console
* ???
* Profit!
*/
var codes = [
@Gabelbombe
Gabelbombe / cartesian.php
Last active August 29, 2015 14:07
Build a cartesion array
$attributeValues = [
'color' => ['Red', 'White', 'Blue'],
'fabric' => ['Cloth', 'Silk']
'size' => range(1, 4),
];
/**
* Builds a Cartesian array based of sub array contents
*
* @param $set
@Gabelbombe
Gabelbombe / repeat-vs-firsttime.sql
Last active February 1, 2016 17:40
Magento: Customer Segmentation Reports (Repeat vs. First Time Buyers) in Donut Chart format (http://goo.gl/4MoAh0)
#################################################################
#################################################################
# ○ The number and percentage of customers who placed an order #
# ○ VS. number and percentage of repeat customer orders #
# #
# +------------------+-------+------------+ #
# | Type | Count | Percentage | #
# +------------------+-------+------------+ #
# | Total Customers | 35 | 100.0% | #
# | Single Customers | 1 | 2.9% | #
@Gabelbombe
Gabelbombe / paid-vs-coupon.sql
Last active August 29, 2015 14:07
Paid vs Coupon sales raw query
CREATE VIEW foodhub_magento.paid_vs_coupon AS ## One long ass view
SELECT '' AS 'promotion_used' # 'Promotion Used'
, '' AS 'promotion_code' # 'Promotion Code'
, COUNT(subtotal) AS 'times_used' # 'Times Used (Orders #)'
, SUM(subtotal) AS 'cum_price' # 'Cumulative Price'
, '' AS 'cum_paid_coupon' # 'Cumulative Paid with Coupon'
, '' AS 'avg_w_coupon' # 'Average Order Total (W/ Coupon)'
, AVG(subtotal) AS 'avg_wo_coupon' # 'Average Order Total (W/O Coupon)'
, '' AS 'cum_saving' # 'Cumulative Savings'
, '' AS 'cum_loss' # 'Cumulative Loss'
@Gabelbombe
Gabelbombe / gist:45871caa61cd104fdf22
Last active August 29, 2015 14:07
Segmentaion Report: Coupon based orders
SELECT '' AS 'Promotion Used'
, '' AS 'Promotion Code'
, '' AS 'Times Used (Orders #)'
, SUM(subtotal) AS 'Cumulative Price'
, '' AS 'Cumulative Paid with Coupon'
, '' AS 'Average Order Total (W/ Coupon)'
, AVG(subtotal) AS 'Average Order Total (W/O Coupon)'
, '' AS 'Cumulative Savings'
, '' AS 'Cumulative Loss'
, CONCAT(ABS(ROUND(