Skip to content

Instantly share code, notes, and snippets.

@inderpreet99
inderpreet99 / finder-open-iterm-here.scpt
Last active March 1, 2020 17:49 — forked from cowboy/finder-open-iterm-here.scpt
Finder Open iTerm Here: Drop a folder on this script (or just run it) to open a new iTerm window there. If the selected item isn't a folder, it will open the item's parent folder. Great when bound to a hotkey in FastScripts or added to the Finder Sidebar. Works with iTerm2-v3 (2.9)
(*
* Finder Open iTerm Here - v1.0.2 - 4/14/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*)
tell application "Finder"
@mikehearn
mikehearn / BriefLogFormatter.kt
Created February 25, 2016 10:02
BriefLogFormatter
// A couple of inlined utility functions: the first is just a syntax convenience, the second lets us use
// Kotlin's string interpolation efficiently: the message is never calculated/concatenated together unless
// logging at that level is enabled.
inline fun <reified T : Any> loggerFor(): org.slf4j.Logger = LoggerFactory.getLogger(T::class.java)
inline fun org.slf4j.Logger.trace(msg: () -> String) {
if (isTraceEnabled) trace(msg())
}
/**
* A Java logging formatter that writes more compact output than the default.
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@diegopacheco
diegopacheco / deploy-rpm-nexus.sh
Last active March 19, 2024 11:13
deploy-rpm-nexus.sh
#!/bin/bash
### Method 1
###
mvn deploy:deploy-file \
-DgroupId=com.github.diegopacheco.sandbox.devops \
-DartifactId=fpmtest \
-Dversion=1.0.0 \
-DgeneratePom=true \
-Dpackaging=rpm \
@kjkrol
kjkrol / StreamZip.java
Last active March 1, 2022 11:52
Zipping streams using JDK8 with lambda
import java.util.Iterator;
import java.util.function.BiFunction;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
* Zipping streams into parallel or sequential stream using JDK8 with lambda
*
* @author Karol Krol
*/
@viktorklang
viktorklang / Future-retry.scala
Last active July 23, 2023 23:48
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
@return1
return1 / trim_enabler.txt
Last active August 25, 2023 02:59
TRIM Enabler for OS X Yosemite 10.10.3
#
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs
# just run "sudo trimforce enable" to activate the trim support from now on!
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
def countChange(money: Int, coins: List[Int]): Int =
if (money < 0 || coins.isEmpty)
0
else if (money == 0)
1
else
countChange(money - coins.head, coins) + countChange(money, coins.tail)
@jboner
jboner / latency.txt
Last active May 17, 2024 01:05
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@eberle1080
eberle1080 / dirwatcher.scala
Created September 25, 2011 22:45
Uses the Java 7 WatchEvent filesystem API from within Scala
/**
* watcher.scala
*
* Uses the Java 7 WatchEvent filesystem API from within Scala.
* Based on http://markusjais.com/file-system-events-with-java-7/
*
* @author Chris Eberle <eberle1080@gmail.com>
* @version 0.1
*/