Extracting a Database From a mysqldump File

If you make full databases backup in one single file, you could need sometime to restore only one db from that dump file.

Here you are a easy way to extract it:

grep -n "Current Database: " mysqldumpfile.sql

19:– Current Database: `database1`
3546:– Current Database: `dabatase2`
6127:– Current Database: `database3`
6491:– Current Database: `database4`
10001:– Current Database: `database5`
10371:– Current Database: `database6`
11626:– Current Database: `database7`
11634:– Current Database: `database8`
16577:– Current Database: `database9`
18591:– Current Database: `database10`
18687:– Current Database: `mysql`
19336:– Current Database: `database11`
19589:– Current Database: `database12`
20278:– Current Database: `database13`
22557:– Current Database: `database14`
22961:– Current Database: `database15`
23320:– Current Database: `database16`
23719:– Current Database: `database17`

The previous output show you the database name and in which line it start. You only have to take the lines between that and the next database start minus one. If we want to extract database9:

sed -n '16577,18590p' mysqldumpfile.sql > database9.sql

With that you will get a dump only with database9 data.

Could be you don’t want to extract one database from the dump file, but you want all databases but one. The process it is the same, you have to know where each database start, and run the sed command but this time, it will be everything but the indicated. Let say we want to extract everything from the mysqldump file but mysql database:

sed -n '18687,19335!p' mysqldumpfile.sql > mysqldumpfilewithoutmysqldb.sql

EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!

Recently, one of my servers has started to show this message in syslog:

Feb 21 21:44:18 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:18 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:18 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:18 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:18 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:29 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:29 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:29 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:29 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!
Feb 21 21:44:29 servername01 kernel: EXT4-fs warning (device sdb1): ext4_dx_add_entry:1535: Directory index full!

The message Directory index full! sound like inode’s problem. But after checking it, there isn’t any problem:

df -i

Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 25600000 393314 25206686 2% /
tmpfs 2046261 4 2046257 1% /lib/init/rw
udev 2046261 2255 2044006 1% /dev
tmpfs 2046261 1 2046260 1% /dev/shm
/dev/sda3 95477760 23 95477737 1% /mnt/backup
/dev/sdb1 122101760 24863770 97237990 21% /var/www/willy

20% is high, but it shouldn’t be a problem. After googling about it, a found it could be a problem if some dir has lot of files. Maybe not too much to fill up the inodes in the partition, but too much for a dir.

Inside /var/www/willy are the documentroots for the server’s vhosts. So I checked how many files had each:

cd /var/www/willy
for dir in `ls -1`; do echo $dir; find ./$dir -type f|wc -l; done

domain 6.com

The domain domain7.com spent lot of time in show his file’s number. I had to stop the script because it didn’t look to finish soon. I think find command is a slow way to count files, so I stopped the script, research inside domain7.com directory and l found this:

cd cache_files1/
ls -1|wc -l


20 millions inside only one directory. For sure it has to be a problem. After spoke with the webmaster who manage this server, he told me the domain could be deleted, because it had only 5 visits/day. He will rebuild the cache using some directories inside.

After remove the directory, the messages in syslog disappeared.


I Give Up…

Since I started using internet (18 years ago) I’ve been avoiding put my personal data in public. I didn’t want to put personal data accessible to anybody because I think it’s a security risk (too much paranoid ?).

From today, I have decided to be more transparent in my business and the first step in this process will be to expose myself and be accessible to anybody.


I will share my mistakes in previous startups and my success too, it will be great if anyone can benefits and learn from them.

Another point at which I’ve decided become public is because I have been avoiding social networks all the time, no Facebook, no Linkedin, no Twitter… I thought I didn’t need them but now I think from other perspective and I want to know people with my interests (startups, entrepreneurship, technology…) In my personal environment there aren’t much of them.

With Social Network you can reach lot of interesting people and know them before contact. I usually used e-mail when I wanted to contact somebody, but I think e-mail are dying (somebody should make a drastic upgrade in the protocol) and it is very hard to contact to unknown people through email.

I’d like to know about your experience in startups, business, personal projects or technology. Don’t hesitate to contact me!

How to copy tables in MySQL

My first instinct was to make an export/import, but there is smarter ways to make it:

