Skip to content

Instantly share code, notes, and snippets.

View emres's full-sized avatar
馃挱
"The purpose of computing is insight, not numbers." -- Richard W. Hamming

Emre Sevin莽 emres

馃挱
"The purpose of computing is insight, not numbers." -- Richard W. Hamming
View GitHub Profile
@emres
emres / gist:1494637
Created December 18, 2011 22:08
Language detection in Bash command line (for German)
en_res=$(echo $(cat some_de.txt EN | gzip | wc -c) - $(gzip -c EN | wc -c) | bc); \
de_res=$(echo $(cat some_de.txt DE | gzip | wc -c) - $(gzip -c DE | wc -c) | bc); \
(echo $en_res EN && echo $de_res DE) | sort -n | head -1 | cut -d' ' -f2
@emres
emres / gist:1494633
Created December 18, 2011 22:06
Language detection in Bash command line - some_de.txt
echo "Iridium ist ein chemisches Element mit dem Symbol Ir und der Ordnungszahl 77. Es z盲hlt zu den 脺bergangsmetallen, im Periodensystem steht es in der Gruppe 9 (in der 盲lteren Z盲hlung Teil der 8. Nebengruppe) oder Cobaltgruppe. Das sehr schwere, harte, spr枚de, silber-wei脽 gl盲nzende Edelmetall aus der Gruppe der Platinmetalle gilt als das korrosionsbest盲ndigste Element. Unter 0,11 Kelvin wechselt es in den supraleitf盲higen Zustand 眉ber." > some_de.txt
@emres
emres / gist:1494616
Created December 18, 2011 22:04
Language detection in Bash command line - some_en.txt
echo "A very hard, brittle, silvery-white transition metal of the platinum family, iridium is the second-densest element (after osmium) and is the most corrosion-resistant metal, even at temperatures as high as 2000 掳C. Although only certain molten salts and halogens are corrosive to solid iridium, finely divided iridium dust is much more reactive and can be flammable. Iridium was discovered in 1803 among insoluble impurities in natural platinum. Smithson Tennant, the primary discoverer, named the iridium for the goddess Iris, personification of the rainbow, because of the striking and diverse colors of its salts. Iridium is one of the rarest elements in the Earth's crust, with annual production and consumption of only three tonnes." > some_en.txt
@emres
emres / gist:1494606
Created December 18, 2011 21:58
Language detection in Bash command line
en_res=$(echo $(cat some_en.txt EN | gzip | wc -c) - $(gzip -c EN | wc -c) | bc); \
de_res=$(echo $(cat some_en.txt DE | gzip | wc -c) - $(gzip -c DE | wc -c) | bc); \
(echo $en_res EN && echo $de_res DE) | sort -n | head -1 | cut -d' ' -f2
@emres
emres / gist:1493151
Created December 18, 2011 11:55
Bash quirk - part 2
$ time LC_COLLATE=C echo "why?"
why?
real 0m0.000s
user 0m0.000s
sys 0m0.000s
@emres
emres / gist:1493114
Created December 18, 2011 11:44
Bash quirk - part 1
$ time echo "why?"
why?
real 0m0.000s
user 0m0.000s
sys 0m0.000s
$ LC_COLLATE=C time echo "why?"
why?
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2048maxresident)k
@emres
emres / swing-demo.scala
Created August 3, 2011 18:10
Adaptation of the JRuby swing demo code from the JRuby Wikipedia article
/*
*
* Adaptation of the JRuby swing demo code from the Wikipedia article at
* http://en.wikipedia.org/wiki/JRuby#JRuby_calling_Java
*
* */
var frame = new javax.swing.JFrame
frame.getContentPane.add(new javax.swing.JLabel("Hello, World!"))
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE)
@emres
emres / RandomPuzzle.java
Created July 31, 2011 11:20
A Java puzzler related to random numbers
import java.util.Random;
public final class RandomPuzzle {
public static void main(String[] args) {
for(int i = 0; i < 256; i++) {
System.out.println(new Random(i).nextInt(8));
}
}
}
@emres
emres / subtitles.el
Created February 21, 2011 14:23
subtitles.el - work on .srt (subripper) subtitle files
;; -*- mode: emacs-lisp; coding: hebrew-iso-8bit-unix -*-
;; subtitles.el - work on .srt (subripper) subtitle files
;; Copyright (C) 2009 Ehud karni <ehud@xxxxxxxxxxxxxx>
;; This file is NOT part of GNU Emacs, distribution conditions below.
;;
;; EHUD KARNI 讬谞专拽 讚讜讛讗
;; Ben Gurion st' 14 谉讜讬专讜讙 谉讘 '讞专
;; Kfar - Sava 44 257 讗讘住 - 专驻讻
;; ==================================
@emres
emres / pangram.py
Created November 22, 2010 14:17
Python function to check if a given string is a pangram
from string import ascii_lowercase as al
def is_pangram(s):
return set(al) - set(s.lower()) == set([])