Skip to content

Instantly share code, notes, and snippets.

View allquixotic's full-sized avatar
🎯
Focusing

Sean McNamara allquixotic

🎯
Focusing
View GitHub Profile
@allquixotic
allquixotic / rebuildff.sh
Created January 4, 2014 05:22
Administration scripts for [SO-ChatBot](https://github.com/allquixotic/so-chatbot) using [so-chatbot-driver](https://github.com/allquixotic/so-chatbot-driver) -- both Firefox and PhantomJS versions of the admin scripts depending on what you want to do.
#Rebuilds the SO-ChatBot from git master, then restarts the bot -- FIREFOX VERSION.
cd SO-ChatBot; git pull; cd ..; ./reloadff.sh
@allquixotic
allquixotic / master.js
Created January 4, 2014 05:43
master.js as of 1/4/2014 of https://github.com/allquixotic/SO-ChatBot with PhantomJS 1.9.x hacks applied
(function(definition){if(typeof define=="function"){define(definition)}else if(typeof YUI=="function"){YUI.add("es5-sham",definition)}else{definition()}})(function(){var call=Function.prototype.call;var prototypeOfObject=Object.prototype;var owns=call.bind(prototypeOfObject.hasOwnProperty);var defineGetter;var defineSetter;var lookupGetter;var lookupSetter;var supportsAccessors;if(supportsAccessors=owns(prototypeOfObject,"__defineGetter__")){defineGetter=call.bind(prototypeOfObject.__defineGetter__);defineSetter=call.bind(prototypeOfObject.__defineSetter__);lookupGetter=call.bind(prototypeOfObject.__lookupGetter__);lookupSetter=call.bind(prototypeOfObject.__lookupSetter__)}if(!Object.getPrototypeOf){Object.getPrototypeOf=function getPrototypeOf(object){return object.__proto__||(object.constructor?object.constructor.prototype:prototypeOfObject)}}function doesGetOwnPropertyDescriptorWork(object){try{object.sentinel=0;return Object.getOwnPropertyDescriptor(object,"sentinel").value===0}catch(exception){}}if(Objec
@allquixotic
allquixotic / pjs19.patch
Created January 4, 2014 06:28
phantomjs 1.9.x patch for SO-ChatBot
diff --git a/source/IO.js b/source/IO.js
index 20c4e50..5e0ef35 100644
--- a/source/IO.js
+++ b/source/IO.js
@@ -1,3 +1,13 @@
+/** es5-sham.min.js from https://github.com/kriskowal/es5-shim and the minified version of this patch https://github.com/abe33/source-map/commit/61131e53ceb3b69d387da3c6daad6adbbaaae9b3 for PhantomJS 1.9.x. */
+if(!Function.prototype.bind) {Function.prototype.bind = function(scope){var self = this;return function(){return self.apply(scope, arguments);};}}
+(function(definition){if(typeof define=="function"){define(definition)}else if(typeof YUI=="function"){YUI.add("es5-sham",definition)}else{definition()}})(function(){var call=Function.prototype.call;var prototypeOfObject=Object.prototype;var owns=call.bind(prototypeOfObject.hasOwnProperty);var defineGetter;var defineSetter;var lookupGetter;var lookupSetter;var supportsAccessors;if(supportsAccessors=owns(prototypeOfObject,"__defineGetter__")){defineGetter=call.bind(prototypeOfObject.__defineGetter__);defineSetter=call.bind(prototypeO
user@computer:~/dev/robovm$ java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1~deb7u1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
user@computer:~/dev/robovm$ cat /etc/issue
Debian GNU/Linux jessie/sid \n \l
user@computer:~/dev/robovm/HelloWorld$ uname -a
Linux computer 3.10.9-vs2.3.6.6 #1 SMP Thu Sep 5 16:08:01 CDT 2013 x86_64 GNU/Linux
user@computer:~/dev/robovm$ cat HelloWorld.java; bin/robovm -use-debug-libs -verbose -cp classes/ HelloWorld
@allquixotic
allquixotic / gist:8929480
Last active August 29, 2015 13:56
Cavil memory export 2-10-2014
eyJhZmsiOnt9LCJ0b2RvIjp7Ijk0OTA1IjpbXX0sImxlYXJuIjp7InRlc3QiOiJ7XCJuYW1lXCI6XCJ0ZXN0XCIsXCJvdXRwdXRcIjpcIkl0J3MganVzdCBhIGZ1Y2tpbmcgdGVzdCwgbm93IGdvIGF3YXlcIixcImlucHV0XCI6XCIvLiovXCIsXCJjcmVhdG9yXCI6XCJhbGxxdWl4b3RpY1wiLFwiZGF0ZVwiOlwiMjAxMy0xMC0xMVQwMjoyNToxNC43MDNaXCIsXCJkZXNjcmlwdGlvblwiOlwiVXNlci10YXVnaHQgY29tbWFuZDogIGBJdCdzIGp1c3QgYSBmdWNraW5nIHRlc3QsIG5vdyBnbyBhd2F5YFwifSIsIndoeSI6IntcIm5hbWVcIjpcIndoeVwiLFwib3V0cHV0XCI6XCJCZWNhdXNlLiBOb3cgc2h1dHVwLlwiLFwiaW5wdXRcIjpcIi8uKi9cIixcImNyZWF0b3JcIjpcIk1yLiBJIERvbid0IENhcmVcIixcImRhdGVcIjpcIjIwMTMtMTAtMTRUMjM6MjM6MzYuMjY3WlwiLFwiZGVzY3JpcHRpb25cIjpcIlVzZXItdGF1Z2h0IGNvbW1hbmQ6ICBgQmVjYXVzZS4gTm93IHNodXR1cC5gXCJ9Iiwib2siOiJ7XCJuYW1lXCI6XCJva1wiLFwib3V0cHV0XCI6XCJEaWQgSSBub3QganVzdCBhc2sgeW91IHRvIHNodXQgdXA/IElmIG5vdCwgdGhlbi4uLnNodXR1cC5cIixcImlucHV0XCI6XCIvLiovXCIsXCJjcmVhdG9yXCI6XCJNci4gSSBEb24ndCBDYXJlXCIsXCJkYXRlXCI6XCIyMDEzLTEwLTE0VDIzOjI4OjI2LjMwNFpcIixcImRlc2NyaXB0aW9uXCI6XCJVc2VyLXRhdWdodCBjb21tYW5kOiAgYERpZCBJIG5vdCBqdXN0IGFzayB5b3UgdG8gc2h1dCB1cD8g
@allquixotic
allquixotic / ModBot-Mono-Linux
Last active August 29, 2015 14:04
Support ModBot on Mono/Linux (CentOS 5 with Mono 3.0.7) by switching out System.Data.SQLite for Mono.Data.Sqlite, changing Data Source, etc. Also fixed a weird NPE in Irc.cs. To get everything working, we had to download the MySQL/Net Connector binary, the JSON.Net binary, recompile sqlite to a newer version (it was only 3.3.x and needed 3.5.x),…
diff --git a/ModBot/Commands.cs b/ModBot/Commands.cs
index 8180c45..b6c1840 100644
--- a/ModBot/Commands.cs
+++ b/ModBot/Commands.cs
@@ -1,15 +1,15 @@
using System;
using System.Linq;
using System.Text;
-using System.Data.SQLite;
+using Mono.Data.Sqlite;
<!doctype html>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 15 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
@allquixotic
allquixotic / cross-build.sh
Created September 18, 2014 17:14
phantomjs mingw64 build script for Fedora/CentOS 7
#!/usr/bin/env bash
export QMAKE=mingw64-qmake
export MAKE=mingw64-make
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-gcc
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig
export LIBDIR=/usr/x86_64-w64-mingw32/sys-root/mingw/lib
set -e

##New tool I wanna write!

###Assumptions:

  1. The end-user's system does not filter outbound traffic (so SSH is okay)
  2. User is running Windows Vista/7/8/8.1 (bitness irrelevant)
  3. Assume that a .NET Framework with the CLR 4 is installed
  4. The tool must not use an existing web browser or browser profile from the system
  5. No installation in Add/Remove Programs
  6. Distributed as a single .exe that launches immediately without prompting the user to unpack
  7. File size is not an issue, but since multiple files are probably needed, will need to unpack natives and EXEs to a temp dir

If I plug a line or USB microphone into my PC, I can record audio at 44.1kHz. That's one sample of audio about every 23 microseconds. The audio wave must be sampled and played back precisely or it will sound distorted. How do non-realtime OSes manage the very time-sensitive process of audio recording and playback with such high sample rates? Is the process any different whether the audio is played/recorded on motherboard audio versus USB speakers/microphone?

It comes down to buffering.

44.1 kHz does not mean that there is an analog signal that has to be timed perfectly when being sent from the sound card (USB, PCIe, on-board, doesn't matter) to the CPU. In fact, the signal is digital. To have a digital Pulse Code Modulation bitstream being sent at 44100 Hertz just means that, for each second of audio, there will be 44,100 "data points" in the signal. The signal is quantized, meaning that it's basically a sequence of numbers. The size of those numbers (8-bit, 16-bit, etc) is determined by the *