Skip to content

Instantly share code, notes, and snippets.

@zero-is-one
zero-is-one / gist:3237735
Created August 2, 2012 15:04
Superfastblur Algorithm for Openframeworks with alpha support
// Super Fast Blur v1.1
// by Mario Klingemann <http://incubator.quasimondo.com>
// converted to C++ by Mehmet Akten, <http://www.memo.tv>
// Add alpha support by Victor Sigma, <http://www.aphes.com>
//
// Tip: Multiple invovations of this filter with a small
// radius will approximate a gaussian blur quite well.
//
void superFastBlur(unsigned char *pix, int w, int h, int radius) {
@zero-is-one
zero-is-one / gist:4496027
Last active December 10, 2015 21:38
Merging two images as if they are overlayed..... Taken from: http://forum.openframeworks.cc/index.php?topic=4431.0 Some small bugs in the original code have been fixed. This assumes both images are the same size and each pixel has RGBA values
// a and b are both RGBA images
int totalPixels = a.width * a.height;
unsigned char * aPixels = a.getPixels();
unsigned char * bPixels = b.getPixels();
for(int i=0; i<totalPixels; i++) {
int base = i*4;
// deal with r,g,b
float bAlpha = float(bPixels[base+3])/256.0f;
@zero-is-one
zero-is-one / Logitech HD Pro Webcam C920 XML
Created January 23, 2013 15:56
Logitech HD Pro Webcam C920 XML resolution
<?xml version="1.0" encoding="utf-8"?>
<Resolutions>
<Camera PID="0x0834" NOUVCRESOLUTIONCHECK="1" RULES="VfxPhoto|ZoomPhoto">
<Resolution>
<BitRate>800,1200,1500</BitRate>
<SelectedWidth>640</SelectedWidth>
<SelectedHeight>360</SelectedHeight>
<DisplayedWidth>640</DisplayedWidth>
<DisplayedHeight>360</DisplayedHeight>
<StreamingWidth>640</StreamingWidth>
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 13 columns, instead of 12. in line 6.
"Name","Size","State","Sector","Historically Black","Urbanization","Total Enrollment","Undergraduate Enrollment","Percent Admitted (Total)","Graduation Rate (Total)","Tuition and Fees","Total Price (On Campus, In-State)","Total Price (On Campus, Out-State)"
"Alabama A & M University",2500,"Alabama","Public- 4-year or above","Yes","City: Midsize",4922,4128,50,32,6828,17688,23016
"University of Alabama at Birmingham",15000,"Alabama","Public- 4-year or above","No","City: Midsize",17575,11128,72,45,6264,21153,29145
"University of Alabama at Huntsville",734,"Alabama","Public- 4-year or above","No","City: Midsize",7629,5935,64,45,8094,21691,33021
"Auburn University",35000,"Alabama","Public- 4-year or above","No","City: Small",25469,20446,70,66,8698,22352,36926
"Concordia College Selma",800,"Alabama","Private not-for-profit- 4-year or above","Yes","Town: Remote",719,719,,5,8090,18040,18040
"Heritage Christian University",750,"Alabama","Private not-for-profit- 4-year or above","No","Rural: Fringe",86,60,,0,12030,2108
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 9.
"Name","Size","State","Sector","Urbanization","Total Enrollment","Percent Admitted (Total)","Graduation Rate","Tuition","Total Price (In-State)","Total Price (Out-of-State)"
"Alabama A & M University",2500,"Alabama","Public- 4-year or above","City: Midsize",4922,50,32,6828,17688,23016
"University of Alabama at Birmingham",15000,"Alabama","Public- 4-year or above","City: Midsize",17575,72,45,6264,21153,29145
"University of Alabama at Huntsville",734,"Alabama","Public- 4-year or above","City: Midsize",7629,64,45,8094,21691,33021
"Auburn University",35000,"Alabama","Public- 4-year or above","City: Small",25469,70,66,8698,22352,36926
"Concordia College Selma",800,"Alabama","Private not-for-profit- 4-year or above","Town: Remote",719,,5,8090,18040,18040
"Heritage Christian University",750,"Alabama","Private not-for-profit- 4-year or above","Rural: Fringe",86,,0,12030,21087,21087
"University of Mobile",2500,"Alabama","Private not-for-profit- 4-year or above","Rural: Fringe",1734,81,43,17220,29830,29830
"Talladega C
@zero-is-one
zero-is-one / Chinese Learning Word Order
Last active April 28, 2024 17:35
I didn't like the word order that most Chinese learning courses use. This list is the most common used chinese words/phrases and orders them so that no word is shown before its components are shown. It also includes the php files that I used to help generate this list for my own reference.
是 | [shì] to be, 是不是? shìbushì? is (it) or is (it) not?; 是否 shìfǒu whether or not, is (it) or is (it) not?
不 | [bù] not [bú] (used before tone #4); 不是 bú shì isn't
了 | [le] <verb particle marking a new situation or a completed action>; 你来了! Nǐ láile! You have come!; 我累了! Wǒ lèile! I've gotten tired!; 那好了! Nà hǎole! That's OK (now)!; 我只请了一位客人. Wǒ zhǐ qǐngle yí wèi kèren. I invited only one guest. [liǎo] end, finish, settle, dispose of, know clearly, to be able, (=了解 liǎojiě) understand, comprehend; 了了 liǎoliaǒ clearly understand, settle (a debt/etc.), to be intelligent; 了了 liǎole to be over/ended/finnish/settled; 你卖不了! Nǐ mài bùliǎo! You will not be able to sell (it)! [liào] (=瞭 liaò) to survey/watch{Compare with 子 zǐ child}
人 | [rén] person; 人类 rénlèi humankind; 有人吗? yǒu rén ma? Is there anybody here?{Compare with 入 rù enter}
我 | [wǒ] I, me, my; 我们 wǒmen we, us{Compare with 找 zhǎo seek}
在 | [zài] at; 现在 xiànzài now; 存在 cúnzài exist
有 | [yǒu] have, there is; 没有 méiyǒu haven't, there isn't;
@zero-is-one
zero-is-one / gist:5767767
Last active December 18, 2015 10:19
playing around with 3d cube
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js canvas - geometry - head</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #f0f0f0;
var letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
var words = []
for (var i = 0; i < letters.length; i++)
for (var j = 0; j < letters.length; j++)
for (var k = 0; k < letters.length; k++)
for (var l = 0; l < letters.length; l++)
for (var m = 0; m < letters.length; m++)
if (isPronounceable(letters[i]+letters[j]+letters[k]+letters[l]+letters[m]))
words.push(letters[i]+letters[j]+letters[k]+letters[l]+letters[m])
@zero-is-one
zero-is-one / mail.py
Last active May 13, 2019 18:38
A simple mail server for testing. From: http://djangosnippets.org/snippets/96/
from datetime import datetime
import asyncore
from smtpd import SMTPServer
class EmlServer(SMTPServer):
no = 0
def process_message(self, peer, mailfrom, rcpttos, data):
filename = 'mail.eml'
f = open(filename, 'w')
f.write(data)
/**
* Filter to check for CSRF attacks from the ajax requests.
*/
Route::filter('csrf_header', function()
{
if (Session::token() != Request::header('x-csrf-token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
});