Skip to content

Instantly share code, notes, and snippets.

View paulaksm's full-sized avatar

Paula Moraes paulaksm

View GitHub Profile
@paulaksm
paulaksm / NXTremoteControl_TA.java
Last active March 7, 2018 15:47
PC controller for NXTtr.java
/*
* September 21, 2009
* Author Tawat Atigarbodee
* Modified in March 03, 2018
* This program creates a Control Window for controlling NXT brick running NXTtr.java via USB.
*
* To compile this program.
* - Install Lejos 0.8.5
* - Include Lejos_nxj library to the project path
* - Compiled with nxjpcc
@paulaksm
paulaksm / NXTtr.java
Created March 3, 2018 13:28
Brick code for NXTremoteControl_TA.java
/* Application for brick, compiled with nxjc
Client-Server architecture
Commands sent by NXTremoteControl_TA.java*/
import java.io.*;
import lejos.nxt.*;
import lejos.nxt.comm.*;
public class NXTtr
{
@paulaksm
paulaksm / USBInterface.py
Last active March 21, 2018 18:53
Test for NXT-PC communication via USB
# USB socket communication with LEGO Minstorms NXT -- adapted from nxt-python library
# Copyright (C) 2006, 2007 Douglas P Lau
# Copyright (C) 2009 Marcus Wanner
# Copyright (C) 2011 Paul Hollensen, Marcus Wanner
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@paulaksm
paulaksm / teste_cam.py
Last active March 13, 2018 13:38
Simple camera test for Python3 and OpenCV
import cv2
import numpy as np
'''
CAMERA TEST
'''
cam = cv2.VideoCapture(0)
ret, frame = cam.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imwrite('gray.png', gray)
@paulaksm
paulaksm / motion.py
Created March 20, 2018 01:19
use with NXTtr.java
'''
Uses USB connection (requires pyusb and udev rules for lego USB)
Tries to increase velocity using synchronized motors for forward and backward motion.
Is possible to increase power up to 60 in weak_turn() calls, but it best behaves with 40
'''
import nxt
import time
import keyboard as key
import USBInterface
@paulaksm
paulaksm / NXTpy.java
Created March 20, 2018 14:02
Python <-> Java
/* Application for brick, compiled with nxjc
Client-Server architecture
Commands sent by NXTremoteControl_TA.java*/
import java.io.*;
import lejos.nxt.*;
import lejos.nxt.comm.*;
public class NXTpy
{
@paulaksm
paulaksm / download.sh
Last active June 4, 2018 01:41
Test for gradient descent implementation (put the files in 'ep-grad-desc/' directory)
#!/bin/bash
wget https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv
@paulaksm
paulaksm / get-ieee.txt
Created August 26, 2018 04:15
Download IEEE papers from command line
# If under a valid institutional IP address, the followng command will download an IEEE hosted paper of a specific <ID-NUMBER>
and saved it as paper.pdf
wget "http://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&isnumber=&arnumber=<ID-NUMBER>" -O paper.pdf
@paulaksm
paulaksm / hdf5_example.py
Created November 26, 2018 14:51
Generate HDF5 files for array images with their labels
''' Generate HDF5 files for array images and their labels... unfortunately this function won't work inside the Kaggle kernel
because of its limited resources
'''
def create_data_labels(height=256, width=455, channels=3, filename='driving'):
data_filename = filename + '_data'
label_filename = filename + '_labels'
txt_labels = pd.read_csv('../input/driving_dataset/driving_dataset/data.txt', sep=" ", header=None)
path = '../input/driving_dataset/driving_dataset/'
hdf5_file = h5py.File('self_driving_dataset.hdf5', mode='w')
hdf5_file.create_dataset(data_filename, (txt_labels.shape[0], height, width, channels), np.uint8)
@paulaksm
paulaksm / code.txt
Created February 1, 2019 16:46
GPU memory available on Google Colab
!ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi
!pip install gputil
import psutil
import humanize
import os
import GPUtil as GPU
GPUs = GPU.getGPUs()
# XXX: only one GPU on Colab and isn’t guaranteed
gpu = GPUs[0]