Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active July 5, 2024 02:48
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
@havvg
havvg / ajax-form.js
Created August 1, 2012 13:20
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@EugeneLoy
EugeneLoy / Log test names (JUnit, SLF4J)
Last active August 29, 2015 14:02
Add this field to your test class to log names of the tests when they start. Works with JUnit 4.9+ and SLF4J.
@Rule
public TestRule loggingRule = new TestWatcher() {
protected void starting(Description description) {
Logger logger = LoggerFactory.getLogger(description.getClassName());
logger.info("Starting: {}", description.getMethodName());
}
};
@PauloLuan
PauloLuan / GetExternalSdCardPath.java
Last active October 31, 2022 07:02
how to get the external sd card path on android.
public static String getExternalSdCardPath() {
String path = null;
File sdCardFile = null;
List<String> sdCardPossiblePath = Arrays.asList("external_sd", "ext_sd", "external", "extSdCard");
for (String sdPath : sdCardPossiblePath) {
File file = new File("/mnt/", sdPath);
if (file.isDirectory() && file.canWrite()) {
@staltz
staltz / introrx.md
Last active July 4, 2024 10:11
The introduction to Reactive Programming you've been missing
@EugeneLoy
EugeneLoy / Call private methods on Scala and Java objects
Last active August 29, 2015 14:07
Helper that allows to call private methods on Scala/Java objects
package object utils {
/**
* Helper that allows to call private methods on Scala/Java objects.
*
* Usage: `someObject.exposeMethod('methodName)(arg1, arg2, arg3)`
*
* See: https://gist.github.com/EugenyLoy/5873642543f869c7e25f
*/
implicit class ExposePrivateMethods(obj: AnyRef) {
@theikkila
theikkila / keywords.json
Last active November 24, 2021 14:21
7000 skill keywords
[
"Automotive",
"Budgeting",
"HVAC",
"Heaters",
"Hydraulics",
"Logistics Management",
"Management",
"Negotiation",
"Project Planning",
@EugeneLoy
EugeneLoy / gist:76727e5cec6943f5dd73
Created March 24, 2015 16:50
Save GET to file with datetime as a name
curl -i https://api.github.com/repos/EugenyLoy/awesome-github > `date -u '+%F'_%H_%M`.txt
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@EugeneLoy
EugeneLoy / cheatsheets
Last active June 11, 2021 13:34
Cheat Sheets
Searching ---------------------------------------------------------------------
Find all files that has full filename pattern "YYY" in this rdirectory, recursive:
find . -wholename "YYY"
Find all matches of regexp "XXX" in file YYY:
grep -n -E "XXX" YYY
Find all occurences of "XXX" in all files with name "YYY" in this directory, recursive:
find . -name "YYY" -print0 | xargs -0 grep -n -F "XXX"