Skip to content

Instantly share code, notes, and snippets.

View cemremengu's full-sized avatar
😵

Cemre Mengu cemremengu

😵
View GitHub Profile
@anandpathak
anandpathak / pg12_partman_dockerfile
Created October 26, 2021 12:38
docker file for postgres 12 with partman
FROM postgres:12
RUN apt-get update && \
apt-get install -y git make gcc
RUN git clone https://github.com/pgpartman/pg_partman
RUN cd pg_partman && make NO_BGW=1 install

Rust Error Handling Cheatsheet - Result handling functions

Introduction to Rust error handling

Rust error handling is nice but obligatory. Which makes it sometimes plenty of code.

Functions return values of type Result that is "enumeration". In Rust enumeration means complex value that has alternatives and that alternative is shown with a tag.

Result is defined as Ok or Err. The definition is generic, and both alternatives have

@bgadrian
bgadrian / set.go
Last active April 23, 2024 13:50
How to implement a simple set data structure in golang
type Set struct {
list map[int]struct{} //empty structs occupy 0 memory
}
func (s *Set) Has(v int) bool {
_, ok := s.list[v]
return ok
}
@beginor
beginor / snowflake-id.sql
Last active April 18, 2024 20:13
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@tejasgoradia
tejasgoradia / apache-nifi-install.sh
Last active February 17, 2022 22:18
bash script to install apache nifi on CentOS 7
#!/bin/bash
# create nifi user and group
sudo useradd -m nifi --shell /bin/bash
# create installation directory
sudo mkdir /opt/nifi
# download the tar ball
sudo curl -o /opt/nifi/nifi-1.6.0-bin.tar.gz http://apache.melbourneitmirror.net/nifi/1.6.0/nifi-1.6.0-bin.tar.gz
@subfuzion
subfuzion / dep.md
Last active June 14, 2023 15:46
Concise guide to golang/dep

Overview

This gist is based on the information available at golang/dep, only slightly more terse and annotated with a few notes and links primarily for my own personal benefit. It's public in case this information is helpful to anyone else as well.

I initially advocated Glide for my team and then, more recently, vndr. I've also taken the approach of exerting direct control over what goes into vendor/ in my Dockerfiles, and also work from isolated GOPATH environments on my system per project to ensure that dependencies are explicitly found under vendor/.

At the end of the day, vendoring (and committing vendor/) is about being in control of your dependencies and being able to achieve reproducible builds. While you can achieve this manually, things that are nice to have in a vendoring tool include:

NiFi Example: How to Put/Get to/from a DistributedCache

Left part: Put

Set values you'd like to cache to the content of a FlowFile. Then pass it to PutDistributedCache.

Right part: Get

You can enrich incoming FlowFiles by adding an attribute with a value fetched from DistributedCache.

#!/bin/bash
# Install Wavefront Proxy and configures standard telegraf plugin
# ####
function logo() {
cat << "EOT"
__ __ _____ __
/ \ / \_____ ___ __ _____/ ____\______ ____ _____/ |_
\ \/\/ /\__ \\ \/ // __ \ __\\_ __ \/ _ \ / \ __\
\ / / __ \\ /\ ___/| | | | \( <_> ) | \ |
@jchannon
jchannon / AuthenticationModule.cs
Last active March 29, 2017 12:40
How to use ASP.Net Core Cookie Middleware and sign the user in within a Nancy module
public class AuthModule : NancyModule
{
public AuthModule()
{
Post("/login", async _ =>
{
var myclaims = new List<Claim>(new Claim[] { new Claim("Id", "SOME USER ID FROM SOMEWHERE!!") });
var claimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity(myclaims, "MyCookieMW"));
@olivere
olivere / bulk_processor_example1.go
Created January 16, 2016 11:17
Example #1 of bulk processor usage
// This is an example of using elastic's BulkProcessor with Elasticsearch.
//
// See https://github.com/olivere/elastic and
// and https://github.com/olivere/elastic/wiki/BulkProcessor
// for more details.
/*
* This example illustrates a simple process that performs bulk processing
* with Elasticsearch using the BulkProcessor in elastic.
*