links for 2010-01-21

  • Six-legged locomotion is a simple, robust system of walking that is very popular both in the animal kingdom and among robotics hobbyists. Robot hexapods range from simple one-motor toys to advanced platforms with 18 or more servos. This tutorial shows you how to build a very simple autonomous hexapod robot using just three servos. The 2"-high hexapod is capable of walking forward and backward, and can turn left and right. Two forward-looking distance sensors provide obstacle avoidance. The brain of the hexapod is the Pololu Micro Maestro, a 6-servo controller that can read inputs and play motion sequences in a stored script.

Mexico

Mexico is an elimination-style dice game.

After each round, one player is eliminated.  When all players but one have been eliminated, the remaining player wins the game.  When playing for stakes the final remaining player wins the money that was wagered by each person who was eliminated in earlier rounds.

The game gets its name from a roll of 2-1 or Mexico the highest scoring roll in the game.

What you need to play

  • 2 dice
  • 2 or more players.
  • Chips or money (Suggested that you have 3 or more tokens for each person)

How to play the game
Everyone rolls one dice.  The player with the highest roll goes first (re-roll on ties).  The person to the left goes next and it continues clockwise until all players have had a turn.

The first player can roll the dice up to three times, the amount of the rolls he or she takes will determine how many rolls subsequent players may take in that round.  However, only the last result of a player’s turn counts towards his or her final score for that turn rather than the best result of two or three rolls.  Thus, it is in the first players interest not to re-roll the dice more than is necessary as doing so will give opponents more opportunities to beat his roll.

On a players turn they roll both dice and combine the value of the dice in to one number.  The higher dice use for the ten spot and the lower dice is used for the 1s.  For example, a roll of  5 and 6 would become ‘65′ , roll of 3-5 would become ‘53′ , roll of 5-5 would become ‘55′.

Whoever has the lowest score (see scoring below) at the end of the round has to put one chip into the pot.  The player that lost the last round starts the next around if they have any chips left.

Scoring
There are twenty-one different results that you can get by combining the numbers as described above.  Doubles count as higher than any mixed dice result.  A roll of 21, known as ‘Mexico’, is the highest roll that you can get in this game.

From lowest to highest
31, 32, 41, 42, 43, 51, 52, 53, 54, 61, 62, 63, 64, 65, Double 1s, Double 2s, Double 3s, Double 4s, Double 5s, Double 6s, 21 (”Mexico”)

Landmines

Landmines is a drinking game.

What you need to play

  • 2 Shot glasses
  • 2 or more players
  • Some quarter

How to play the game
The first player takes a quarter and spins it on the table, then with one hand takes a shot of beer, sets the shot glass down, and with the same hand takes the next shot of beer, sets it down and then grabs the quarter before it is no longer spinning.
If the spinner is successful then his turn is over and the next player goes.  If the quarter stops spinning or spins off the table, the player must continue to spin and take shots of beer until he succeeds.
As the game goes on, you will acquire empty beer cans.  When you have an empty you may place it anywhere on the table, including directly in front of your opponent, (if he spins the quarter it will bounce off a can and make it harder for him to successfully take his shots).
The drinking game is called landmines because with all the empty beer cans on the table, one can get confused as to which can he/she is drinking from.  If caught picking up an empty beer can to drink from, the player must (A) chug the rest of their beer, or (B) chug an entire beer.

Klondike

Klondike is a dice poker game.
Klondike is loosely based on poker originating in cheap casinos on the American frontier. Its really easy to play if you know anything about poker; even if you don’t its still pretty easy.

What you need to play

  • 5 dices
  • A sheet of paper to keep score
  • 1 or more people

How to play the game
The banker or dealer rolls first and creates a poker hand from his roll.
The players then each take there turn to roll the 5 dice and try to make a poker hand.
Five of a kind (4, 4, 4, 4, 4)
Four of a kind (3, 3, 3, 3,1)
Full House, Three of a kind and a pair (4, 4, 4, 5, 5)
Three of a kind (6, 6, 6, 3, 1)
Two pairs (5, 5, 3, 3, 1)
One pair (5, 5, 1, 2, 6)

Rules
Only one throw is allowed.
The numbers are ranked high to low as 1, 6, 5, 4, 3, 2.
Any dice that are not used are ignored.
The dealer wins a tie.

