Skip to content

Instantly share code, notes, and snippets.

@TheMadav
TheMadav / Routes
Created May 21, 2014
User Controller for Laravel, using Sentry
View Routes
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
@TheMadav
TheMadav / password.blade.php
Last active Aug 29, 2015
Laravel Bootstrap Form fields
View password.blade.php
<?php
if ($errors->has($field) ):
echo "<div class='form-group has-error has-feedback'>";
elseif ( Input::old($field) && ! $errors->has($field) ):
echo "<div class='form-group has-success has-feedback'>";
else:
echo "<div class='form-group'>";
endif;
?>
{{ Form::label($field, trans($context.'.'.$field)) }}
@TheMadav
TheMadav / messages.blade.php
Created May 21, 2014
Laravel Messages Blade - displaying Bootstrap Messages based on Flash Data
View messages.blade.php
@if(isset($success) || Session::has('success') )
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<strong>Success!</strong> {{ isset($success) ? $info : Session::get('success') }}
</div>
@endif
@if(isset($error) || Session::has('error') )
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
@TheMadav
TheMadav / csv_yaml_converter.rb
Created Apr 2, 2019
Converter for YAML to CSV (Excel) and back
View csv_yaml_converter.rb
require 'deep_merge/rails_compat'
require 'yaml'
require 'yaml2csv'
require 'time'
def convert_csv_to_yaml input_file
hash = {}
file = File.read(input_file, encoding: 'bom|utf-8')
file.split("\n").each { |line| hash.deeper_merge!(line.gsub(/"\\"|"$/, " ").gsub(/""/,'"').chomp.split(/(?<!<)\/|;/).reverse.inject() { |m,v| {v => m} }) }
You can’t perform that action at this time.