Skip to content

Instantly share code, notes, and snippets.

Lauri Hahne lhahne

Block or report user

Report or block lhahne

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View getweight.js
const weightData$ = get$(`/1/user/-/body/log/weight/date/${today}.json`)
.map(response => response.data.weight[0]);
View getusertoken.js
server.get('/user', (req, res) => {
res.send({
token: req.user.token
});
});
View fitbitget.js
const token$ = rx.Observable.fromPromise(axios.get('/user'))
.map(response => response.data.token);
const get$ = path => token$.flatMap(token => rx.Observable.fromPromise(axios.get(`https://api.fitbit.com${path}`,
{headers: {Authorization: 'Bearer ' + token}})));
View passportoauth2.js
passport.use(new FitbitStrategy({
clientID: process.env.ID,
clientSecret: process.env.SECRET,
callbackURL: host + "/auth/callback"
},
function(accessToken, refreshToken, profile, done) {
done(null, {token: accessToken});
}
));
View serverless.js
var AWS = require("aws-sdk");
AWS.config.update({
region: "eu-west-1",
});
var dynamodbDoc = new AWS.DynamoDB.DocumentClient()
var table = "serverless-counter";
@lhahne
lhahne / list.js
Last active Aug 29, 2015
declarative html generation
View list.js
var HelloMessage = React.createClass({
render: function() {
var generateList = function() {
return [1, 2, 4].map(function(i) { return <li>{i}</li> });
};
return (
<div>Hello {this.props.name}
<ul>{generateList()}</ul>
</div>
);
@lhahne
lhahne / core.clj
Last active Aug 29, 2015
json from clojure
View core.clj
(ns clojure-json.core
(:require [cheshire.core]))
(defn my-json
[numbers-to-take numbers-to-map]
{:time (new java.util.Date)
:topic "Generating json from clojure"
:numbersToTake numbers-to-take
:letsNestIt {:someNumbers (take numbers-to-take (repeatedly rand))}
:numbersDoubled (map (partial * 2) numbers-to-map)})
@lhahne
lhahne / StationList.js
Last active Aug 29, 2015
react native view
View StationList.js
var React = require('react-native')
var {Text, ListView, AppRegistry} = React
var StationMetadataStore = require('./StationMetadataStore')
var StationList = React.createClass({
getInitialState() {
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
return {stations: ds.cloneWithRows([])}
},
View StationList.js
var React = require('react')
var StationMetadataStore = require('./StationMetadataStore')
var StationList = React.createClass({
getInitialState() {
return {stations: []}
},
componentDidMount: function() {
this.unsubscribe =
@lhahne
lhahne / StationMetadataStore.js
Last active Aug 29, 2015
StationMetadataStore
View StationMetadataStore.js
var Bacon = require('bacon')
var _ = require('lodash')
var METADATA_URL = 'http://rata.digitraffic.fi/api/v1/metadata/station'
var stations = Bacon.fromPromise(fetch(METADATA_URL))
.flatMap(response => Bacon.fromPromise(response.json()))
var stationsByCode = stations.map((stations) =>
_.indexBy(stations, 'stationShortCode'))
You can’t perform that action at this time.