Skip to content

Instantly share code, notes, and snippets.

View 4e1e0603's full-sized avatar
🎯
I may be slow to respond.

David Landa 4e1e0603

🎯
I may be slow to respond.
  • Prague, Czech Republic
View GitHub Profile
@bruth
bruth / README.md
Last active December 13, 2024 17:35
Postgres push notification

Postgres push triggers

Watch a table for changes and push a notification with a payload describing the change.

Example

In the Postgres shell:

-- Create the functions

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o

@vidavidorra
vidavidorra / auto-deploy_documentation.md
Last active June 5, 2024 19:20
Auto-deploying Doxygen documentation to gh-pages with Travis CI

Auto-deploying Doxygen documentation to gh-pages with Travis CI

This explains how to setup for GitHub projects which automatically generates Doxygen code documentation and publishes the documentation to the gh-pages branch using Travis CI. This way only the source files need to be pushed to GitHub and the gh-pages branch is automatically updated with the generated Doxygen documentation.

Sign up for Travis CI and add your project

Get an account at Travis CI. Turn on Travis for your repository in question, using the Travis control panel.

Create a clean gh-pages branch

To create a clean gh-pages branch, with no commit history, from the master branch enter the code below in the Git Shell. This will create a gh-pages branch with one file, the README.md in it. It doesn't really matter what file is uploaded in it since it will be overwritten when the automatically generated documentation is published to th

@ruxo
ruxo / rectangle.fs
Last active February 9, 2023 23:13
F# Geometry types
type Rect =
{ Left:int; Top:int; Width:int; Height:int }
with
static member create(w, h) = { Left=0; Top=0; Width=w; Height=h }
static member create(l,t,r,b) = { Left=l; Top=t; Width=(r-l)+1; Height=(b-t)+1 }
static member shrink n r = { Left=r.Left+n; Top=r.Top+n; Width=r.Width-2*n; Height=r.Height-2*n }
static member scan r =
seq {
for y = r.Top to r.Top+r.Height-1 do
for x = r.Left to r.Left+r.Width-1 do
@fredbenenson
fredbenenson / kickstarter_sql_style_guide.md
Last active May 22, 2025 23:58
Kickstarter SQL Style Guide
layout title description tags
default
SQL Style Guide
A guide to writing clean, clear, and consistent SQL.
data
process

Purpose

@eXpl0it3r
eXpl0it3r / screenshot.cpp
Created October 31, 2015 01:24
Non-blocking screenshots with SFML
#include <SFML/Graphics.hpp>
#include <thread>
int main()
{
sf::RenderWindow window({1920, 1080}, "Screenshot!");
sf::Texture tex;
tex.create(1920, 1080);
sf::Clock cl;
@giumas
giumas / Logging - SQLite handler
Last active February 15, 2023 02:23
A minimal SQLite handler for the python logging module
from __future__ import absolute_import, division, print_function, unicode_literals
import sqlite3
import logging
import time
__version__ = "0.1.0"
initial_sql = """CREATE TABLE IF NOT EXISTS log(
@DavidBrower
DavidBrower / ValueObject.cs
Created September 1, 2015 16:24
ValueObject Base Class
public abstract class ValueObject<T> : IEquatable<T> where T : ValueObject<T>
{
private List<PropertyInfo> Properties { get; }
protected ValueObject()
{
Properties = new List<PropertyInfo>();
}
public override Boolean Equals(object obj)
@jaceklaskowski
jaceklaskowski / deployment-tool-ansible-puppet-chef-salt.md
Last active July 11, 2025 05:01
Choosing a deployment tool - ansible vs puppet vs chef vs salt

Requirements

  • no upfront installation/agents on remote/slave machines - ssh should be enough
  • application components should use third-party software, e.g. HDFS, Spark's cluster, deployed separately
  • configuration templating
  • environment requires/asserts, i.e. we need a JVM in a given version before doing deployment
  • deployment process run from Jenkins

Solution

#lang racket
(require net/http-client)
(require net/url)
(require json)
(require net/uri-codec)
(require racket/cmdline)
(define lg (make-logger 'currency-logger))
(current-logger lg)