Skip to content

Instantly share code, notes, and snippets.

View mickeypash's full-sized avatar
🐢
slow and steady wins the race

Mickey Pashov mickeypash

🐢
slow and steady wins the race
View GitHub Profile
-- 17. Get the names of people, who live at the same address
SELECT fname, sname, address
FROM Member
WHERE address = (SELECT address
FROM Member
GROUP BY address HAVING COUNT(address) > 1);
@mickeypash
mickeypash / DateClient3.java
Created April 26, 2015 13:18
DateClient3 AP 2015
import java.net.*;
import java.io.*;
public class DateClient3 {
private static String server = "127.0.0.1";
private static int PORT = 8765;
public static void main(String[] args) throws IOException{
//Create the socket, a reader and a writer
Socket socket = new Socket(server,PORT);
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
/* Note that the writer helps the server
@mickeypash
mickeypash / DateServer3.java
Last active August 29, 2015 14:19
DateServer3 AP 2015 Simon's example
import java.io.*;
import java.net.*;
import java.util.Date;
public class DateServer3 {
private static int PORT = 8765;
private static ServerSocket listener;
public static void main(String[] args) {
try {
listener = new ServerSocket(PORT);
while(true) {
@mickeypash
mickeypash / Client-Server.java
Created April 26, 2015 13:03
Client-Server AP 2015 Simon's example
public class Server {
private static int PORT = 9000;
public static void main(String[] args){
ServerSocket listener = new ServerSocket(PORT);
Socket client = listener.accept();
PrintWriter out = new PrintWriter(client.getOutputStream(), true);
@mickeypash
mickeypash / Visitor pattern.java
Created April 25, 2015 20:50
Visitor pattern AP 2015 Simon's example
// MyElement only implements the accept method and this just called the visit method of MyVisitor
public interface MyElement {
public void accept(MyVisitor visitor);
}
import java.util.Calendar;
public class Human implements MyElement {
public Calendar dOB;
public Human(Calendar d) {
dOB = d;
@mickeypash
mickeypash / Decorator pattern.java
Created April 25, 2015 20:49
Decorator pattern from AP 2015 Simon's example
// the first step is to define an abstract
// class that both BasicCar and our decorators will extend
public abstract class Car {
public abstract double getPrice();
public abstract String getDescription();
}
public class BasicCar extends Car{
public double getPrice() {
@mickeypash
mickeypash / Main.java
Created April 9, 2015 21:15
Google Code Jam Winning solution Round 3 - Magical, Marvelous Tour
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.io.FileInputStream;
import java.util.Arrays;
@mickeypash
mickeypash / brew-list.txt
Last active August 29, 2015 14:18
A list of my currently install packages
archey About this Mac in terminal form
brew-cask homebrew-style CLI workflow for the administration of Mac applications distributed as binaries.
cmatrix Matrix animation in your terminal (oldie but goodie)
gawk makes it possible to handle simple data-reformatting jobs with just a few lines of code
gibo
git Apple's git is outdated, this allows you to have the news git
git-flow A set of git extensions to provide high-level repository operations
gmp
go Go is a tool for managing Go source code.
htop-osx
@mickeypash
mickeypash / lab-exam-q3.txt
Last active August 29, 2015 14:16
suggested way of calculating the number of files
Lab exam for calculating the number of files and folders in a file system
http://sourcemaking.com/design_patterns/Composite/java/1
interface FileComponent
+ calculateTotal();
FileComposite
+ calculateTotal()
for item in composite
total += leaf.calculateTotal();
@mickeypash
mickeypash / .aliases
Created February 27, 2015 20:54
my aliases so far
# Aliases
# --------
# Projects
alias ipy="python -i $1"
alias prof="subl ~/.profile"
alias spy="cd ~/Documents/scripts/"
alias itech="cd ~/Documents/itech-team-pamm && workon itech-team-pamm"
alias tp="cd ~/Documents/workspace/AE4 && git pull"
alias socs="ssh [email protected] -L 8080:webapps.dcs.gla.ac.uk:443"