This file contains hidden or 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
int getint(char end) { | |
int s = 0; | |
int ch; | |
ch = getchar(); | |
while (ch != end && ch != EOF) { | |
s = s * 10 + ch - '0'; | |
ch = getchar(); | |
} | |
return s; | |
} |
This file contains hidden or 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
inline void putint(int n) | |
{ | |
static char buf[20]; | |
register int pos; | |
register int x = n; | |
if (x == 0) { | |
putchar('0'); | |
return; | |
} | |
if (x == INT_MIN) { // x = -x do not work for the minimal value of int, so process it first |
This file contains hidden or 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
#!/usr/bin/python2 | |
import sys | |
import re | |
records = [] | |
for line in sys.stdin: | |
records.append(re.match(r'[ ]*(\d)+ ([^ ]+)(.*)', line.rstrip()).groups()) | |
for record in sorted(records, key=lambda d:int(d[0])*(len(d[1])+len(d[2])), reverse=True): | |
print "%s %s%s" % record |
This file contains hidden or 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 <assert.h> | |
#include <stdio.h> | |
#include <string.h> | |
typedef int T; | |
/** | |
* [Sorting network](http://en.wikipedia.org/wiki/Sorting_network) | |
*/ | |
void sort8(T ar[], int n) { |
This file contains hidden or 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
# http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n | |
:a | |
N | |
$!ba | |
s/\\/\\\\/g | |
s/"/\\"/g | |
s/\r/\\r/g | |
s/\t/\\t/g | |
s/\f/\\f/g | |
s/\n/\\n" +\n"/g |
This file contains hidden or 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
#!/bin/sh | |
REPO=~/.m2/repository | |
exec scala -classpath $REPO/commons-io/commons-io/2.4/commons-io-2.4.jar:$REPO/javax/mail/mail/1.4.6/mail-1.4.6.jar:$REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar "$0" "$@" | |
!# | |
import java.io.InputStreamReader | |
import java.nio.charset.Charset | |
import javax.mail.internet.MimeUtility | |
import org.apache.commons.io.IOUtils |
This file contains hidden or 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
.PHONY: all | |
all: highvote-pdf.mk | |
make -j4 -f $< WEB2PDF=/home/henix/web2pdf.sh | |
highvote-pdf.mk: highvote.html | |
xmllint --html --xpath "//a[@class='question-hyperlink']/@href" $< 2> /dev/null | sed -e 's/ href="//g' -e 's/"/\n/g' | lua link2mk.lua > $@ | |
highvote.html: | |
curl 'http://stackoverflow.com/questions/tagged/scala?sort=votes&pagesize=50' > $@ |
This file contains hidden or 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
* { | |
font-family: "DejaVu Serif", "AR PL New Sung", "WenQuanYi Zen Hei", serif; | |
} | |
@page { | |
/*background-color: #C7EDCC;*/ | |
background-color: #CCB995; | |
margin: 1.5cm; | |
} |
This file contains hidden or 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
#!/bin/sh | |
find . -name "*.jar" | xargs -L 1 unzip -l | grep 'class$' | awk '{print $4}' | sed -e 's/\.class$//g' -e 's/\//./g' |
This file contains hidden or 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
/* RPN = Reverse Polish notation */ | |
operator(add). | |
operator(sub). | |
operator(mul). | |
operator(div). | |
doop(add, A, B, C) :- C = A + B. | |
doop(sub, A, B, C) :- C = A - B. | |
doop(mul, A, B, C) :- C = A * B. |