IntelliJ / Adroid Studio / CLion / GoLand / PyCharm / PHPStorm keymap shortcuts I can’t live without

Download settings.jar (Import with `File -> Import Settings`)

I got to IntelliJ after years of using Emacs and Eclipse. Here’s how my keymap looks now that I work with Jetbrains tools, these are the keyboard shortcuts I can’t live without as a programmer.


Legend (Mac keyboard)
⌘ Command
⇧ Shift

⌘1 Show Intent Actions (Things like assign to local variable)
⌘- Decrease font size
⌘= Increase font size
⌘0 Reset font size
⌘↓ Scroll to botom
⌘↑ Scroll to top
⌘f Find in text
⌘. Find next highlighted error
^⇧F Find in path (searches in all files, like a grep)
⌘⇧G Find Usages (Find all Occurrences of selected symbol [variable, method, class, identifier])
⌘I Show current function/method parameter info
F3 Jump to source (go inside function’s code)
⌘E Show list of recent files
⌘B Build
⌘L Jump to line number
⌘[ Back
⌘] Forward
⌘T Show implementations of an interface.
⌘⇧F Format (selected) code
⌘⇧O Organize/Optimize imports
⌘⌥R Rename current symbol
^K Kill line
⌘D Duplicate line
Ctrl+G on selected token – repeats selection and enables multiple cursors
Alt+Up | Alt+Down – Move the current line up or down

Debugger shortcuts
F5 Step Into
F6 Step Over
F7 Step Out
F9 Resume Program

^K Cut up to Line End. (Deletes everything to the right of where the text cursor or caret is)

What to do when lighttpd won’t start and won’t give out any error output?

So you upgraded your server, or just all of a sudden you try to start lighttpd, it says the server started ok, but you check and there’s no lighttpd process.

You then go after your error log files, and nothing… what the fuck is happening?

try this to attempt to debug.

sudo strace -ff /usr/local/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf

In my case the output showed me lighttpd was having permission issues trying to access a log file…

[pid 28073] close(5) = 0
[pid 28073] munmap(0x7fe884c71000, 4096) = 0
[pid 28073] write(3, "2015-02-04 11:04:23: (log.c.164)"..., 49) = 49
[pid 28073] close(2) = 0
[pid 28073] open("/dev/null", O_RDWR) = 2
[pid 28073] brk(0x2203000) = 0x2203000
[pid 28073] open("/home/bh/access.log", O_WRONLY|O_CREAT|O_APPEND, 0644) = -1 EACCES (Permission denied)
[pid 28073] write(3, "2015-02-04 11:04:23: (log.c.118)"..., 98) = 98
[pid 28073] write(3, "2015-02-04 11:04:23: (server.c.1"..., 83) = 83

[bash scripting] How to get a file’s name without its extension(s).

Say you have an encrypted file and you want to make a shorthand command to decrypt that file, you’ll want the resulting file to be named (without the .gpg), or say you want the name, with no extension?), you can use bash’s magic variable voodo for that.

Screen Shot 2014-09-06 at 4.29.38 PM

A simple version of that script would look something like this:
Screen Shot 2014-09-06 at 4.34.26 PM

[SOLVED] Sublime Text 2: Git binary could not be found in PATH

Got this annoying dialog popping up on Sublime Text 2?
Screen Shot 2014-07-22 at 4.31.03 PM

Go to Preferences > Browse Packages …

Screen Shot 2014-07-22 at 4.33.02 PM

a Finder window will open, go to the “Git” folder, open the file called “Git.sublime-settings”

Look for “git_command” and set it’s value to the path of your git executable

Screen Shot 2014-07-22 at 4.31.47 PM

(you can find the path of your git executable on the Terminal by typing “which git”)

Screen Shot 2014-07-22 at 4.35.24 PM

Top Eclipse (IDE) features I can’t live without

(If you are in Windows, replace “Cmd” for “Ctrl”, and “Option” for “Alt”)

Cmd + 1: Create variables out of function’s outputs, get suggestions to fix issues.

“Shift + Cmd + T”: Open Type.

“Shift + Cmd + R”: Open Resource.

Select element and press “Option + Cmd + R” to rename a class, variable, method, the refactor will be performed throughout the entire project flawlessly.

Select element and press “Cmd + T”: Show Type Hierarchy, great to know what classes implement an interface, or what classes extend an abstract class.

WordPress: Cannot create directory error, got everything chmoded to 777?

So you went as far as chmod’ing your entire folder structure to 777 (very unsafe), you’ve hacked wp/wp-admin/includes/file.php