Example game play
The dealer rolls, (5, 5, 5, 3, 1) and has three of a kind.
Player 1 rolls (6, 6, 6, 2, 5) and has three of a kind but the dealer wins ties.
Player 2 rolls (3, 3, 2, 2, 2) and a full house beats the dealer.
Player 2 wins.

Variations
The casino variation is played with 10 dice using a table with a layout with three sections, “win”, “lose”, “Beat two aces”.  The banker rolls five dice and sets them sides.  The players then take turns rolling the other 5 dice trying to beat the banker.  A player that bets on win must try to throw a combination that is higher then the bankers, while a player that bets on lose has to try to roll less then the banker.  A player that bets on two aces must throw at lest two pairs.  Because all ties win for the house, the house has the edge on ‘win’ or ‘lose’ bets at 5.194%.  The house edge on ‘beat two aces’ is 11.111%.

King’s Cup

A classic drinking game that evolves filling a cup (the kings cup) with random shots of liquor for the unfortunate loser of the game.
As with all drinking games the point of the game is to get drunk.

You will need

  • A large cup (must be able to hold several shots)
  • A deck of cards (jokers removed)
  • 2+ players

Set up
Place a large cup in the center of a table with cards spread around it face down.

How to play the game
Each player picks a card from the face down cards and follows the rules below.
Once done the turn order goes to the left.
Mob rules – majority always rules, if they say drink when or if you messed up, you drink.

Ace- Social, everyone drinks.
2- Is for You, you pick someone to drink.
3- Is for Me, you drink.
4- Is for Whores, girls drink.
5- Rule, make a rule everyone must follow until the next 5 is picked.  If rule is broken, that person must drink.  See below for example rules
6- Is for dicks, guys drink.
7- Multiples of 11, The person who picks this card begins to count..”1″, the next person continues saying.. “2″, and the nextplayer says..”3″, and so on.  As soon as you reach 7 (whoever it lands on), the player says “F*CK YOU!” instead.  The direction then reverses (so the person who just said 6, now must say 8 and whoever said 5 says 9), and continues untill 11 is the number to be said and instead saying “F*CK YOU” and the direction again reverses.  Whoever f*cks up…DRINKS!

8- Don’t be late, a.k.a thumbs on table or points to the sky.  Whoever is the last to pick-up on the play must drink.
9- Nines is rhyme.  The person who draws this card will say a word, then the person to the right has to say a word that rhymes with it.  This continues around the table until someone messes up.  This person has to drink.
10- Waterfalls.  The person who picks this card has a choice of playing waterfall.  That person begins to drink.  The person next to the starter then begins to drink soon after, the player next to them begins drinking after the follower, and so on.  The trick is you can’t stop drinking until the starting player stops, then each player in order can stop once the player before them has stopped.
Jack – Go Back, the person before you drinks.
Queen- Questions (my personal least favorite).  Player turns to the person next to them and asks a question (ex: Have you ever licked a donkey’s butt hole?)  Then that person must turn to the next person and ask a relevant question (ex: Wouldn’t a Donkeys butt hole taste like candy?) the person who fumbles drinks.  Each question must be answered with a question!!
King- This is the kicker.  Whenever a king is drawn, that person must pour however much of their drink they wish into the empty cup on the table.  The person who draws the last king MUST DOWN THE KINGS CUP!  You could see what chaos would occure with more than one deck and several diffrent types of booze!

Variations of this Game

