Skip to content

Instantly share code, notes, and snippets.

View Maslor's full-sized avatar

Gabriel Freire Maslor

View GitHub Profile
@Maslor
Maslor / Python.py
Created August 12, 2015 15:51
Simple example class in python. When object Python is created with a name argument, it prints said name.
class Python:
def __init__(self, name):
self.name = name
print name
@Maslor
Maslor / ExpandableListView.java
Last active August 26, 2015 09:36 — forked from uphy/ExpandableListView.java
JavaFX Expandable ListView
/**
* Copyright (C) 2015 uphy.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@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
@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 / 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 / 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)
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 / 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";
@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 / 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';
}
//-->