Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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;
#!/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 / gist:c36071aa4a149ca84ad12d99fea0246c
Created April 13, 2018 18:18
AsyncConfiguration with custom timeout
package com.ruby.cms.comp.aggregator.util.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.annotation.AsyncConfigurer;
@litvil
litvil / macosx_remove_java9.sh
Created October 25, 2017 15:22 — forked from schnell18/macosx_remove_java9.sh
MacOS X remove Java 9
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-9.jdk/
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
@litvil
litvil / Makefile
Created May 2, 2017 19:58
Databases with Vagrant in Docker containers
DB_USERNAME ?= dbuser
DB_PASSWORD ?= dbpass
BIND_HOST ?= 0.0.0.0
POSTGRESQL_IMAGE ?= postgres:9.6
POSTGRESQL_CONTAINER ?= upper-postgresql
POSTGRESQL_PORT ?= 5432
MYSQL_IMAGE ?= mysql:5.7