Skip to content

Instantly share code, notes, and snippets.

🐦
chirp

Aram Peres momothereal

🐦
chirp
Block or report user

Report or block momothereal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SwingTicTacToe.java
package tictactoegame.ui;
import javax.swing.*;
import java.awt.*;
public class SwingTicTacToe extends JFrame {
/**
* The font used for the buttons.
*/
View ffmount.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <sys/mount.h>
extern char * ffmount(char *path)
{
int rc;
@momothereal
momothereal / road_navigation.py
Created Jun 17, 2018
My solution to the "Road navigation" edabit challenge
View road_navigation.py
# coding=utf-8
import json
import os
def neighbours_of(edges, node):
neighbours = []
for edge in edges:
if node in edge:
neighbours.append(edge[0 if edge[1] == node else 1])
@momothereal
momothereal / sort.py
Last active May 10, 2018
Selection, Insertion, Bubble and Merge sort in Python 3
View sort.py
def selection_sort(array):
for index in range(len(array)):
currentMin = array[index]
currentMinIndex = index
# check the minimum value in the sub-array after the current index
for subIndex in range(index + 1, len(array)):
if array[subIndex] < currentMin:
currentMin = array[subIndex]
currentMinIndex = subIndex
@momothereal
momothereal / add_tf.py
Last active Mar 13, 2018
A python TensorFlow script that uses supervised learning to sum scalars
View add_tf.py
import numpy as np
import tensorflow as tf
batch_size = 1
data_size = 10000
batches = int(data_size / batch_size)
# X is a (n 2) matrix with random positive floats between 0 and 100
X = np.random.rand(data_size, 2)
# Y is a (n 1) matrix with the sum of the two columns of X
@momothereal
momothereal / stm-curl-realtime.sh
Created Feb 8, 2018
curl request to find real-time STM bus times at a certain stop.
View stm-curl-realtime.sh
# This is a curl command to get live/real-time STM bus schedules for a stop.
# Note that the "Origin" request header set to "http://beta.stm.info" is necessary.
curl -H "Accept: application/json" -H "Origin: http://beta.stm.info" "https://api.stm.info/pub/i3/v1c/api/en/lines/{BUS_LINE}/stops/{STOP_ID}/arrivals?d={DATE_YYYY_MM_DD}&t={24H_TIME_HHMM}&direction={DIRECTION}&wheelchair=0&limit=5"
# {BUS_LINE} = Line number (e.g. 123)
# {STOP_ID} = Stop number (e.g. 12345)
# {DATE_YYYY_MM_DD} = The date, in the YYYYMMDD format (e.g. 20180208)
# {24H_TIME_HHMM} = The time, in 24-hour format (HHMM) (e.g. 1348)
# {DIRECTION} = Line direction, E/W/N/S
View httpserver.js
// the shortest JS code to create and run an HTTP server, using the least amount of different characters possible.
// this only works on node.js for obvious reasons.
require('http').createServer((e,r)=>{r.write('r');r.end()}).listen(80)
// if you don't want any response body (just accept the connection):
require('http').createServer((e,r)=>r.end()).listen(80)
View bashrc_branch_colors.sh
# Adapted from https://gist.github.com/ankurk91/2efe14650d54d7d09528cea3ed432f6d#file-bashrc-md
# Show git branch name
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
pls_branch="git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'"
branch_name=$(eval $pls_branch)
echo -ne $branch_name
if [ ! "$branch_name" = '' ]; then
View SudokuSolver.java
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
/*
* Written by Aram Peres
*/
public class SudokuSolver {
public static void main(String[] args) throws IOException {
View keybase.md

Keybase proof

I hereby claim:

  • I am momothereal on github.
  • I am momothereal (https://keybase.io/momothereal) on keybase.
  • I have a public key ASBFvh5Vc6VpYW2Rvr8jOhpGkTGfSPtlcua3G9bx-wo8ugo

To claim this, I am signing this object:

You can’t perform that action at this time.