Skip to content

Instantly share code, notes, and snippets.

View chico's full-sized avatar

Chico Charlesworth chico

View GitHub Profile
@chico
chico / MainActivity
Created October 31, 2014 10:28
GPUImage.saveToPictures blocks UI with preview
// in onCreate()
glSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView);
mGPUImage = new GPUImage(this);
mGPUImage.setGLSurfaceView(glSurfaceView);
// on user button click
mCamera.mCameraInstance.takePicture(null, null, new Camera.PictureCallback() {
@chico
chico / robotarm.js
Last active December 14, 2015 22:11
var five = require('johnny-five')
var board = new five.Board()
var moveBase = function(board, base, cb) {
base.to(10, 2000)
board.wait(2500, function () {
base.to(170, 3000)
board.wait(3500, function () {
/********************************************************
* PID Basic Example
* Reading analog input 0 to control analog PWM output 3
********************************************************/
#include <PID_v1.h>
#define PIN_INPUT 0
#define PIN_OUTPUT 3
Verifying that +ccharlesworth is my blockchain ID. https://onename.com/ccharlesworth
@chico
chico / switch.css
Last active September 7, 2016 11:05
.onoffswitch {
position: relative; width: 90px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 1px solid red; border-radius: 20px;
passport.use(new MailChimpStrategy({
clientID: config.auth.mailchimpAuth.clientID,
clientSecret: config.auth.mailchimpAuth.clientSecret,
callbackURL: config.auth.mailchimpAuth.callbackURL,
passReqToCallback : true
},
function(req, token, refreshToken, profile, done) {
token = token + '-' + profile.dc; // Append datacenter to token for API calls to work
// Save and use token for doing Mailchimp API calls
}
var result = {ok: true};
console.dir(result, {depth: null, colors: true});
@chico
chico / MainActivity.java
Created March 22, 2018 11:49
CIFAR_10 Android Fix for Mammoth Interactive's Mobile Learning course
private float[] formatImageData() {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), imageResouceIds[imageArrayIndex]);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 32, 32, true);
int[] intArray = new int[1024];
scaledBitmap.getPixels(intArray, 0, 32, 0, 0, 32, 32);
float[] floatArray = new float[3072];
int n = 0;
for (int i = 0; i < 1024; i++) {
floatArray[n++] = ((intArray[i] >> 16) & 0xff) / 255.0f;
floatArray[n++] = ((intArray[i] >> 8) & 0xff) / 255.0f;
@chico
chico / firefox_osx_alias_command.sh
Last active January 11, 2019 10:02
firefox osx alias command
alias firefox="open -a Firefox 'https://www.bbc.com' && open -a Firefox 'https://flipboard.com' && open -a Firefox 'https://twitter.com' && open -a Firefox 'http://producthunt.com' && open -a Firefox 'https://blog.codinghorror.com'"
@chico
chico / localStorageSize.js
Created April 11, 2019 11:07
Get the size of localStorage, copied from https://stackoverflow.com/a/15720835, execute it in the JavaScript console
var _lsTotal=0,_xLen,_x;for(_x in localStorage){ if(!localStorage.hasOwnProperty(_x)){continue;} _xLen= ((localStorage[_x].length + _x.length)* 2);_lsTotal+=_xLen; console.log(_x.substr(0,50)+" = "+ (_xLen/1024).toFixed(2)+" KB")};console.log("Total = " + (_lsTotal / 1024).toFixed(2) + " KB");