Skip to content

Instantly share code, notes, and snippets.

View kikoso's full-sized avatar
💭
Learning things.

Enrique López Mañas kikoso

💭
Learning things.
View GitHub Profile
@kikoso
kikoso / TimeBasedSeedPortfolioSimulation.kt
Created April 12, 2025 07:50
Portfolio Simulation with a Time Based Seed.
val rng = Random(System.currentTimeMillis())
val accumulatedResults = (1..simulations).map {
val accumulatedReturnsA = simulatePortfolioAccumulatedReturns(portfolioA, rng)
val accumulatedReturnsB = simulatePortfolioAccumulatedReturns(portfolioB, rng)
SimulationResult(it, accumulatedReturnsA, accumulatedReturnsB)
}
@kikoso
kikoso / SameSeedPortfolioSimulation.kt
Created April 12, 2025 07:48
Portfolio Simulation using the same Seed
val rng1 = Random(123)
val rng2 = Random(123)
val accumulatedResults = (1..simulations).map {
val accumulatedReturnsA = simulatePortfolioAccumulatedReturns(portfolioA, rng1)
val accumulatedReturnsB = simulatePortfolioAccumulatedReturns(portfolioB, rng2)
SimulationResult(it, accumulatedReturnsA, accumulatedReturnsB)
}
@kikoso
kikoso / add_frame_to_screenshot.py
Created December 8, 2023 18:10
Add Frame to Screenshot in Android
from PIL import Image
def overlay_images(background_path, overlay_path, output_path, padding=40, transparency=0, top_margin=30):
# Open background image
background = Image.open(background_path)
# Open overlay image
overlay = Image.open(overlay_path)
#!/usr/bin/env python3
#
# Extract the ticket's id from the branch name and add it
# to the commit message. Adapted from:
# https://andy-carter.com/blog/automating-git-commit-messages-with-git-hooks
# Parameters are explained here:
# https://git-scm.com/docs/githooks#_prepare_commit_msg
import re
import sys
function copyPortfolioValue() {
var rangeToLog = 'Investment!B71:F71';// this is where the data tocopy is located
var sheetToLogTo = 'Value';// this is the name of new sheet we want to copy to
var ss = SpreadsheetApp.getActive();// getting th spreadsheetvar
valuesToLog = ss.getRange(rangeToLog).getValues();// getting the desired data
var logSheet = ss.getSheetByName(sheetToLogTo);// getting the sheet to copy
if (!logSheet) {// just in case you didn’t createit
logSheet = ss.insertSheet(sheetToLogTo);
}
var rowToAppend = valuesToLog.reduce(function (a, b) { return a.concat(b); })// format data
@kikoso
kikoso / KeyPair.kt
Last active October 26, 2020 19:30
KeyPair.kt
private lateinit var keyPair: KeyPair
private fun generateKey() {
val startDate = GregorianCalendar()
val endDate = GregorianCalendar()
endDate.add(Calendar.YEAR, 1)
val keyPairGenerator: KeyPairGenerator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, ANDROID_KEYSTORE)
val parameterSpec: KeyGenParameterSpec = KeyGenParameterSpec.Builder(KEY_ALIAS,
void getStops(double latitude, double longitude, int radiusInMeters)
void getStops(double latitude, double longitude)
void getStops(double latitude)
@JvmOverloads
fun getStops(
latitude: Double,
longitude: Double = 0.0,
radiusInMeters: Int = 100
)
implements ('com.example.android:my-lib:1.0.0@aar'){
transitive=true
}
@file:JvmName("ClassName")
package org.file
class MyUtils
fun getLocale()