Skip to content

Instantly share code, notes, and snippets.

@PseudoSky
PseudoSky / video_url_regex.js
Created June 8, 2015 07:47
Regexes for popular media sites to extract the resources ID. Which can then be used to embed in an iframe or another url format.
function youtube(url){
return url.match(/^.*(youtu.be\/|v\/|embed\/|watch\?|youtube.com\/user\/[^#]*#([^\/]*?\/)*)\??v?=?([^#\&\?]*).*/)[3];
}
function vimeo(url) {
var m = url.match(/^.+vimeo.com\/(.*\/)?([^#\?]*)/);
return m ? m[2] || m[1] : null;
}
console.log(youtube("http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0"));
@PseudoSky
PseudoSky / rpi_pyaudio_use.py
Created October 21, 2015 16:27
Python scripts to dub down recorded audio frequency in real time and pipe it back through multiple outputs.
import math
import pyaudio
import sys, time
import numpy as np
import wave
RRATE = 16000 #from scipy import signal
WAVE = 15000
sigme = ''.join([chr(int(math.sin(x/((RRATE/WAVE)/math.pi))*127+128)) for x in xrange(RRATE)])
import java.util.Arrays;
import java.util.Collections;
import android.view.MotionEvent;
import java.lang.reflect.Method;
class Gestures {
int maxOffset, minLength,st,et,tOff;
String functionName;
PVector startPos, endPos;
PApplet pApp;
@PseudoSky
PseudoSky / css-perspective.js
Created November 19, 2015 01:05
CSS Perspective Transformation Example
var rotZ = 0;
var rotZ = 0;
var rotZ = 0;
var persp= 0;
var image = document.getElementById('image');
var funk=function(){
image.style.transform="translateX(-96px) translateY(0px) translateZ(0px) rotateX("+rotX+"deg) rotateY("+rotY+"deg) rotateZ(" +rotZ+"deg)";
rotZ+=.5;
rotX+=.7;
@PseudoSky
PseudoSky / css-perspective.js
Last active November 19, 2015 01:29
CSS Perspective Transformation Example
// Variables to control the rotation and perspective of the image
var rotX = 0;
var rotY = 0;
var rotZ = 0;
var persp= 0;
// The skew increment
var skew = 0;
var deltaS=.5;
import java.util.ArrayList;
import java.util.Collections;
int index = 0;
int double_tap_threshold=1000;
int press_and_hold_time_threshold=200;
int press_and_hold_movement_threshold=4;
int rotate_speed=1;
@PseudoSky
PseudoSky / n-bit-reverse.c
Created November 30, 2015 01:56
Bit reversal
/*
Reverse the bits in a byte with 3 operations (64-bit multiply and modulus division)
*/
unsigned char b; // reverse this (8-bit) byte
b = (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
/*
Reverse an N-bit quantity in parallel in 5 * lg(N) operations
@PseudoSky
PseudoSky / sjcl-shared-key-debug.js
Last active December 16, 2015 18:36
How to use sjcl.js for ECDH and Shared Key Exchange
function User(username, key_pair){
this.username = username;
/* If no existing keys generate them */
if(!key_pair){
this.keys = sjcl.ecc.elGamal.generateKeys(192,0);
}else{
this.keys = key_pair
}
@PseudoSky
PseudoSky / elasticsearch-2.1.1-elog
Last active January 11, 2016 17:26
Heroic Error log for issue on mac.
Same results on elasticsearch versions
Version: 2.0.0, Build: de54438/2015-10-22T08:09:48Z, JVM: 1.8.0_45
Version: 2.1.1, Build: 40e2c53/2015-12-15T13:05:55Z, JVM: 1.8.0_45
Could it be JVM: 1.8.0_45?
[snow@snow elasticsearch-2.1.1]$ bin/elasticsearch
[2016-01-11 12:19:41,226][INFO ][node ] [Adri Nital] version[2.1.1], pid[88371], build[40e2c53/2015-12-15T13:05:55Z]
[2016-01-11 12:19:41,227][INFO ][node ] [Adri Nital] initializing ...
[2016-01-11 12:19:41,323][INFO ][plugins ] [Adri Nital] loaded [], sites []
[2016-01-11 12:19:41,344][INFO ][env ] [Adri Nital] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [79.6gb], net total_space [232.6gb], spins? [unknown], types [hfs]
@PseudoSky
PseudoSky / plotter.pde
Created February 18, 2016 15:30
Nicer plotter for differential visualization
import processing.serial.*;
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
float inByte = 0;
float prev=0;
float prev2=0;
float norm=0;