Skip to content

Instantly share code, notes, and snippets.

@ruben-h
ruben-h / Codeship dokku deployment recipe.md
Last active August 29, 2015 14:22 — forked from bibstha/gist:49540af53fa0ec5ab869
Codeship deployment to a dokku app

After migrating from heroku to dokku, we had to also chance codeship so we deploy to dokku. I followed the following steps to successfully deploy to dokku.

  1. Save the public key of the codeship project. It is found in Project Settings > General Settings.
  2. Copy the public key to a file /tmp/codeship_projectname.pub.
  3. Make sure when pasting, all the contents are in a single line and not multiple lines.
  4. Add the public key to dokku using the following command in console. Reference.
cat /tmp/codeship_projectname.pub | ssh root@yourdokkuinstance "sudo sshcommand acl-add dokku [description]"

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder
@ruben-h
ruben-h / Devices.java
Last active August 29, 2015 14:26
Helper class to get the consumer friendly device name.
/*
* Copyright (C) 2014 Jared Rummler <jared.rummler@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ruben-h
ruben-h / RxJava.md
Created September 28, 2015 12:15 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@ruben-h
ruben-h / api.java
Created September 28, 2015 12:19 — forked from cesarferreira/api.java
RxJava and Retrofit sample
public interface API {
@GET("/user/{username}/dogs")
Observable<Dog> getAllDogsOf(@Path("username") String username);
@GET("/dog/{id}")
Observable<Dog> getDogInfoById(@Path("id") int dogId);
}
@ruben-h
ruben-h / migration-guide.md
Created December 15, 2015 10:03 — forked from staltz/migration-guide.md
How to show migration guides in GitHub Markdown

How to show migration guides in GitHub Markdown

Use the diff code highlighting tag.

  ```diff
  - foo
  + bar

Example:

@ruben-h
ruben-h / idle.js
Created December 17, 2015 13:02 — forked from gsans/idle.js
Idle user snippet
mergedStreams = rx.Observable.merge(
rx.DOM.keydown(document),
rx.DOM.click(document),
rx.DOM.mousemove(document),
rx.DOM.scroll(document),
rx.DOM.touchstart(document)
);
var idleStream = mergedStreams
.bufferWithTime(5000)
@ruben-h
ruben-h / ultimate-ut-cheat-sheet.md
Created March 22, 2016 13:26 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@ruben-h
ruben-h / gulpfile.js
Created May 10, 2016 07:44 — forked from sl-digital/gulpfile.js
Basic GulpFile
//==============================================================================
// H&L GulpJS + Node - Front End Asset Management
//==============================================================================
var gulp = require("gulp"),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
@ruben-h
ruben-h / 01-gulpfile.js
Created May 31, 2016 12:06 — forked from markgoodyear/01-gulpfile.js
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),