Skip to content

Instantly share code, notes, and snippets.

View acacha's full-sized avatar

Sergi Tur Badenas acacha

View GitHub Profile
@jdamcd
jdamcd / EmailAdapter.java
Last active December 12, 2015 07:48
Email adapter for AutoCompleteTextView
private ArrayAdapter<String> getEmailAddressAdapter(Context context) {
Account[] accounts = AccountManager.get(context).getAccountsByType("com.google");
String[] addresses = new String[accounts.length];
for (int i = 0; i < accounts.length; i++) {
addresses[i] = accounts[i].name;
}
return new ArrayAdapter<String>(context, android.R.layout.simple_dropdown_item_1line, addresses);
}
@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

@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)
{
@adamwathan
adamwathan / database.php
Created May 2, 2014 20:07
Using an in-memory SQLite for functional testing in Laravel 4
<?php
// app/config/testing/database.php
return [
'default' => 'sqlite',
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
@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');
@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
@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!'
@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
@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')
}
}