Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# view here:
# https://i.stack.imgur.com/OK3po.png
e=$'\e['
for n in {0..7}; do
printf "${e}"'38;05;'"${n}"'m%-6s' '('"$n"') '
done
@litvil
litvil / CamelKafkaAvroDeserializer.java
Created June 8, 2018 16:59
Camel Kafka Avro serializer and deserializer
package com.company.mapping;
import io.confluent.common.config.ConfigException;
import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient;
import io.confluent.kafka.serializers.AbstractKafkaAvroDeserializer;
import io.confluent.kafka.serializers.KafkaAvroDeserializerConfig;
import org.apache.kafka.common.serialization.Deserializer;
import java.util.Collections;
import java.util.List;
@litvil
litvil / jenv macOS
Created September 20, 2018 18:34
jenv macOS
/usr/libexec/java_home -verbose
brew install jenv
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(jenv init -)"' >> ~/.zshrc
(restart terminal)
jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home
@litvil
litvil / gist:6a52735784843be7e072c9b7b287221b
Created January 24, 2019 19:55
Two Git accounts ssh config
In ~/.ssh/ create a file called config with contents based on this:
#user1 account
Host bitbucket.org-user1
HostName bitbucket.org
User git
IdentityFile ~/.ssh/user1
IdentitiesOnly yes
#user2 account
@litvil
litvil / trigger.sql
Created February 6, 2019 14:48
PostgresQL trigger for updated_at
-- create function
CREATE OR REPLACE FUNCTION trigger_set_update_timestamp()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- create trigger
@litvil
litvil / recipe.example.md
Created April 26, 2019 18:51 — forked from peterbsmyth/recipe.example.md
Making chained API Calls using @ngrx/Effects

Making chained API Calls using @ngrx/Effects

Purpose

This recipe is useful for cooking up chained API calls as a result of a single action.

Description

In the below example, a single action called POST_REPO is dispatched and it's intention is to create a new repostiory on GitHub then update the README with new data after it is created.
For this to happen there are 4 API calls necessary to the GitHub API:

  1. POST a new repostiry
  2. GET the master branch of the new repository
  3. GET the files on the master branch
@litvil
litvil / install_elixir_phoenix.sh
Created February 23, 2020 23:34 — forked from ryanwinchester/install_elixir_phoenix.sh
Install Elixir and Phoenix on macOS
# Update brew
brew update
# Need postgres
brew install postgresql
# Install elixir
brew install elixir
# Install hex package manager