First you have to create the table with the same schema:

CREATE TABLE database2.newtable LIKE database1.table;

Then you can copy data from table to newtable:

INSERT INTO database2.newtable SELECT * FROM database1.table;

If you need, you can add WHERE clause to the select, also, if you are working in the same db you don’t need to specific the database name.

Remote – 37signals

I’m going to join a new team to build a great idea, but we are not in the same city. So we had an argument about distributed team or traditional team. I looked for references about successful distributed teams to show the team we don’t need a physical place. Nobody has to move to same city and we don’t have to hire people from our selected city.

A have read lot of articles and most name a couple of time to 37signals and their book Remote. So I had to read it. 37signals culture is awesome, is not only because they built a healthy company with a distributed team, it’s the way they are doing. Everyone want to to hire the best skilled employee, but many time his/her behavior don’t match with yours. They don’t hire based on more skilled but the guy share some interests with the team (sports, hobbies… etc).


The book give you good advice about how to manage a remote team, below you can find my notes from it.

Where do you go when you really have to get work done? Your answer won’t be “the office in the afternoon”

A company that is efficiently built around remote work doesn’t even have to have a set schedule. This is especially important when it comes to creative work. If you can’t get into the zone, there’s rarely much that can force you into it. When face time isn’t a requirement, the best strategy is often to take some time away and get back to work when your brain is firing on all cylinders

How many breakthrough ideas can a company actually digest? Far fewer than you imagine. Most work is not coming up with The Next Big Thing. Rather, it’s making better the thing you already thought of six months—or six years—ago. It’s the work of work.

if you can’t let your employees work from home out of fear they’ll slack off without your supervision, you’re a babysitter, not a manager. Remote work is very likely the least of your problems.

The whole point of innovation and disruption is doing things differently from those who came before you

we’ve found that we need a good four hours of overlap to avoid collaboration delays and feel like a team

The point is to avoid locking up important stuff in a single person’s computer or inbox. Put all the important stuff out in the open, and no one will have to chase that wild goose to get their work done.

At 37signals, we use a chat program we created called Campfire. Other techy shops use IRC servers to achieve the same. The idea is to have a single, permanent chat room where everyone hangs out all day to shoot the breeze, post funny pictures, and generally goof around.

At 37signals we’ve institutionalized this through a weekly discussion thread with the subject “What have you been working on?” Everyone chimes in with a few lines about what they’ve done over the past week and what’s intended for the next week. It’s not a precise, rigorous estimation process, and it doesn’t attempt to deal with coordination. It simply aims to make everyone feel like they’re in the same galley and not their own little rowboat.

At 37signals, we try our best to encourage our remote workers to adopt a healthy lifestyle. Everyone gets a $100 monthly stipend for a health club membership, and we cover the cost of weekly fresh fruit and vegetable deliveries from local farmers.

keeping everyone’s outlook healthy and happy. That task is insurmountable. No assholes allowed. But for remote work, you need to extend it to no asshole-y behavior allowed, no drama allowed, no bad vibes allowed.

The benefits of a physical company (restaurant, gym, laundry) sets a challenge for a manager directing a remote workforce. He has to ensure that this diversity of human experience happens for his troops as well. The job starts with putting together a team of people who are naturally interested in more than just their work—and it continues with encouraging those other interests to bloom.

as a remote worker, you shouldn’t let employers get away with paying you less just because you live in a cheaper city. “Equal pay for equal work” might be a dusty slogan, but it works for a reason. If with regard to compensation you accept being treated as a second-class worker based on location, you’re opening the door to being treated poorly on other matters as well

We call these regular check-ins “one-on-ones,” but other companies simply call them “check-ins” or “regulars.” The key is to make them casual and conversational. This is a “what’s up, how are things?” call more than a specific critique of a specific project or a response to a piece of work. These chats typically last twenty or thirty minutes, but it’s good to keep an hour open—just in case.

At 37signals we’ve created a number of ways to eradicate roadblocks. First, everyone gets a company credit card and is told to “spend wisely.” There’s no begging to spend money on needed equipment to get the work done, and there are no expense reports to fill out (just forward all receipts to an internal email address in case of an audit). Second, workers at 37signals needn’t ask permission to go on vacation or specify how much time they’ll take. We tell them: just be reasonable, put it on the calendar, and coordinate with your coworkers. If you let them, humans have an amazing power to live up to your high expectations of reasonableness and responsibility

