Wednesday, June 26, 2013

[coding] Unsatisfied

I have a large project at work that is a big deal.  My manager is on vacation, and the senior PM who was filling in for the PM who left the company is about to go on vacation.  The one tester on the project has a habit of staring into space blankly whenever I explain something.  It will shortly become the wild west here.

In addition, I am attempting to get fit.  First I ran until my legs hurt constantly, then I biked until my legs hurt constantly, and then I started lifting until everything hurt constantly.  I've been working with a personal trainer and trying to figure out just how hard I can push myself without breaking everything.

In addition, this side business is consuming my life.  It is so much more work that I ever want to do, but I have to do it because I committed and because I want to make money and quit my day job.  Oh and my business partner is super emotional and I have to learn people skills now and also some people we almost took on as partners tried to screw me out of the business.

In addition, I am single again and breathing requires ten times the amount of effort it used to.  In addition, I have less sleep now due to what I assume is mild loneliness.  And now I have to spent a shit ton of time stalking old romantic interests on facebook, destroying my ability to attract mates by giving myself a haircut, and going on dates with girls from PlentyOfFish and NOT OkCupid based on a profile I am too lazy to update because I don't want to bother updating until I work out for a few months and don't look skinny and also buy all new clothes or something.

Also I'm in a kickball league and actively trying to continue my transformation into an extrovert.  It is a challenge.  Oh and kicking a ball is fun too.

Also I am addicted to reading /r/fatpeoplestories on reddit.  This is closely related, and probably a large cause of, the second paragraph of this post.

Therefore, what is it do you think I am spending my time on?  What would be wisest?  Yeah.  3-SAT.  Fucking hell.  When I die my tombstone will probably read "dedicated most of his life in the service of an ultimately flawed belief concerning a mathematical thingy no one cares about."  Anyway.

I was in the shower a week or a few days ago, thinking about my 3-SAT algorithm, and wondering how I could find an instance of 3-SAT that breaks it.  Unfortunately, as if part of some kind of weird addiction, trying to think about how to break it ultimately leads to just thinking about how it has to work.


Then I thought:  why not just convince other people to break it for me?  The world is mostly full of two kinds of people:

1) people who have never heard of 3-SAT
2) people who think P != NP

Its the second group of people that roll their eyes everyone another dumbass tries to announce an algorithm that they think is polynomial time for all instances of 3-SAT.  I think those people can help me out.  I have dedicated hundreds of hours into becoming an expert in a single, crazy approach that makes no sense to other people.  I have basically zero knowledge of breaking 3-SAT algorithms.  However, all of these skeptics in category 2 could fill in that gap for me.  They just need to be inspired to want to help instead of just rolling their eyes and relegating me to the computer science equivalent of someone who claims bigfoot exists but can't prove it.

