Skip to content

Instantly share code, notes, and snippets.

@patrickhulce
patrickhulce / mac-setup.sh
Last active December 2, 2022 04:03
GitHub Self-Hosted Runners
#!/bin/bash
# Non-scripted Tasks:
# - Configure device name in Preferences > Sharing
# - Enable Remote Login & Remote Management in Preferences > Sharing
# - Enable automatic login/disable password after sleep in Preferences > Security & Privacy > General
# - Disable screensaver/sleep in Preferences > Energy Saver
# - Disable spotlight indexing of home directory
# - Add a runner in GitHub UI to grab your token https://github.com/<org>/<repo>/settings/actions/runners/new
@tennox
tennox / deepDiffObj.js
Last active September 15, 2022 02:30 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
import _ from 'lodash';
/**
* Deep diff between two objects - i.e. an object with the new value of new & changed fields.
* Removed fields will be set as undefined on the result.
* Only plain objects will be deeply compared (@see _.isPlainObject)
*
* Inspired by: https://gist.github.com/Yimiprod/7ee176597fef230d1451#gistcomment-2565071
* This fork: https://gist.github.com/TeNNoX/5125ab5770ba287012316dd62231b764/
*
@acrylic-origami
acrylic-origami / IxKotlin.kt
Last active February 14, 2019 02:59
Rx operator implementations from the five major classes outlined in https://lam.io/writing/ReactiveX using Kotlin reactive channels
import kotlin.collections.*
import org.reactivestreams.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.reactive.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
@ExperimentalCoroutinesApi
fun <T, U> Publisher<T>.debounce(timeout: Long, ctx: CoroutineContext) = GlobalScope.publish(ctx) {
var idx = 0;
@paramsen
paramsen / build.groovy
Last active January 17, 2024 08:17
Generate Android version code from git count in Gradle (build.gradle)
// Generate a minor version code from git commit count (for prod builds)
static def generateVersionCode() {
def result = "git rev-list HEAD --count".execute().text.trim() //unix
if(result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim() //windows
if(result.empty) throw new RuntimeException("Could not generate versioncode on this platform? Cmd output: ${result.text}")
return result.toInteger()
}
def majorVersion = 1
@ribasco
ribasco / how-to-install-java-on-raspbian.md
Last active March 27, 2021 18:37
How to install the latest java version in Raspbian (Stretch)

Introduction

The default version of java provided in the latest raspbian images are outdated, so we are going to install from the ppa:webupd8team/java repository instead. Please note that add-apt-repository ppa:webupd8team/java will not work, so we will need to add the repository manually.

Installation

  1. Create the gpg key file and paste the following lines of text below
nano key.txt
@whalemare
whalemare / commit-msg-redmine
Last active July 15, 2019 09:49
Add link to redmine ticket by working branch name
message=$(cat "$1")
currentBranch=$(git rev-parse --abbrev-ref HEAD)
currentBranch=$(echo "$currentBranch" | grep -o '[a-zA-Zа-яА-Я]\+-\d*')
echo "current ticket = $currentBranch"
countTrackerWords=$(echo "$message" | grep -w -c Tracker)
if [ $countTrackerWords == 0 ] && [ ! -z $currentBranch ]
then {
@udalov
udalov / getKType.kt
Last active March 16, 2021 21:54
DEPRECATED example how to obtain KType instance from reified T. Please use "typeOf" since 1.3.40!
import java.lang.reflect.*
import kotlin.reflect.KClass
import kotlin.reflect.KType
import kotlin.reflect.KTypeProjection
import kotlin.reflect.KVariance
import kotlin.reflect.full.createType
// --- Interface ---
inline fun <reified T : Any> getKType(): KType =
@ultraon
ultraon / build.gradle
Last active August 19, 2020 18:10
Good example of the merged Jacoco code covarage Gradle configuration
apply plugin: 'com.android.application'
apply from: "$rootDir/coverage.gradle"
//...
android {
//...
buildTypes {
//...
debug {
@mmazzarolo
mmazzarolo / hideOnScroll.js
Last active October 31, 2023 07:32
react-native-action-button hide on scroll
// 1. Define a state variable for showing/hiding the action-button
state = {
isActionButtonVisible: true
}
// 2. Define a variable that will keep track of the current scroll position
_listViewOffset = 0
// 3. Add an onScroll listener to your listview/scrollview
<ListView
@wjmazza
wjmazza / google-sheets-colour-preview.js
Last active April 19, 2024 06:15 — forked from Pathoschild/google-sheets-color-preview.js
A Google Sheets script which adds colour preview to cells. When you edit a cell containing a valid CSS hexadecimal colour code (like #000 or #000000), the background colour will be changed to that colour and the font colour will be changed to the inverse colour for readability.
/*
This script is meant to be used with a Google Sheets spreadsheet. When you edit a cell containing a
valid CSS hexadecimal colour code (like #000 or #000000), the background colour will be changed to
that colour and the font colour will be changed to the inverse colour for readability.
To use this script in a Google Sheets spreadsheet:
1. go to Tools » Script Editor » Spreadsheet;
2. erase everything in the text editor;
3. change the title to "Set colour preview on edit";