This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
cv2.namedWindow("camera", 1) | |
capture = cv2.VideoCapture(0) | |
# Set to None to use default size | |
# To improve performance, can specify a lower resolution. e.g. 320x240 | |
width = 320 | |
height = 240 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2012 the V8 project authors. All rights reserved. | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are | |
# met: | |
# | |
# * Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# * Redistributions in binary form must reproduce the above | |
# copyright notice, this list of conditions and the following | |
# disclaimer in the documentation and/or other materials provided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.clarenceho.test; | |
public class FizzBuzz { | |
public static String doFizzBuzz1(int i) { | |
StringBuilder sb = new StringBuilder(); | |
if (i % 3 == 0) { | |
sb.append("Fizz"); | |
} | |
if (i % 5 == 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long long perfectSquare(long long num) | |
{ | |
// obvious cases | |
int lastDigit = num % 10; | |
if (num <= 0 || lastDigit == 2 || lastDigit == 3 || lastDigit == 7 || lastDigit == 8) | |
{ | |
return 0; | |
} | |
long long section = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Testing I2C on Raspbery Pi | |
# Send a byte to slave and request a byte back | |
# | |
# Created by Clarence Ho 2015 | |
import smbus | |
import time | |
# for RPI rev 1... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.clarenceho.util; | |
import static org.junit.Assert.*; | |
import org.junit.Test; | |
import java.math.BigDecimal; | |
public class TestNewton { | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.clarenceho.util; | |
import java.util.function.UnaryOperator; | |
import java.math.BigDecimal; | |
import java.math.RoundingMode; | |
/** | |
* Given equation y = f(x), find successively better approximations to the roots | |
* (or zeroes) of a real-valued function (i.e. find x where y = 0) | |
* <p> |
NewerOlder