How to add an existing GIT repository to github.

Most of the times, it makes more sense to start working on something that slowly transforms into the beginning of a project that deserves to be on github. This post is about creating a local repository and putting it on github.

1. First we must convert the main local folder into a git repository. For this example let’s call the folder “my-new-project”. With your terminal go to that folder and type:
[bash]git init[/bash]

the repository will initialize but nothing will be added to it yet. If you type git status you will see all the things you can add to it, so use git add to add the folders you want to track, and then go ahead and do a git commit -m “initial commit”

2. Now go to github.com and create your repository “my-new-project”, and copy the clone url of the repo, I personally like to work with the one that starts with “ssh://” since I like to work with ssh keys and not have to deal with passwords.

You can easily configure your ssh certificates for multiple things, not just github but keys for many many servers working with the ~/.ssh/config file (no need to deal with effing ssh-agent).

If you created this github repository with some other account, make sure to give yourself contributor access on the github role settings, otherwise you won’t be able to pull/push.

3. Time to pull (fetch+merge) the remote repo and then push this baby up.
You do that by invoking the following commands (let’s suppose the remote url is git remote add origin git@github.com:myaccount/my-new-project.git):
[bash]git remote add git@github.com:myaccount/my-new-project.git
git pull origin master[/bash]

you should see something like below coming from the remote repo’s master branch:

[bash]warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From github.com:myaccount/my-new-project
* branch master -> FETCH_HEAD
Merge made by the ‘recursive’ strategy.
.gitignore | 6 ++++++
README.md | 2 ++
2 files changed, 8 insertions(+)
create mode 100644 .gitignore
create mode 100644 README.md[/bash]

and then just
[bash]git push[/bash]

and you’re done, you should see your initial commit on github now.

How to make a Mean Green Juice. #Juicing #Paleo

Green juices are a great complement to the Paleo Diet. Some of us are not that fond of vegetables and while still training our palate to enjoy vegetables, these green juices are loaded with lots of micronutrients that will nourish, clean, and protect your cells. With a lot of ice, they’re not that bad in taste, and the health benefits are absolutely worth it, not to mention how much fun it is to use a juicer.

Ingredients:
– 4 celery sticks
– 1 cucumber
– 2 apples
– 1/2 lemon
– 1 tbsp ginger
– 4 leafs of Kale
– Brocolli (optional)

How much electricity does the Facebook app consume everyday by making phones vibrate with push notifications?

My silly little goal is to convince Facebook to pre-configure its mobile apps so they don’t make phones vibrate by default and push silent notifications to mobile users.

Help me make an estimate, we need to know on average how many milliwatts the average phone will spend per notification, and an estimate of how many push notifications are received by smartphones worldwide from facebook.

Say a phone consumes 150 milliwatts per push notification, and in one minute alone facebook sends 1 million notifications, Facebook would be consuming the world about 9 Megawatts/hour. This would be just a number thrown out there since I don’t know for sure if that’s the average power consumed, nor I know how many notifications are received per minute, I bet it’s way more than 1 million per minute.

Would love the help from people who work at Facebook or who have stats on push notifications, as well as any engineer working with phone hardware at any major phone manufacturing company.

Twitter is also sending a lot of notifications to phones.

Turn off vibration on your Facebook app, you will save a considerable amount of battery every day.

can’t ssh to ec2 ubuntu instance, /etc/fstab breaks bootup due to missing ebs volume [SOLVED]

Screen Shot 2013-08-21 at 12.08.04 PM

So the /etc/fstab file on your root volume looked like this

LABEL=cloudimg-rootfs / ext4 defaults 0 0
/dev/xvdf /mnt/backups auto defaults,comment=cloudconfig 0 2

by mistake you deleted the ebs volume that you had mounted on /mnt/backups (or whatever folder) and you restarted your ubuntu instance not knowing that if the /etc/fstab would break it would not continue to start all the application layer networking services like ssh on port 22…

you can ping the machine, but you can’t ssh, amazon support won’t respond or will tell you to fuck yourself.

you learn that ubuntu has had this bug for a while, but it’s been addressed by passing your volume configuration a nobootwait option.

you wish your /etc/fstab looked like this, but you can’t get in, amazon doesn’t give you any other options from their console to go in and solve the problem through a console…

LABEL=cloudimg-rootfs / ext4 defaults 0 0
/dev/xvdf /mnt/backups auto defaults,nobootwait,comment=cloudconfig 0 2

No worries, I have a fix that will let you edit that file, and boot back and try to recover things, you may have lost that ebs volume, but you won’t have to setup this computer again.

1. Make a snapshot of the root volume on that instance. This will take a while.
2. Make a new ebs volume of that snapshot and put it on the zone where the ec2 instance lives.
3. Create an identical temporary new ec2 instance on the same zone.
4. Attach the snapshot volume you created on step 2 to the new instance.
5. ssh to the new machine.
6. sudo fdisk -l, you should see all the attached devices, you will see something like this referring to the attached ebs

Disk /dev/xvdf: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/xvdf doesn't contain a valid partition table

Don’t listen to that last message, you do have a valid partition.

