Skip to content

Instantly share code, notes, and snippets.

View marinho's full-sized avatar

Mario Brandao marinho

  • stuff stuff @ SAP
  • Berlin, Germany
View GitHub Profile
import json
class LevelCreator(object):
_json_obj = None
_file_name = str()
_level_id = str()
_source_layer_id = str()
_output_layer_id = str()
_next_uid = int()
_tile_size = 16 # px
@marinho
marinho / project-paths-into-geo.ts
Last active January 19, 2018 08:17
Projection of a plain polygon (with paths) into a geographic area (including rotation)
/** This code was written as a solution for the following Stack Overflow entry:
* https://stackoverflow.com/questions/48307362/draw-a-multi-polygon-with-metric-dimensions-over-part-of-a-sphere-using-d3-geo/48336677
*
* Even though it seems to work fine, this code has at least 2 needs for improvements:
* - some of the types and functions here actually exist in existing libraries and could be used from them instead
* - d3-geo's mercator projection inverted should be able to do the same job more elegantly, in combination with
* other d3-geo features
*/
import * as turf from '@turf/turf'; // https://npmjs.com/package/@turf/turf
# coding=utf-8
from __future__ import print_function
from datetime import date, datetime
# --------------- Helpers that build all of the responses ----------------------
def build_speechlet_response(title, output, reprompt_text, should_end_session):
return {
@marinho
marinho / alexa-skill-wer-ist-mario.py
Last active June 24, 2017 05:02
Alexa skill "Wer ist Mario?"
"""
This sample demonstrates a simple skill built with the Amazon Alexa Skills Kit.
The Intent Schema, Custom Slots, and Sample Utterances for this skill, as well
as testing instructions are located at http://amzn.to/1LzFrj6
For additional samples, visit the Alexa Skills Kit Getting Started guide at
http://amzn.to/1LGWsLG
"""
from __future__ import print_function
@marinho
marinho / FractionCalculator.scala
Last active June 14, 2017 21:19
Playing with implicit conversions and infix in Scala
import scala.language.implicitConversions
import scala.language.postfixOps
// numerator
// ( numerator ÷ denominator ) create a fraction object as -----------
// denominator
object Main extends App {
implicit def intToFraction(i: Int) = new IntWithFraction(i)
@marinho
marinho / app-tsconfig.json
Created January 18, 2017 09:25
Issue when installing Angular 2 library
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmitHelpers": true,
@marinho
marinho / gulpfile.js
Created November 5, 2016 15:02
New gulpfile.js for sc5-stylesheet
var gulp = require('gulp');
var styleguide = require('sc5-styleguide');
var sass = require('gulp-sass');
const projectTitle = 'C4RE Style Guide';
const sourcePath = 'src';
const outputPath = 'output';
const styleSourcePath = sourcePath + '/styles';
const scssRoot = styleSourcePath + '/tutorial.scss';
const scssWild = styleSourcePath + '/**/*.scss';
@marinho
marinho / gulpfile.js
Created November 5, 2016 13:40
sg-wrapper not working in sc5-styleguide
// Imports
var gulp = require('gulp');
var sass = require('gulp-sass');
var styleguide = require('sc5-styleguide');
// Path definitions
var sourcePath = 'src';
@marinho
marinho / how-to-consume-observables-from-a-list.ts
Last active November 3, 2016 07:43
How to consume observables from a list and resolve their live updates in the DOM?
import xs from 'xstream';
import { run } from '@cycle/xstream-run';
import { makeDOMDriver, div, span, i, header, h1, section, button } from '@cycle/dom';
const
html = require('./panel.html'),
css = require('./panel.css');
function main(sources) {
const subscriptions$ = xs.of([
@marinho
marinho / panel.ts
Created November 2, 2016 22:32
trying CycleJS + XStream for the first time
import xs from 'xstream';
import { run } from '@cycle/xstream-run';
import { makeDOMDriver, div } from '@cycle/dom';
// import { Observable } from 'rxjs/Observable';
const
html = require('./panel.html'),
css = require('./panel.css');
function main() {