Skip to content

Instantly share code, notes, and snippets.

View gist:8149297
<?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,
View gist:8672182
<?php
public function getEntryJson(EntryModel $entry)
{
$entryData = array();
foreach ($entry->getType()->getFieldLayout()->getFields() as $field)
{
$field = $field->getField();
$handle = $field->handle;
View iptables
*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
View shipping.sh
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",
View rating.sh
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",
View address.sh
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",
View tracking.sh
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 / utm_tracking.js
Created Mar 27, 2018
Add GET fields from current URL to all hyperlinks on page
View utm_tracking.js
<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);