Skip to content

Instantly share code, notes, and snippets.

Avatar

Sergi Tur Badenas acacha

View GitHub Profile
@jdamcd
jdamcd / EmailAdapter.java
Last active Dec 12, 2015
Email adapter for AutoCompleteTextView
View EmailAdapter.java
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);
}
@adamwathan
adamwathan / database.php
Created May 2, 2014
Using an in-memory SQLite for functional testing in Laravel 4
View database.php
<?php
// app/config/testing/database.php
return [
'default' => 'sqlite',
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
@acacha
acacha / example_of_vue_methods.js
Created Jun 19, 2017
example_of_vue_methods.js
View example_of_vue_methods.js
methods: {
remove() {
this.removed = true
this.$emmit('removed')
}
}
@tortuetorche
tortuetorche / 01.FiniteStateMachine.README.md
Last active Oct 12, 2017
FiniteStateMachine Trait with Example.Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.
View 01.FiniteStateMachine.README.md

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

@gtt116
gtt116 / gist:e7abe1c32a46df85b7599fbc7a9f9f73
Created Apr 25, 2017
autossh supervisord config file
View gist:e7abe1c32a46df85b7599fbc7a9f9f73
[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
@ericelliott
ericelliott / wait.js
Created Jan 19, 2017
Wait -- an ES6 promise example
View wait.js
const wait = time => new Promise((resolve) => setTimeout(resolve, time));
wait(3000).then(() => console.log('Hello!')); // 'Hello!'
@derhansen
derhansen / removeJobsRedisDriver.php
Last active Jul 7, 2021
Laravel 5 - remove all jobs from a queue (redis driver)
View removeJobsRedisDriver.php
Redis::connection()->del('queues:myqueue');
@JesseObrien
JesseObrien / gist:7418983
Last active Jul 8, 2021
Bind parameters into the SQL query for Laravel ORM
View gist:7418983
<?php
class MyModel extends Eloquent {
public function getSql()
{
$builder = $this->getBuilder();
$sql = $builder->toSql();
foreach($builder->getBindings() as $binding)
{
@burgalon
burgalon / AccountAuthenticator.java
Last active Sep 1, 2021
Implementing OAuth2 with AccountManager, Retrofit and Dagger
View AccountAuthenticator.java
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);
@daguilarm
daguilarm / RegionTableSeeder.php
Last active Oct 12, 2021
Laravel seed: Provincias de España
View RegionTableSeeder.php
<?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