Skip to content

Instantly share code, notes, and snippets.

import org.json.JSONObject
import java.io.File
const val tinyPngApiKey = "<YOUR-API-KEY-GOES-HERE>"
val projectDir = File("<PATH-TOPROJECT-ROOT>")
val supportedExtensions = listOf("png", "jpg")
fun main() {
projectDir.walk().forEach { srcFile ->
if (supportedExtensions.contains(srcFile.extension)) {
1. Download Git Bash (only if on Windows)
2. Go to your users folder and open the .ssh folder. Then open Git Bash / Terminal there and generate a key pair:
ssh-keygen -m PEM -t rsa
3. Copy the key to your server:
ssh-copy-id -i <keyname> <user>@<host>
5. Login to your Ubuntu server via SSH:
ssh -i <keyname> <user>@<host>
@MarkusKramer
MarkusKramer / Base64.kt
Last active October 29, 2024 14:53
Kotlin Multiplatform Base64 - no extra dependencies. Based on Java's implementation.
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js"></script>
</head>
<body>
<div id="root">
</div>
@PrashantBhatasana
PrashantBhatasana / Jenkinsfile
Last active August 26, 2021 15:35
This is the Jenkins file for building React Navite application.
def err = null
try {
node {
stage('Preparation') {
git credentialsId: 'fef4159e-285b-45d9-80ca-5981c4576ba5', url: 'https://github.com/prashant-bhatasana/demoApp/'
}
stage('Dependencies') {
@EmmanuelGuther
EmmanuelGuther / ApiRefreshToken.kt
Last active May 15, 2023 09:01
Retrofit builder to handle calls with authorization requirements and interceptor with refresh token.
interface ApiRefreshToken {
companion object {
private const val REFRESH_TOKEN = "/refreshToken"
}
@FormUrlEncoded
@POST(REFRESH_TOKEN)
fun refreshToken(@Field("refreshToken") refreshToken: String?): Call<TokenModel>
}
@fritz-c
fritz-c / git-hubdiff
Last active November 9, 2022 19:46
Open up diff on Github
#!/usr/bin/env bash
# Opens the comparison of two commits on Github (only for repositories on Github)
# Download this script as "git-hubdiff" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git hubdiff` from inside any git repo.
usage()
{
echo "USAGE"
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@vasanthk
vasanthk / System Design.md
Last active November 19, 2024 10:54
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@race604
race604 / adb+
Last active August 20, 2023 09:03
#!/bin/bash
# Script adb+
# Run any command adb provides on all your currently connected devices,
# Or prompt to select one device
showHelp() {
echo "Usage: adb+ [-a] <command>"
echo " -h: show help"
echo " -a: run command on all device"
echo " command: normal adb commands"