Skip to content

Instantly share code, notes, and snippets.

View Maslor's full-sized avatar

Gabriel Freire Maslor

View GitHub Profile
@Maslor
Maslor / learningVicky.java
Created February 26, 2016 13:56
Robot that learns words if they are new. Only accepts alphanumeric characters.
import java.util.List;
import java.util.ArrayList;
public class Robot {
public List<String> wordList = new ArrayList<String>();
String notUnderstand = "I do not understand the input";
String thanks = "Thank you for teaching me";
String iKnow = "I already know the word";
public Robot(){
@Maslor
Maslor / findSum.js
Created February 26, 2016 12:05
Javascript function that sums all the integers given as argument. Returns -1 if it receives a negative number as an argument.
function findSum(){
sum = 0;
for (i = 0; i < arguments.length; i++){
if (arguments[i] < 0) return -1;
else sum += arguments[i]
}
return sum;
}
@Maslor
Maslor / example.html
Created February 25, 2016 11:58
toggle HTML element
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
@Maslor
Maslor / gist:519f6c27fbe3edabe645
Created October 6, 2015 22:23
adb - remounting a filesystem as read-write and back to read-only
mount -o rw,remount /system
mount -o ro,remount /system
@Maslor
Maslor / filteredls.js
Created September 29, 2015 08:43
javascript that works as a filtered ls.
var fs = require('fs');
var path = process.argv[2];
var fileExtension = process.argv[3];
var array = [];
fs.readdir(path, function(err,data){
for (var i = 0; i < data.length; i++) {
if(data[i].indexOf("."+fileExtension)!==-1){
array += data[i] + "\n";
var fs = require('fs');
var path = process.argv[2];
fs.readFile(path,'utf8', function(err,data){
var spltArr = data.split('\n');
console.log(spltArr.length-1);
});
@Maslor
Maslor / lineCounter.js
Last active September 28, 2015 13:42
synchronous javascript that counts the number of occurrences of \n in a file
var fs = require('fs')
var str = fs.readFileSync(process.argv[2]).toString()
var s = str.split('\n')
console.log(s.length-1)
@Maslor
Maslor / sum.js
Created September 28, 2015 13:08
javascript that sums the arguments it receives
var sum = 0;
for (cont = 2; cont < process.argv.length; cont++) {
sum += +process.argv[cont];
};
console.log(sum);
@Maslor
Maslor / rockPaperScissors.js
Last active February 26, 2016 13:05
Rock, paper, scissors game on javascript (simple implementation)
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
@Maslor
Maslor / first_try.tcl
Last active September 15, 2015 21:33
Basic configuration of a cisco router on the GNS3 emulator.
conf t
interface f0/0
no shut
ip add 222.222.10.1 255.255.255.0
int f0/1
no shut
ip add 222.222.20.1 255.255.255.0