return new WP_Error( 'mkdir_failed_ziparchive', __( get_current_user() . ' Could not create directory. ('.$_dir.')' )...

to print out exactly what directory it cannot create and what user is trying to create the folder, everything is correct, yet it won’t create the fucking folder?

the issue might be your vsftpd configuration!

Go to /etc/vsftpd.con and make sure that you have this setting uncommented:


restart your vsftpd (sudo service vsftpd restart) and try upgrading again, you’ll want to hit that ‘Donate Bitcoin’ button if I saved your ass today.


AWS troubleshooting: how to fix a broken EBS volume (bad superblock on xfs)

As great as EBS volumes are on Amazon Web Services, they can break and not ever mount again, even though your data could still be there intact, a simple corruption on the filesystem structure can cause a lot of damage. On this post I teach you how to move all that data onto a new EBS drive, so keep calm and read slowly.

So, you try to mount your drive after some updates and you get an error like this on dmesg | tail:

[56439860.329754] XFS (xvdf): Corruption detected. Unmount and run xfs_repair

so you unmount your drive, invoke xfs_repair and you get this…

$ sudo xfs_repair -n /dev/xvdf
Phase 1 - find and verify superblock...
bad primary superblock - bad magic number !!!

attempting to find secondary superblock...

and no good secondary superblock is found.

Don’t panic, this is what you have to do next to solve this issue:

  1. Go to your AWS dashboard, EC2 section.
  2. Click on “Volumes”
  3. Find the broken volume.
  4. Create a snapshot of the broken volume (this takes a while)
  5. Create a new volume the same size (or larger than) your old drive out of the snapshot you just created (this takes a while)
  6. Attach your new volume to the same EC2 instance (no need to reboot or anything), if the old drive was mapped to /dev/xvdf, the new one will be mapped to /dev/xvdg (see how the last letter increases alphabetically)

Now here’s a gotcha, Amazon will not create your new drive using the same file system type (xfs), for some reason it will create it using the ext2 filesystem.

$ sudo file -s /dev/xvdg
/dev/xvdg: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=2e35874f-1d21-4d2d-b42b-ae27966e0aab (large files)

Here you have two options:
1. Live with the new ext2 file system, make sure your /etc/fstab is updated to look something like this:
/dev/xvdg /path/to/mount/to auto defaults,nobootwait,noatime 0 0

or 2. copy the contents of your drive to a temporary location, usually inside /mnt which has plenty of space from that ephemeral drive the ec2 instances come to, and then mkfs.xfs the new volume, and then copy the contents back… (which what I did, as I chose to create a larger drive and the ext2 format that came on the new volume only recognized the size of the snapshot)

Hope this saved your ass, leave a note if I did.

Remember to never do any irreversible action until you have a disk snapshot, try your best to never lose data.

How I finally started losing weight

Me on Aug-18-13 at 1.04 PM Miami

On January 1st 2013, like so many people all over the world I took that pledge of getting back to my healthy weight.

Ever since I’ve not missed a single week of weight lifting, running and swimming.

In the process I’ve tried different diets like controlling portion sizes, diets where you eat only during certain hours but then you have to fast, but all of that is simply unsustainable and you gain the weight right back. My biggest achievement with those “diets” was just going from 200lbs to 196lbs, despite all the hard work at the gym, despite running 6 to 8 miles (I like running) several times a week, I’d just gain the weight back.

So then I read about the Paleo diet, and some of the things in that diet don’t really convince me very much (like not eating beans for example), so I started a Paleo-ish diet with a simple rule: Eat as much as you need but whatever it is you put in your body it has to be non-processed, it has to be natural and organic if possible. I’m now like a vegetarian that adds beef, chicken or fish on the other half of the plate.

This meant basically getting rid of bread, pasta, white rice, and lowering my cheese and milk consumption (but I think I’ll be bringing back milk since I’m lactose tolerant something which I’ve confirmed with a genome scan)

In only 4 weeks of eating lean meats, a lot of vegetables and fruits to accompany the meats I’ve finally lost 10lbs and after a run this morning for the first time in about 3 years I saw my weight into the high 180s (188).

I’ve found that this simple rule has controlled my appetite, I get full with less food, and since I’m eating so healthy now I don’t feel guilty if I eat something outside of the diet whenever the opportunity is presented, I just have this mentality now of seeing some things as “not food” and I just don’t put it in my body anymore. It’s as if my palate has been retrained after just 4 weeks.

In the process I’ve learned to cook a bit more, and now I find it very enjoyable the act of cooking, specially with other people in the kitchen.

If you’re struggling with weight, stop putting poison in your body, working out will only make you stronger and agile, more toned, but you won’t lose any weight. It’s absolutely true when they say eating is 80% of the weight loss equation.

Eat natural, be kind to your body.

Once I reach the first goal of 175 lbs I’ll post pictures of how I looked on Jan 1st, and how I’ll look then, I’ll try to wear the same clothes.

The final goal will be to reach my natural weight of about 165 lbs.

Adobe Premiere Pro CS6 recommended settings to edit and export YouTube videos

30 fps drop frame timecode
Editing mode: Custom
Timebase: 29.97fps

Video Settings
Frame size: 1920h 1080v (1.0000)
Frame rate: 29.97 frames/second
Pixel Aspect Ratio: Square Pixels (1.0)
Fields: No Fields (Progressive Scan)

Audio Settings
Sample rate: 48000 samples/second

Default Sequence
Total video tracks: 3
Master track type: Stereo
Audio Tracks:
Audio 1: Standard
Audio 2: Standard
Audio 3: Standard

Export Settings:

Codec: MainConcept H.264 Video
TV Standard: NTSC
Frame Size: 1920 x 1080
FPS: 29.97fps
Filed Order: None (Progressive)
PAR: Widescreen 16:9
Profile: Main
Bitrate Encoding: VBR, 1 Pass (some recommend 2 Pass)
Target Bitrate [Mbps]: 13.89 (nitrate could be lower 8-10 MB/s if file size too large)
Maximum Bitrate [Mbps]: 15.36

Codec: AAC
Output Channels: Stereo
Frequency: 48kHz
Audio Quality: High
Bitrate [kbps]: 128 – 192kbps depending on how important is the audio vs file size (background noise vs music video)
Advanced Settings->Precedence: Bitrate

How to use Google’s calculator to convert Amps and Volts, to kWh

Say you have an electric engine that consumes 8 amps at 12 V, and you would like to know how much this would translate in kilowatt hours?

Go to Google’s search box and type

8 amps * 12 v * 1 hour

Screen Shot 2013-05-26 at 8.27.15 AM

And you will get the total output in Joules, which is 345,600 joules.

Then tell google

345600 joules to kwh

And google will tell you

0.096 kilowatt hours (which is what a small electric fan will consume in an hour), or the same as 8 * 12 = 96 watts * 1 hr, 96 Wh

Screen Shot 2013-05-26 at 8.29.47 AM