Trying to conjure motivation by means of rewards or threats is terribly ineffective. In fact, it’s downright counterproductive. Rather, the only reliable way to muster motivation is by encouraging people to work on the stuff they like and care about, with people they like and care about.

If you’re a manager and notice that one of your employees is slacking, schedule a one-on-one and find out what’s up. Is the person bored with a project that’s not challenging enough, or are they feeling stuck and, in reaction, procrastinating to avoid a situation that feels impossible? See what you can do to get your employee back on track. The roadblock may be structural, or it may be more personal. Perhaps the employee is feeling burned out.

“In thirty years’ time, as technology moves forward even further, people are going to look back and wonder why offices ever existed.” —RICHARD BRANSON, FOUNDER OF VIRGIN GROUP

Remote work has already progressed through the first two stages of Gandhi’s model for change: “First they ignore you, then they laugh at you, then they fight you, then you win.” We are squarely in the fighting stage—the toughest one—but it’s also the last one before you win

For the Win – Gamification


We have decided to launch our first app for mobiles. So I have been researching about gamification. I found a Coursera course about it, by Kevin Werbach (next course will start in January 2014, more info here). The teacher wrote a book too,  For the Win, I found the course more interesting that book, more complete and more entertaining.

Gamification is nothing new, only one name for some stuffs, which companies already did (rankings, prizes, badgets…), but Gamification try to collect and explain  in proven ways to apply them successfully. In resume, with gamification, we will try to apply game elements in ordinary or boring task to make them more entertaining and get more productivity from your “players” (clients, employees, partners… ).

I took lot of notes and memos from book and course, at the end there is some references and examples of gamification.


1. What is gamification.
The use of game elements and game design techniques in non-game contexts.
– Game Elements: Points, Level and Progression, Resources Collection, Quests, Avatars, Social Graph.
– Game Design Techniques:
– Non-game Context: Some objective other than success in the game: Business, school, social impact, personal improvement, running…
Gamification can motivate, it can be apply to many domains: external, internal, behavior change and Gamification encompasses many techniques.

2. Why it might be valuable.
3. Ho to do it effectively.
4. Specific applications.

Takeaways for Gamification (takeaway = key fact, point, idea to be remembered):
– Voluntariness.
– Learning or problem solving.
– Balance of structure and exploration.

Real World Building Blocks:
– E-business 2.0: analytics, cloud, mobiles, etc.
– Social network and media.
– Loyalty programs.
– Management and marketing research.

Case Studio:
DodgeBall/Foursquare situation.:
– Needed “Engagement Gap”.
– Didn’t have many “Choices”.
– Didn’t have any “Progression”.
– It was very “Social”.
– They want to convert this in an “Habit”.
DodgeBall/Foursquare Solutions:
– Badgets for checkin.
– Top Users.
– Differnet Level inside badgets.

Think like a game designer.
– The component that you have to put together to create that experience (experience: what the players feel when play the game).
– “I am a game designer” (Different than being a game designer).
– Differnet than thinking like a gamer.
– Think on your participants as Players (customers, employees, community, target population).
* Players are the center of a game.
* Players feel a sense of autonomy/control.
* Players paly.
– Goal: Get your players playing, and keep them playing.

Design Rules:
– The Player Journey:
* Onboarding (how to get the player into the game as quickly and easyly as possible).
* Scaffolding (ways to overcome difficult aspect of the game or help the player figure out how to play).
– Guides, Highlighting, Feedback (well done!), Limited options, Limited monsters Impossible to fail.
* Pathways to mastery.
– Balance: Not to easy not to difficult.
– Create an Experience: People particpate in something that mean something (like Turntable, people pick music and form part of the crowd).

Tapping the Emotions:
– Games become engagement because the are fun.
– What things are Fun ?
– Winning.
– Problem-solving.
– Emploring.
– Chilling.
– Teamwork.
– Recognition.
– Triumphing.
– Collecting.
– Surprise.
– Imagination.
– Sharing.
– Role Playing.
– Customization.
– Goofing off.