There are lots of different variations of this game, replacing some rules with others.  Some of the more common rules that I have seen are:

  • “Little (Green) Man (Wee Man)” – Before a player takes a drink, he must remove a “little man” from the rim of his cup before taking a drink.
  • “Don’t Break the Circle” – The cards around the King’s Cup must continue to make a circle around the cup through touching one another while people pull their cards on their turns.
  • “No First Names” – No using another player’s first name.
  • “Aristocracy” – Whenever a player addresses another player by name, they must give them a suitable title, such as Baron or Lady.
  • “Drink, Drank, Drunk (3D)” – No player may say drink, drank or drunk.
  • “Dyslexia” – All players have their names reversed, so, for example, Tom becomes Mot.
  • “Numbers” – Whenever a player says a number of any type, he/she must take that many drinks.
  • “In My Pants” – After the conclusion of any statement, a player must say “In My Pants” or another phrase, such as “In my bed”, “When I’m naked”, “Because I’m a slut”, etc.
  • “First Person” – No one can use any pronouns (e.g., I, my, me, mine, etc.) Very interesting when combined with the “In my pants” rule.
  • “S” – Any player to say a word beginning with “s” must drink.
  • “Orgasms” – Whenever someone says a certain word, the other players at the table have to fake an orgasm. The last person to do so has to drink.
  • “Pointing” – Often phrased something like “Whenever I point at Ronan he must drink” or “Whenever someone points they have to put their face on the table until the next person points”.
  • “Polite Society” – No swearing.
  • “Srebmun” – All numbers must be pronounced backwards.
  • “Two Hander” – All drinking must be done with both hands simultaneously contacting the glass, cup, or bottle.
  • “Rob Lawlor” drink with left hand and with pinky in the air. Sometimes, the rule can be more general and dictate that all players may drink with their non-dominant hands only.
  • “Rick James” – When anyone says anything, they must end the phrase by saying “BITCH!”.
  • “Superheroes” – Players can’t say any others’ names, and have to replace them with a superhero’s name. One can assign them, or just make them up.
  • “Pirate” – All players must look into the can and say “Aaarrrr!!” (like a pirate) before they drink.
  • “Fuck” – Every sentence must have “Fuck” in it.
  • “Add a Drink” – Every time a drink needs to be taken, one must add one more drink to whatever amount of drink must be taken (i.e: one shot is needed, so two shots are taken)
  • “Righty Tighty” – One must hold his drink in his right hand until the game is over.
  • “Hook up Rule” – All players can only be referred to by the name of someone they have hooked up with in the past.
  • “Pockets” – Anyone who puts their hands in their pockets must drink.
  • “Chins” – Everyone must keep chins on table unless taking a drink.
  • “Balls” – Every time anyone takes a drink, they must act like the beer can / cup / bottle is a penis, and ‘caress the balls’ beneath the ‘penis’ as they’re taking a drink.
  • “Eye Contact” – No person playing the game can make eye contact with another person playing the game. The consequence of this is both people must drink.
  • “Face-Touching” – No player is allowed to touch his own face during the remainder of the game.
  • “Period” – Everyone must speak the applicable punctuation for everything they say (period).
  • “Let it Ring” – No player is allowed to answer any cellphone or text anyone till the game is over. If caught doing so they are required to finish thier drink before the game continues
  • “Dress Code” – Certain items of clothing may be forbidden to be worn by any player. Bras and underwear are popular choices, especially when playing with other strip rules.

Jackpot

Jackpot is a dice game that was played in many taverns in the middle ages.  People could often find the game’s layout on the taverns tables.  In lower-class establishments the layout is often crudely carved into the tables surface, whereas finer establishments have been known to use specific tables set aside for the game.

This game is also known as Dragon’s Hoard.

What you need to play

  • 2 dice
  • 2 or more players
  • Some chips (Max of 33 chips need, most of the time a lot less are required)
  • A game board descried below (can me made with a pen)

 

Game Board
The game is usually nine circles with the numbers 3 through 11 inside them.  A design is drawn in the center.

How to play the game
Players throw the dice in turn.  After each throw, the players place a chip on the corresponding number on the layout.  For example, if a player throws a total of 4, he places a chip on the area of the layout marked 4.  The dice are then passed counter clock wise.  Once a number on the layout has three or more chips on it, the next player to roll that number collects them.

If a player rolls a pair of 1’s, (known as Dragon Eyes), that player places a chip on all the numbers on the layout.
If a player rolls a pair of 6’s, (know as Stealing the Hoard), they collect all the chips on the layout.
Play continues for a pre-determined time, or until it is agreed to end the game.

links for 2009-12-19

  • When Paris-born, Israeli-raised Yael Naim met David Donatien, a West Indian drummer, the two sat down to share their rich musical experiences. Combining Yael’s classical education and love of pop and jazz, this collaboration lead into recording 13 beautifully arranged compositions, mostly sung in Hebrew, with instrumentation of piano, guitar, cello, bass and percussion. While the mood ranges from melancholic to sweeter and hopeful notes, she carries intimate feeling throughout her songs.
    (tags: music audio blog)
  • The easiest way to create an image gallery within WordPress is by using the add feature (from WP 2.5+), but to give your gallery something extra you may wish to add the Lightbox effect. Originally developed by Lokeshdhaker.com, Lightbox has gained widespread popularity because it is easy to use and it gives a professional and stylish finish to your images.

