Skip to content

Instantly share code, notes, and snippets.

View carbontwelve's full-sized avatar
🎯
Focusing

Simon Dann carbontwelve

🎯
Focusing
View GitHub Profile
@carbontwelve
carbontwelve / notifications.blade.php
Created December 10, 2013 10:54
Found this somewhere on the internet and need to keep it safe for future projects. Very nice for using bootstrap notification boxes in Laravel4 views
@if ($errors->any())
<div class="alert alert-error alert-block">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4>Error</h4>
Please check the form below for errors
</div>
@endif
@if ($message = Session::get('success'))
<div class="alert alert-success alert-block">

Things you need to install on a fresh computer

OSX/Windows

NodeJS:
Url:           http://nodejs.org/
Required for: npm to install Bower
@carbontwelve
carbontwelve / 0_reuse_code.js
Created December 13, 2013 15:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@carbontwelve
carbontwelve / snippets.js
Created December 16, 2013 12:42
Javascript snippets
/**
* jQuery String Padding Function
* Only supports left padding.
* @link http://stv.whtly.com/2009/02/27/simple-jquery-string-padding-function/
**/
$.strPad = function(i,l,s) {
var o = i.toString();
if (!s) { s = '0'; }
while (o.length < l) {
o = s + o;
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
<?php
$env = $app->detectEnvironment(
function()
{
if (isset($_SERVER['HTTP_HOST']))
{
switch ( $_SERVER['HTTP_HOST'] )
{
case 'example.local':
$env = 'local';
@carbontwelve
carbontwelve / routes.php
Created February 19, 2014 10:28
How to check if a route exists in laravel4
<?php
$routeExists = Route::getRoutes()->hasNamedRoute('route.name');
dd($routeExits);
@carbontwelve
carbontwelve / usefull_commands.sh
Last active June 24, 2021 06:10
Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
# Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
php -dxdebug.remote_autostart artisan
#Running phpcs for 5.3:
phpcs -pv --standards= --runtime-set testVersion 5.3 --ignore=*/public/*,*.js,*.css,*/tests/*,*/views/training/* .
@carbontwelve
carbontwelve / Snippets.php
Created February 25, 2014 15:42
Laravel CSRF Before filter on post
<?php
// CSRF Protection
$this->beforeFilter('csrf', array('on' => 'post'));
@carbontwelve
carbontwelve / curl_example.php
Created March 27, 2014 13:54
PHP Curl to check if url is alive
<?php
function check_alive($url, $timeout = 10, $successOn = array(200, 301)) {
$ch = curl_init($url);
// Set request options
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_NOBODY => true,
CURLOPT_TIMEOUT => $timeout,