Skip to content

Instantly share code, notes, and snippets.

View markus2610's full-sized avatar

Markus markus2610

View GitHub Profile
@markus2610
markus2610 / CompositeParameterProvider.kt
Created December 22, 2023 09:24 — forked from mrmans0n/CompositeParameterProvider.kt
Simple example that allows you to add 2 PreviewParameterProviders to a Compose preview
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import kotlin.reflect.KClass
/**
* Creates a [PreviewParameterProvider] based on the classes of two existing providers.
*
* You can create your own easily with Kotlin delegation:
* ```
* class ExampleProvider : PreviewParameterProvider<Pair<Type1, Type2>>
* by compositeProvider(Type1ParameterProvider::class, Type2ParameterProvider::class)
@markus2610
markus2610 / AlignmentLines.kt
Created March 3, 2023 08:21 — forked from manuelvicnt/AlignmentLines.kt
Full code for the Alignment lines in Jetpack Compose documentation
// NOTE: This code uses Compose 1.0.0-beta09
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@markus2610
markus2610 / AnimationClocks.kt
Created November 8, 2022 15:36 — forked from adamp/AnimationClocks.kt
Working with animation frame time in Jetpack Compose
/**
* Returns a [State] holding a local animation time in milliseconds.
* The value always starts at `0L` and stops updating when
* the call leaves the composition.
*/
@Composable
fun animationTimeMillis(): State<Long> {
val millisState = state { 0L }
val lifecycleOwner = LifecycleOwnerAmbient.current
launchInComposition {
@markus2610
markus2610 / hex2bgr.py
Created November 5, 2022 12:43 — forked from stfuchs/hex2bgr.py
snippet to convert hex color list to cv::Scalar vector(bgr)
# example color list:
c = """#e41a1c
#377eb8
#4daf4a
#984ea3
#ff7f00
#ffff33
#a65628
#f781bf
#999999"""
@markus2610
markus2610 / request-interceptor.ts
Created April 17, 2021 17:34
Http Intercepter with CryptoJS
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operators';
import * as CryptoJS from 'crypto-js';
export class RequestInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// Encrypt the body.
const updatedReq = req.clone({

Charles command-line options

Charles supports a few command line options out of the box, documented here.
Unfortunately they seem to operate only as parameters for new Charles sessions, so you won't be able to run commands on a running instance of Charles.

Start a specific Charles session

A Charles session contains all of your recorded information. It is represented by the Session window; by default a new session is automatically created when you start Charles.
Sessions can be saved from File → Save Session (+S).
Once saved, if you want you can start Charles from the saved session by running:

@markus2610
markus2610 / Mongo.md
Created December 31, 2020 10:30 — forked from jnewman12/Mongo.md
Data Modeling With Mongo

Data Modeling with MongoDB

mongo


Objectives

  • Understand model relationships in MongoDB
  • Understand One-to-Many relationships
@markus2610
markus2610 / Docker shell commands.sh
Created October 15, 2020 14:30 — forked from bahmutov/Docker shell commands.sh
A personal cheat sheet for running local Node project in a Docker container
# See list of docker virtual machines on the local box
$ docker-machine ls
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1
# Note the host URL 192.168.99.100 - it will be used later!
# Build an image from current folder under given image name
$ docker build -t gleb/demo-app .
const fs = require('fs');
const yargs = require('yargs');
const { Argv } = yargs;
const { promisify } = require('util');
const { resolve } = require('path');
const exists = promisify(fs.exists);
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
@markus2610
markus2610 / shell_helper.sh
Last active May 28, 2020 16:28
Just basic commands I often forget
[[ -f ~/.ssh/id_rsa ]] && echo exists #Test if a file exists
[[ -d ~/.ssh ]] && echo exists #Test if a directory exists
[[ $@ == *"--arg1"* ]] && echo exists #Test if text is present in string
git log --cherry -p HEAD...SOURCE #See how merge will be done
git reset 55b0788 #Move/reset HEAD to that commit
rm -rf src && git checkout 55b0788 #Git revert like
ls -lah #List files with size in MB
du -hcs directory_here #Show directory size in MB