Skip to content

Instantly share code, notes, and snippets.

View bhaskarmelkani's full-sized avatar
🎯
Focusing

Bhaskar Melkani bhaskarmelkani

🎯
Focusing
View GitHub Profile
#!/bin/bash
set -e
# A precommit hook that uses spotless to format only staged files
# It also supports partially stage files using the following steps:
# 1. It stashed all the unstaged changes and then runs spotlessApply
# 2. After spotless apply is finished it applyes the stashed changes back on the code (that is also formatted/changed by spotless)
# 3. All the files that have conflicts due to the stash apply, it merges the conflict with the changes that are coming from the stash to not loose any new changes that were not staged

Navika Behaviour

Consuming Nakadi Subscription

  • Url: GET /subscriptions/{subscription_id}/events
  • Query Parameters:
    • batch_limit:
      • Maximum number of Events in each chunk (and therefore per partition) of the stream.

      • Default: 1
    • max_uncommitted_events:

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active July 14, 2024 18:27
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active July 19, 2024 09:20
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@rajaraodv
rajaraodv / Monad-sample.js
Created November 9, 2016 00:28
A sample implementation of Monad
//Monad - a sample implementation
class Monad {
constructor(val) {
this.__value = val;
}
static of(val) {//Monad.of is simpler than "new Monad(val)
return new Monad(val);
};
map(f) {//Applies the function but returns another Monad!
return Monad.of(f(this.__value));

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

@dypsilon
dypsilon / reader.js
Last active April 28, 2024 08:50
Example usage of the reader monad.
/**
* This short program will encrypt the user password
* and insert a new record into a mock database.
*/
const Reader = require('fantasy-readers');
const R = require('ramda');
const crypto = require('crypto');
// our mock database
const database = [
@grrywlsn
grrywlsn / proxy-s3.nginx
Created June 6, 2016 22:47
Proxying Nginx to S3
location ~* ^/(.*) {
set $s3_bucket = "<bucket-name>.s3-website-eu-west-1.amazonaws.com";
proxy_http_version 1.1;
proxy_buffering off;
proxy_ignore_headers "Set-Cookie";
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-s3cmd-attrs;