Skip to content

Instantly share code, notes, and snippets.

@TheMadav
TheMadav / csv_yaml_converter.rb
Created April 2, 2019 07:43
Converter for YAML to CSV (Excel) and back
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} }) }
@TheMadav
TheMadav / password.blade.php
Last active August 29, 2015 14:01
Laravel Bootstrap Form fields
<?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 17:23
Laravel Messages Blade - displaying Bootstrap Messages based on Flash Data
@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 / Routes
Created May 21, 2014 17:21
User Controller for Laravel, using Sentry
<?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.