My first idea:  a contest.  Just throw up a website with an upload button, and promise $X to the first person who can break my algorithm.  Obviously we would need some limits on submission rates per IP, and on problem size and so on to save computing costs.  I can write up some clues (that they should obviously take with a grain of salt), such as saying its a clause-finding algorithm and probably weaker for lower c/v ratios, and make the algorithm print out a number from 0 to 2*(# variables) which indicates how much difficulty it had with an instance, allowing people to fine tune whatever generators they are using to make it more difficult.

Is this a stupid idea?  Probably.  Should I instead be spending my time reading the literature and actually learning how other people are trying to solve this?  Probably.  Am I actually going to do that?  Probably not.


Also, I still have the 1.001 billion 3-SAT instances on which I spent nearly $1000 to generate with Azure instances.

So...all I need is some kind of cheap storage, queue and workflow system that can handle billions of 3-SAT instances.  And this time around I'm not paying for 20 virtual machines to do the processing.

I do have one of those cheap-ass web hosting services, where they promise you "unlimited" shit and cancel your account if your usage doesn't follow their idea of what you should use it for.  I'm already paying for it for other reasons, so I might as well re-use it here.

Also, I need to test drive CloudMine to see if it will work for the skin care app.

Therefore, I sat around for a few hours dreaming this up:

Heterogeneous, cheap-ass 3-SAT storage system for billions of instances


Cleanup

0.  remove duplicates, 2-clauses, 1-clauses, and shuffle so there are no missing variables
1.  swap variables so highest count first (optional)
2.  swap literals so highest count first (optional)
3.  sort literals in clauses by variable # (optional)
4.  sort clauses (optional)


Sharding

Sharding is a fancy ass word for storing things in multiple databases when one database isn't large enough.  We shard on:
1.  v = number of variables
2.  c = number of clauses
3.  counts.  Counts is an descending-ordered list of the counts of each variable.  In addition to listing just the counts of each variable, we also list the higher of the counts of the positive and negative literals.
4.  guid hash.  if we still need more sharding after all that (i.e. if we have millions of instances with the same histogram of variable and literal counts) then just use a hash of the guid that we use to identify each instance.  This is lame though.

5.  Craziness:  if you sorted and ordered the clauses and literals well enough (see Cleanup), you could actually just create a single array of all the literal values for every instance and use that to construct a tree-based index where the nodes of the tree are the actual values in the list.  This wouldn't actually remove all duplicates (duplicate detection should be NP-Complete) however  it would eliminate most of the waste that comes from our poor representation of 3-SAT instances.

Instance GUID

probably something like:  

v.c.vcount0.vliteralcount0.vcount1.vliteralcount1....date.host.randomNumber

v is # variables, c is # clauses, then see #3 in previous section, and host is the host that generated it.


Android App

I should make an android app that generates 3-SAT instances, so that when I am bored standing in the lunch line I can generate an instance according to some parameters, upload it, and look at the results.  Normally I use Duolingo to learn spanish when I'm bored, but the cafeteria is too loud for that.


The Data Store

Obviously all of these tables probably need tombstone fields to avoid ever deleting a row.  Also obviously these tables may be in different databases.

instance_shards
This table only exists in one place

shard_version (increment when new sharding scheme)
v_min
c_min
varcount_min = null (string)
instance_id_hash = null

instances
Many tables exist.  Consult instance_shards to know which one.

instance_id (guid)
v
c
literal_counts
instance_content_location  (url pointing to the actual cnf file)
execution_results_location  (database table with execution details - null when not solved yet)
tag_id (tells you about where this instance came from)


execution_results
Many tables exist.  Might have sort of a 1:1 relationship with instances...not sure.

execution_id (auto increment)
instance_id
result = Unsat, Sat, Fail (0,1,2)
difficulty = 0...2v
details_location = null (reserved for future use)

Details might include algorithm version, host, how many jumps were fixed by filters, etc.


instance_contents
first version:  just a database table
second version:  maybe cloudmine
or s3
or a fileserver at my apartment
the main computer of the U.S.S. Enterprise
carrier pigeons

queue_table
Also, I'll need  queue table when I get around to implementing a portal for people to submit their attempts to break the algorithm.


[coding] Eclipse and Git

Most of the tutorials out there for Eclipse and Git seem to assume that all you want to do is create a brand new project in eclipse, and then add that to a brand new git repository.  I find it strange that the need to create new eclipse project in an existing git repository (i.e. in a new git repository that is set up to push/pull from a remote repository like, idk, github) doesn't appear after twenty minutes of googling/reading.  So here are my instructions.

Eclipse + Git

On server
1.  On server (say, a brand new ubuntu server machine that you just installed git on) create bare repository.


On local computer
2.  create new project in eclipse
3.  Team -> Share ...
3a.  create new git repo
4.  edit new git repo
4a.  r-click on remotes -> create remote
5.  configure for push first, so you can push to the remote and have something in it.


Yeah, sounds simple now.  Imagine being me and always forgetting how you did it every other time.

Note:  this is more for git beginners like me, who still use the local git repo more like a workspace, and behave as if the remote one is a centralized server, as if we were still using SVN.  In my defense, at least I'm not using some disgusting shit like perforce.


P.S. best Git/Eclipse resource I could find:  http://www.vogella.com/articles/EGit/article.html

Saturday, June 22, 2013

My Attempt to Ruin the Movie Called The Purge

I'm not kidding.  This is full of spoilers.

Also, before I being, this movie gave me more reasons to consider something I had been mulling over:  horror and sci fi are very closely linked.  They usually have some kind of premise (what if all people in the world started killing each other?) but simply take it in different directions.  Sci fi movies explore the premise, while horror movies use it as a means to kill people.

So, lets begin.

The premise of The Purge is that somehow, an American government sanctions a 12 hour period where all crimes are allowed (except against top government officials).  There is no explanation about how such a situation could possibly have been allowed to occur, especially since such a situation could arguably said to violate human rights and cost america all of its allies, making it hard for us to obtain oil.  Anyway.  Part of the premise, so I was willing to give them that.

There is a limit against the types of weapons that may be used during the purge.  However law enforcement is suspended (and law enforcement officers are probably not "level 10" government officials, making them fair game) so there is no way for that rule to be enforced.

Despite all crimes being legal, no one appears interested in bank heists.  Only murder.  Specifically, risky murder because others are also out of commit murder.  In addition, it seems more likely that people would be more interested in finding women to gangrape violently.  Also, there was no mention of the hedonistic parties that would probably ensue.

Fire, police, and ambulance/hospital services are all suspended during this period.  It would seem an obvious course of action to make sure that every member of an upper class family is familiar with basic first aid and basic martial arts and basic firearms training.  The characters, a typical upper class family, have none of this.  They have a random collection of firearms.  They have no armor.

During the purge, everyone just hangs out in their homes, which all appears to have a simple security system with a single point of failure.  They don't leave the country.  Also, no corporations appear to have been created in order to offer people shelter, protected by private security forces that can be trusted because of their performance in past purges.

In fast, there doesn't appear to exist any private security.  Instead of locking rich houses down, why not have private security companies patrol areas?  Why not have privatized medical and fire personnel that are hired by communities?  Why aren't their lockdown hotels that allow people to rent a room for the night?  The movie tried to add this context where some people argue that the purge affects the poor disproportionately, but such hotels could be done on a budget.

When the characters fired guns, they somehow had the herculean strength to get off a large number of rounds without the kickback affecting their aim.  Of course this happens in almost every movie humankind has made, so I guess I can't really fault them for it.

The father is a salesman of home security systems.  He himself uses one of the systems that his company sells, and has sold the same system that he uses to all of his neighboors.  His neightboors, who are just as rich as him, resent him for selling them a security system.  I don't know what the fuck their problem could have been.  They could have bought from a different salesman, or from a different company, or not bought a security system.  Instead, they chose to buy one from him and be mad about it.  This ridiculous sub plot is the basis of the surprise ending.

The plot basically begins during the purge, because a small child knows the code to unlock the security system and unlocks it when the father isn't around to allow a stranger in the house.

In a side plot that really wasn't necessary, the daughters teenage boyfriend thought that murdering her father would be an acceptable way to ease some mild drama between the boyfriend and the dad.  He apparently did not think the girl would mind if he killed her father.

The man they allowed inside was being hunted by a gang of teenagers who threatend to breach the house's security system if the family does not deliver the stranger to them.  All of the characters assume the gang can be taken at their word, and that handing over the stranger will actually guarantee their safety.

Despite the life or death nature of the situation, both of the children do the opposite of their parents instructions at almost every opportunity.

At close to the climax of the movie, they are binding the stranger with duct tape, and they have only moments to hand him over to the teenagers.  This is the point when they sit down for a morality crisis tea party.  All of the characters other than the father say things like "look at what you're doing!  oh no so terrible."  Everyone presents a one-sided emotional plea that would have made perfect sense if the Dad was trying out a new hobby where he ties people up and kills them, but made no sense when the entire family was facing a dire ultimatum.

So, effectively, they first alienate the stranger by hunting him down, and THEN they don't even make use of him as a bargaining chip.  They could have increase the number of armed adults from 2 to 3, but instead he is just tied up when the teenage gang breaches the security and enters the house.

The family leaves all of the pictures on the walls so that the teenage gang know how many family members to hunt down.

The family fails to play loud music or anything else that might harm the gangs ability to find them.

Instead of taking the high ground to kill some of the teenagers, or forming real defensive positions, or creating distractions, the father and mother stand around with firearms.  The son briefly hides in the basement where he waves a flashlight around to make himself easy to find, and the daughter just goes missing off screen, so that she can have random scenes being attacked, or maybe be a brief deus ex machina, I don't know which.  Instead of letting the teenagers come to them, the father and mother wander around the house so that someone can get the drop on them.

With the exception of the father who is knifed while passing through a doorway that he somehow failed to clear while wielding a shotgun, all of the members of the family are repeatedly attacked and seconds away from death before an off screen character shoots the person about to make the kill.

When the teenage gang members start dying, the rest of the gang presses the attack, even though it is clear that the family is armed enough to put up a fight and present a serious threat.

Then, at the climax, neighboors--the ones who are still mad about choosing to buy security systems--show up.  They are not wearing body armor but suits and cocktail dresses.  They walk in the house and shoot the teenagers.  Despite all of the difficulty the father and mother had with combat, the neighboors don't have any trouble as they walk in and somehow always end up behind where the teenagers are facing.

A heart monitor watch is introduced early in the movie.  It appears to have been placed there for no other reason that to include the heart beeping trope that they usually do in hospitals.  As that scene played out, I couldn't think of anything else other than the fact that the script writers deliberately planted the plot device early in the movie, and actually went out of their way just to include something cliche that should have been avoided.

Everything I wrote and will write doesn't matter compared to this:  there is apparently no ill affects in society from the purges.  Magically, no one has PTSD, or lifelong emotional problems caused by memories of watching people kill, almost being killed, or being raped mercilessly.

The reason I hated it the most, though, was that as with all horror movies I couldn't identify with a single character.  No one behaved as I would.  No one.  Everyone was a giant pussy, a psycopath, or an idiot.

First of all, this happens once a year.  Leave the fucking country.  Can't leave the country?  Travel to an undiclosed location.  Can't travel?  Create a private hotel with a private security company that is paid to protect the guests.  Open an entire fucking chain.  When the super secure hotel is not being used during the purge, it can double as a normal hotel.

Hotel unavailable because of lame plot device?  Stay with father.  Safer in greater numbers.

Are police, emergency and other services going to be unavailable?  Guess what.  EVERYONE IN THE FAMILY IS TAKING EMT CLASSES.  Also, everyone in the family is learning Krav Maga.  Also, everyone in the family is going to the shooting range.

Also, in addittion to the family arsenal of weapons, we will have body armor.

In addition of the ineffective metal sheets that would be impractical to build into a houses architecture, we will have a panic room.  People under 18 who do not listen to their parents during life threatening situations will not have the codes to disarm the security system.  Also, the houses security system will not be a completely on or off situation.  It will be possible to only open the front door.

In addition, the upper floors of the house will have build in sniper nests, so that it is possible to fire out of the house.

In addition, all of the entrances to the house will have flame-based booby traps.

Again, BODY FUCKING ARMOR.  Also, flash bang grenades.  And caltrops.

Also, if I was faced with the ultimatum of handing over a stranger by an arbitrary deadline, or having my entire family slaughtered, the optimal strategy is to obtain the stranger and plan to hand him over at the last second before the deadline.  Also, explain to the stranger your desire to not kill him and solicit his help in brainstorming a better solution.  This approach is best, because both choices in the ultimatum involve the strangers death, and this strategy makes those two outcomes similar enough that there is little practical value in choosing one over the other.  The only different is, by cooperating with the family, the stranger has a better chance of survival.  While executing this plan, I would most likely attempt to devise an alternate solution.  We could:

0.  Make it clear to everyone that our survival depends on our actions in the next few hours, and that when we are down to the wire, we are not going to drop what we are doing to debate the wider moral implications.  In addition, I would explain that the arbitrary choices I make are the ones I've calculated for our best chance of survival, and in no way represent the right or moral choice in that situation.  We may be making the evil choice.  We may be making the righteous choice.  Too bad!  When a madman puts my family under a ridiculous and survival related ultimatum, the entire universe loses the privilege of expecting me to behave in a way that is consistent with any moral standard or belief system of any person or culture.  I do not mean that my survival supercedes such beliefs, only that I may choose to do the wrong thing.  Also we will not be stopping in the middle of anything to have weird out of place conversations about right and wrong.  Conversations like that only happen while making plans.

1.  Go to the second floor, or anywhere we can make a hole, and start sniping the teenagers to reduce their numbers and so that they can't walk around the yard freely.  Start with their leader.  Or,

2.  Open up just one entrance, so that the teenagers can enter but only on our terms, and we have made whatever preparations necessary involving furniture, weapons and booby traps in order to give ourselves the advantage.  Or,

3.  Wait until they enter and set the house on fire.  Or,

4.  Fight our way out of the house and make a run for it.  Distractions could be used to allow the children to escape.  Or the parents and stranger take off in different directions while allowing the children to hide in one place, in a corner, guns facing outward.  Presumably the gang would lose interest in the house once their quarry has left it.  Or,

5.  Create a ruse based on the premise that the stranger is in control of the situation inside the house.  Possibly have him threaten to kill himself if they enter.

In conclusion, the movie was phenominaly stupid because:
  • the premise was phenominaly stupid
  • the realization of the premise made no sense
  • most killings were predictable
  • the survival main characters was mostly effected by deus ex machina
  • the characters' behavior made no sense
  • all of the main characters make poor decisions during the entire movie
Redeeming  qualities
  • most of the dialog did not make me cringe


Ironically, this movie is still less stupid than Sunshine.

Monday, June 17, 2013

Thursday, June 13, 2013

Fuck the NSA

I've known a number of...people...who do that thing where they think they don't do anything wrong, so its ok for law enforcement to spy on them and download their sex tapes off of their computer and do whatever they want with them.


This article presents the best counter-arguments to that line of thinking.

For the record, I have never owned, touches, seen, or been near, a lobster.  I have also never talked in an elevator in New York.  And etc.

Wednesday, June 12, 2013

The Spaghetti Monster

The coder grabbed his mountain dew and his lucky chair and prepared for battle.  He met his adversary on the plains of incompetence.  It loomed there on the mountain of technical debt, flaws piled together, grown for a millennia under the tender care of programmers who didn't understand the language they wrote, grown in to the most monstrous glob of spaghetti code.  It had no heart but triple pairs of mixed concerns.

"I've seen you here before, and I have ignored you.  Too long have you been allowed to live, sheltered by management's indifference.  Too many times have I written you off as someone else's aborted fetus of code.  Well," the coder chugged his soda and threw it on the ground, "not today."

The beast growled and charged down the slope.

The programmer raised his keyboard in the air and screamed "I will end you!"

And then he flipped off the people looking at him funny.

Monday, June 10, 2013

I don't know if this will actually work

I copied this from here, and haven't read it.   Thought I would do my part to waste the NSA's time.  More likely, this was a waste of my time.


North Korea attack drill domestic security deaths, law enforcement prevention dirty bomb hostage. Shots fired looting SWAT threat pipe bomb incident facility. First responder militia initiative. Nuclear hazmat chemical spill, North Korea nerve agent exposure, biological anthrax cloud - ebola recall avian flu, infection pandemic & toxic wave. Pork influenza plague symptoms quarantine tamiflu.

Infrastructure security CIKR AMTRAK collapse, computer infrastructure communications infrastructure telecommunications, WMATA metro; electric outage port dock bridge brown out cancelled, body scanner power lines grid. Gang drug violence drug cartel, Mexico heroin marijuana cocaine narcotics, San Diego, Ciudad Huarez, MS13 Mexican army methamphetamine, trafficking kidnap bust!

Guzman Arellano-Felix, Tucson US Consulate decapitated, narco banners shootout execution. Terrorism Al Qaeda Iraq Afghanistan Iran Pakistan attack, conventional weapon target weapons grade enriched ammonium nitrate, home grown nationalist recruitment - car bomb Hezbollah IRA IED AQAP Al-Shabaab plot, weapons cache Taliban Jihad fundamentalism.

Emergency hurricane, ice stranded mudslide erosion hail twister tornado, help disaster snow templor forest fire, typhoon avalanche sleet aid relief closure. Cyber security botnet DDOS denial of service malware virus trojan keylogger cyber command 2600 spammer fishing rootkit phreaking brute forcing mysql injection cyber terrorism. Worm conficker scammers, hacker China social media.