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
"""
Example of Geraldo Reports printing content above page header
1st page:
------
| page header with content printed once
------
| child band with normal page header content
------
@marinho
marinho / swift-functions
Last active August 29, 2015 14:12
Playing with Swift
// Interesting pieces of code while I learn the language
import UIKit
func isPrime(number: Int) -> Bool {
let basicPrimes = [1,2,3,5,7,11,13,17,19]
let basicNonPrimes = [0,4,6,8,9,10,12,14,15,16,18,20]
if contains(basicPrimes, number) {
return true
} else if contains(basicNonPrimes, number) {
def calc_savings(years=10, monthly=500, rate=1.12, initial=0.):
"""
years = amount of years to saving money
monthly = amount saved per month (inflation is ignored)
rate = rate per year to apply. Must be 1 + annual interest rates
initial = initial amount to startup
"""
total = initial
for n in range(years):
total = (total + monthly * 12) * rate
@marinho
marinho / ng2-redux-action-example.spec.ts
Last active September 20, 2016 11:25
Basic example of a Redux action being tested in Angular 2 (final version)
/*
* Testing a Redux based action in Angular 2 app (using ng2-redux)
* More info: https://angular.io/docs/ts/latest/guide/testing.html#!#inject
*/
import { TestBed, async, inject } from '@angular/core/testing';
import { NgRedux } from 'ng2-redux';
import { Observable } from 'rxjs';
import { AppState } from '../../store';
import { rootReducer } from '../../store/reducers';
@marinho
marinho / refCountWithDelay.ts
Created October 7, 2016 15:45
RxJS operator to delay before disposal when refCount reaches zero
import { Observable } from 'rxjs/Observable';
import { ConnectableObservable } from 'rxjs/observable/ConnectableObservable';
import { Subscription } from 'rxjs/Subscription';
import { async } from 'rxjs/scheduler/async';
/* This operator makes more sense when used with .publishReplay(1), as example below:
*
* let some$ = Observable.create(observer => {
* console.log(1110);
* observer.next('a value');
@marinho
marinho / console.txt
Created October 21, 2016 02:23
Exported console log output for debugging in Angular 2
2016-10-21 04:06:05 Device API logging initialized - DEVICE
Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'indexOf' of undefined
ORIGINAL STACKTRACE:
Error: Uncaught (in promise): TypeError: Cannot read property 'indexOf' of undefined
at resolvePromise (http://localhost:3000/polyfills.bundle.js:17988:31)
at http://localhost:3000/polyfills.bundle.js:18024:17
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:17795:37)
at Object.onInvokeTask (http://localhost:3000/vendor.bundle.js:36127:37)
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:17794:42)
@marinho
marinho / webpack.test.js
Created October 26, 2016 09:33
Webpack test configuration to use angular2-template-loader correctly
/**
* @author: @AngularClass
*/
const webpack = require('webpack');
const helpers = require('./helpers');
const path = require('path');
/**
* Webpack Plugins
@marinho
marinho / webpack.js
Created October 28, 2016 20:50
Issue with rendering fonts and loading css files with require in the same project
// loaders (just the related ones) when icon fonts work but require('./file.css') don't
loaders: [
// ...
{
test: /\.scss$/, // this is here just for reference. I got no issues with sass files
loaders: ['to-string-loader', 'css', 'sass']
},
{
test: /\.css$/,
@marinho
marinho / webpack.config.js
Created November 2, 2016 20:56
CopyWebpackPlugin not copying static files
const
webpack = require('webpack'),
path = require('path'),
fileSystem = require('fs'),
helpers = require('./config/helpers'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
@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() {