Skip to content

Instantly share code, notes, and snippets.

@yurylyt
yurylyt / gist:3866363
Created October 10, 2012 15:31
Chosen on a hidden element
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>GwtQuery: Chosen plugin example</title>
<link rel="stylesheet" href="bootstrap.css"/>
<link rel="stylesheet" href="style.css"/>
<link rel="stylesheet" href="http://harvesthq.github.com/chosen/chosen/chosen.css"/>
<style type="text/css">
body {
@yurylyt
yurylyt / gist:3951355
Created October 25, 2012 08:12
where-do-stack-traces-come-1
public class Main {
public static void main(String[] args) throws IOException {
try {
foo();
} catch (RuntimeException e) {
bar(e);
}
}
@yurylyt
yurylyt / gist:3951362
Created October 25, 2012 08:14
where-do-stack-traces-come-2
public static void main(String[] args) throws IOException {
final RuntimeException e = foo();
bar(e);
}
private static RuntimeException foo() {
return new RuntimeException();
}
private static void bar(RuntimeException e) {
@yurylyt
yurylyt / gist:3951368
Created October 25, 2012 08:16
where-do-stack-traces-come-3
Exception in thread "main" java.lang.RuntimeException
at Main.foo(Main.java:7)
at Main.main(Main.java:15)
@yurylyt
yurylyt / gist:3951373
Created October 25, 2012 08:16
where-do-stack-traces-come-4
public class Throwable implements Serializable {
public synchronized native Throwable fillInStackTrace();
//...
}
@yurylyt
yurylyt / gist:3951375
Created October 25, 2012 08:17
where-do-stack-traces-come-5
public class SponsoredException extends RuntimeException {
@Override
public synchronized Throwable fillInStackTrace() {
setStackTrace(new StackTraceElement[]{
new StackTraceElement("ADVERTISEMENT", " If you don't ", null, 0),
new StackTraceElement("ADVERTISEMENT", " want to see this ", null, 0),
new StackTraceElement("ADVERTISEMENT", " exception ", null, 0),
new StackTraceElement("ADVERTISEMENT", " please buy ", null, 0),
new StackTraceElement("ADVERTISEMENT", " full version ", null, 0),
@yurylyt
yurylyt / gist:3951377
Created October 25, 2012 08:17
where-do-stack-traces-come-6
Exception in thread "main" SponsoredException
at ADVERTISEMENT. If you don't (Unknown Source)
at ADVERTISEMENT. want to see this (Unknown Source)
at ADVERTISEMENT. exception (Unknown Source)
at ADVERTISEMENT. please buy (Unknown Source)
at ADVERTISEMENT. full version (Unknown Source)
at ADVERTISEMENT. of the program (Unknown Source)
Exception in thread "main" ExceptionFromHell: Catch me if you can
@yurylyt
yurylyt / gist:3951380
Created October 25, 2012 08:18
where-do-stack-traces-come-7
public class StackTraceBenchmark extends SimpleBenchmark {
@Param({"1", "10", "100", "1000"})
public int threadDepth;
public void timeWithoutException(int reps) throws InterruptedException {
while(--reps >= 0) {
notThrowing(threadDepth);
}
}
public class Deadlock {
public static void main(String[] args) {
final Integer mutex1 = 1;
final Integer mutex2 = 2;
new Thread(new DeadlockRunnable(mutex1, mutex2)).start();
new Thread(new DeadlockRunnable(mutex2, mutex1)).start();
}
static class DeadlockRunnable implements Runnable {
private final Integer first;
// ==UserScript==
// @name Maxdone Hide Recurring
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide recurring tasks
// @author Yury Lytvynenko
// @match https://maxdone.micromiles.co/*
// @grant none
// ==/UserScript==
var hidden = false;