This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download file from https://results.elections.virginia.gov/vaelections/2019%20November%20General/Json/GeneralAssembly.json | |
import json | |
all_results = None | |
with open('va-elections.json') as f: | |
all_results = json.load(f) | |
races = all_results['Races'] | |
votes_by_party = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
caption always '%{= kc}screen / %{kw}%-w%{+bu ky}%n %t%{-bu kw}%+w%{kc}%-37=%{kc} CPU (1/5/15m) %l - %c' | |
altscreen on # also, add "export TERM=xterm" to ~/.zshrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.yuvalshavit; | |
import java.util.Random; | |
import java.util.concurrent.TimeUnit; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.BenchmarkMode; | |
import org.openjdk.jmh.annotations.Mode; | |
import org.openjdk.jmh.annotations.OutputTimeUnit; | |
import org.openjdk.jmh.annotations.Scope; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.IO(getContents, putStr) | |
main :: IO () | |
main = do stdin <- getContents | |
putStr (trimR stdin) | |
trimR :: String -> String | |
trimR "" = "" | |
trimR "\n" = "" | |
trimR (h:t) = h : trimR t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean shouldRun; | |
synchronized (NonSingletonActor.class) { | |
shouldRun = ! executed; | |
executed = true; | |
} | |
if (shouldRun) { | |
// your code here, not under synchronization | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class So32063820 { | |
public String withFinals() { | |
final String a = "hello "; | |
final String b = "world"; | |
return a + b; | |
} | |
public String withoutFinals() { | |
String a = "hello "; | |
String b = "world"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Pluses { | |
public static void main(String[] args) { | |
int first = 1; | |
int second = 100; | |
System.out.println(first + + + + + + second); // 101 | |
System.out.println(first); // 1 | |
System.out.println(second); // 100 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "/usr/share/hubspot/mesos/slaves/20140430-110919-2712310282-5050-4748-53/frameworks/sy3x2/executors/rg941/runs/49d41680-d58e-435e-b66a-588a8766596b/content_web_proc-web-7274_293-1406223393098-1-tarly-us_east_1a/app/.deploy_virtualenv/lib/python2.6/site-packages/gevent/greenlet.py", line 327, in run | |
result = self._run(*self.args, **self.kwargs) | |
File "/usr/share/hubspot/mesos/slaves/20140430-110919-2712310282-5050-4748-53/frameworks/sy3x2/executors/rg941/runs/49d41680-d58e-435e-b66a-588a8766596b/content_web_proc-web-7274_293-1406223393098-1-tarly-us_east_1a/app/.deploy_virtualenv/lib/python2.6/site-packages/raven/transport/base.py", line 197, in send | |
response = compat.urlopen(req, data, self.timeout).read() | |
File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen | |
return _opener.open(url, data, timeout) | |
File "/usr/lib64/python2.6/urllib2.py", line 397, in open | |
response = meth(req, response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Modifier; | |
public class Ctors { | |
private class MyInner { | |
} | |
public static void main(String[] args) { | |
Class<?> cls = Ctors.MyInner.class; | |
int modifiers = cls.getModifiers(); | |
System.out.println(modifiers); // prints 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Ctors { | |
private class MyInner { | |
} | |
} | |
// $ javac Ctors.java && javap -c -private Ctors\$MyInner.class | |
// Compiled from "Ctors.java" | |
// class Ctors$MyInner { | |
// final Ctors this$0; | |
// |
NewerOlder