Skip to content

Instantly share code, notes, and snippets.

<project name="myproject" default="dist" basedir=".">
<property name="src.dir" value="src" />
<property name="build.dir" value="build" />
<property name="dist.dir" value="dist" />
<path id="project.classpath">
<pathelement location="${build.dir}"/>
</path>
<target name="compile" description="Compile the project">
<mkdir dir="${build.dir}" />
package com.myproject;
public class Foo {
public int bar(int a) {
return a+1;
}
}
<project name="myproject-test" default="test" basedir=".">
<property name="src.dir" value="src" />
<property name="build.dir" value="build" />
<property name="reports.dir" value="reports"/>
<property name="tested.jar.file" value="myproject.jar"/>
<property name="junit.reports.dir" value="${reports.dir}/junit"/>
<path id="project.classpath">
<pathelement location="lib/junit-4.4.jar"/>
<pathelement location="${tested.jar.file}"/>
<pathelement location="${build.dir}"/>
package com.myproject;
import org.junit.Test;
public class FooTest {
@Test
public void test1() throws Exception {
Foo f = new Foo();
assert f.bar(1) == 2;
Thread.sleep(60000); // Just to simulate long tests
@barnash
barnash / 1.py
Last active December 27, 2015 10:49
Code samples from Recitation2
m = int(input("enter a positive integer to check if it's a**2 + b**2: "))
for a in range(1, m):
for b in range(1 ,m):
if a**2 + b**2 == m:
print (a, b, m)
import random
def is_prime(num):
for i in range(1000):
a = random.randint(2, num - 1)
if pow(a, num - 1, num) != 1:
return False
return True
def dh_exchange(p):
g = random.randint(1, p - 1)
@barnash
barnash / client.py
Created December 10, 2013 06:13
קוד מתרגול 6
import socket
client = socket.socket()
client.connect(("127.0.0.1", 5678))
print("Connected! I'm the man/woman!")
client.send("Hey you!".encode())
message = client.recv(2000).decode()
print("Server sent " + message)
@barnash
barnash / oop.py
Created December 17, 2013 06:30
קוד מתרגול 7
class Point:
""" this point is...
bnla ba lba
"""
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
def __repr__(self):
return "(" + str(self.x) + "," + str(self.y) + ")"
{% extends 'includes/base_header.html' %}
{% from 'includes/links.html' import course_link %}
{% block window_title %}אנשים{% endblock %}
{% block stylesheets %}{{ super() }}
<link rel="stylesheet" type="text/css" href="/static/css/people-list.css" />
{% endblock %}
@barnash
barnash / recursion.py
Created December 24, 2013 06:37
קוד מתרגול 8
def my_max(lst):
mv = lst[0]
for i in lst:
if i > mv:
mv = i
return mv
def rmax_oz(lst):
if len(lst) == 1:
return lst[0]