links for 2009-12-17

CakePHP – Security.level

I been having reports from my users that they are getting randomly logged out of my web applications. After much debugging I found that CakePHP regenerates the session on every request.

File: core.php
/**
* The level of CakePHP security. The session timeout time defined
* in 'Session.timeout' is multiplied according to the settings here.
* Valid values:
*
* 'high' Session timeout in 'Session.timeout' x 10
* 'medium' Session timeout in 'Session.timeout' x 100
* 'low' Session timeout in 'Session.timeout' x 300
*
* CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high
'.
*/
Configure::write('Security.level', 'high');

After changing the ‘Security.level‘ to medium the problem stopped happening.

Get special folders with SHGetKnownFolderPath

This application will print the special folders that you should be storing your applcations data in.
UAC on Windows Vista/7 will no longer alowe you to write to files in the “C:\Program Files\” with out elevation to administrator. Instead you should be writting your settings file to the “LocalAppData” folder and your output and log file to “Documents” folder.

More information on UAC

Source code:

#include <shlobj.h>
void GetSpecialFolder( REFKNOWNFOLDERID rfid ) {
LPWSTR wszPath = NULL;
HRESULT hr = SHGetKnownFolderPath ( rfid, KF_FLAG_CREATE, NULL, &wszPath );
if ( SUCCEEDED(hr) )
{
wprintf( _T("Path: %s\n"), wszPath );
}
}

int _tmain(int argc, _TCHAR* argv[])
{
GetSpecialFolder( FOLDERID_ProgramData ); // Shared program data directory for all users
GetSpecialFolder( FOLDERID_RoamingAppData ); // Per-user program data directory (roaming)
GetSpecialFolder( FOLDERID_LocalAppData ); // Per-user program data directory (non-roaming)

GetSpecialFolder( FOLDERID_ProgramFiles ); // App install directory
GetSpecialFolder( FOLDERID_Documents ); // Logs, reports, output
return 0;
}

Why don’t we have free phones yet?

