Skip to content

Instantly share code, notes, and snippets.

@robertbanh
robertbanh / utm_tracking.js
Created March 27, 2018 18:30
Add GET fields from current URL to all hyperlinks on page
<script type="text/javascript">
$(document).ready(function() {
$('a').each(function() {
var href = $(this).attr('href');
if (href !== undefined) {
if (href.indexOf('?') == -1) {
var url = document.URL;
var index = url.indexOf('?');
if (index != -1) {
url = url.substring(index);
@robertbanh
robertbanh / tracking.sh
Created November 20, 2017 21:58
Tracking API
curl 'https://api.shipengine.com/v1/tracking?carrier_code=stamps_com&tracking_number=9405511899223197428490' -X GET \
-H "Content-type: application/json" \
-H "api-key: dmtzyBFq9DsGMGd1GkzHilzeEAKsyyRyxQH3cz7M+Lo"
@robertbanh
robertbanh / address.sh
Created November 20, 2017 21:57
Address API
curl 'https://api.shipengine.com/v1/addresses/validate' -X POST \
-H "Content-Type: application/json" \
-H "api-key: dmtzyBFq9DsGMGd1GkzHilzeEAKsyyRyxQH3cz7M+Lo" \
-d '
[
{
"name": "Dade Murphy",
"phone": "+1 (212) 555-5555",
"company_name": "Zero Cool",
"address_line1": "345 Chambers Street",
@robertbanh
robertbanh / rating.sh
Created November 20, 2017 21:57
Rating API
curl 'https://api.shipengine.com/v1/rates' -X POST \
-H "Content-type: application/json" \
-H "api-key: dmtzyBFq9DsGMGd1GkzHilzeEAKsyyRyxQH3cz7M+Lo" \
-d '
{
"shipment": {
"ship_to": {
"name": "Dade Murphy",
"phone": "+1 (212) 555-5555",
"company_name": "Zero Cool",
@robertbanh
robertbanh / shipping.sh
Last active November 20, 2017 21:53
Shipping API
curl 'https://api.shipengine.com/v1/labels' -X POST \
-H "Content-type: application/json" \
-H "api-key: dmtzyBFq9DsGMGd1GkzHilzeEAKsyyRyxQH3cz7M+Lo" \
-d '
{
"shipment": {
"service_code": "usps_priority_mail",
"ship_to": {
"name": "Dade Murphy",
"phone": "+1 (212) 555-5555",
<?php
public function getEntryJson(EntryModel $entry)
{
$entryData = array();
foreach ($entry->getType()->getFieldLayout()->getFields() as $field)
{
$field = $field->getField();
$handle = $field->handle;
<?php
// Get the entry
$entry = craft()->entries->getEntryById(100);
// Define the new Matrix data
$matrixData = array(
'1' => array( // '1' is an existing block ID
'type' => 'text', // 'text' is the block type handle
'enabled' => true,
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# Accept all loopback traffic
-A INPUT -i lo -j ACCEPT
# Drop invalid/unknown/spoofed TCP sessions
-A INPUT -p tcp ! --syn -m state --state NEW -j DROP