7. Create a folder where to mount the disk. sudo mkdir /mnt/old-volume
8. Mount it sudo mount -t auto /dev/xvdf /mnt/old-volume
9. Get into /mnt/old-volume/etc/fstab and fix it.
10. Unmount /mnt/old-volume, turn off the instance, detach the repaired volume.
11. Turn off the original instance, detach the broken root volume (at /dev/sda1)
12. Attach the repaired volume to the original instance under /dev/sda1
13. Start the original instance.
14. ssh to it. (it will have a new ip address, make sure to update your DNS or load balancing entries)
15. Terminate the temporary instance and all the volumes that you won’t need.
16. Get to work.
17. Leave a tip below. 😉

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.

The Paleo Argument against 100% vegetarian diets

Here’s a quote from the book The Paleo Diet

“The notion that human beings were meant to be vegetarians runs contrary to every shred of evolutionary evidence from the fossil and anthropological record. We owe a huge debt to lean meat. In fact, scientific evidence overwhelmingly suggests that if our ancient ancestors had eaten a meatless diet, we wouldn’t be where we are today… and we would all look a lot more like our nearest animal relative – the chimpanzee.

How can this be? Chimps are hairy, and they have a big gut. They swing from trees. Well, yes, but about 5 to 7 million years ago, so did our prehuman ancestors. The evidence is that the family tree forks – and humans moved into a category all their own. But genetically speaking, we are only about 1.7 percent different from the chimp.

Chimps are mostly vegetarians (although they do eat a few insects, bird eggs, and the occasional small animal), and they have the big, protruding belly characteristic of vegetarian animals (horses and cows, for example, have big bellies, too). Apes need large active guts to extract the nutrients from their fiber-filled, plant-based diet.

About 2.5 million years ago, our ancestors began trading in their big guts for bigger brains – to the point where today our bellies are about 40 percent smaller than those of chimps and our brains are about three times larger. The turning point came when our ancestors figured out that eating animal food (meat and organs) gave them much more energy. Over the years, their bellies began to shrink because they didn’t need the extra room to process all that roughage. All the energy formerly needed by the gut was diverted to the brain, which doubled and then tripled in size. Without nutrient-dense animal foods in the diet, the large brains that makes us human never would have had the change to develop. Meat and animal foods literally shaped our genome.”

It’s in our DNA, our digestive tract evolved to eat meat, it is healthy to eat meat and a lot of the myths against meat come from the findings related to saturated fats in the 1950s (the ones that come from butter, cheese and fatty meats) which raised cholesterol and increased risk of heart disease, and then this created more of the high carb diets which just fucked us all up.

[SOLVED] Java7 SMTP Issue (Caused by: sun.security.pkcs11.wrapper.PKCS11Exception)

So you had your little program that would use AWS to send emails, and all of a sudden after a Java 7 update you get a stack trace like this:

[java]
javax.mail.MessagingException: Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 465;
nested exception is:
javax.net.ssl.SSLException: Server key
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1962)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:196)

Caused by: javax.net.ssl.SSLException: Server key
at sun.security.ssl.Handshaker.throwSSLException(Handshaker.java:1274)

Caused by: java.security.spec.InvalidKeySpecException: Could not create EC public key
at sun.security.pkcs11.P11ECKeyFactory.engineGeneratePublic(P11ECKeyFactory.java:169)
at java.security.KeyFactory.generatePublic(KeyFactory.java:334)

Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DOMAIN_PARAMS_INVALID
at sun.security.pkcs11.wrapper.PKCS11.C_CreateObject(Native Method)
at sun.security.pkcs11.P11ECKeyFactory.generatePublic(P11ECKeyFactory.java:233)
[/java]

It seems like the SSL Socket Factory in Java 7 is missing some of the Ciphers when it comes to setting up SSL socket cipher suits (see SSLSocket.setEnabledCipherSuites)

so… the question is now,
how do I tell java mail to use the cipher suit I used to use in java 6?

Easy, when you’re setting up your Session properties, make sure to include the following key:

[java]properties.put(“mail.smtp.ssl.ciphersuites”,”SSL_RSA_WITH_RC4_128_MD5 SSL_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA SSL_RSA_WITH_DES_CBC_SHA SSL_DHE_RSA_WITH_DES_CBC_SHA SSL_DHE_DSS_WITH_DES_CBC_SHA SSL_RSA_EXPORT_WITH_RC4_40_MD5 SSL_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA TLS_EMPTY_RENEGOTIATION_INFO_SCSV”);[/java]

which specifies in a space separated String a list of tokens that represent the cipher suites the SSL sockets will use. At some point that list gets split into a String[] and passed to SSLSocket.setEnabledCipherSuites.

This is how my session properties look like in case you want to know:

[java]
Properties properties = new Properties();
properties.put(“mail.transport.protocol”, “smtp”);
properties.put(“mail.smtp.auth”, true);
properties.put(“mail.smtp.ssl.enable”,true);
properties.put(“mail.smtp.port”, emailSMTPPort);
properties.put(“mail.smtp.host”, emailSMTPHost);
properties.put(“mail.smtp.ssl.ciphersuites”,”SSL_RSA_WITH_RC4_128_MD5 SSL_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA SSL_RSA_WITH_DES_CBC_SHA SSL_DHE_RSA_WITH_DES_CBC_SHA SSL_DHE_DSS_WITH_DES_CBC_SHA SSL_RSA_EXPORT_WITH_RC4_40_MD5 SSL_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA TLS_EMPTY_RENEGOTIATION_INFO_SCSV”);
[/java]

Cheers, don’t forget to tip If I saved your ass.