Skip to content

Instantly share code, notes, and snippets.

View gmelodie's full-sized avatar
🤟
Computing stuff

Gabriel Cruz gmelodie

🤟
Computing stuff
View GitHub Profile
@gmelodie
gmelodie / xcreep.sh
Last active August 6, 2020 23:29
Copy the contents of a file to X's clipboard (wrapping for "xclip -selection c")
# example: ./xcreep.sh somefile.txt
if [ $# -ne 1 ]
then
echo "usage: $0 <INPUTFILE>"
exit 1
fi
INPUTFILE=$1
cat $INPUTFILE | xclip -selection c
@gmelodie
gmelodie / iface_scan.c
Created March 25, 2019 00:20
Network interface scanner
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/if_packet.h>
#include <net/ethernet.h>
#include <netdb.h>
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <errno.h>
@gmelodie
gmelodie / port_scan.py
Created March 25, 2019 00:19
Port scanner
import socket
import optparse
def createParser():
# Create command line parser
parser = optparse.OptionParser('usage prog -H <target host> -p ' + \
'<target port>')
parser.add_option('-H', dest='tgtHost', type='string',\
@gmelodie
gmelodie / gameFinished.js
Created February 2, 2019 11:26
JS winner checker function
function gameFinished() {
// check rows
for (i = 1; i < 4; i++)
if (document.getElementById('div_'+i+'1').innerHTML == document.getElementById('div_'+i+'2').innerHTML &&
document.getElementById('div_'+i+'2').innerHTML == document.getElementById('div_'+i+'2').innerHTML)
return document.getElementById('div_'+i+'1').innerHTML;
// check cols
for (i = 1; i < 4; i++)
if (document.getElementById('div_1'+i).innerHTML == document.getElementById('div_2'+i).innerHTML &&
@gmelodie
gmelodie / tic_almost_rdy.html
Last active February 2, 2019 11:28
Tic-tac-toe game without winner checking
<html>
<script type="text/javascript">
let ex = true;
let oh = false;
function gameFinished() {
return null;
// dunno what to put here yet
}
@gmelodie
gmelodie / tic_choose_player.js
Created February 1, 2019 23:58
Javascript for choosing player on tic-tac-toe
<script type="text/javascript">
let ex = true;
let oh = false;
function computePlay(buttonId) {
let divId = "div_"+buttonId;
let playSymbol;
if (ex) {
playSymbol = 'X';
} else if (oh) {
@gmelodie
gmelodie / tic_X_O.html
Created February 1, 2019 23:08
Tic-tac-toe with button replacing
<html>
<script type="text/javascript">
function computePlay(buttonId) {
let divId = "div_"+buttonId;
document.getElementById(divId).innerHTML = 'X'
//selected.style.display = 'none';
}
</script>
<h1> Tic-tac-toe </h1>
@gmelodie
gmelodie / tic_hide_v3.html
Created January 30, 2019 13:02
Tic-tac-toe hiding feature v3
<html>
<script type="text/javascript">
function computePlay(buttonId) {
let selected = document.getElementById(buttonId);
selected.style.display = 'none';
}
</script>
<h1> Tic-tac-toe </h1>
<form id='board'>
@gmelodie
gmelodie / tic_hide_v2.html
Created January 30, 2019 12:55
Version 2 of tic-tac-toe, fixing hiding problems
<html>
<script type="text/javascript">
function getSelectedButton(form, name) {
let radios = form.elements[name];
for (button in radios) {
if (radios[button].checked) {
return radios[button];
}
}
@gmelodie
gmelodie / tic_hide.html
Created January 27, 2019 17:57
Hiding the buttons on tic-tac-toe game
<html>
<script type="text/javascript">
function getSelectedButton(form, name) {
let radios = form.elements[name];
for (button in radios) {
if (button.checked) {
return button;
}
}
}