Skip to content

Instantly share code, notes, and snippets.

@carolosf
carolosf / gitaliases.sh
Last active March 9, 2016 16:08
aliases for git
#!/bin/bash
# from https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
@carolosf
carolosf / ExplodeNestedArrayPhp
Last active April 12, 2023 09:06
Explode To Nested Array - Converts a string with a delimiter into a nested associative array and assigns the value to the final key
<?php
/**
* Converts a string with a delimiter into a nested associative array and assigns the value to the final key
* by Carolos Foscolos - I call this little algorithm bubble wrap - because it's like wrapping bubbles around each other
* explodeToNestedArray('.', 'abc.def', 'XYZ') becomes ['abc' => ['def' => 'XYZ']]
*
* @param string $delimiter
* @param string $key
* @param $value
*

Keybase proof

I hereby claim:

  • I am carolosf on github.
  • I am carolosf (https://keybase.io/carolosf) on keybase.
  • I have a public key whose fingerprint is ECA5 5E77 8B17 5457 4404 83DE C4BC 249A 4B99 BADA

To claim this, I am signing this object:

@carolosf
carolosf / build.gradle.kts
Last active November 20, 2017 18:21
Example gradle build file using kotlin dsl
// Gradle version 4.3.1 and kotlin dsl 0.12.3
// Kotlin 1.1.60
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.Coroutines
group = "com.example"
version = "1.0-SNAPSHOT"
buildscript {
val kotlinVersion: String by extra { "1.1.60" }
@carolosf
carolosf / midi.sh
Created February 24, 2018 18:17
Nice mappings for FL Studio 12 and my M-Audio Axiom air 32 mini
#!/bin/bash
# Nice mappings for FL Studio 12 and my M-Audio Axiom air 32 mini
# aseqdump -l
# aseqdump -p "Axiom A.I.R. Mini32"
# sudo apt install xdotool
aseqdump -p "Axiom A.I.R. Mini32" | \
while IFS=" ," read src ev1 ev2 ch label1 data1 label2 data2 rest; do
#echo "$srsc $ev1 $ev2 $ch $label1 $data1 $label2 $data2 $rest"
case "$ev1 $ev2 $data1 $data2" in
"Control change 17 127" ) xdotool key space ;;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.List;
public class CreateMonsterRepositorySql implements CreateMonsterRepository {
private final JdbcTemplate jdbcTemplate;
public CreateMonsterRepositorySql(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
@carolosf
carolosf / README.md
Created April 4, 2018 20:31
Useful Command Line
@carolosf
carolosf / build.gradle
Last active April 24, 2018 16:18
Kotlin 1.2.31 ElasticSearch 6.2.3 Clean Architecture exercise
buildscript {
ext.kotlin_version = '1.2.31'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@carolosf
carolosf / dynamicSorting.kt
Last active May 15, 2018 21:45
Sort objects in Kotlin by dynamically sorted field order
data class User(val id: String, val email: String, val title: String)
val sortedById = {u : User -> u.id}
val sortedByEmail = {u : User -> u.email}
val sortOrder = listOf("id", "email")
val transformedSortOrderListToComparable = sortOrder.map {
when (it) {
"id" -> sortedById //Can inline
group 'com.example'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"