Skip to content

Instantly share code, notes, and snippets.

@lgvalle
lgvalle / WallActivity.java
Created June 15, 2014 19:45
rxjava + facebook
(...)
private void setupLayout() {
// Create Adapter
// (...)
listView.setAdapter(fbPostAdapter);
// Subscribe on provider changes.
homeProvider.getObservable().subscribe(new Observer<FbPost>() {
@lgvalle
lgvalle / legacyActivity.java
Last active August 29, 2015 14:14
Legacy code
public class LoginActivity extends Activity {
private EditText mEmailEdit;
private EditText mPassword;
private Button btnSend;
private EditText mPhoneNumber;
private TextWatcher watcher;
@Override
protected void onCreate(Bundle savedInstanceState) {
@lgvalle
lgvalle / FacebookHomeProvider.java
Last active August 8, 2016 03:50
rxjava + facebook
public class FacebookHomeProvider {
protected final PublishSubject<FbPost> behaviorSubject;
private Request request;
public FacebookHomeProvider() {
behaviorSubject = PublishSubject.create();
behaviorSubject.subscribeOn(Schedulers.io());
}
/**
@lgvalle
lgvalle / gist:3ad43349c4e0202ec147
Last active August 8, 2016 03:52
rxjava + twitter4j
public class HomePresenterImpl implements HomePresenter {
private static final String TAG = HomePresenterImpl.class.getSimpleName();
private final HomeScreen screen;
private final DataProvider provider;
private Subscription subscription1;
public HomePresenterImpl(HomeScreenImpl screen, DataProvider dataProvider) {
this.screen = screen;
this.provider = dataProvider;
}
@lgvalle
lgvalle / step1.js
Last active August 8, 2017 06:54
Post: Take control of your backend (I)
exports.fetch = functions.https.onRequest((req, res) => {
(…) // TODO Fetch from API
(…) // TODO Clean up
(…) // TODO Return result
})
@lgvalle
lgvalle / step2.js
Last active August 8, 2017 06:57
Post: Take control of your backend (II)
const Client = require('node - rest - client').Client
const client = new Client()
exports.fetch = functions.https.onRequest((req, res) => {
client.get(BACKEND_URL, function (data, response) {
(…) // TODO Clean up
return res.status(200)
.type('application / json')
.send(data)
<rss xmlns:media=”http://search.yahoo.com/mrss/" xmlns:dc=”http://purl.org/dc/elements/1.1/" version=”2.0">
 <channel>
 <title>London | The Guardian</title>
 <link>https://www.theguardian.com/uk/london</link>
 <description>Latest news and features from theguardian.com, the world’s leading liberal voice</description>
 <language>en-gb</language>
 <copyright>Guardian News and Media Limited or its affiliated companies. All rights reserved. 2017</copyright>
 <pubDate>Mon, 31 Jul 2017 15:32:49 GMT</pubDate>
 <dc:date>2017–07–31T15:32:49Z</dc:date>
 <dc:language>en-gb</dc:language>
function cleanUp(data) {
// Empty array to add cleaned up elements to
const items = []
// We are only interested in children of the 'channel' element
const channel = data.rss.channel
channel.item.forEach(element => {
item = {
title: element.title,
description: element.description,
[{
"title": "'Leaving London means I can afford kids': readers on why the capital lost its sparkle",
"description": "Almost 100,000 Londoners moved out last year. Here they, and others who are avoiding the city altogether, explain why it is no longer the place to be&lt;br&gt;&lt;/p&gt;&lt;p&gt;The rate of Londoners leaving the capital is more than &lt;a href="https://www.theguardian.com/uk-news/2017/jul/24/bloated-london-property-prices-fuelling-exodus-from-capital"&gt;80% higher than five years ago&lt;/a&gt;, according to Savills, with people in their thirties the age group most likely to leave. &lt;/p&gt;&lt;p&gt;We asked readers why they’re leaving London, or avoiding moving to the capital altogether. Here’s what you said:&lt;/p&gt;&lt;p&gt;All my salary was being spent on living costs in London&lt;/p&gt; &lt;a href="https://www.theguardian.com/uk-news/2017/jul/31/leaving-london-means-i-can-afford-kids-readers-on-why-the-capital-lost-its-sparkle"&gt;Continue reading...&lt;/a&gt;",
"date": "Mon, 31 Jul 2
@lgvalle
lgvalle / docker-compose.yml
Last active February 26, 2018 15:32
openstf
version: '3'
services:
rethinkdb:
image: rethinkdb:2.3
ports:
- "8080:8080"
- "28015:28015"
- "29015:29015"
restart: always
volumes: