Skip to content

Instantly share code, notes, and snippets.

View platisd's full-sized avatar
:octocat:
(づ。◕‿‿◕。)づ

Dimitris Platis platisd

:octocat:
(づ。◕‿‿◕。)づ
View GitHub Profile
@platisd
platisd / erlserver.erl
Last active January 14, 2016 22:58
Group 1 - Lindell & Co
% Can you explain what this following piece of code from erlserver:do_recv/1 does?
HaX = lindellnco_hashtag_evaluator:evaluate_hashtag(grab_x_from_string(Bin)),
HaY = lindellnco_hashtag_evaluator:evaluate_hashtag(grab_y_from_string(Bin)),
Xsearch = list_to_binary(grab_x_from_string(Bin)),
Str1 = grab_y_from_string(Bin),
[YList|_] = string:tokens(Str1,"\r"),
Ysearch = list_to_binary(YList),
@platisd
platisd / translator.erl
Last active January 14, 2016 22:58
Group 2 (Pinecone)
%Can you explain the sequence of events that occurs during the communication to the CouchDB
%in order to save a tweet? Just a high level description of what the code does.
couch_save_tweet(Hashtag) ->
Db = couch_open_db(),
{Status, Doc} = couchbeam:open_doc(Db, Hashtag),
case Status of
ok ->
{[{_, Ids},{_,_},{_,Uses}]} = Doc,
@platisd
platisd / battle_module.erl
Created January 14, 2016 22:57
Group 3 (MIB)
%Can you explain how your battle server works? Give a high level description of the code below
battle_loop(Session, Celeb1, HP1, Celeb2, HP2) ->
receive
{tweet, Celebrity, Tweet} ->
case Celebrity of
Celeb1 ->
bridge ! {battle, Session, Celeb1, HP1, HP2-1, Tweet},
battle_loop(Session, Celeb1, HP1, Celeb2, HP2-1);
Celeb2 ->
@platisd
platisd / keywords_listen.erl
Created January 14, 2016 23:10
Group 4 - TLDR
%can you give us a high level explanation of the following code?
handle_post(Sock) ->
Length=get_content_length(Sock),
PostBody=get_body(Sock, Length),
Status = processJSON(PostBody),
case Status of
{ok, added} -> send_accept(Sock),twitter_parser:restart_keyword_change();
{ok, removed} -> send_accept(Sock),twitter_parser:restart_keyword_change();
@platisd
platisd / twitterminer_couchbeam.erl
Created January 14, 2016 23:25
Group 6 - The Explorers
% Have you address the feature in the "TODO" comment below? If yes, where and explain the code, if no,
% how does this affect your overall performance and quality of product?
-module(twitterminer_couchbeam).
-export([connect_server/0, open_db/1, save_doc/3, open_doc/2, read_value/3, update_value/4, extend_doc/4, save_to_doc/5, doc_exists/2, db_save/2]).
%TODO: When saving to database: First check if Key already exists. If so: Update Value instead of creating Key, Value. (Check if there's already
%a built-in support for this - can two keys have the same value, or are they merged automatically?)
connect_server() ->
couchbeam:server_connection("127.0.0.1", 5984, "", []).
@platisd
platisd / newsroom_server_app.erl
Created January 14, 2016 23:59
Group 8 - Lego Empire
%Why is the following piece of code so important not to be changed? Explain what's its purpose
% ///// DO NOT TOUCH ////
handle_cast(_Message, Redis) -> {noreply, Redis}.
handle_info(_Message, Redis) -> {noreply, Redis}.
terminate(_Reason, _Redis) -> terminated.
code_change(_OldVersion, Redis, _Extra) -> {ok, Redis}.
% ///// END ////
%if not so important then what does this do
@platisd
platisd / dataMiner_db.erl
Created January 15, 2016 00:12
Group 9 - The Minions
%can you give a high level description of the following code? What does it do?
saveVenue(#venue{fs_id=FSID,
insta_id=InstaID,
name=Name,
address=Address,
contact=Contact,
img_posts=Posts}) ->
case InstaID of
"" -> ok;
@platisd
platisd / word_server.erl
Created January 15, 2016 00:18
Group 10 - X
%Can you give a high level description of what the following code does?
% Function which runs when you use text_val/1
text_Eval(BinText, From, State) ->
Self = self(),
%%io:format("BinText from text_Eval/3 ~ts~n", [BinText]),
Text = binary:bin_to_list(BinText),
Tokens = string:tokens(Text, " "), % split by spaces into list
%%PointsList=[word_Eval(N, State) || N <- Tokens], %Create a list with all scores for each word
Pids = [spawn_link(fun () ->Self ! {self(), word_Eval(N, State)} end) || N <- Tokens],
@platisd
platisd / assignment7.ino
Last active March 19, 2016 11:33
Άσκηση 7 - Εξάσκηση στα nested if's χρησιμοποιώντας το smartcar
/* Διαβάστε τον κώδικα, προσπαθήστε να καταλάβετε τι κάνει από μόνοι σας (σκοπίμως δεν έχουν μπει σχόλια που να εξηγούν
τι κάνουν οι διάφορες εντολές) και μετά γράψτε μόνοι σας το υπόλοιπο πρόγραμμα με τις οδηγίες που θα βρείτε στα σχόλια.
Χρησιμοποιήστε της μεταβλητές αληθείας (boolean) ώστε οι εντολές της κάθε κατάστασης (state) να εκτελούνται μόνο μια φορά.
Ο σκοπός σας είναι, να τελειώσετε το πρόγραμμα στο σπίτι και όταν το δοκιμάσετε στο αμαξάκι, το αμαξάκι να επιδείξει
την εξής συμπεριφορά:
Θα προχωρήσει περίπου 20 εκατοστά και θα στρίψει 180 μοίρες (αυτό είναι ήδη έτοιμο για εσάς).
Θα προχωρήσει ΕΠΙΠΛΕΟΝ περίπου 60 εκατοστά (δηλαδή πόσα απ' την αρχή της λειτουργίας του;) και θα στρίψει 90 μοίρες προς
τα αριστερά.
Τέλος, θα συνεχίσει να κινείται ευθεία, μέχρι να διανύσει συνολικά (από την αρχή δηλαδή της λειτουργίας του) 150 εκατοστά. */
#include <Smartcar.h>
@platisd
platisd / adnroidCar_w_Smartcar_shield.ino
Last active April 18, 2016 12:08
The AndroidCar sketch from the Android Autonomous vehicle, migrated to the Smartcar shield library
/* The running arduino sketch on the Android Autonomous Vehicle by Team Pegasus
* Original file: https://github.com/platisd/AndroidCar/blob/master/examples/androidCar/androidCar.ino
* Description: The vehicle is based on an Arduino Mega, that is connected to various sensors
* (infrared, ultrasound, speed encoder, gyroscope and 9DOF IMU) and receives driving instructions
* from an Android phone, via Bluetooth, that is attached on the top of the vehicle. The vehicle
* can follow street lanes, park and overtake obstacles, using image processing on the Android phone.
*
* Author: Dimitris Platis
*/
#include <Smartcar.h>