Skip to content

Instantly share code, notes, and snippets.

View agarwa13's full-sized avatar

Nikhil Agarwal agarwa13

View GitHub Profile
@agarwa13
agarwa13 / fire_ga_event_on_form_submit.js
Created October 22, 2017 00:34
Google Analytics Event on Form Submit
$('#replace-with-css-id-for-form').submit(function(e){
e.preventDefault();
_gaq.push(['_trackEvent', 'Forms', 'Submit', 'Home Contact']);
var form = this;
setTimeout(function(){ form.submit()}, 150);
});
@agarwa13
agarwa13 / hide-date-from-related-posts.css
Created May 21, 2017 14:17
Big Hawaii Travel - Hide Date from Related Posts
@agarwa13
agarwa13 / hide-post-views.css
Created May 21, 2017 14:14
Big Hawaii Travel Hide Post Views
.post-views{
display: none;
}
@agarwa13
agarwa13 / acceleratorstrategies.com.css
Created May 3, 2017 00:54
CSS for acceleratorstrategies.com.css Footer
.footer-widget{
margin-bottom: 30px !important;
}
#footer-widgets{
padding-top: 30px !important;
}
@agarwa13
agarwa13 / deploy.script
Created February 18, 2017 00:48
Deploy Script for Laravel Forge Site
cd /home/forge/bloggercasts.com
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
if [ -f artisan ]
then
php artisan migrate --force
fi
@agarwa13
agarwa13 / facebook-pinterest-opengraph-incompatability.php
Created September 30, 2016 01:16
Solution for Pinterest and Facebook Open Graph Incompatibility on Article Author Meta Tag
if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'Pinterest' ) !== false ) {
echo '<meta property="article:author" content="' . esc_attr( $author ) . '"/>' . "n";
} elseif ( !empty( $author_facebook ) ) {
echo '<meta property="article:author" content="http://www.facebook.com/' . esc_attr( $author_facebook ) . '"/>' . "n";
}
@agarwa13
agarwa13 / Notification.php
Created November 5, 2015 02:42
Notification Service that manages an array in session. It allows us to specify notifications to send to the user in controllers and other locations conveniently.
<?php
/**
* Created by PhpStorm.
* User: Nikhil
* Date: 11/2/2015
* Time: 9:56 PM
*/
namespace App\Services;
@agarwa13
agarwa13 / NotificationInsertion.php
Created November 5, 2015 02:40
Laravel 5.1 Middleware that ensures notifications set by the controller if any are sent along with any json responses.
<?php
namespace App\Http\Middleware;
use App\Services\Notification;
use Closure;
use Session;
class NotificationInsertion
{
@agarwa13
agarwa13 / notifications.blade.php
Created November 5, 2015 02:39
Laravel 5.1 Blade File that allows us to conveniently notify our users along with any response. Note we are using notifyjs to prettify our notifications.
<script src="{{asset('/vendor/notifyjs/notify.min.js')}}"></script>
<script>
$(document).ajaxComplete(function(event, xhr, settings){
$( ".log" ).text( "Triggered ajaxComplete handler." );
console.log(xhr.responseText);
response = $.parseJSON(xhr.responseText);
// Check for Notifications and Display Them
if(response.hasOwnProperty('notifications')){
for(var i=0; i< response.notifications.length; i++){
@agarwa13
agarwa13 / migration.php
Last active November 5, 2015 02:36
Laravel 5.1 Migration that creates a table where we will store email addresses that have bounced or complained.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBadEmails extends Migration
{
/**
* Run the migrations.
*