Skip to content

Instantly share code, notes, and snippets.

@blzjns
blzjns / tasks.json
Created March 24, 2016 14:12
vscode (Visual Studio Code) task for go lang
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
"version": "0.1.0",
"command": "go", //or absolute path: /usr/local/go/bin/go
@blzjns
blzjns / araketu.js
Last active May 12, 2021 03:17
O fogo é fogo! Esquenta! Esquenta nosso amor O fogo é fogo! Esquenta! Que o Ará chegou... #sourcecodepoetry #araketu #axecode
import { EARTH } from 'universe';
import { dj } from 'salvador-bh';
const araketu = {
isPlaying: dj.checkOSomDaCaixa(),
todoMundo: async () => await EARTH.getAllPeople()
};
if(araketu.isPLaying) {
araketu.todoMundo().forEach((p) => {
@blzjns
blzjns / MultipartFormData.scala
Last active August 30, 2019 13:27
multipart akka http scala request formdata file client
import java.nio.file.{Path, Paths}
import akka.stream.scaladsl.Source
val foo: Path = Paths.get("/images/foo.jpg")
val bar: Path = Paths.get("/images/bar.png")
val data = Multipart.FormData {
Source {
List (
Multipart.FormData.BodyPart.fromPath("foo", ContentTypes.`application/octet-stream`, foo),
@blzjns
blzjns / CustomContentType.scala
Created August 10, 2016 18:19
akka http custom content type
import akka.http.scaladsl.Http
import akka.http.scaladsl.client.RequestBuilding._
val customContentType = ContentType(MediaType.customWithFixedCharset("binary", "octet-stream", HttpCharsets.`UTF-8`)) //Content-Type: binary/octet-stream
val someData = "{}"
//simple http call using above content type
Http().singleRequest(
Put("http://127.0.0.1:8080/someendpoint")
@blzjns
blzjns / CircuitBreakerSpotlight.scala
Created August 25, 2016 19:44 — forked from patriknw/CircuitBreakerSpotlight.scala
Circuit Breaker Spotlight
import akka.pattern.CircuitBreaker
val breaker =
CircuitBreaker(system.scheduler,
maxFailures = 5,
callTimeout = 10.seconds,
resetTimeout = 1.minute)
def dangerous: Future[String] =
breaker.withCircuitBreaker(Future(dangerousCall))
@blzjns
blzjns / fixGitUntrackedFiles.sh
Last active December 12, 2019 16:16
Fixes failing (not working) .gitignore
git rm -r --cached .
git add .
git commit -m "fix untracked files"
@blzjns
blzjns / BubbleSortExample.java
Created September 8, 2017 00:05
Bubble Sort Sample with Comments
package com.company;
import java.util.Arrays;
public class BubbleSortExample {
public static void main(String[] args) {
int[] list = {34, 203, 3, 746, 200, 984, 198, 764, 9}; // list of numbers, aka: array
bubbleSort(list);
@blzjns
blzjns / git-prompt.sh
Last active February 15, 2020 04:42
Custom git bash command-line header. Displays user name, current path, repo name, and repo branch
displayUserTxt=">_ blzjns"
userBgColor="\e[7;49;32m"
branchColor="\e[1;35m"
pathColor="\e[0;33m"
repoColor="\e[36m"
boldTxt=$(tput bold)
noTextFmt="\e[0m"
if test -f /etc/profile.d/git-sdk.sh; then
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
@blzjns
blzjns / binaryJump.js
Created January 9, 2022 10:44
BinarySearch on multi-dimensional (2D grid), best jump/move from position [X, Y] given a set of directions (up, down, left, right)
/*
Using BinarySearch,
from a given point [x, y] on a 2D grid (WxH) find the next-best position in order to reach an element as soon as possible.
*/
const W = readInt('Building width: '); // width of the building.
const H = readInt('Building height: '); // height of the building.
const N = readInt('Max. no of turns: '); // maximum number of turns before game over.
let X = readInt('Start from X: ');
let Y = readInt('Start from Y: ');
if [ -z $mexer_c_nois ]; then
se_prepara
fi