Skip to content

Instantly share code, notes, and snippets.

View afonsomatos's full-sized avatar
🎯
Focusing

Afonso Matos afonsomatos

🎯
Focusing
  • Lisboa, Portugal
View GitHub Profile
@afonsomatos
afonsomatos / NeuralNetwork.cpp
Created January 31, 2019 00:43
neural in c++
#include <iostream>
#include "NeuralNetwork.h"
using namespace std;
using namespace Eigen;
NeuralNetwork::NeuralNetwork(vector<int> nodes, double learning_rate)
: nodes{ nodes }, learning_rate{ learning_rate }, layers { nodes.size() }
{
// Initialize weights
@afonsomatos
afonsomatos / neural.py
Created January 30, 2019 22:17
python neural network
import numpy
from scipy.special import expit as sigmoid
class neural_network:
def __init__(self, nodes, learning_rate):
self.nodes = nodes
self.layers = len(nodes)
self.lr = learning_rate
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConnectFour
{
enum Tile { Empty, X, O };
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PigDice
{
class Dice
{
@afonsomatos
afonsomatos / OverloadedStrings.hs
Created September 8, 2015 16:36
OverloadedStrings example
{-# LANGUAGE OverloadedStrings #-}
import GHC.Exts ( IsString(..) )
newtype Vowels = Vowels String deriving Show
instance IsString Vowels where
fromString = Vowels . filter (`elem` "aeiou")
@afonsomatos
afonsomatos / DirTree.hs
Created August 28, 2015 00:33
Get files recursively inside directories
module System.Directory.Tree where
import System.Directory ( doesFileExist, getDirectoryContents )
data DirTree = Directory String [DirTree]
| File String
deriving (Show, Eq)
getDirTree :: FilePath -> IO [DirTree]
getDirTree path = getDirectoryContents path
@afonsomatos
afonsomatos / FirstSOChatMessage.hs
Created August 22, 2015 17:36
Get first stackoverflow chat message
module Main where
import Network.HTTP (simpleHTTP, getRequest, getResponseBody)
import Text.HTML.TagSoup
import Data.List (isInfixOf, isPrefixOf)
type Link = String
type UserID = String
hostname = "http://chat.stackoverflow.com"
function getNextChar (char) {
if (char == 'z') return 'A';
if (char == 'Z') return 'a';
return String.fromCharCode(char.charCodeAt(0) + 1);
}
function getNextString (str) {
@afonsomatos
afonsomatos / syllabes.hs
Created July 11, 2015 19:58
words syllabes
-- Format src.txt so that it gives us a list of words and correspondig syllabes
-- divided by 1 space
import System.IO
import System.Directory
import System.Environment
import Data.List
main = do
-- Open input and output files
@afonsomatos
afonsomatos / challenge.js
Last active August 29, 2015 14:24
Benjamin's challenge
"use strict";
let x = 101;
// a^2 + b^2 + c^2 + d^2 = 101
// Loop a
for (let a = 0; a < x; ++a) {
// Loop b
for (let b = 0; b < a; ++b) {
// Loop c