Skip to content

Instantly share code, notes, and snippets.

View WallActivity.java
(...)
private void setupLayout() {
// Create Adapter
// (...)
listView.setAdapter(fbPostAdapter);
// Subscribe on provider changes.
homeProvider.getObservable().subscribe(new Observer<FbPost>() {
View legacyActivity.java
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) {
View FacebookHomeProvider.java
public class FacebookHomeProvider {
protected final PublishSubject<FbPost> behaviorSubject;
private Request request;
public FacebookHomeProvider() {
behaviorSubject = PublishSubject.create();
behaviorSubject.subscribeOn(Schedulers.io());
}
/**
View gist:3ad43349c4e0202ec147
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 Aug 8, 2017
Post: Take control of your backend (I)
View step1.js
exports.fetch = functions.https.onRequest((req, res) => {
() // TODO Fetch from API
() // TODO Clean up
() // TODO Return result
})
@lgvalle
lgvalle / step2.js
Last active Aug 8, 2017
Post: Take control of your backend (II)
View step2.js
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)
View raw_response.xml
<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>
View step4.js
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,
View tidy_up_response.json
[{
"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
View docker-compose.yml
version: '3'
services:
rethinkdb:
image: rethinkdb:2.3
ports:
- "8080:8080"
- "28015:28015"
- "29015:29015"
restart: always
volumes: