Skip to content

Instantly share code, notes, and snippets.

View metalmatze's full-sized avatar
🤘

Matthias Loibl metalmatze

🤘
View GitHub Profile
package main
import (
"github.com/tucnak/telebot"
"log"
"time"
)
var (
bot *telebot.Bot
@metalmatze
metalmatze / rx-retrofit.java
Created October 22, 2015 23:24
Retrofit returning a observable which is mapped and then copied into the realm Database
Api.with(getActivity()).request()
.authors()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(authorJsonArray -> authorJsonArray.data)
.subscribe(authors -> {
realm.beginTransaction();
realm.copyToRealmOrUpdate(authors);
realm.commitTransaction();
});
render() {
return (
<GoogleMaps
containerProps={{
style: {
height: "100%"
}
}}
ref="map"
@metalmatze
metalmatze / element-name.html
Created May 12, 2015 10:38
Polymer element
<dom-module id="element-name">
<style>
/* CSS rules for your element */
</style>
<template>
<!-- local DOM for your element -->
<div>{{greeting}}</div> <!-- data bindings in local DOM -->
</template>
</dom-module>
@metalmatze
metalmatze / photo.coffee
Created March 4, 2015 18:08
GET image and display base64
$http.get(url, {
headers:
Authorization: 'Bearer ' + authenticationService.getToken()
responseType: 'arraybuffer'
})
.success((data) ->
image = new Image()
reader = new FileReader()
blob = new Blob([data])
@metalmatze
metalmatze / machine-accuracy.rb
Created February 13, 2014 09:13
This little ruby script calculates lower numbers until there is no difference for the machine
difference = 1
i = 0
while 1 + difference != 1
puts "#{i} | #{sprintf('%16.8e', difference)} | unequal 1"
difference = difference / 2.0
i += 1
end
@metalmatze
metalmatze / machine-accuracy.php
Created February 10, 2014 11:40
This little script calculates lower numbers until there is no difference for the machine
<?php
$difference = 1.0;
$i = 0;
while(1.0 + $difference != 1.0)
{
if ($i % 5 == 0)
printf("%4.0f | %16.8e | unequal 1\n", $i, $difference);