tag:blogger.com,1999:blog-13375983357881748282024-03-13T13:21:35.462-07:00Nitish Bezzala's BlogUnknownnoreply@blogger.comBlogger76125tag:blogger.com,1999:blog-1337598335788174828.post-54614352324027310962017-10-30T00:28:00.002-07:002017-10-30T00:28:32.535-07:00A short fairy tale<div dir="ltr" style="text-align: left;" trbidi="on">
She saw him.<br />
He saw her.<br />
He said, "I love you".<br />
She said "I love you too".<br />
And they got married and lived happily ever after.<br />
<br />
Why does this never happen in real life!!?!!</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-1337598335788174828.post-6604370205234684842017-06-13T18:16:00.000-07:002017-06-14T02:42:31.274-07:00Getting the best out of someone<div dir="ltr" style="text-align: left;" trbidi="on">
I was at the barber shop, and he asked me how I wanted him to cut my hair. And I had my opinions, and I started telling him exactly how I wanted it. He didn't understand what I said, so he asked me questions, and wanted me to explain.<br />
<br />
I was tired, and didn't really have the patience, so that day, I said, "Just do what you think is best."<br />
<br />
And he spent a long time on that hair cut. Even when I thought it was done, he would go on and cut that one hair which was a little bit longer over there.<br />
<br />
And then he asked me one more question, and this time, I told him, "I already told you, just do what you think is best."<br />
<br />
And that's when he told me, "Yes, you said that. That's why I'm putting all my heart into this haircut."<br />
<br />
If you want someone to put their heart and soul into a job, just tell them that that's what you expect from them. Don't tell them how to do their job. They'll ask you for help if they need it, they'll figure it out.<br />
<br />
Trust people to do their best!</div>
Unknownnoreply@blogger.com12tag:blogger.com,1999:blog-1337598335788174828.post-43142991085999448262017-04-29T15:13:00.001-07:002017-04-29T15:13:30.126-07:00Notes on react-native<div dir="ltr" style="text-align: left;" trbidi="on">
Follow the instructions in the tutorial to install react-native and to create your application.<br />
<br />
To run the application<br />
$ react-native start<br />
<br />
Then in a different window<br />
$ react-native run-android<br />
<br />
<br />
<br />
<br />
<br />
<span class="token operator"></span><span class="token operator"></span><br />
<span class="token operator"></span></div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-1337598335788174828.post-42101342696963768542017-01-22T23:58:00.002-08:002017-01-22T23:58:44.035-08:00Simple solutions to seemingly difficult problems<div dir="ltr" style="text-align: left;" trbidi="on">
At a company where I once worked, we used a tool which provided a few functions which we used to create the code in our applications. We were not able to modify the generated code, so we could only use the functions available to us.<br />
Of course, we didn't have all the functions that a normal programming language would have, so solving some problems was not so easy.<br />
<br />
We had a feature, where we could define the translation for a string in various languages. When the user selected the language in the front end, the translation of the string for that language would appear on the screen. And we had a function which gave us the translated string so that we could create other strings with it. This was sufficient for all the initial applications that we built.<br />
<br />
Once, the team got a requirement that needed us to know which language the user was using. We checked, and found that we didn't have a function for this.<br />
<br />
Following the process, we requested the supplier to develop the new feature, and they said that it would take a few months.<br />
<br />
This wasn't ideal, and we were looking at other options, like what features we could delay in order to push this one up the priority list. We also looked at the option of paying more money for getting this feature sooner.<br />
<br />
We then held a meeting to decide on the best solution. It was here that I realized that there was a much simpler solution. In fact, the problem statement itself contained the solution.<br />
<br />
All we needed was a string called language, which would be translated into the language selected by the user.<br />
<br />
Sometimes, the best solutions, are the simplest!</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-34593303633915379132016-10-29T22:31:00.004-07:002016-11-05T18:15:26.790-07:00starting with reactjs<div dir="ltr" style="text-align: left;" trbidi="on">
It might be a good idea to learn these concepts from ES6 first. <br />
<br />
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Arrow_functions">Arrow functions</a><br />
<a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes">Classes</a><br />
<br />
<br />
The recommended way to start developing a new ReactJS project is to use the npm module create-react-app <br />
<br />
To install create-react-app<br />
<span style="color: blue;">npm install -g create-react-app</span><br />
<br />
To create a new project <br />
<span style="color: blue;">create-react-app hello-world</span><br />
<br />
<span style="color: blue;">cd hello-world</span><br />
<br />
<span style="color: blue;">npm start</span><br />
<br />
To start making changes, edit the src/App.js file.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
create-react-app uses webpack, babel and ESLint under the hood. Need to check them out some day soon.<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-9288053949547772552016-04-28T00:04:00.002-07:002016-04-28T00:05:17.646-07:00Old JavaScript story<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">p { margin-bottom: 0.25cm; direction: ltr; color: rgb(0, 0, 10); line-height: 120%; text-align: left; }p.western { font-family: "Liberation Serif",serif; font-size: 12pt; }p.cjk { font-family: "Droid Sans Fallback"; font-size: 12pt; }p.ctl { font-family: "FreeSans"; font-size: 12pt; }</style>
<br />
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
When
I first joined Livehelper, back in the days before JQuery, the first
problem I was given was this, “Sometimes our scripts don't work.
Can you find out why and fix it?”</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
Livehelper
used JavaScript code to track visitors to websites. Our clients were
website owners, and
</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
would
put our code on their sites, and the script would report back to
the servers on how long the users were spending on each page. We also
allowed the operators to pull the client into a chat.</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
I
tried asking the customer relationship manager a few questions, such
as when does it happen, and if he had any examples of sites where it
didn't work, if it was possible that the problem was in the server
end. But all he knew was that sometimes, it would work for all
clients, but not for that one particular client who had a problem.
And we didn't know why, and we had not been able to fix it.</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
Since
I was new to Livehelper, I had to understand the code, and so I
started going through it, and writing alerts and making sure that the
code worked as expected.
</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
I
also started getting to know the team, and they became more
comfortable with me. I could ask a few more open ended questions, and
eventually, I learnt something that might be useful – whenever the
script didn't work, the client website had a lot of JavaScipt on the
page.
</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
Earlier,
while going through the code, I noticed that we had used global
variables like w for width, l for length etc. This was necessary
because we had to reduce the size of our scripts and reduce download
times. I used a 56 kbps modem at that time.
</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
But
I also remembered what I learnt at my first job at Infoyug, that we
do not use global variables like “i”. “i” can be used as a
local variable inside a for loop, but if you want a global variable,
you need it to be very long and descriptive, so that you do not
override it by mistake.</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
And
that is what I thought was happening here. The clients were trying to
reduce their javascript sizes too, and must have been using the same
variables that we were, and if our script was loaded first, it
wouldn't work because our variables were being overwritten.
</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
I
spoke to the managers about what I thought the problem was, and we
agreed to try changing our variables to lhW, lhC etc.
</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
Once
we made this change, the scripts started working properly on every
site, and we never lost another customer due to our code not working.
</div>
<div class="western" style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-76224870034102030252016-04-05T00:44:00.004-07:002016-04-05T00:45:10.219-07:00How to cook mutton kurma<div dir="ltr" style="text-align: left;" trbidi="on">
So, you start by going to the shop and actually buying some mutton. By the time you get home, you might be tired, and might not actually feel like cooking. So, as soon as you get home, you first put the mutton in the freezer. This is very important it you care about little things like your health.<br />
<br />
While you're at the shop you should try to remember what all you don't have at home, so you can buy them right then, and not have to come back to the shop later. Let's see what you need - onions, tomatoes, cinnamon sticks, cloves, oil, ginger-garlic paste, green chillies, mint leaves, coriander leaves, meat masala, potatoes, carrots, peas, beans, turmeric powder, salt.<br />
<br />
Never forget salt. Food tastes terrible without salt. Even if you have salt at home, buy some more. You never know when you'll need it. But then again, you have to put the right amount of salt. What you really need is to learn the tricks for getting your salt right. And you've come to the right place to learn!<br />
<br />
Cooking needs patience. It needs time, and a relaxed mind.<br />
<br />
So, when you are well rested, you take the mutton out of the freezer and defrost it. You'll have to put the microware on low power, and put the mutton inside for about 20 minutes.<br />
<br />
While it is defrosting, take out two onions, and dice them into small pieces. Put 2 table spoons of oil in a bowl, and heat the oil. When the oil is hot, you can see a bit of smoke coming from it. Put 4 cloves and a cinnamon stick in the oil. Leave for about a minute and add the onions. Fry and mix the onions till they are brown. Then add one spoon of ginger-garlic paste. Fry it till it smells good.<br />
<br />
While the onions are frying, cut two chillies and add them. Also, cut a tomato into small pieces. Put in the tomato and fry some more.<br />
<br />
<br />
Add while the tomatoes fry, cut two potatoes into medium sized pieces.<br />
<br />
Put a spoon of salt into the bowl, and a quarter tea spoon of turmeric powder. Add a spoon of meat masala too. Mix and fry a little bit. Add the mutton, and fry that for two minutes.<br />
<br />
Then add a glass of water, and let it heat.<br />
<br />
By now, you've probably run out of the patience that you need so much.<br />
<br />
Quickly cut up two carrots, and a bunch of beans into small pieces and add them in the bowl. Toss in a few peas too. If you have anything else from the ingredients list, toss them in as well. Add water till everything is covered.<br />
<br />
Then cover the bowl and let it boil for 20 minutes.<br />
<br />
Put on an alarm for 20 minutes later, and then go check facebook. Or watch TV. Or something.<br />
<br />
When the alarm rings, run to the kitchen. Check if there is still water in the bowl. Heave a sigh of relief.<br />
<br />
Now, if there is too little water, add some more, and heat it a bit longer. This time, stay right next to the stove.<br />
<br />
Take a spoon, and taste the gravy. It should be a little bit salty to taste. If it isn't, add quarter spoon of salt, mix well, and taste again.<br />
<br />
If too salty, add half a cup of water, and half a potato and let it boil a bit longer.<br />
<br />
Repeat till you get the salt right.<br />
<br />
Curse yourself for watching TV when you could have so easily cooked rice in that time.<br />
<br />
Make some rice or chapatis. Or just toast that bread which already is on the kitchen table.<br />
<br />
Enjoy!<br />
<br /></div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-1337598335788174828.post-74299306282367445802015-01-09T00:16:00.003-08:002015-01-09T00:52:47.939-08:00How to make your first contribution to CPAN - the first steps<div dir="ltr" style="text-align: left;" trbidi="on">
The first thing we want to try to do is to make a small change to an existing module.<br />
<br />
If you already know what you'd like to contribue, that is good. If not, you may be able to find ideas at <a href="https://github.com/CPAN-PRC/resources">https://github.com/CPAN-PRC/resources</a><br />
<br />
I was assigned to the <a href="https://metacpan.org/pod/DateTime::Format::Pg">DateTime::Format::Pg</a> module.<br />
<br />
On the MetaCPAN page, I see that the code is hosted on github at <a href="https://github.com/lestrrat/DateTime-Format-Pg/blob/master/lib/DateTime/Format/Pg.pm">https://github.com/lestrrat/DateTime-Format-Pg/blob/master/lib/DateTime/Format/Pg.pm</a><br />
<br />
The first step is to follow the instructions at <a href="https://help.github.com/articles/fork-a-repo/">https://help.github.com/articles/fork-a-repo/</a> and to get a copy of the code on your box.<br />
<br />
Next, we need to run the tests, and make sure they pass. We also need to check that all the dependencies for this module are installed. We do this in different ways depending on which build system the module uses. If we find a Build.PL in the module, then we use<br />
<br />
<span style="color: blue;">perl Build.PL</span><br />
<span style="color: blue;">./Build test </span><br />
<br />
If we find a Makefile.PL, then we do<br />
<span style="color: blue;">perl Makefile.PL</span><br />
<span style="color: blue;">make test</span><br />
<br />
If we find a dist.ini, then we first have to make sure we have Dist::Zilla installed. Then we run<br />
<br />
<span style="color: blue;">dzil test</span><br />
<br />
If we want to run only the tests, but we have the module already installed, then the tests will use that module and not the code that we pulled from github. To make sure we run the tests on our code, we use the -Ilib switch.<br />
<br />
<span style="color: blue;">prove -Ilib t/*</span><br />
<br />
If you get all your tests passing, you can start adding more tests to this module and then change the code as you see fit.<br />
<br />
If you're stuck at any stage, jump onto <a href="https://chat.mibbit.com/?channel=%23pr-challenge&server=irc.perl.org">#pr-challenge on irc.perl.org</a>, and ask for help. You will find some very helpful people there.<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-15022726650925398172014-09-26T01:51:00.001-07:002014-12-15T23:13:08.763-08:00Jumping to conclusions<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
"The fake tree is dying. The leaves are falling off."<br />
"Quick. Glue it back on."<br />
"Wow. He knows the secret of bringing dead things to life."<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-33007642698738928832014-09-26T01:50:00.002-07:002014-12-15T23:12:08.629-08:00English is a strange language<div dir="ltr" style="text-align: left;" trbidi="on">
"Where's Philip?"<br />
"In his room."<br />
"How is he?" <br />
"Knackered"<br />
"What's he doing"<br />
"Sleeping."<br />
"With whom?"<br />
"Stupid, I said <i>knackered</i>. Not naked!"</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-56951284825800475462014-06-25T00:30:00.001-07:002014-06-25T00:30:16.810-07:00Friendly Tech Support<div dir="ltr" style="text-align: left;" trbidi="on">
"Can you please stop the rain?"<br />
"Sure, what time would you like me to turn it off?"<br />
"I was planning to go home at 4, could you please turn it off from 4 to 4:15?"<br />
"OK, Let me login to the server."<br />
"The cloud server?"</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-9301346928489935552014-06-21T17:37:00.000-07:002014-06-21T17:37:12.586-07:00Luck<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="yiv7925531917MsoNormal" id="yui_3_16_0_1_1403397278618_2674">
You do not plan on being lucky. You do not plan on being successful.</div>
<div class="yiv7925531917MsoNormal" id="yui_3_16_0_1_1403397278618_2672">
You just do a good job, and plan for all kinds of problems.</div>
<div class="yiv7925531917MsoNormal" id="yui_3_16_0_1_1403397278618_2672">
<br /></div>
<div class="yiv7925531917MsoNormal" id="yui_3_16_0_1_1403397278618_2672">
Do that right, and you just might get lucky and be successful.</div>
<div class="yiv7925531917MsoNormal" id="yui_3_16_0_1_1403397278618_2894">
<span style="color: #1f497d;"> </span></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-8217004491779557982014-06-21T15:51:00.001-07:002014-06-21T17:40:18.638-07:00How to bake bread<div dir="ltr" style="text-align: left;" trbidi="on">
Tips for people like me who are new too cooking, and always get confused -<br />
<ul style="text-align: left;">
<li>Tea spoon is the small one and table spoon is the big one. </li>
<li>Remember to set the alarm every time you need to keep something aside for 15 minutes or half an hour.</li>
<li>Clean the bowls and pans as soon as you are done with them, cleaning them later when the dough has hardened is a big pain.</li>
</ul>
Stuff you need:<br />
<ul style="text-align: left;">
<li>Flour</li>
<li>Yeast</li>
<li>Milk powder or milk</li>
<li>Oil or butter</li>
<li>A pan to bake bread in </li>
<li>An oven</li>
<li>Warm water</li>
<li>Bowl</li>
<li>Table spoon</li>
<li>Tea spoon</li>
<li>Clean cloths</li>
<li>A nice warm place where the yeast can grow</li>
</ul>
<br />
Take a bowl and add two tea spoons of yeast, and a bit for luck. Add two table spoons of sugar and one tablespoon of milk powder (or two table spoons of milk), to feed the yeast.<br />
<br />
If you are lucky enough to have 24 hours hot water at home, open the hot water tap, and wait until the water stays hot, then open the cold water tap, and make the water slightly warm to touch. Otherwise, find a way to make warm water. Make sure its not hot, or the yeast will die, and you'll end up making some terrible chapathis!<br />
<br />
If you have a measuring jar, add one cup of water, if not, add a glass of water.<br />
Mix well, until there are no clumps of yeast around.<br />
<br />
Cover the bowl with a cloth and keep aside in a warm place for 15 minutes. When you take it out, you should see a frothy mixture and it should smell of yeast. <br />
<br />
Add two tablespoons of salt and one table spoon of oil and mix well. Then add in maida or wheat flour and mix until it stops sticking to the bowl, but it still sticks to your hand. If that doesn't make sense, well, just don't make it too dry. You'll figure it out by the time you bake a few times.<br />
<br />
Cover the bowl and with a cloth and keep it in a warm place for another half an hour.<br />
<br />
Take a bread baking pan and spread oil on it. Transfer the dough from the bowl to this pan, cover with a cloth and keep aside for another half an hour. If you don't have a pan, don't worry, just oil a plate and use it. It won't be shaped like the shop bread, but it will taste the same.<br />
<br />
20 minutes later, turn on the oven to Bake, and set it to 180 degerees Celcius.<br />
<br />
10 minutes after that, take the pan with the dough and put it in the oven. You should start getting the sweet aroma of a bakery around 5 minutes later.<br />
<br />
Wait for half an hour. Have a nice plastic or wooden spoon ready to help you scoop out the bread.<br />
<br />
Take out the bread and turn it around, knock on it a few times and make sure it sounds hollow. If it doesn't, it needs more baking.<br />
<br />
Cover the hot bread in a cloth and keep it till it cools. And if like me, you can't resist, every once in a way, cut out a slice and help yourself to it.<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-43559249834920963342014-06-13T03:37:00.001-07:002014-06-13T03:37:25.786-07:00Good old Perl<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: blue;">What is Perl used for?</span><br />
<br />
<span style="color: purple;"><i>Testing, Web Applications, BioPerl.</i></span><br />
<br />
<span style="color: blue;">Why?</span><br />
<br />
<span style="color: #660000;"><i><span style="color: purple;">Because it has always been used for them.</span></i></span><br />
<br />
<span style="color: blue;">How are most Perl web applications run?</span><br />
<br />
<span style="color: purple;"><i>Mod Perl.</i></span><br />
<br />
<span style="color: blue;">How long more with this continue?</span><br />
<br />
<span style="color: purple;"><i>As long as possible. Probably many years into the future....</i> </span><br />
<br />
<span style="color: blue;">Where is Perl used for Web Applications and Testing? </span><br />
<br />
<span style="color: purple;"><i>In the enterprise. A lot of HTML developers may have learnt PHP, and made it more popular than Perl. But for real projects, in large corporations, the choice was Perl.</i></span><br />
<br />
<span style="color: blue;">What does an enterprise want?</span><br />
<br />
<span style="color: purple;"><i>Stability.</i></span><br />
<br />
<span style="color: purple;"><i>This is where Perl shines. It has proven itself many times over. </i></span><br />
<br />
<i><span style="color: purple;">Companies will keep their existing applications running without change for as long as they can. If they have existing frameworks, they will continue using them for new applications. If they can copy and paste existing code, and use it in a new appliction, they will. A new technology will only be considered if it provides a compelling advantage, generally in terms of money. </span></i><br />
<i><span style="color: purple;"><br /></span></i>
<i><span style="color: purple;">If a company has an existing framework, and does decide to use a new language or framework, then they have to start supporting two frameworks, because they are never going to have the time to translate all the existing applications to the new one. Having to support two or more frameworks or languages is bad, because it leads to increased team size, support and training costs.</span></i><br />
<br />
<span style="color: blue;">So, what should Perl do?</span><br />
<br />
<i><span style="color: purple;">Learn about, support, and train people in the technologies used in the enterprise. And if that means supporting Red Hat Linux, Perl 5.8 and mod_perl, then so be it. </span></i><br />
<br />
<i><span style="color: purple;">Continue doing that, and the next enterprise application could well be written with Dancer or Mojolicious, while reusing the existing Perl modules at that company.</span></i><br />
<i><span style="color: purple;"><br /></span></i>
<span style="color: purple;"><br /></span></div>
Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-1337598335788174828.post-9488704118133504832014-06-03T19:36:00.002-07:002014-06-03T19:36:54.776-07:00Redhat Linux commands<div dir="ltr" style="text-align: left;" trbidi="on">
To check the status of samba and start it if needed.<br />
<br />
<span style="color: blue;">chkconfig --list smb</span><br />
<span style="color: blue;">service smb start</span><br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-35683743741203351162014-04-23T00:41:00.003-07:002017-06-22T22:02:28.309-07:00More efficient night shelters<div dir="ltr" style="text-align: left;" trbidi="on">
I was at <a href="https://www.facebook.com/CharityITEvents">Charity IT</a> recently, a weekend event where developers help charities with IT projects. The projects selected are small and can be delivered by a small team in 2 days. We have a team member from the charity sitting with us througout, and answering any questions that we have.<br />
<br />
One of the charities we worked with is the <a href="http://www.wellingtonnightshelter.org.nz/">Wellington Night Shelter</a>. They provide beds for the homeless, and we helped them speed up their reporting. The reports are used to generate more funds.<br />
<br />
Many homeless people struggle to find a place to stay out of the wind, the rain and the cold. The night shelter starts admissions at 5:30 PM and there is a queue when it opens. It gets full quickly, and many people are left out at the end of the day to fend for themselves.<br />
<br />
While there are so many buildings that are empty at nights. <br />
<br />
I realized this last evening, I was walking past a school, and it was closed. It
struck me that schools all over the world are closed at nights. <br />
<br />
What a waste!<br />
<br />
What would it take to make a school a night shelter?<br />
<br />
Here are my ideas.<br />
<br />
A charity organization needs to organize security, to check how many people are entering the school in the evening. Then they wake up the people in the morning, let them get showered if possible, and then make sure they are out of the building an hour before the first student or the first teacher comes in. Also, arrange for portable beds, which can be folded and put aside in the day time.<br />
I am sure the homeless people will be happy to move a few desks and chairs every evening and put beds in their place, and to move them back in the morning before leaving.<br />
<br />
Also, we need to organize security for the homeless peoples belongings. We want them to sleep well at night, and not have to think about who is going to steal some of the few things that they have.<br />
<br />
What this means, is that the parents, the students, the teachers, the staff of the charity organization, and the homeless people, all of them feel safe and secure with this idea and with how it is implemented.<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-21031391826593443232014-03-30T22:44:00.004-07:002014-03-31T17:24:12.529-07:00How to move to Amsterdam<div dir="ltr" style="text-align: left;" trbidi="on">
If you are a Perl developer and want to move to Amsterdam to work for Booking.com, it is a good idea to do these first.<br />
<br />
I don't work for Booking.com, and I didn't get through the interview. But if I did these things, I would have had a much better chance.<br />
<br />
The interview questions, and the suggestions here are based on what is actually being used by Booking.com in production. They use MySQL, and a lot of their code is old and is written in object oriented Perl. So, understanding them and being able to work with them is important.<br />
<br />
<b>Practice writing Perl code:</b><br />
Write object oriented Perl code (not Moose)<br />
Write code to read from large files<br />
Write code to work with MySQL databases<br />
Write code which uses hashes of hashes and other complicated data structures<br />
Write Perl versions of the examples in Programming Pearls <br />
<br />
<b>Read these:</b><br />
Read the Perl FAQ<br />
Read the MySQL documentation<br />
Read Programming Pearls<br />
<br />
Learn about the Booking.com business model<br />
Think about the problems they could possibly have, and how you would solve them.<br />
<br />
Learn about database design, normalization, denormalization, sharding and anything else related to MySQL performance.<br />
<br />
They are always looking for Perl developers. It would help to prepare well and then apply.<br />
<br />
All the best!</div>
Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-1337598335788174828.post-31533621335470680762014-03-24T20:55:00.001-07:002016-06-23T01:44:25.763-07:00MySQL commands<div dir="ltr" style="text-align: left;" trbidi="on">
To login to mysql without selecting a database<br />
<span style="color: blue;">mysql -h hostname -u username -p</span><br />
(hostname can be an IP addrress)<br />
<br />
To create a new database, and user and grant permissions on that database to the new user. <br />
<span style="color: blue;">create database moodle;</span><br />
<span style="color: blue;">create user 'moodle'@'localhost' identified by 'password';</span><br />
<span style="color: blue;">grant all privileges on moodle.* to 'moodle'@'localhost';</span><br />
<br />
To run the sql script in the file text_file.sql in the database databasename:<br />
<span style="color: blue;">mysql -h hostname -u username databasename -p < text_file.sql</span><br />
<br />
To create a table:<br />
<span style="color: blue;">CREATE TABLE categories (<br /> id INTEGER PRIMARY KEY AUTO_INCREMENT,<br /> name VARCHAR(64) NOT NULL,<br /> created_on DATE,<br /> created_by INTEGER REFERENCES user(id),<br /> modified_by INTEGER REFERENCES user(id),<br /> modified_on DATE <br />);</span></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-41283345184554260622014-03-24T12:48:00.003-07:002014-03-25T16:10:40.707-07:00How to test creating a new row in the database<div dir="ltr" style="text-align: left;" trbidi="on">
A webpage has a form and a 'Create my account' button on it which is used to create a new user. <br /><br /><span style="color: blue;">initial = User.count<br />click_button "Create my account"<br />final = User.count<br />expect(initial).to eq final</span><br />Here, User is the resultset, which includes all users.<br />We didn't fill in any data, and we are clicking the button to submit an empty form. We expect that a new user will not be created. <br />So the initial count of users should remain unchanged after clicking the "Create my account" button.<br /><br />To test the case where the User is successfullly created, you fill in all the values, and check that the final count is 1 more than the intial count.<br /><br /><span style="color: blue;">visit signup_path<br />fill_in "Name", with: "Example User"<br />fill_in "Email", with: "user@example.com"<br />fill_in "Password", with: "foobar"<br />fill_in "Confirmation", with: "foobar"<br />expect do<br /> click_button "Create my account"<br />end.to change(User, :count).by(1)</span><br /><br />RSpec allows you to write the first test this way-<br /><br />expect { click_button "Create my account" }.not_to change(User, :count) </div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-22642370600377160992014-03-24T11:32:00.000-07:002014-03-30T18:43:18.992-07:00Working with Ruby on Rails<div dir="ltr" style="text-align: left;" trbidi="on">
If you make a change to the Gemfile, run bundle install, and remember to restart the server.<br />
<br />
<span style="color: blue;">bundle install</span><br />
<span style="color: blue;">rails server</span><br />
<br />
<span style="color: blue;">rails console</span><br />
<span style="color: blue;">rails console test</span><br />
<span style="color: blue;">rails server --environment=production</span><br />
<span style="color: blue;">rake db:migrate RAILS_ENV=production</span><br />
<br />
<br />
When you change a model and add a new column, if you want to use it in your form, you can't just update the view. You have to add the new column name to the whitelist in the controller.<br />
<br />
<span style="color: blue;"> # Never trust parameters from the scary internet, only allow the white list through.</span><br />
<span style="color: blue;"> def user_params</span><br />
<span style="color: blue;"> params.require(:user).permit(:name, :email, :password, :password_confirmation)</span><br />
<span style="color: blue;"> end</span><br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-39275613066897782662014-03-23T16:55:00.002-07:002014-03-23T16:55:53.210-07:00SQLite Commands<div dir="ltr" style="text-align: left;" trbidi="on">
sqlite3 development.sqlite3<br />
sqlite> .tables<br />
sqlite> .schema users<br />
sqlite> select * from users;<br />
sqlite> .quit<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-79735588388132082402014-03-23T16:33:00.001-07:002014-03-23T23:44:26.388-07:00Ruby on Rails models<div dir="ltr" style="text-align: left;" trbidi="on">
We generate a rails model only once, when we want to create a new table in the database. After that we use migrations to make changes to our tables.<br />
<br />
<br />
rails generate model User name:string email:string<br />
bundle exec rake db:migrate<br />
<br />
bundle exec rake db:rollback<br />
<br />
rails console # Saves to DB<br />
rails console --sandbox # Will not save to DB<br />
<br />
>> User.new<br />
>> user = User.new(name: "Test One", email: "asdf@asdf.com") #Create in memory<br />
>> user.save # Write to DB, returns true on success<br />
>> user.name<br />
>> user.updated_at<br />
>> user2 = User.create(name: "Test two", email: "asdf1@asdf.com") # Create and write to DB<br />
>> user2.destroy<br />
<br />
>> User.find(1)<br />
>> User.find_by(email: "asdf@asdf.com")<br />
<br />
>> User.first<br />
>> User.all<br />
<br />
>> user.email = "test@one.com"<br />
>> user.save<br />
>> user.reload # If you don't want to save your changes, and read details from DB<br />
<br />
>> user.update_attributes(name: "Testing One", email: "qwer@qwer.com") # write to DB<br />
>> user.update_attribute(:name, "Tester One")<br />
<br />
rake test:prepare<br />
<br />
rails generate migration add_password_digest_to_users password_digest:string<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-1337598335788174828.post-13297326516644615352014-02-02T15:32:00.000-08:002014-02-02T15:32:56.188-08:00bash tips<div dir="ltr" style="text-align: left;" trbidi="on">
Check if the last command you ran was successful<br />
<br />
<i>echo $?</i><br />
<br />
If it returns 0, the command completed successfully. 1 means, it errored out.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-29901531802152704702014-01-06T13:53:00.002-08:002014-01-22T16:19:35.526-08:00Useful Linux Commands (ubuntu)<div dir="ltr" style="text-align: left;" trbidi="on">
Find the size of a directory <br />
<span style="color: blue;">du -ah </span><br />
<br />
See how much space is free, and how much is used<br />
<span style="color: blue;">df -h</span><br />
<br />
List all the commands that you can use as sudo<br />
<span style="color: blue;">sudo -l</span><br />
<br />
If the output of the command is: <br />
<i> (www-data) NOPASSWD: /usr/bin/php<br /> (www-data) NOPASSWD: ALL</i><br />
<i> </i>You can run php as www-data, but also, you can run any other command as www-data.<br />
<br />
To run chmod as www-data<br />
<span style="color: blue;">sudo -u www-data chmod g+w testdir</span><br />
<br />
Copying files from one machine to another, when you want to copy only the changes the next time around.<br />
<span style="color: blue;">rsync -avz from_local_dir machinename:/some/dir/on_other_machine</span><br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-1337598335788174828.post-43072128372243473322014-01-05T14:13:00.001-08:002014-01-05T14:14:24.525-08:00Postgres commands<div dir="ltr" style="text-align: left;" trbidi="on">
dropdb dbname<br />
<br />
createdb -E utf8 -O username databasename<br />
<br />
pg_restore -O path_to_dump.pgdump -U username -d databasename<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0