Skip to content

Instantly share code, notes, and snippets.

Barosl Lee barosl

Block or report user

Report or block barosl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@barosl
barosl / gist:2760954
Created May 21, 2012
Simple Exif manipulation script
View gist:2760954
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
View js-web-socket-client.html
<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');
@barosl
barosl / gist:0c2cff4755144a7d372d
Last active Aug 29, 2015
Decoding a hex string
View gist:0c2cff4755144a7d372d
>>> bytes.fromhex('ab')
b'\xab'
>>> import binascii
>>> binascii.unhexlify('ab')
b'\xab'
>>> import codecs
>>> codecs.decode('ab', 'hex')
b'\xab'
@barosl
barosl / gist:1d3a9f2b6959d32ea2ca
Created Jan 7, 2015
Unscientific benchmarks of programming languages
View gist:1d3a9f2b6959d32ea2ca
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
@barosl
barosl / Traceback
Created Apr 12, 2015
This... is... so Java
View Traceback
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)
@barosl
barosl / main.rs
Created Jul 7, 2015
Implicit coercion rules in Rust
View main.rs
// 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) {}
@barosl
barosl / add.c
Created Jul 26, 2015
Function overloading in C
View add.c
#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);
@barosl
barosl / prime-naive.rs
Created Aug 2, 2015
Naive prime number generation in Rust
View prime-naive.rs
//! 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)
You can’t perform that action at this time.