Skip to content

Instantly share code, notes, and snippets.

View sabid's full-sized avatar
🏠
Working from home

Sabid Barahona sabid

🏠
Working from home
View GitHub Profile
@sabid
sabid / Operaciones-Git
Created January 5, 2017 20:59 — forked from jelcaf/Operaciones-Git
Git Tips - Mini-trucos de Git para facilitarme la tarea
#############################################
# Push de la rama actual
git push origin $rama_actual
#############################################
# Volver a un commit anterior, descartando los cambios
git reset --HARD $SHA1
#############################################
# Ver y descargar Ramas remotas
@sabid
sabid / jquery set data attr
Created September 15, 2014 23:48
jquery set data attr
console.log($("#you").data("you")); // Hello mean
$("#you").data("you", "yes change you atribute"); // yes change you atribute
console.log($("#you").data("you")); // yes change you atribute
With HTML atributes
There has already been an answer chosen as a correct one, however its seems like none of the answers clearly and concisely explain what is happening.
So let me give this a shot:
@sabid
sabid / Filter records by year
Created August 4, 2014 20:42
Filter records according to year using Laravel Eloquent ORM
Route::get('/year',function()
{
$year= '2013';
return Post::whereRaw('YEAR(`posted_date`) = ?', array($year))->get();
});
Auto:
http://albertokempis.com/content/filter-records-according-year-using-laravel-eloquent-orm
@sabid
sabid / part_of_date
Created August 4, 2014 20:41
PHP Part of a date
$parts = explode('-', '2068-06-15');
echo $parts[0];
@sabid
sabid / .htaccess
Created August 4, 2014 19:15
Laravel Remove public folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
@sabid
sabid / Database
Last active March 29, 2023 00:55
Laravel + Jquery Ajax Country and City
CREATE TABLE `paises` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
CREATE TABLE `ciudades` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pais_id` int(11) DEFAULT NULL,
`nombre` varchar(50) DEFAULT NULL,
@sabid
sabid / Laravel: Blade: Limit foreach loop
Created July 21, 2014 06:35
Laravel: Blade: Limit foreach loop
@foreach ($posts->slice(0, 5) as $post)
<h1>{{ $post['title'] }}</h1>
@endforeach
@sabid
sabid / Laravel Form select populate.php
Last active August 29, 2015 14:03
Laravel Form::select() Populate fron data base
Controller Create
$ciudades_opciones = \Ciudad::orderBy('nombre', 'asc')->lists('nombre','id');
View of create
{{ Form::select('ciudad_id', array('default' => 'Seleccione') + $ciudades_opciones, null, array('class' => 'form-control select2me')) }}
Note: the null options is the default value
@sabid
sabid / Laravel Artisan tinker
Created July 8, 2014 18:02
Laravel Artisan tinker
Example:
$user= User::find(1);
var_dump($user->projects);
@sabid
sabid / 0_reuse_code.js
Created July 8, 2014 17:59
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