Skip to content

Instantly share code, notes, and snippets.

@Unitoi01
Unitoi01 / full button
Last active March 12, 2018 15:26
Button for walkie talkie
import RPi.GPIO as GPIO
import time
import sys
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
@Unitoi01
Unitoi01 / gist:0a60225e953f0ed200be6ff1bf5acdc6
Created March 12, 2018 15:25
install and then use hub-crtrl
sudo apt-get update
sudo apt-get install libusb-dev
git clone https://github.com/codazoda/hub-ctrl.c
cd hub-ctrl.c
gcc -o hub-ctrl hub-ctrl.c -lusb
cp hub-ctrl ..
cd ..
@Unitoi01
Unitoi01 / python Shuffle
Created April 23, 2018 19:11
Takes from text file and shuffles, then iterates
import random
import time
def shuffleRead():
first=True
count=0
f=open('output.txt', 'r+')
lines= f.readlines()
if(first==True):
first=False;
import random
import time
def prepareMessage(messageRaw):
words_list = messageRaw.split()
lineLength = 0
message = ''
for word in words_list:
if(lineLength == 0):
message = message + word
#!/usr/bin/python2
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BCM)
buttonPin = 4
lightPin=3
GPIO.setup(buttonPin, GPIO.IN,pull_up_down=GPIO.PUD_UP)
public static void main(String[] args){
int[] myIntArray = new int[1,2,3,4,5,6,7,8];
int ans= 0;
for(int i=0; i<myIntArray.length; i++){
if(myIntArray[i]%2=0){
ans++;
}
}
System.out.println("There are"+ ans+" "+"even numbers
myIntArray= [1,2,3,4,5,6,7,8]
ans=0
#pound signs are to comment, also there are no arrays in Python, only lists! Which are better
for i in range(len(myIntArray)):
if(myIntArray[i]%2=0):
ans=ans+1
class Node:
#1
def __init__(self, val):
self.val = val
self.leftChild = None
self.rightChild = None
#2
def get(self):
return self.val
class BST:
#1
def __init__(self):
self.root = None
#2
def setRoot(self, val):
self.root = Node(val)
#3
def insert(self, val):
if(self.root is None):
import numpy as np
import cv2 as cv
import math
face_cascade= cv.CascadeClassifier('C:\Program Files\opencv\sources\data\haarcascades\haarcascade_frontalface_default.xml')
#direct path to the haarcascade, which is included in openCV
pic= cv.imread('face.jpg')
#the path to one image that OpenCV will convert to a numpy array
gray= cv.imread('face.jpg,0)