Skip to content

Instantly share code, notes, and snippets.

View byjujohn's full-sized avatar

Byju John byjujohn

View GitHub Profile
@byjujohn
byjujohn / SparkPost cURL Create (POST) Transmissions API Example
Created April 27, 2016 10:19 — forked from bdeanindy/SparkPost cURL Create (POST) Transmissions API Example
cURL POST Example to send an email using the SparkPost Transmissions API
curl \
-H "Content-Type: application/json" \
-H "Authorization: <REPLACE_WITH_YOUR_API_KEY>" \
-X POST -d '{"options":{"open_tracking":true,"click_tracking":true},"return_path":"bounces@<REPLACE_WITH_YOUR_SENDING_DOMAIN_HERE>","metadata":{"some_useful_metadata":"testing_sparkpost"},"substitution_data":{"signature":"<REPLACE_WITH_YOUR_FIRST_AND_LAST_NAME>"},"recipients":[{"address":{"email":"<REPLACE_WITH_YOUR_EMAIL_ADDRESS>","tags":["learning"],"substitution_data":{"customer_type":"Platinum","first_name":"<REPLACE_WITH_YOUR_FIRST_NAME>"}}}],"content":{"from":{"name":"Awesome Company","email":"testing@<REPLACE_WITH_YOUR_SENDING_DOMAIN>"},"subject":"My first SparkPost Transmission","reply_to":"Awesome Company ","text":"Hi {{address.first_name}}\r\nYou have just sent your first email through SparkPost!\r\nCongratulations,\r\n{{signature}}","html":"<strong>Hi {{address.first_name}},</strong><p>You have just sent your first email through SparkPost!</p><p>Congratulations!</p>{{signature}}"}}' \
https://api.sparkpos
@byjujohn
byjujohn / slackpost
Created January 29, 2016 09:17 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@byjujohn
byjujohn / Laravel 4 - Passing parameters to class based filters
Last active August 29, 2015 14:13
Laravel 4 - Passing parameters to class based filters
<?php
// app/roues.php
Route::group(array('before' => 'myfilter.filtername:value1,value2'), function() {
// Routing logic
});
// app/filters.php
Route::filter('myfilter.filtername', 'MyCustomFilterClassNameFilter@filtermethodFilter');
@byjujohn
byjujohn / gist:5514603
Created May 3, 2013 22:12
PHP: Print array/object formatted
<?php print "<pre>" . print_r($var, true) . "</pre>"; ?>
@byjujohn
byjujohn / gist:5510159
Created May 3, 2013 15:48
Unix: Rename uppercase file names to lowercase
find . -type f|while read f; do mv $f `echo $f |tr '[:upper:]' '[ :lower:]'`; done
@byjujohn
byjujohn / urlrewrite.php
Last active April 8, 2022 04:03
Magento: Programatically add custom URL Rewriting
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
ini_set('memory_limit', '32M');
set_time_limit (0);
require_once MAGENTO . '/app/Mage.php';
Mage::app();
Mage::getModel('core/url_rewrite')->setIsSystem(0)->setOptions('RP')->setIdPath('Imported-Old-Website-URL-test1')->setTargetPath('alicia-suspender-skirt-32360')->setRequestPath('SHOPONLINE.aspx?Product=Alicia Skirt&amp;Brand=Lascivious Test&amp;PID=1975')->save();
Mage::getModel('core/url_rewrite')->setIsSystem(0)->setOptions('RP')->setIdPath('Imported-Old-Website-URL-test2')->setTargetPath('alicia-suspender-skirt-32360')->setRequestPath('SHOPONLINE.aspx?Product=Alicia Skirt&Brand=Lascivious Test&PID=1975')->save();
@byjujohn
byjujohn / gist:4501574
Created January 10, 2013 12:11 — forked from hightemp/gist:2387916
Magento : Usefull Code Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@byjujohn
byjujohn / gist:4501573
Created January 10, 2013 12:10
Magento : Product navigation (getting previous and next items)
<?php
/**
* Determine the previous/next link and link to current category
*/
$_ccat = $this->helper('catalog/data')->getCategory();
$ppos = $_ccat->getProductsPosition();
$current_pid = $this->helper('catalog/data')->getProduct()->getId();
// build array from products positions
$plist = array();
foreach ($ppos as $pid => $pos) {
@byjujohn
byjujohn / gist:3713871
Created September 13, 2012 11:57 — forked from smonteverdi/gist:1993942
PHP: Send Email
<?
if (isset($_REQUEST["id"]) && ($_REQUEST["id"]<>"")) {
$data1=mysql_query("SELECT * FROM your_table WHERE id=".$_REQUEST["id"]);
$data=mysql_fetch_array($data1);
$from =mymail@mydomain.com;
$to = $data["email_field"];
$user = $data["name_field"];
$subject = "Enter your subject line here"; /*or if it comes from the table*/ $subject = $data["subject_field"];
$header="From:" . $from . "\r\n " ."Reply-To:". $from ;
$body="Hello ". $user .",\n\nFirst line\n\nYour message goes here, \nbest regards,\nyour_name and such\n";
@byjujohn
byjujohn / email.php
Created September 13, 2012 11:57 — forked from michaelaguiar/email.php
PHP - Send Email
<?php
// Configuration
$myEmail = 'YOUR EMAIL HERE';
$error = '';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers