Skip to content

Instantly share code, notes, and snippets.

@tomekc
tomekc / git_tricks.sh
Created January 10, 2023 10:46
Git tricks
# List all branches with commit date and committer
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname)|%(committerdate)|%(authorname)'
@tomekc
tomekc / instalacja nowego maca.md
Created May 31, 2022 21:12
Cheat sheet guide to setup new Mac:
@tomekc
tomekc / makefile_help.md
Created May 17, 2022 09:53
Makefile help

Default "help" target in Makefile

GREEN  := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE  := $(shell tput -Txterm setaf 7)
RESET  := $(shell tput -Txterm sgr0)

.PHONY: help
help: ## Show this help.
@tomekc
tomekc / human_readable_id_base32.go
Last active March 16, 2021 23:32
Build human-readable ID using Base32 in Go
package main
import (
"encoding/base32"
"fmt"
)
func main() {
id := 202790
@tomekc
tomekc / database.go
Created July 3, 2020 05:55
Trivial REST API returning contents of database
package main
import (
"context"
"database/sql"
"encoding/json"
_ "github.com/go-sql-driver/mysql"
"net/http"
. "strings"
)
@tomekc
tomekc / nested-for-loops.js
Created February 16, 2020 22:59
Zagnieżdżone pętle for w JavaScripcie
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 December 10, 2019 22:03
Corona SDK - scene template
-- Include modules/libraries
local composer = require "composer"
-- Variables local to scene
--
-- Create a new Composer scene
local scene = composer.newScene()
@tomekc
tomekc / .vimrc
Last active September 17, 2024 22:13
Vim awesome plugins
execute pathogen#infect()
syntax on
filetype plugin indent on
set t_Co=256
set background=dark
colorscheme lost-shrine
set cul
@tomekc
tomekc / promises_branching.js
Created August 22, 2017 14:14
Branching inside promise chain (JavaScript, Bluebirdjs)
var Promise = require('bluebird');
console.log('=== Branching promises demo ===');
function getNameById(id) {
return Promise.resolve("Ziutek");
}
/*
Add missing data to object.
@tomekc
tomekc / noise_level_meter.ino
Created June 2, 2017 09:05
Noise level meter
#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