Anatomy of Fun:
Nicole Lazzaro’s 4 Keys:
– Easy Fun (goffing off, chilling, go out with your friend…)
– Hard Fun (challenge, problem-solving, mastery…)
– People Fun (working together as a team, socializing…)
– Serious Fun (giving to other, good for your family, )
Marc LeBlanc’s 8 Kinds of Fun:
– Sensation
– Fantasy
– Narrative
– Challenge
– Fellowship
– Discovery
– Expression
– Submission
– Fun can (and should) be designed.
– Fun can be challenging!
– Appeal to differnet kinds of fun.

Finding the Fun:
-progress bar to complite your profile: feedback, progression, completion.

Game Elements (tools for gamification).
– Tic Tac Toe elements: Board, Tokens, 2 players, competitive, turns, win and draw states. No progression or scoring.
– The Pyramid of Gamification Elements:
* Dinaymics: Big-picture aspects; “grammar” (constraints, emotions, narrative, progression, relationships).
* Mechanics: Processes that drive action forward; “verbs” (challenges, chance, competition, cooperation, feedback (very important), resource acquisition, rewards, transactions, turns, win states).
* Components: Specific instantiantions of mechanics and dynamics; “nouns” (achivements, avatars, badges, boss fights, collections, combat, content unlocking, gifting leaderboards, levels, points, quests, social graph, teams, virtual goods).
– The PBL Triad:
* Points: keep score, determine win states, connect to rewards, provide feedback, display of progress, data for the game designer, fungible.
* Badges: Representations of achievement, flexibility, style, signaling of importance, credentials, collections, social display (status symbols).
* Levelboard: Ranking, Personalized leaderboards (don’t show your position relative to first, it could be your: 555 and leader: 127.000.242. You can show the middle ranking, with you with 555, and some people above you with 834, 999… and others under you: 453, 322… Or shoy only the levelboard with your friends.).
– The Elements are not the game!
– Not all reewards are fun / Not all fun is rewarding.

Bing Gordon Interview:
– Scoring is demotivation.
– People like more cooperation than competition.

– Influence behavior through stimulus.
– Consequences.
– Behavioral Economics:
* Loss aversion.
* Power of defaults.
* Confirmation bias.
– Takeaways:
* Observation.
* Feedback loops.
* Reinforcement.

Cognitive Evaluation Theory (Rewards):
– Tangible / Intangible
– Expected / Unexpected
– Contingency:
* Task non-contigent.
* Engagement-contigent.
* Completion-contigent.
* Performance-contigent.

Reward Schedules:
– Continuous. (the less interesting).
– Fixed Ratio.
– Fixed Interval.
– Variable. (The more interesting, because it is surprise).

Intrinsic Motivation: You do the thing because you want to do. Just for doing the thing.
– Reward could substitute the motivation (Over-Justification Effect).
– Reward types do matter: unexpected, performance-contigent.
Extrinsic Motivation: You are doing something for the reward.
– Status: You are in the top of the leaderboard.
– Access: You get access to somewhere where other people cant.
– Power: You can do something that other cant.
– Stuff: Things that you get.
Give rewards in this order: stuff, power, access and status.
Kind of Extrinsic motivations:
* External regulation: You have to do it because your boss said it.
* Introjection: You do it because other people will think you are cool.
* Identification: I’ll do it because it is important for me.
* Integration: I really want to do exercise, but I don’t.

Self Determination Theory
– Competence: people do it because they can do it.
– Autonomy: The people feel they have the control.
– Relatedness: The activity is related to you in something.

Design Thinking:
– Purposive.
– Human centered.
– Balance of analytical & creative
– Iterative: Prototyping and playtesting.

Gamification Design Framework (D6):
– 1. Define business objectives.
* 1. List and rank possible objectives.
* 2. Eliminate means to ends.
* 3. Justify objectives.
– 2. Delineate target behaviours (the things you want the user to do).
* Specific
* Success metrics (“win states”).
* Analytics (DAU/MAU (Daily Average Users/Monthly Average Users), Virality, Volume of activity).
– 3. Describe your players.
* Demography, Age groups, what kind of thing the want to buy, do…
* Type of players (WoW):
– Achievers: They want to get points and do missions.
– Explorer: They want to investigate the world.
– Socializers: They want help and interactue with others players.
– Killers: They want to win over other players. Compete.
– 4. Devise activity loops.
* Engagement Loops: Motivation -> Action -> Feedback -> Motivation…
* Progression Loops: small steps to achieve a big one.
– 5. Don’t forget the fun!
– 6. Deploy the appropiate tools.

