Skip to content

Instantly share code, notes, and snippets.

View poanchen's full-sized avatar

PoAn (Baron) Chen poanchen

View GitHub Profile
@poanchen
poanchen / playMusicWithMultipleInterfaces.pde
Created April 8, 2018 00:56
Demonstration of using multiple interfaces to play or stop music with the help of Processing Sound library
import processing.sound.*;
interface Class1 {
void playSong();
void stopSong();
}
interface Class2 {
void playSong();
void stopSong();
@poanchen
poanchen / lookUpProcessAndKillTheProcess.sh
Created March 6, 2018 07:49
look up the process that is using the port number and kill it (windows 10)
netstat -a -o -n
taskkill /F /PID 12345
@poanchen
poanchen / kill.bash
Created February 23, 2018 22:14
Killing the process id that occupy the port you were using
lsof -w -n -i tcp:port_number
kill -9 pid_number
@poanchen
poanchen / runJava.py
Created February 5, 2018 09:21
A python script that will find the latest java program compile and execute them
import os
i = 12
while os.path.exists("./Solution" + str(i) + ".java"):
i += 1
i -= 1
os.system("javac Solution" + str(i) + ".java")
os.system("java Solution" + str(i))
@poanchen
poanchen / createDefaultMainJava.py
Created February 5, 2018 09:20
A python script that will create a barebone Java code with the default main class along with testcase1 and printlist functions that are necessary for doing competeive programming questions
import os
i = 12
while os.path.exists("./Solution" + str(i) + ".java"):
i += 1
file_contents = """import java.util.*;
import java.lang.*;
public class Solution%s {
public static void testCase1() {
}
@poanchen
poanchen / Vector3.cpp
Created September 19, 2017 04:13
Define operator+ and operator+= for the simple 3D vector class below
// https://repl.it/LO2b
#include <iostream>
using namespace std;
struct Vector3 {
float x, y, z;
Vector3& operator+(const Vector3& rhs) {
*this += rhs;
@poanchen
poanchen / SimpleMap.cpp
Created September 19, 2017 04:12
Create a std::map and insert into it the key-value pairs {“one”,1}, {“two”,2}, and {“three”,3}.
// https://repl.it/LO2s
#include <iostream>
#include <map>
using namespace std;
int main()
{
std:map <string, int> intMap;
@poanchen
poanchen / LinkedListNode.cpp
Created September 19, 2017 04:11
Write a simple class template “LinkedListNode”, which stores an object of type “T” and a pointer to the next node of type “LinkedListNode*”. It doesn’t need to have any member functions.
// https://repl.it/LORG
#include <iostream>
using namespace std;
template <class T>
class LinkedListNode {
public:
T value;
LinkedListNode<T>* next;
@poanchen
poanchen / HelloWorldInterface.cpp
Created September 19, 2017 04:10
Create an interface class with a pure virtual function. Create another class that inherits from it, and give a concrete implementation of the pure virtual function.
// https://repl.it/LEHR
#include <iostream>
using namespace std;
class HelloWorldInterfaceA
{
public:
virtual void printHelloWorldA() = 0;
};
@poanchen
poanchen / SimpleClass.cpp
Created September 19, 2017 04:08
Write a simple class that uses with a private variable and a public member function.
// https://repl.it/LECL
#include <iostream>
using namespace std;
class SimpleClass
{
private:
string privateStr;
public: