Skip to content

Instantly share code, notes, and snippets.

@tomekc
tomekc / CoronaSDK-Module.lua
Created Dec 4, 2015
Creating modules in Corona SDK
View CoronaSDK-Module.lua
local M = {}
function M.create()
-- initialize members: M.foo = "bar"
end
function M.foo()
end
return M
@tomekc
tomekc / pom.xml
Last active Dec 11, 2015
Dropwizard bootstrap POM.
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.yammer.dropwizard</groupId>
@tomekc
tomekc / absurd_rest_service.js
Created Jul 4, 2013
Before running, install express by running npm install express and run with: node absurd_rest_service.js in this script's directory. Then: To submit calculation to curl -i -H "Content-Type: application/json" -d '{ "operation" : "+", "operands" : [ 2,3] }' http://localhost:3000/calculations To see results, use link from response: curl http://loca…
View absurd_rest_service.js
/*
Before running, install express by running
npm install express
and run with:
node absurd_rest_service.js
in this script's directory.
@tomekc
tomekc / .gitignore
Created Nov 24, 2013
.gitignore for Xcode and AppCode projects. Collected from internet's collective wisdom :]
View .gitignore
# xcode noise
build/*
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
*.mode1
*.mode2v3
*.mode1v3
xcuserdata
@tomekc
tomekc / Game.h
Created Dec 13, 2013
Sparrow Framework 2.0 boilerplate
View Game.h
#import <Foundation/Foundation.h>
#import <Sparrow-Framework/Sparrow.h>
@interface Game : SPSprite
@end
@tomekc
tomekc / bmf.lua
Last active Jan 1, 2016
Bitmap font support in Corona SDK, compatible with Graphics 2.0
View bmf.lua
module( ..., package.seeall )
-- AngelCode bitmap font support
-- Updated for Graphics 2.0
-- Download sprite module from https://github.com/coronalabs/framework-sprite-legacy/raw/master/sprite.lua
local sprite = require( "sprite" )
-- Specify an Angelcode format bitmap font definition file (".FNT")
-- The spritesheet(s) that this file references need to be located in the resource directory.
@tomekc
tomekc / learn_bluebird.js
Last active Mar 15, 2016
Learning playground for Bluebird.js
View learn_bluebird.js
//
// npm install bluebird
// npm install superagent
//
var Promise = require('bluebird');
var request = require('superagent');
console.log('Promises with Bluebird');
function get(url) {
@tomekc
tomekc / Optional+getOrElse.swift
Last active Oct 28, 2016
Add .getOrElse() method to Swift's Optional<T>, to unwrap value with fallback to default value. Idea borrowed from Scala language.
View Optional+getOrElse.swift
// An extension to Optional type:
// getOrElse() will return optional's value if exists, otherwise the default value provided as argument will be returned.
//
// Note: Since Xcode6 beta 5, you can use '??' operator.
//
// (c) Tomek Cejner 2014
// @tomekcejner
extension Optional {
func getOrElse(val:T) -> T {
if self != nil {
View monolity_mikroserwisy.md

Starcie monolitu i mikroserwisów

Obrona monolitu

Artykuł - Dan Haywood: In defence of Monolith Wyważone porównanie obu podejść. Część 2

Monolit musi być dobrze zmodularyzowany by był utrzymywalny. Prawdopodobnie większość monolitów taka nie jest.

Monolit dobrze się sprawdza w złożonej domenie biznesowej, mikroserwisy błyszczą tam, gdzie jest wielka skala.

View noise_level_meter.ino
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;
#define BLINK_LED 16
#define WIFI_LED_PIN 16
#define NUM_MEASURES 1200 // Sampling freq. is 20 hz