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
//! Conforms to the input data format of http://www.spoj.com/problems/PRIME1/ but not usable as a | |
//! solution due to the slowness of the algorithm | |
use std::io::{stdin, BufRead}; | |
use std::error::Error; | |
fn get_line<R: BufRead>(r: &mut R) -> Result<String, Box<Error>> { | |
let mut line = String::new(); | |
try!(r.read_line(&mut line)); | |
Ok(line) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int addi(int a, int b) { | |
return a + b; | |
} | |
char *adds(char *a, char *b) { | |
char *res = malloc(strlen(a) + strlen(b) + 1); |
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
// A normal function that accepts a `&str` | |
fn a(_: &str) {} | |
// A normal function that accepts a *trait* that is implemented by `&str` | |
trait StringNeeded {} | |
impl<'a> StringNeeded for &'a str {} | |
fn b<X: StringNeeded>(_: X) {} |
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
scala.MatchError: 123 (of class java.lang.Integer) | |
at App$.main(test.scala:4) | |
at App.main(test.scala) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) | |
at java.lang.reflect.Method.invoke(Unknown Source) | |
at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:70) | |
at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31) | |
at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:101) |
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
Unscientific benchmarks using https://github.com/barosl/kong | |
C (optimized): 1.1s | |
Rust (optimized): 1.2s | |
C: 1.6s | |
Java: 3.7s | |
Haskell (optimized): 5.5s | |
Rust: 6.6s | |
JavaScript (with Node.JS): 9.3s | |
PyPy: 9.9s |
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
>>> bytes.fromhex('ab') | |
b'\xab' | |
>>> import binascii | |
>>> binascii.unhexlify('ab') | |
b'\xab' | |
>>> import codecs | |
>>> codecs.decode('ab', 'hex') | |
b'\xab' |
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
<meta name="viewport" content="width=device-width"> | |
<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.js"></script> | |
<style> | |
#in { width: 500px; } | |
</style> | |
<input type="text" id="in"> | |
<div id="out"></div> | |
<script> | |
sock = new WebSocket('ws://baro.sl:7942/wakana'); | |
//sock = new WebSocket('ws://baro.sl:8765/wakana'); |
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
HOURS_DIFFERENCE = 9 # can be negative | |
import os | |
import time | |
import datetime | |
import pyexiv2 | |
for fname in os.listdir('.'): | |
if fname.lower().endswith('.jpg'): | |
print fname |