Skip to content

Instantly share code, notes, and snippets.

Avatar

Shankar Manamalkav mnshankar

View GitHub Profile
View vscode settings.json
{
"git.path":"C:\\laragon\\bin\\git\\bin\\git.exe",
"php.validate.executablePath": "C:\\laragon\\bin\\php\\php-7.1.14-Win32-VC14-x64\\php.exe",
"workbench.iconTheme": "material-icon-theme",
"workbench.statusBar.visible": false,
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "top",
"editor.formatOnPaste": true,
"explorer.openEditors.visible": 0,
"workbench.activityBar.visible": true,
@mnshankar
mnshankar / routes.php
Last active Jun 13, 2017 — forked from coreymcmahon/routes.php
Using macros to implement custom response types in Laravel - www.slashnode.com
View routes.php
<?php
Response::macro('csv', function($data, $filename = 'data.csv', $status = 200, $delimiter = ",", $linebreak = "\n", $headers = array())
{
return Response::stream(function () use ($data, $delimiter, $linebreak) {
foreach ($data as $row) {
$keys = array(); $values = array();
$firstPassComplete = (isset($firstPassComplete)) ? true:false;
foreach ($row as $k => $v) {
if (!$firstPassComplete){
@mnshankar
mnshankar / Envoy.blade.php
Created Apr 15, 2014
Laravel Envoy script for easy VPS deployment
View Envoy.blade.php
@servers(['web' => 'mnshankar@1.1.1.1'])
@task('deploy')
{{--"project" is the name of the project that is being deployed into /var/www/home--}}
rm -rf /var/www/home/project && mkdir /var/www/home/project
{{--Navigate to the project folder--}}
cd /var/www/home/project
@mnshankar
mnshankar / nginx.conf
Last active Sep 9, 2020
Nginix config for hosting multiple laravel projects in sibling folders.
View nginx.conf
server {
listen 80;
root /vagrant;
index index.html index.htm index.php app.php app_dev.php;
# Make site accessible from http://set-ip-address.xip.io
server_name 192.168.33.10.xip.io;
access_log /var/log/nginx/vagrant.com-access.log;
error_log /var/log/nginx/vagrant.com-error.log error;
@mnshankar
mnshankar / post-receive.sh
Last active Jul 24, 2016
post-receive hook for git deploy (Laravel 4)
View post-receive.sh
#!/bin/sh
WEBROOT=/var/www/domain.com/project
GIT_WORK_TREE=$WEBROOT git checkout -f
#change directory to the project dir
cd $WEBROOT
rm -f storage/cache/*
echo 'cache cleared'
rm -f storage/views/*
echo 'views cleared'
# Check if a composer.json file is present
@mnshankar
mnshankar / macros
Last active Feb 26, 2020
Laravel 4 (Twitter Bootstrap 3.0 compliant) form macros that I commonly use
View macros
<?php
/*********************************************************************************************
* Example usage (In view)
* <div class="welcome">
<?php echo Form::open(array('route'=>'process','class'=>'form-horizontal'))?>
<?php echo Form::textField('first_name')?>
<?php echo Form::textField('last_name')?>
<?php echo Form::emailField('email')?>
<?php echo Form::passwordField('password')?>
<?php echo Form::selectField('select_one', array('1'=>'abc', '2'=>'def'))?>
@mnshankar
mnshankar / l4.formfield.php
Last active Dec 24, 2015
Form element in L4 (TBS styling)
View l4.formfield.php
<!-- email -->
<div class="form-group">
<?php echo Form::label('email',null,array('class'=>'col-lg-2 control-label'))?>
<div class="col-lg-4">
<?php echo Form::email('email', null,
array('class'=>'form-control', 'placeholder'=>'email'))?>
{{$errors->first('email', '<span class="alert alert-error">:message</span>')}}
</div>
</div>
You can’t perform that action at this time.