“Re:Should be” by canajin56 (660655) on Wednesday December 16, @12:21PM (#30459990)

At least you guys have a choice of providers. Here in Canada, we almost have government-backed monopolies with even higher monthly bills.

Are you kidding? It’s not like we’re limited to the big 3 (Rogers, Telus, Bell), we have all sorts of other providers! There’s KOODO, their ads lead me to believe they don’t do all that nasty hidden fee stuff. Oh, rebranded TELUS to seem less evil? Oh, well, there’s always FIDO, they make the same claims about being not as evil as Rogers in all their ads! Oh…they’re owned by Rogers, to rebrand and seem less evil, too? Well, there’s always Solo Mobile. Oh…same deal with Bell? Virgin Mobile? Oh, Bell again? Why do they need TWO sham fronts? My favorite customer gouging one was the guy who ran up the $60,000 monthly bill, because they sold him an “Unlimited* Data** Plan!” that didn’t cover any data usage other than the phones built in browser, so all that smartphone shit that also used data was billed at dollars on the kilobyte. The best part of that was the way Telus or whoever it was was unrepentant “It’s not our fault he did not fully read the contract, but out of sheer generosity we will reduce the bill to a mere 6 grand!” A close runner up is KOODO/Telus’s promise of “No activation fee”, while there is a cancellation fee that is due in advanced when you sign up! Sort of like Blockbusters “No late fee *cough*but-there’s-a-restocking-fee-if-you-return-it-late*cough*”
Source: http://apple.slashdot.org/comments.pl?sid=1480704&cid=30459990

**Mostly thinking out loud**

Why don’t we have free phones yet?
Well lets look in to the barriers to a free phone. Software stack (OS), Hardware (the physical phone), Cell phone network (Cell phone towers and RF frequencies).

The software is pretty much done for us now that Google has released http://www.android.com. Even before  the android there where plenty of free open source smart phone stacks.

The hardware is a little tricker, it takes a lot of effort to build a solid phone with the right feature set. But over the last few years we have seen great strides in open hardware such as http://www.arduino.cc/. Everything from Servos, webcams, wind turbines, to even more complex things like Graphics cards, GPS, and multi-touch tablets.  There is even an open hardware cellphone Openmoko (FreeRunner) that has its own software stack. The hardware can be made with enough smart people behind it.

The network required an array of physical cell phone towers spread across the coverage area and RF frequency that the Cellphones can use to communicate with the cell phone towers (How cell phone talk to each other). The RF frequency sold by the government to the highest bidder for billions.  There is no way for an open source group or any small business to enter the field. Roadblock.

So how do we work around the cell phone networks?

Distributed network.

One option is you could use short range open RF frequency and hop your signal from device to device until it found its detestation (Mesh_networking). Every device on the network would be responsible for receiving message checking to see if the message was meant for them if not sending it on to the next node. After a connection is made a short route could be created to optimize the connection and a backup route in case the first rout drops off. Every time a device comes in contact with anther devices it could create a list of contacted devices and the last time they saw them. This list would help in creating routs between people. The more users on the network the better chance there is that your message would get delivered.

Problems

These are just the ones that I can think of off the top of my head. I’m sure there are many more.

  • Fractured networks. If two people are too far apart and there are not enugh nodes to connect them to each other they will not be able to send a message between each other.
  • Privacy. If the message has to be relayed thou many different devices there is a chance that it could be intercepted by one of these devices and read by an unintended target. Public and private key encryption should help with reducing the ability for third parties to spy on conversations but the risk is still there.
  • Battier life. Since every device would be essentially active all the time they would consume a enormous amount of power.  Think of your current cell phone and how long the battery lasts when you are talking on it. At most a battery charge would only last a day.
  • Wear and tare. Again since all the devices are talking all the time the devices would break down a lot faster then your normal cell phone. instead of years think maybe one full year. More disposable electronics means more trash in our landfills, ect…
  • DOS attacks. Since every device has the requirement to repeat message that it receives to every other devices on the network until a destination is found the system acceptable to denial of service attacks.
  • RF frequency. Collisions between two different devices talking on the same channel.

Distributed networks doesn’t seem to be the right option for a free cell phone network.

I never

I Never is a drinking, word game.
This is an absurdly easy game. It’s not about how much you drink, but what you can find out about your friends. This is a game you don’t just want to play with your buddies, you will want some girls in the mix and preferably people that have lived an eventful life.

What you will need
Some non-bashful people who have lived at least a semi eventful life.  A good mixture of guys and girls is important.

How to play the game
Everyone sits in a circle and the person that suggested the game goes first.  They say, “I have never….” followed by something that he or she may or may not have done. (See below for some examples)  If anyone has done the event they have to drink.  The person to the right goes next and starts with, “I have never…”.  The games gets good as people try more daring things.
“I have never…”

  • Cheated on a test
  • Cheated on a Girl/Boy friend
  • Stole from a homeless man
  • Made out with a stranger
  • Slept with a stranger

Feel free to suggest some other “I have never…’s”

links for 2009-12-11

CakePHP – Disable validation in controler

When upgrading an old web application to start using CakePHP but the old systems was riddled with invalid data. When the creating the CRUD system I need a way of updating this invalid data.

The following line of code will disable the validation in the controller.

$this->Story->validate = array(); // Stop valadation on the story.

Source: Cakephp Save with a table where the primary key is not ‘id’

CakePHP – Search bar

This code snippet will create a search box that uses can use to search for text in the database.
The control creates a query to search certain fields of publsihed stories

View or layout:
<?php
echo $form->create('Stories', array('url' => array('action' => 'index')));
echo $form->input('search_text', array('label' => false));
echo $form->end('Search');
?>

Controler:
<?php
function admin_index( )
{
$conditions = array( 'Story.terms !=' => '0' ) ;
if( isset( $this->data['Stories']['search_text'] ) )
{
$this->set('title', ' Search "'. $this->data['Stories']['search_text'] .'"' );
$conditions = array(
'Story.published' => '1',
'or' => array(
'Story.title LIKE' => '%' . $this->data['Stories']['search_text'] . '%',
'Author.name LIKE' => '%' . $this->data['Stories']['search_text'] . '%'
));
}

$data = $this->paginate( 'Story', $conditions);
$this->set('data', $data );
}
?>