Skip to content

Instantly share code, notes, and snippets.

View rabinshr's full-sized avatar

Rabin Shrestha rabinshr

View GitHub Profile
@rabinshr
rabinshr / order_taxes-after-full-refund
Created September 27, 2018 04:42
Order taxes records after full refund
[
{
"id": 65,
"order_id": 112,
"order_address_id": 11,
"tax_rate_id": 32,
"tax_class_id": 0,
"name": "NV STATE TAX - NEVADA",
"class": "NEVADA",
"rate": "4.6000",
@rabinshr
rabinshr / order_taxes-before-refund
Created September 27, 2018 04:42
Order taxes records before refund
[
{
"id": 59,
"order_id": 112,
"order_address_id": 11,
"tax_rate_id": 32,
"tax_class_id": 0,
"name": "NV STATE TAX - NEVADA",
"class": "NEVADA",
"rate": "4.6000",
Timed out after 60 seconds
#0 /Users/rabin.shrestha/dev/codebase/bigcommerce/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php(555): PHPUnit_Extensions_Selenium2TestCase_WaitUntil->run(Object(Closure), 60)
#1 /Users/rabin.shrestha/dev/codebase/bigcommerce/tests/Functional/Utils/SeleniumHelper.php(159): PHPUnit_Extensions_Selenium2TestCase->waitUntil(Object(Closure), '60000')
#2 /Users/rabin.shrestha/dev/codebase/bigcommerce/tests/Functional/Utils/SeleniumHelper.php(123): Functional\Utils\SeleniumHelper->waitForElementByXPathWithTimeout('(//td[@class='l...', '60000', true)
#3 /Users/rabin.shrestha/dev/codebase/bigcommerce/tests/Functional/PageObjects/ControlPanel/Orders/OrderLineItemRefundPage.php(80): Functional\Utils\SeleniumHelper->waitForElementByXPath('(//td[@class='l...')
#4 /Users/rabin.shrestha/dev/codebase/bigcommerce/tests/Functional/Utils/ControlPanel/Orders/OrdersUITestUtil.php(1306): Functional\PageObjects\ControlPanel\Orders\OrderLineItemRefundPage->completeLineItemRefundS
@rabinshr
rabinshr / query_result.csv
Last active January 25, 2016 04:38
Query Results dump
itemid shipid itemprodid itemordprodid itemprodsku itemprodname itemqty itemprodoptions itemprodvariationid itemprodeventname itemprodeventdate product_attribute_combination_id product_attributes is_bundled_product ordprodbin prodname url
28 27 76 10 Test Product 1 0 NULL 0 NULL 0 Test Product /test-product/
29 27 77 11 WeightFactoredProduct 1 0 NULL 0 NULL 1 WeightFactoredProduct /weightfactoredproduct/
@rabinshr
rabinshr / rubocop_pre_commit_hook
Created November 12, 2015 01:05 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@rabinshr
rabinshr / home-brew.sh
Last active August 29, 2015 14:16
Package manager for Max OSX
#!/bin/bash
which -s brew
if [[ $? != 0 ]] ; then
# Install Homebrew
echo "installing brew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "updating brew"
brew update
/* Better styles for embedding GitHub Gists */
.gist{font-size:12px;line-height:18px;margin-bottom:20px;width:100%}
.gist pre{font-family:Menlo,Monaco,'Bitstream Vera Sans Mono','Courier New',monospace !important}
.gist-meta{font-family:Helvetica,Arial,sans-serif;font-size:12px !important}
.gist-meta a{color:#26a !important;text-decoration:none}
.gist-meta a:hover{color:#0e4071 !important}
@rabinshr
rabinshr / reliable_copy.sh
Last active August 29, 2015 14:01
Reliably copy files from a folder. Particularly useful when you have a jittery network that timeouts every now and then
#!/bin/bash
# reliable file/s transfer from a folder
# try rsync
I=0
MAX_RESTARTS=100
LAST_EXIT_CODE=1
if [ $# -lt 2 ]; then
@rabinshr
rabinshr / logviewer.sh
Last active August 29, 2015 14:01
A log viewer that allows viewing of log files in log folder. Particularly useful in situations where a user doesn't have root priviledges but requires to view logs
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
usage="
Usage: $(basename "$0") -d LOG_DIRECTORY [-r LOG_FILE]
for($orderlines as $ol_id=>$ol_amount) {
if ($ol_amount <= $available) {
identify_and_add_refund_detail($refund_id, $ol_amount, $ol_id);
unset($orderlines[$ol_id]);
} else {
identify_and_add_refund_detail($refund_id, $available, $ol_id);
$leftover = $ol_amount - $available;
$orderlines[$ol_id] = $leftover;
}
$available -= $ol_amount;