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 / 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 / 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
barosl /
Created Aug 2, 2015
Naive prime number generation in Rust
//! Conforms to the input data format of 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));
barosl /
Created Jul 7, 2015
Implicit coercion rules in Rust
// 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 / 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 / gist:1d3a9f2b6959d32ea2ca
Created Jan 7, 2015
Unscientific benchmarks of programming languages
View gist:1d3a9f2b6959d32ea2ca
Unscientific benchmarks using
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 / gist:0c2cff4755144a7d372d
Last active Aug 29, 2015
Decoding a hex string
View gist:0c2cff4755144a7d372d
>>> bytes.fromhex('ab')
>>> import binascii
>>> binascii.unhexlify('ab')
>>> import codecs
>>> codecs.decode('ab', 'hex')
View js-web-socket-client.html
<meta name="viewport" content="width=device-width">
<script src="//"></script>
#in { width: 500px; }
<input type="text" id="in">
<div id="out"></div>
sock = new WebSocket('ws://');
//sock = new WebSocket('ws://');
You can’t perform that action at this time.