Skip to content

Instantly share code, notes, and snippets.

'''Read an html file from a file like object, parse(possibly selective) it and give back the data to the callback for processing.
'''
import urllib2
import re
import sys
from BeautifulSoup import BeautifulSoup
from BeautifulSoup import SoupStrainer
# Inline configs.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int equi(int a[], int n ) {
int i, j;
long int sum = 0;
int **sum_list = calloc(sizeof *sum_list, n);
assert(sum_list != NULL);
for (i = 0; i < n; i++) {
#include <stdio.h>
double fib(int num)
{
if (num <= 1)
return 1;
else
return fib(num-1) + fib(num-2);
}
public class FibNum {
public static void main(String args[]) {
System.out.printf("%.0f\n", fib(Integer.parseInt(args[0])));
}
public static double fib(int n) {
if (n <= 1)
return 1;
else
return fib(n-1) + fib(n-2);
}
$> gcc -o fib -O3 fib.c
$> time ./fib_num
165580141
real 0m1.452s
user 0m1.448s
sys 0m0.000s
$> javac FibNum.java
$> time java -server FibNum
$> gcc -o fib fib_num.c
$> time ./fib
165580141
real 0m3.606s
user 0m3.604s
sys 0m0.000s
#!/usr/bin/perl -w
use strict;
# Lookup the calling object's properties. If not found, lookup for the key in
# base class.
sub dispatch {
my $props = shift;
my $key = shift;
return $props->{$key} || ($props->{'base'} && $props->{'base'}($key))
import java.lang.reflect.*;
class Foo
{
private int i = 10;
public int getI() { return i; }
}
class PrivateTest
/* Hello.java */
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello World");
}
}
/* Hello2.java */
struct node
{
int info;
struct node *next;
};
int cycle(struct node *head)
{
struct node *slow, *fast;