John L. Sokol - computer expert, video, compression, information theory and all things cool.
Saturday, November 01, 2014
Past, Present and Future of Robotics
- Past, Present and Future of Robotics.
At the Beijing Science Festival 9/19/2014
http://youtu.be/9CQb59_tHA0
Friday, July 04, 2014
Hacker Dojo Lightning Talks, 2014 06-13
I am speaking about my Bluetooth chessboard project 20m 30s in.
Wednesday, July 02, 2014
ULN3113
Controlling the World with Your PC - Page 161
Monday, June 30, 2014
Cymatic universe
4 and 1/2 years later serious physicists are considering that maybe our universe is a vibrating superfluid.
Well, I have been thinking about this now for years and I have an alternate theory.
One I call the Cymatic Universe, one that is in a nonlinear medium and behaves like a non Newtonian superfluid that's lossless.
Published on 12/02/2010
Published on 6/30/2014
Have We Been Interpreting Quantum Mechanics Wrong This Whole Time?
Fluid Tests Hint at Concrete Quantum Reality
Tuesday, June 17, 2014
Reverse Polish Notation - Spreadsheet Calculator
This is for a job I was interviewing for 2 years back.
Beautiful piece of code I wrote although I never got the job.
Hello John,
It was really nice to talk to you.
Attached is the coding question we send to everyone. Feel free to use
whatever languages/tools
you are most comfortable with to solve it. It is not really intended
to be an embedded exercise per se, but rather a way to see how you
might tackle a simple problem.
If you have any questions, feel free to ask. Once we cross this stage
I am looking forward to meet you and YYYY our business development
manager will coordinate with you.
Thanks,
XXXX
Spreadsheet Calculator
A spreadsheet consists of a two-dimensional array of cells, labeled A1, A2, .... Each cell contains either an integer (its value) or an expression.
Expressions contain integers, cell references, and the operators '+', '-', '*', '/'. Expressions are given in Reverse Polish Notation (see http://en.wikipedia.org/wiki/Reverse_Polish_notation). Write a program (in Python/C++/Java/C) to read a spreadsheet specification and evaluate the values of all the cells. A spreadsheet is specified as a plain text file:
• Line 1: two integers, defining the width and height of the spreadsheet (n, m)
• n*m lines each containing an expression which is the value of the corresponding cell (cells enumerated in the order A1, A2, A, B1, ...).
Your program should output its data in the same format, but each cell should be reduced to a single floating point value.
Example
For example, the following spreadsheet:
2 2
A2
4 5 *
A1 B2 /
3
evaluates to:
2 2
20
20
6.6666667
3
The above example input visually looks like:
1 2
-------------------------
A | A2 | 4 5 * |
-------------------------
B | A1 B2 / | 3 |
-------------------------
Test Cases
• We provide several example input and output files. • We value elegance, simplicity, and readability in your code
Comments • All numbers in the input are positive integers, but internal calculations and output should be with floats. You can assume that there are no more than 26 rows (A-Z) in the spreadsheet. • Your program should detect cyclic dependencies in the input data and report these by throwing CircularReferenceException.
• You may assume that input file is formatted correctly, and all of the expressions are well-formed.
• Just passing the provided test cases does NOT mean you have a correct implementation.
-------------------
https://github.com/johnsokol/RPN-Spreadsheet-Calculator/
#include <cctype>
#include <iostream>
#include <map>
#include <sstream>
#include <fstream>
#include <stack>
// RPN SpreadSheet Calculator
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
using namespace std;
#define FALSE 0
#define TRUE 1
namespace Error
{
struct CircularReferenceException
{
};
struct Zero_divide
{
};
struct Unresolved
{
};
struct Table_error
{
const char *p;
Table_error (const char *q)
{
p = q;
}
};
struct Syntax_error
{
const char *p;
Syntax_error (const char *q)
{
p = q;
}
};
}
class spreadsheet
{
typedef struct
{
std::string data;
double result;
bool solved;
} ElementType;
typedef map < std::string, ElementType > TableType;
TableType table;
int x, y;
public:
int unresolved_elements;
bool tablefail;
enum Token_value
{
STRING, NUMBER, PRINT, END, ADD = '+', SUB = '-', MUL = '*', DIV = '/'
};
spreadsheet ()
{
};
~spreadsheet ()
{
};
double RPNeval (string expr);
void load (istream &);
void solve_pass ();
void solve ();
void dumpresults ();
void dumpmap ();
};
double
spreadsheet::RPNeval (string expr)
{
double a, b, result;
#define MATH_OPERATION( op ) \
if(mystack.size() < 2) throw Error::Syntax_error("Stack Underrun"); \
a = mystack.top(); mystack.pop(); \
b = mystack.top(); mystack.pop(); \
mystack.push(b op a);
stringstream input (stringstream::in | stringstream::out);
string token;
stack < double >mystack;
char ch;
input << expr;
while (input.get (ch))
{
switch (ch)
{
case 0:
break; // Should never get here
case '\t':
case ' ':
break;
case ADD:
MATH_OPERATION (+)break;
case SUB:
MATH_OPERATION (-)break;
case MUL:
MATH_OPERATION (*)break;
case DIV:
if ((mystack.size () >= 2) && (mystack.top () == 0))
throw Error::Zero_divide ();
MATH_OPERATION (/)break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
input.putback (ch);
input >> result;
mystack.push (result);
break;
default:
if (isalpha (ch))
{
input.putback (ch);
input >> token;
if (table.find (token.c_str ()) != table.end ())
{
if (table[token.c_str ()].solved == 1)
{
mystack.push (table[token.c_str ()].result);
}
else
{
unresolved_elements++;
throw Error::Unresolved ();
}
}
else
throw Error::Syntax_error ("Invalid CELL");
}
else
throw Error::Syntax_error ("Invalid symbol");
}
}
result = mystack.top ();
mystack.pop ();
return result;
}
void
spreadsheet::load (istream & input)
{
char tmpstr[255];
char element[6];
int i, j;
stringstream ss (stringstream::in | stringstream::out);
unresolved_elements = 0;
cin.getline (tmpstr, 255);
ss << tmpstr;
ss >> x;
ss >> y;
// Check x & y size and throw exception for too large
if (x > 26 || y > 100)
{
throw Error::Table_error ("exceeded maximum size");
// exit(1);
}
for (i = 0; i < x; i++)
for (j = 0; j < y; j++)
{
sprintf (element, "%c%d", 'A' + i, 1 + j);
cin.getline (tmpstr, 255);
table[element].data = tmpstr;
table[element].result = 0;
table[element].solved = FALSE;
unresolved_elements++;
}
}
void
spreadsheet::solve_pass ()
{
TableType::const_iterator iter;
unresolved_elements = 0;
tablefail = FALSE;
for (iter = table.begin (); iter != table.end (); iter++)
{
try
{
if (table[iter->first].solved == FALSE)
{
table[iter->first].result = RPNeval (iter->second.data);
table[iter->first].solved = TRUE;
}
}
catch (Error::Unresolved)
{
// Don't do anything, will try again next passs.
}
catch (Error::Syntax_error e)
{
cerr << "Syntax Error:" << e.p << "\n";
tablefail = TRUE;
}
catch (Error::Zero_divide)
{
cerr << "Divide by Zero Error" << "\n";
tablefail = TRUE;
}
}
}
void
spreadsheet::solve ()
{
int lastunresolved;
do
{
lastunresolved = unresolved_elements;
//dumpresults();
solve_pass ();
}
while ((unresolved_elements != 0)
&& (unresolved_elements < lastunresolved) && !tablefail);
if (unresolved_elements != 0 && !tablefail)
throw Error::CircularReferenceException ();
if (tablefail)
throw Error::Syntax_error ("Unable to resolve table");
}
void
spreadsheet::dumpmap ()
{
TableType::const_iterator iter;
for (iter = table.begin (); iter != table.end (); iter++)
{
cout << iter->first << " = " << iter->second.data << "\n";
}
}
void
spreadsheet::dumpresults ()
{
TableType::const_iterator iter;
cout << x << " " << y << "\n";
for (iter = table.begin (); iter != table.end (); iter++)
{
//cout << iter->first
if (table[iter->first].solved)
cout << table[iter->first].result ;
else
cout << "unresolved ";
cout << "\n";
}
}
int
main (int argc, char *argv[])
{
spreadsheet ss;
try
{
ss.load (cin);
ss.solve ();
if (ss.unresolved_elements == 0 && !ss.tablefail)
ss.dumpresults ();
}
catch (Error::CircularReferenceException)
{
cerr << "Circular Reference Exception\n";
}
catch (Error::Syntax_error e)
{
cerr << "Syntax Error:" << e.p << "\n";
}
catch (Error::Table_error e)
{
cerr << "Table Error:" << e.p << "\n";
}
return 0;
}
Saturday, May 31, 2014
Friday, May 09, 2014
Wednesday, May 07, 2014
memetic monoculture
How Google’s Algorithm Silences Minority Opinion
http://highspeedinternet.com/blog/technology/how-googles-algorithm-silences-minority-opinions
Friday, March 28, 2014
Fwd: Your Bill is Now Available
From: Verizon Wireless <VZWMail@ecrmemail.verizonwireless.com>
Date: Fri, Mar 28, 2014 at 9:43 PM
Subject: Your Bill is Now Available
To: JOHN.SOKOL@gmail.com
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wednesday, December 25, 2013
Thursday, December 19, 2013
Tale of two robotic golf caddy's
http://www.youtube.com/watch?v=snZnpudOSRg Shadow Caddy, a better way to go BANKRUPT
Saturday, November 02, 2013
How to Build a Universe: Philip K. Dick on Reality, Media Manipulation, and Human Heroism
Tuesday, September 24, 2013
Dunkin' Donuts - USB charging plugs
Wednesday, September 11, 2013
Real Artificial Brains
DARPA SyNAPSE Program
SyNAPSE is a DARPA-funded program to develop electronic neuromorphic machine technology that scales to biological levels. More simply stated, it is an attempt to build a new kind of computer with similar form and function to the mammalian brain. Such artificial brains would be used to build robots whose intelligence matches that of mice and cats.
SyNAPSE is a backronym standing for Systems of Neuromorphic Adaptive Plastic Scalable Electronics. It started in 2008 and as of January 2013 has received $102.6 million in funding. It is scheduled to run until around 2016. The project is primarily contracted to IBM and HRL who in turn subcontract parts of the research to various US universities.
The ultimate aim is to build an electronic microprocessor system that matches a mammalian brain in function, size, and power consumption. It should recreate 10 billion neurons, 100 trillion synapses, consume one kilowatt (same as a small electric heater), and occupy less than two liters of space.
Friday, September 06, 2013
Elon Musk Unveils 'Iron Man'-like Design Tech for SpaceX Rockets (Video)
This is the demo leap motion needs to be showing
Thursday, August 15, 2013
Collective IQ
Saturday, August 10, 2013
Apple patents tech to let cops switch off iPhone video, camera and wi-fi
Apple patents tech to let cops switch off iPhone video, camera and wi-fi
So they can pummel with impunity
Police forces around the world have had the problem that when their officers get a bit carried away and start pepper spraying tied captives there is someone on hand filming the event on their mobile phones.
While six police lay into prone grannies on the floor with long batons, the pictures can be on the net in seconds, meaning supervisors have to answer embarrassing questions.
But they may not need to fear scrutiny much longer - Apple has patented a piece of technology which would allow government and police to block transmission of information, including video and photographs, whenever they like.
All the coppers have to do is decide that a public gathering or venue is deemed "sensitive", and needs to be "protected from externalities" and Apple will switch off all its gear.
The police can then get on with the very difficult task of kettling protesters without having to worry about a few beating anyone to death.
Apple insists that the affected sites are mostly cinemas, theatres, concert grounds and similar locations, but it does admit that it could be used in "covert police or government operations which may require complete 'blackout' conditions".
According to RT it could also be used to prevent whistleblowers like Edward Snowden from taking pictures and broadcasting them on the interent.
Apple said that the wireless transmission of sensitive information to a remote source is one example of a threat to security.
But it said that this sensitive information could be anything from classified government information to questions or answers to an examination administered in an academic setting.
Apple patented the means to transmit an encoded signal to all wireless devices, commanding them to disable recording functions.
The policies would be activated by GPS, and wi-fi or mobile base-stations, which would ring-fence ("geofence") around a building or a "sensitive area" to prevent phone cameras from taking pictures or recording video.
Odd that the company made famous by its 1984 Big Brother video can't really see what it is doing. Perhaps its own secretive culture and an overzealous security treatment of its staff have fostered sympathy for Big Brother after all.
Wednesday, July 03, 2013
Thursday, June 13, 2013
Hey I'm on TV
Peter is 9, and loves robots. He's also living with adult lymphoma, a lung condition that makes it tough to fight off infection. But he still loves gadgets, and wants to see robots in action. Enter Make-A-Wish and Scott Budman. (Published Friday, June 14, 2013)
