Skip to content

Instantly share code, notes, and snippets.

View Kalimaha's full-sized avatar
🌒
not because they are easy, but because they are hard

Guido Barbaglia Kalimaha

🌒
not because they are easy, but because they are hard
View GitHub Profile
@Kalimaha
Kalimaha / MDESRepository.kt
Created October 17, 2019 06:09
MDES pushAccount
package au.com.mebank.bfamdesplayground.repositories
import com.mastercard.api.core.ApiConfig
import com.mastercard.api.core.model.RequestMap
import com.mastercard.api.core.security.mdes.MDESCryptography
import com.mastercard.api.core.security.oauth.OAuthAuthentication
import org.springframework.util.ResourceUtils
import java.io.FileInputStream
import com.mastercard.api.mdestokenconnect.PushAccount
@Kalimaha
Kalimaha / request.json
Last active July 18, 2019 03:40
QA for Optimizely web-hook
Parameters: {
"timestamp"=>1563420412,
"project_id"=>15281680010,
"data"=>{"cdn_url"=>"https://cdn.optimizely.com/datafiles/2sGNLZVuHGeEXKAmKc92mo.json",
"environment"=>"Production",
"origin_url"=>"https://optimizely.s3.amazonaws.com/datafiles/2sGNLZVuHGeEXKAmKc92mo.json",
"revision"=>71},
"event"=>"project.datafile_updated", "optimizely"=>{"timestamp"=>1563420412, "project_id"=>15281680010,
"data"=>{"cdn_url"=>"https://cdn.optimizely.com/datafiles/2sGNLZVuHGeEXKAmKc92mo.json",
"environment"=>"Production", "origin_url"=>"https://optimizely.s3.amazonaws.com/datafiles/2sGNLZVuHGeEXKAmKc92mo.json",
import * as optimizelySDK from "@optimizely/js-web-sdk";
import OptimizelySingleton from "./index";
describe("OptimizelySingleton", () => {
const localIsFeatureEnabled = jest.fn();
beforeEach(() => {
optimizelySDK.createInstance = jest.fn(() => ({
isFeatureEnabled: (featureName, userId) => localIsFeatureEnabled(featureName, userId),
}));
@Kalimaha
Kalimaha / test.kt
Last active June 11, 2019 06:47
Attempt to chain Kotlin's Result
private fun first(a: Int): Result<Int?> =
when(a % 2 == 0) {
true -> Result.success(value = a)
false -> Result.failure(Exception("$a is odd"))
}
private fun second(a: Int?): Result<Int?> = Result.failure(Exception("Because!"))
private fun third(a: Int?): Result<Int?> =
when(a?.compareTo(10)) {
@Kalimaha
Kalimaha / Transaction.tk
Created May 31, 2019 04:33
Transaction model
package blog.guidobarbaglia.models
import java.time.LocalDateTime
data class Transaction(val creditCardNumber: String, val amount: Double, val timestamp: LocalDateTime)
@Kalimaha
Kalimaha / ets_test.exs
Last active February 5, 2019 02:07
Elixir ETS
defmodule SwitchWeb.ETSServiceTest do
use ExUnit.Case
@cache_name :switches_cache
@value_1 "eggs"
@value_2 "bacon"
test "initialize cache" do
initialize()
@Kalimaha
Kalimaha / flow_example.ex
Last active January 30, 2019 06:24
Flow Example
defmodule Sandbox do
def hello do
[1, 3, 5, 7]
|> Flow.from_enumerable()
|> Flow.map(&get(&1))
|> Flow.map(&process(&1))
|> Flow.reduce(fn -> [] end, fn value, acc -> [value | acc] end)
|> Enum.to_list
|> IO.inspect
Properties(
id int NOT NULL PRIMARY KEY,
location_id FOREIGN KEY REFERENCES Locations(id),
rent int,
created_at date
)
@Kalimaha
Kalimaha / KY032.py
Created April 20, 2018 08:15
obstacle detection sensor
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO_PIN = 24
GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
delayTime = 0.5
@Kalimaha
Kalimaha / glue_all_together.ex
Last active April 1, 2018 13:26
GenStage playground
import Tizio
{:ok, source} = Tizio.Source.start_link(%{:spam => "eggs"})
{:ok, consumer} = Tizio.Consumer.start_link(42)
{:ok, another_consumer} = Tizio.AnotherConsumer.start_link(42)
GenStage.sync_subscribe(consumer, to: source)
GenStage.sync_subscribe(another_consumer, to: source);