Skip to content

Instantly share code, notes, and snippets.

View ltpitt's full-sized avatar
🥋
A black belt is a white belt that never quit.

Davide Nastri ltpitt

🥋
A black belt is a white belt that never quit.
View GitHub Profile
@ltpitt
ltpitt / AndroidAlertDialogExample.java
Created May 29, 2017 21:13
A simple AlertDialog in Android
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Alert");
alertDialog.setMessage("Alert message to be shown");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
@ltpitt
ltpitt / freeze.sh
Created May 31, 2017 21:55
How to freeze Python application requirements
# How to freeze pip requirements
pip freeze > requirements.txt
@ltpitt
ltpitt / runguiapp.sh
Last active June 1, 2017 17:06
Run a GUI application when you connect to a Linux computer from ssh
DISPLAY=:0 firefox http://www.google.com
@ltpitt
ltpitt / Conda.bat
Created August 26, 2017 06:56
Conda cheatsheet
# For Windows users# Note: <> denotes changes to be made
#Create a conda environment
conda create --name <environment-name> python=<version:2.7/3.5>
#To create a requirements.txt file:
conda list #Gives you list of packages used for the environment
conda list -e > requirements.txt #Save all the info about packages to your folder
@ltpitt
ltpitt / InstallTensorflow1_1Requirements.bat
Last active August 26, 2017 11:13
Install TensorFlow 1.1 Python Requirements for Deep Learning
conda install -c anaconda pillow
conda install -c conda-forge tensorflow=1.1
conda install jupyter
conda install tqdm
conda install matplotlib
@ltpitt
ltpitt / bubble_sort.py
Created August 28, 2017 08:23
Python implementation of bubble sort
def bubble_sort(a_list):
for number in range(len(a_list)-1,0,-1):
for index in range(number):
if a_list[index]>a_list[index+1]:
temp_list = a_list[index]
a_list[index] = a_list[index+1]
a_list[index+1] = temp_list
my_list = [99,45,13,78,33,85,7,99,21]
bubble_sort(my_list)
@ltpitt
ltpitt / docker-destroy-all.sh
Created December 20, 2017 15:55 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@ltpitt
ltpitt / raspiboy_pico8_kill_close.py
Created March 31, 2018 18:34
Short and long press button for Raspiboy - Kill PICO-8 and shutdown functions
from gpiozero import Button
import subprocess
from signal import pause
def shutdown():
print("Halting system...")
subprocess.check_call(['sudo', 'poweroff'])
def kill_pico8():
print("Killing PICO-8...")
@ltpitt
ltpitt / install_docker.sh
Last active June 28, 2018 14:25
Bash snippet to install Docker on Ubuntu Xenial 16.04 and newer
# Install Docker - Xenial 16.04 and newer
apt-get install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce
docker run hello-world
@ltpitt
ltpitt / create_start_docker.sh
Created June 29, 2018 07:59
Create a Docker image and start a Docker container
sudo docker build -t myimage .
sudo docker run -p 80:80 myimage