Skip to content

Instantly share code, notes, and snippets.

View punkstar's full-sized avatar
🏴󠁧󠁢󠁷󠁬󠁳󠁿

Nick Jones punkstar

🏴󠁧󠁢󠁷󠁬󠁳󠁿
View GitHub Profile
@punkstar
punkstar / ApplyUrlSchemeStrategyProvider.php
Created April 18, 2016 18:15
Laravel: Match protocol of incoming request when generating routes
<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\ServiceProvider;
/**
* Class ApplyUrlSchemeStrategyProvider
### Keybase proof
I hereby claim:
* I am punkstar on github.
* I am punkstar (https://keybase.io/punkstar) on keybase.
* I have a public key whose fingerprint is 5177 3EF6 59A8 B993 8C5A C1EB 18BE BCE3 B9C3 C239
To claim this, I am signing this object:
diff --git a/skin/frontend/base/default/sagepaysuite/js/sagePaySuite_Checkout.js b/skin/frontend/base/default/sagepaysuite/js/sagePaySuite_Checkout.js
index 98913d3..f4d3484 100755
--- a/skin/frontend/base/default/sagepaysuite/js/sagePaySuite_Checkout.js
+++ b/skin/frontend/base/default/sagepaysuite/js/sagePaySuite_Checkout.js
@@ -380,6 +380,17 @@ reviewSave: function(transport){
window._sagepayprocessingorder = false;
}
+ /**
+ * If for some reason the Event.observe(window, 'load') didn't fire, then make sure
@punkstar
punkstar / build_jekyll.sh
Created March 21, 2014 08:32
DeployHQ steps to deploy a jekyll site
# We build everything in a staging directory, so we don't take the site down during a deployment.
rm -rf %path%/../staging/ && mkdir %path%/../staging/
# Perform the actual jekyll build, constants are for encoding issues (I think, can't remember)
source ~/.bashrc && cd %path% && LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 jekyll
# Build the sass files, so we don't need to keep the css in our repo
source ~/.bashrc && cd %path%/../staging/ && LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 && sass --update .
# Copy our .htaccess across
@punkstar
punkstar / negative_subtotal_on_invoice.diff
Created February 26, 2014 12:46
A core Magento fix for if you have negative subtotals on invoices after applying at least a 100% discount to the order (but the customer has to pay shipping).
diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Tax.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Tax.php
index 25bbcc7..38587f4 100644
--- a/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Tax.php
+++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Total/Tax.php
@@ -47,7 +47,8 @@ class Mage_Sales_Model_Order_Invoice_Total_Tax extends Mage_Sales_Model_Order_In
$orderItem = $item->getOrderItem();
$orderItemQty = $orderItem->getQtyOrdered();
- if ($orderItem->getTaxAmount() && $orderItemQty) {
+ // Need to check if we've got tax or hidden_tax applied to the item so that we calculate the row subtotal correctly
@punkstar
punkstar / parameters.yaml
Created February 7, 2014 11:23
Using RVM with Assetic in dev mode
assetic:
use_controller: true
ruby: 'bash'
sass: '/Users/nrj/.rvm/bin/sass'
filters:
scss:
sass:
bin: '/Users/nrj/.rvm/bin/sass'
@punkstar
punkstar / feed.rss
Created December 29, 2012 15:45
Custom Magento admin notification, example RSS feed
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="http://www.magentocommerce.com/notifications_feed" rel="self" type="application/rss+xml" />
<title>MagentoCommerce</title>
<link>http://www.magentocommerc.com/</link>
<description>MagentoCommerce</description>
<copyright>Copyright (c) 2009 Varien</copyright>
<webMaster>support@varien.com (Magento support)</webMaster>
<language>en</language>
@punkstar
punkstar / config.xml
Created December 29, 2012 15:44
Custom Magento admin notifications
<?xml version="1.0" encoding="UTF-8"?>
<config>
...
<adminhtml>
...
<events>
<controller_action_predispatch>
<observers>
<meanbee_notification>
<type>singleton</type>
@punkstar
punkstar / Feed.php
Created December 29, 2012 15:44
Custom Magento admin notifications
<?php
class Meanbee_Notify_Model_Feed extends Mage_AdminNotification_Model_Feed {
public function getFeedUrl() {
$url =
Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://'
. 'www.meanbee.com/path/to/your/file.rss';
}
public function observe() {
$model = Mage::getModel('notify/feed');
@punkstar
punkstar / exam.c
Created December 29, 2012 15:42
C exam question
#include <stdio.h>
int func (int a, int b) {
static int c = 1;
return a + b * (c *= -1);
}
int main () {
int a = 2, b = 3;
int c = func(a, b);