Skip to content

Instantly share code, notes, and snippets.

View acacha's full-sized avatar

Sergi Tur Badenas acacha

View GitHub Profile
@JesseObrien
JesseObrien / gist:7418983
Last active January 31, 2024 06:24
Bind parameters into the SQL query for Laravel ORM
<?php
class MyModel extends Eloquent {
public function getSql()
{
$builder = $this->getBuilder();
$sql = $builder->toSql();
foreach($builder->getBindings() as $binding)
{
@acacha
acacha / DAM_101.md
Last active September 14, 2023 15:26
DAM 101

Vídeo Youtube

https://tubeme.acacha.org/101

El vídeo pot tenir alguns petits canvis per canvis de versions, consulteu els comentaris de Youtube i afegiu els vostres propis amb preguntes en cas de dubtes o fins i tot pengeu solucions a problemes que podeu haver trobat.

Versió Ubuntu

lsb_release -a
@burgalon
burgalon / AccountAuthenticator.java
Last active July 15, 2023 08:29
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@derhansen
derhansen / removeJobsRedisDriver.php
Last active November 10, 2022 17:17
Laravel 5 - remove all jobs from a queue (redis driver)
Redis::connection()->del('queues:myqueue');
@ericelliott
ericelliott / wait.js
Created January 19, 2017 22:16
Wait -- an ES6 promise example
const wait = time => new Promise((resolve) => setTimeout(resolve, time));
wait(3000).then(() => console.log('Hello!')); // 'Hello!'
@acacha
acacha / gist:7b21043ec1cfa06b551ea75aa86edff0
Last active April 5, 2022 18:02
Actualització Ubuntu 20.02 a PHP8 per a Laravel ) i canvis a Valet Linux
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install php8.0-fpm php8.0-cli php8.0-common php8.0-curl php8.0-gd php8.0-mbstring php8.0-mysql php8.0-opcache php8.0-readline php8.0-sqlite3 php8.0-xml php8.0-zip
$ laravel -v
Laravel Installer 4.2.9
$ composer global update
$ laravel -v
Laravel Installer 4.2.10
$ laravel new prova && cd prova
@daguilarm
daguilarm / RegionTableSeeder.php
Last active October 12, 2021 21:22
Laravel seed: Provincias de España
<?php
/*
*
|--------------------------------------------------------------------------
| Listado de Provincias de España vinculadas a Comunidad Autónoma y País
| Formato: Laravel 5.1 seed
| Autor: Damián Aguilar
| http://www.damianaguilar.es
| Twitter: @daguilarm
@gtt116
gtt116 / gist:e7abe1c32a46df85b7599fbc7a9f9f73
Created April 25, 2017 02:33
autossh supervisord config file
[program:autossh]
command=autossh -M0 -N
-o "ExitOnForwardFailure yes"
-o "ServerAliveInterval 15"
-o "ServerAliveCountMax 4"
-o "ControlPath none"
-o "UserKnownHostsFile=/dev/null"
-o StrictHostKeyChecking=no
-R 1234:localhost:1234
-R 4567:localhost:4567
@tortuetorche
tortuetorche / 01.FiniteStateMachine.README.md
Last active October 12, 2017 23:06
FiniteStateMachine Trait with Example.Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.

FiniteStateMachine Trait

Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.

Usage

In your Stateful Class, add the stateMachineConfig() method and call initStateMachine() method at initialization (__contruct() method).

Example

@acacha
acacha / example_of_vue_methods.js
Created June 19, 2017 14:37
example_of_vue_methods.js
methods: {
remove() {
this.removed = true
this.$emmit('removed')
}
}