Skip to content

Instantly share code, notes, and snippets.

@harrah
harrah / DeadlockAvoided.scala
Created February 5, 2013 14:09
Demonstrates "Resource deadlock avoided" exception on a file lock when there is no deadlock.
import java.io._
object A
{
/*
* Starts two concurrent threads that acquire file locks in a timed manner.
* Arguments:
* initialDelayA(ms) lockTimeA(ms) lockFileA initialDelayB(ms) lockTimeB(ms) lockFileB
*
* Example usage: demonstrates "Resource deadlock avoided" when there is no actual deadlock.
@dikiaap
dikiaap / git-io-custom-url.md
Last active June 19, 2024 01:26
git.io custom URL

Update: As of 11 January 2022, git.io no longer accepts new URLs.

Command:

curl https://git.io/ -i -F "url=https://github.com/YOUR_GITHUB_URL" -F "code=YOUR_CUSTOM_NAME"

URLs that can be created is from:

  • https://github.com/*
  • https://*.github.com
@markehammons
markehammons / build.sbt
Created December 19, 2018 04:22
Packaging your application with a minimized runtime courtesy of jlink
import java.io.{ByteArrayOutputStream, PrintWriter}
import java.util.spi.ToolProvider
enablePlugins(JavaAppPackaging)
//this allows us to run tools like jdeps and jlink from within the JVM
def runTool(name: String, arguments: Seq[String]): Either[String,String] = {
val maybeTool: Option[ToolProvider] = {
val _tool = ToolProvider.findFirst(name)
if(_tool.isPresent) {
@lbialy
lbialy / reflection.json
Created May 4, 2019 22:01
How to build native coursier from current master
[
{
"name" : "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"allDeclaredClasses" : true,
"allPublicClasses" : true
}
@nafg
nafg / Webpack.sc
Last active August 16, 2022 23:25
import java.io._
import java.util.zip.ZipInputStream
import geny.Generator
import mill._
import mill.define.Target
import mill.scalajslib._
object WebpackLib {
@jamesmacfie
jamesmacfie / README.md
Created October 22, 2019 02:53
iTerm 2 - script to change theme depending on Mac OS dark mode

How to use

In iTerm2, in the menu bar go to Scripts > Manage > New Python Script

Select Basic. Select Long-Running Daemon

Give the script a decent name (I chose auto_dark_mode.py)

Save and open the script in your editor of choice.

@sify21
sify21 / build.sh
Last active February 16, 2023 11:04
build static native image with graal
# build gcc toolchain targeting x86_64-linux-musl with https://github.com/richfelker/musl-cross-make
# don't use master branch which uses musl v1.2.1(the new malloc implementation has deadlock problems, v1.2.2 fixes it, v1.2.0 doesn't have it)
cd ~
git clone https://github.com/richfelker/musl-cross-make -b v0.9.9
cd musl-cross-make
cp config.mak.dist config.mak
# edit config.mak: TARGET = x86_64-linux-musl
# edit cowpatch.sh to fix an error, add "OPTIND=1" after line 56. see https://github.com/richfelker/musl-cross-make/issues/86
# ensure you have g++, on fedora it's "dnf install gcc-c++"
make -j`nproc`