Skip to content

Instantly share code, notes, and snippets.

Avatar

Tomek Cejner tomekc

View GitHub Profile
@tomekc
tomekc / ps-export-layers-to-png.jsx
Created Jun 7, 2012
Photoshop script that exports to PNG all layers and groups whose names end with ".png".
View ps-export-layers-to-png.jsx
#target photoshop
// $.level = 2;
/*
* Script by Tomek Cejner (tomek (at) japko dot info)
* based on work of Damien van Holten:
* http://www.damienvanholten.com/blog/export-groups-to-files-photoshop/
*
* My version adds support of nested layer groups,
* and exports single layers in addition to groups.
@tomekc
tomekc / .vimrc
Last active Jul 9, 2020
Vim awesome plugins
View .vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
set t_Co=256
set background=dark
colorscheme lost-shrine
set cul
@tomekc
tomekc / database.go
Created Jul 3, 2020
Trivial REST API returning contents of database
View database.go
package main
import (
"context"
"database/sql"
"encoding/json"
_ "github.com/go-sql-driver/mysql"
"net/http"
. "strings"
)
@tomekc
tomekc / nested-for-loops.js
Created Feb 16, 2020
Zagnieżdżone pętle for w JavaScripcie
View nested-for-loops.js
console.log(`Hi!`);
// Odpowiednik enuma w TypeScripcie
let ProjectType = {
CURRENT: "CURRENT",
CLOSED: "CLOSED"
}
let projectsOfUser1 = [
{ name: 'Proj1', type: ProjectType.CURRENT },
@tomekc
tomekc / scene-template.lua
Created Dec 10, 2019
Corona SDK - scene template
View scene-template.lua
-- Include modules/libraries
local composer = require "composer"
-- Variables local to scene
--
-- Create a new Composer scene
local scene = composer.newScene()
@tomekc
tomekc / AppDelegate.swift
Created Jan 9, 2015
CoreData snippet to add to existing project
View AppDelegate.swift
// MARK: - Core Data stack
lazy var applicationDocumentsDirectory: NSURL = {
// The directory the application uses to store the Core Data store file. This code uses a directory named "net.japko.EmptyCoreDataSwiftProject" in the application's documents Application Support directory.
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
return urls[urls.count-1] as NSURL
}()
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
@tomekc
tomekc / promises_branching.js
Created Aug 22, 2017
Branching inside promise chain (JavaScript, Bluebirdjs)
View promises_branching.js
var Promise = require('bluebird');
console.log('=== Branching promises demo ===');
function getNameById(id) {
return Promise.resolve("Ziutek");
}
/*
Add missing data to object.
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
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.

@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 {
You can’t perform that action at this time.