Playbor -> play + labor

Beyond the Basics:
– Inducement Prizes (Competitive).
* A contest to motivate a result.
* SDT: Competence, Autonomy, Relatedness.
* Attributes:
– Multiple individuals/teams capable of competing.
– Costs sufficiently small.
– Balance scale vs. incentives (Karim Lakhani).
– Opportunities to leverage results.
– Collective Action (Collaborative).
– Virtual Economies.
* Balance: Economic dynamics driven by scarcity, not money.

Gamification Resources:

Gamification Examples

  • Keas
  • “club psych”
  • “Windows 7 Language Quality Game”
  • dodgeball (foursquare)
  • Open Badges
  • Google News Badges
  • MLB
  • stackoverflow
  • LiveOps
  • Zamzee (health)
  • SuperBetter (health)
  • Opower (energy)
  • RecycleBank (energy)
  • StanfordCapri
  • Inducement Prize Initiatives: X Prize Foundation, Innocentive, Kaggle, TopCoder.
  • Fold it
  • Plants vs. Zombies
  • Bogost



  • In every job that must be done, there is an element of fun. You find the fun and snap! The job’s a game. — Mary Poppins.

SSH connection timeout and freezing

Surely you have suffered this problem if you run a command through ssh and it take long to finish.

The ssh client is only waiting the command to finish, so ssh server close the connection because it doesn’t hear nothing from the client for a while.

To avoid this, you can setup in your client, to send a token each X seconds:

vim ~/.ssh/config

And add in the file:

Host *
ServerAliveInterval 180

You can change * for specific host and the configuration will only affect that site.

5 steps process to change your behaviors

Recently I found Primal Leadership: The Hidden Driver of Great Performance (It’s free but require signup to read it entirely) which talks about how leader’s emotions can influence people around him and a 5 steps process to change his behaviors about it.

I recommend you to read the whole article, but the 5 steps process are:

  • Who do I want to be ?
  • Who am I now ?
  • How do I get from here to there ?
  • How do I make change stick ?
  • Who can help me ?

The article is focus in leadership, but I think you could use this process in any change you want to face.

Steve Jobs by Walter Isaacson

Steve Jobs biography

I just finished reading the biography of Steve Jobs by Walter Isaacson. I didn’t know much about Jobs and Apple, beyond their products were more closed than Microsoft, so I wasn’t a big fan. Now, through this book I have know a little more about  Jobs (and Apple), I’m still not a fan (and never will), but I have recognize his jobs and contribution to the world.

The funny thing is, until now, I  thought Microsoft was the enemy, but now I think I have to be thankful to Bill Gates because he was more open than Jobs and he won the OS battle.

The book doesn’t idolize Jobs, you can found Jobs like he really was. A difficult person (sometimes even evil) to his friends, family and  employees who took their ideas as his own. But thanks to that he got the best of each and bring to the world a great company.

I didn’t take many quotes from the book (It wasn’t that kind of book). But you can learn a couple of things, knowing about Jobs.to be successful in your business (or whatever you do), the more important: Focus.

Warren Buffett video.

My partner David give me this video, where Warren Buffet answer some questions of MBA students.

I didn’t hear about Warrent Buffet before. He is an investor and you can get many tips from his answers.



While watching the video, I took some notes:

– Don’t risk something important for your in exchange for something that is not important for you.

– You only have to become rich once.

– Be sure to have a “moat” and expand it.

– You don’t need to do lot of ideas, what you are looking for is 1 good idea a year and then carry out to full potential.

– McDonals (and burger’s king) need to make promotions to compete to each other. They don’t sell product by itself, they need the promotion to sell them.

*Moat: idea associated to your product: CocaCola -> Happiness; Kodak -> Quality; Seas Candy -> Love; Disney -> Kids.

I hope you enjoy and find the video useful too.