sushil10018
23 views | +0 today
Follow
Your new post is loading...
Your new post is loading...
Scooped by Sushil Shrestha
Scoop.it!

The Insufficiency of Good Design by Sarah Mei

The Insufficiency of Good Design by Sarah Mei | sushil10018 | Scoop.it

As a developer you should have come to a point where you think about quality of the code you write. You must have wondered what good code actually is and how good design can be achieved. This talk by ‘Sarah Mei’ clarifies the idea of Good code and also provides guideline of how it can be achieved. Good code isn’t written always by everyone. Hence, we need to keep these points in the back of our head which are noted below.

Good Code: [Good code is defined by it’s pattern of dependencies] OO design principles Development practices Other People Good Code Predictor: Technical Qualifications Experience with the code base. Good communication Fixing Problems: Pair Programming Create opportunities for informal communication Use high-bandwidth communication Teach/learn/practice Mantras extracted: Your team’s communication patterns are the best predictor of the quality of the code you produce. Every piece of bad code is trying to tell you something. Hack your team
0
http://www.sushil10018.com/the-insufficiency-of-good-design-by-sarah-mei/
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Clash of Clan for productivity

Clash of Clan for productivity | sushil10018 | Scoop.it

Hey Readers,

Have you guys ever wondered how we can get more productive? More productive as in a sense to get more things done and continuously. Well if you wish to gear up and boost your productivity meter then here is something for Clash of Clan fans.

Distraction for Concentration

sushil10018, Sushil Shrestha

One thing I knew after having long hours of work in office and by myself as a freelancer and spending lots of nights with my mac is that “distraction is necessary for concentration”. One can not simply keep the concentration max at all time and hence require a timely distraction. If you’re a smoker than you should have experienced the rage of concentration after a cigarette. Though, I’m not invoking to smoke of course!

Playing Clash of Clan helps and how is the question. Well, the game is really addictive as it cooperates with the time in real life as troops take some time to train, the defenses takes real time to upgrade and so on. Now, coming to the point of productivity we’re going to use the game as timer. So, once you train a troop to be full in your barrack it would take around 15-20 mins if you’re only training archers and barbarians. Once you have the troops on training, you begin to work then a notification pops up which says that your troop are ready. You then search for the opponent and get some loot. This gives you a good break of around 5 mins and surely refreshes the mind. The second thing you do after loot is train the troop again as always. While the troop is in training you start the work again and so the day goes on.

This process helps a person not to stress himself/herself out with the work pressure and maintain the balance of concentration with distraction. It has been very helpful to me as I was experimenting upon myself. Do try and let me know how you feel about it. You may even remove your smoking habit trying this out!

Best wishes using Clash of Clan for productivity!
@sushil10018

0 http://www.sushil10018.com/clash-of-clan-for-productivity/
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Nuclear feeling

I feel like the nucleus of an atom,
centrally located and densely tightened, fissioning,
into fragments of lighter nuclei
and extracting lump sum of energy
to even frighten my own lost soul.

sushil10018, Sushil Shrestha
0 http://goo.gl/CZ7jY6
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Create Opportunities

Don’t wait for opportunities, they need to be created!

sushil10018, Sushil Shrestha

Most people seem to be waiting for opportunities and complaining for not getting them. But in fact, they are created. How? you may be thinking. Well, every single action you’re doing might create you a better opportunity. Just Keep on doing best of what you are doing when you’re doing it.

Please let me know if you agree or disagree with this through comments below.

http://goo.gl/k6vT1I
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Validation on create with Ripple (Riak On Rails)

Validation on create with Ripple (Riak On Rails) | sushil10018 | Scoop.it

Previously I mentioned how to achieve Uniqueness Validation With Ripple.

Similarly, Ripple doesn’t provide direct method for adding validation only on create while trying to implement Riak On Rails using Ripple as modeling layer. This is very much necessary for the validation of properties such as password which are to be checked only while being created. Below is the code sample I developed for validation on create manually.

class User include Ripple::Document attr_accessor :password validates :password, :presence => true, :length => :in => 8..20 , :if => :not_created? private def not_created? !self.key.present? end

After searching for a while and trying to think of a way, I realized that the key for the object is only determined after it is saved or created. Also, I noticed that Ripple, (Riak On Rails) does support if in the validates class method. Hence, the method in the above code block i.e. “not_created?” checks for the presence of key and the validation is only performed if key is not present resulting the validation to be checked only when the object is created.

This technique may also work in other Rails application where key is replaced by id. The scenario to use this method would be when “:on => :create” doesn’t work or is not supported.

If you have any questions or suggestions please feel free to comment as I’m always ready to learn…

http://goo.gl/4hO7or
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Custom fonts with Wicked PDF on Rails

Well! We all have had a hard time getting through the custom fonts in our website or web-application. It has been easier with the @font-face implementation through CSS though this requires different formats of file integrated through it.

This implementation was OK until our client wanted to have the custom font implemented in the PDF generated by wicked_pdf in our Rails Application. This was not working right as intended, PDF using the default font rather than the custom font specified. And yes, we couldn’t even inspect element to diagnose the problem as could be done in webpage.

I also tried specifying the path to fonts explicity as mentioned here and below, but it still didn’t solve the problem.

# app/assets/styleshsheets/fonts.css.erb @font-face font-family: 'ITC Franklin Gothic STD'; font-style: normal; font-weight: 300; src: url('<%= Rails.root.join('app', 'assets', 'fonts', 'itcfranklingothicstd-book.eot') %>') format('eot')

Searched through Google for some time and went through different articles to then sum up with the solution:

Solution: Base64 Encode @font-face

Yes, we can actually base64 encode the font-face and then use it through CSS @font-face to have it implemented in our website or web-application. This actually solves the problem of using custom fonts with Wicked PDF on Rails.

First, base64 encode ttf or otf of the font-face which can be done with CLI in Linux or Unix:

$ base64 /path/to/Verlag-Black-Italic.ttf > /just/to/save/verlag-black-italic.txt

Then copy the base64 encoded text from /just/to/save/verlag-black-italic.txt to paste it in the @font-face as mentioned below:

@font-face font-family:"font-name"; src:url(data:font/truetype;base64,[paste-base64-here]); font-style:italic; font-weight:900;

Wohoo!!! Now run the PDF generator with the CSS implemented for the font and see the magic happen with your custom font implemented in the PDF. This should make you and your client happy and smiling!

Do leave a comment below if this could be done in a better and/or easier way as Learning is endless…

Resources https://github.com/mileszs/wicked_pdf/issues/250 http://stackoverflow.com/questions/14734375/wicked-pdf-fontsherokurails3-2 http://stackoverflow.com/questions/26867893/converting-and-rendering-web-fonts-to-base64-keep-original-look http://sosweetcreative.com/2613/font-face-and-base64-data-uri
0
http://www.sushil10018.com/custom-fonts-with-wicked-pdf-on-rails/
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Is class required while experimenting Ruby codes in file?

Is class required while experimenting Ruby codes in file? | sushil10018 | Scoop.it

Dear Rubyists,

There I was trying to guide a very good friend of mine, Sajin Shakya who was keen to learn a programming language, Ruby On Rails. I suggested him not to jump onto Rails and dig deep into Ruby first. Hence, as he had learnt C programming earlier, I told him to practice developing similar algorithms he’d previously learnt in his academics through Ruby.

So, he created a method which would calculate the factorial of given number as follows:

require "benchmark" puts Benchmark.measure end puts fact("5")

The benchmark seen was added later to check the performance of the code snippet in comparison to that I suggested to him which looks like this:

require "benchmark" puts Benchmark.measure end puts "7".fact

My first thought before suggesting was if the method definition would work without class definition or not. But to my surprise it was working fine. Then he questioned me why we should be defining the method within the Integer class rather than defining it externally as he’d done. Also, his thought was that it would reduce the line of code as defining class would not be required.

I convinced him with how important the class could be to make our coding life easier but he resisted that in this case it was not required to define the class. Now, our focus was on if the particular change was required to experiment ruby codes in file or not. Hence, the question arose “Is class required while experimenting Ruby codes in file?”.

We benchmarked and noted the difference with the performance but it was not that noticeable. Then, we moved on to figuring out what the difference we could get from these two routes.

The difference noted was that the method were defined within specific class meaning that only that particular class would get the defined method and hence, the error would pop-up immediately if the method implementation was made in a wrong class. And since we’d always have integer to calculate the factorial it seemed legible.

In the first case if a “string” was provided to the method then it would pop-up the error after running through the codes in the method. But in second case it would not bother to run through the codes as it is a “string” and the method is defined for the “integer”. The errors observed can be seen below.

Please feel free to comment your thoughts and help us figure out.

0 http://goo.gl/mkkTEZ
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

What is a share

What is a share | sushil10018 | Scoop.it

Don’t you want to earn money without having to work for? Planning to start investing but don’t have enough money? Well, I think share is a great idea. I do believe we can make more out of share just by understanding it in depth. These videos helped me a lot in clearing the idea about share and investment. I’ve made short notes of these videos to help me memorize hope it will be helpful.

1. What is Value Investing?

Course Objectives: The difference between value trading and valuing investing The difference between an asset and liability Who Created Value Investing 2. Value a Small Business like Warren Buffett

Course Objectives: Describe a small business model How money flows through a small business A comparison of a small and large business How do you value a small business

You’re the owner when you buy share of the business.

3. What is a Balance Sheet and Margin of Safety

Course Objectives: Understand the importance of a balance sheet How to determine the equity of a business Understand a company’s margin of safety Business value – A comparison of Net income and Equity

How safe is that investment? …off to the balance sheet!

4. What is a Share Course Objectives: What is a share? What is Shares Outstanding Comparing terminology between a whole business and 1 share Basic Valuation Techniques for 1 share Why is Stock investing lucrative Key Terminology:

Total Revenue: Total money spent by the customers in business (e.g.: ice-
cream stand)
Cost of Revenue: Total cost of revenue (e.g.: ice-cream, employee, rent)
Income Before Taxes: Total Revenue – Cost of Revenue
Net Income or Earnings: Income Before Taxes – Taxes (IMP)
Dividend: Part of Net Income or Earnings that go to the owner or share
holder.
Equity or Book Value: Other part of Net income or Earnings that go back to
the business.
Board of Directors: Representators of Share holders
CEO: Head of the employees, all of whom work for the owners.
Market Price: Price set by the owner to sell the business.
Book Value(Share): Equity (Company)
Earnings(Share): Net income (Company) Also known as EPS, Earning Per Share
Income Statement: Used to find the company profit i.e. net income or
earnings
Balance Sheet: Used to determine the margin of safety i.e. equity or book
value. It gives the idea of what would happen if the business liquidated
right now! i.e. Total Assets – Total Liabilities = Equity
Risk: Market Price – Equity (i.e. The closer the equity is to the market
price, the safer the investment).
Shares Outstanding: How many pieces the company have been divided into.
Share: Business / Shares Outstanding
Three documents that determines the company value: Income Statement,
Balance Sheet and Cash Flow Statement

Share Terminology:

Shares Outstanding: How many pieces the company have been divided into.
Market Price: The price determined for the share.
Earnings (EPS): Earnings Per Share
Book Value: Equity of a share. The money owner would get if the business
gets isolated at the instance.
P/E: The Price to Earning Ratio = Market Price / EPS

For every [[P/E Ratio]] dollars I spend buying this stock, I
should receive 1 dollar in profit a year later.

Emotion trading offers really cheap prices and really expensive prices.

Your job is to always calculate the intrinsic value of the business
regardless of the size, then compare the value to the price it trades for.

0 http://goo.gl/GePrj4
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Rich Dad, Poor Dad

Rich Dad, Poor Dad | sushil10018 | Scoop.it

I’ve been tired of working 9 hrs a day for money. I have an extreme desire of not having to think about money while spending. But I won’t be able to fulfill my desire if I go on doing what I’m doing and how I’m doing it. That’s the reason why I haven’t been able to get financial freedom.

So, while I was going through these thoughts and asking for suggestions. I was referred this book “Rich Dad Poor Dad” written by Robert Kiyosaki.

What the Rich Teach Their Kids About Money-That the Poor and the Middle Class Do Not!

Robert Kiyosaki, Rich Dad Poor Dad

To be honest this book has helped me a lot in understanding money. Here I’ve listed some points from each chapter that I thought would be helpful.

Important Points from each chatper:  The Rich don’t work for Money The poor & middle class work for money. The rich have money work for them. People’s lives are forever controlled by two emotions: fear and greed. See what others Miss. Why Teach Financial Literacy: It’s not how much money you make. It’s how much money you keep. Rich people acquire assets. The poor and middle class acquire liabilities that they think are assets. Asset puts money in my pocket. A liability takes money out of my pocket. An Employee works for company, government and bank. Mind your own business The rich focus on their asset columns while everyone else focuses on their income statement. Financial struggle is often the result of people working all their lives for someone else. Start minding your own business. Keep your daytime job, but start buying real assets, not liabilities. The History of taxes and the power of corporation “My rich dad just played the game start, and he did it through corporations” – the biggest secret of the rich. If you work for money, you give the power to your employer. If money works for you, you keep the power and control it. “Each dollar in my asset column was a great employee, working hard to make more employees and buy the boss a new Porsche.” The Rich Invent Money Often in the real world, it’s not the smart who gets ahead, but the bold. Games reflect behavior. They are instant feedback systems. The single most powerful asset we all have is our mind. If it is trained well, it can create enormous wealth. The problem with “secure” investments is that they are often sanitized, that is, made so safe that the gain are less. It is not gambling if you know what you’re doing. It is gambling if you’re just throwing money into a deal and praying. Great opportunities are not seen with your eyes. They are seen with your mind. Two types of investors, one who creates investment and other who invests on them. How to create investment: Find an opportunity that everyone else missed. Raise money Organize smart people. Work to Learn – Don’t work For Money Job Security meant everything to educated dad, Learning meant everything to rich dad. “You want to know a little about a lot” was rich dad’s suggestion. Job is an acronym for “Just Over Broke”, workers work hard enough to not be fired, and owners pay just enough so that workers won’t quit. Management of cash flow, system and people are the most important management skills. Most important specialized skills are sales and marketing: The ability to sell. The ability to communicate to another human being be it a customer, employee, boss, spouse or child. Communication skills such as writing, speaking and negotiating are crucial to a life of success. Overcoming Obstacles Overcoming Fear: For most people, the reason they don’t win financially is because the pain of losing money is far greater than the joy of being rich. Failure inspires winners. Failure defeats losers. Overcoming Cynicism: “The sky is falling! The sky is falling!” All of us have doubts which paralyze us. It’s those doubts and cynicism that keep most people poor and playing safe. Overcoming Laziness: “I can’t afford it” shut down your brain. “How can I afford it?” opens up possibilities, excitement and dream. Greed Beats Laziness. Overcoming Bad Habits: If I pay myself first, I get financially stronger, mentally and fiscally. Overcoming Arrogance: What I know makes me money, what I don’t know loses me money. Getting Started Find a reason greater than reality: the power of spirit. Make daily choices: the power of choice. Choose friends carefully: the power of associations. Master a formula and then learn a new one: the power of learning quickly. Pay yourself first: the power of self-discipline. Pay your brokers well: the power of good advice Be an Indian giver: the power of getting something for nothing. Use assets to buy luxuries: the power of focus. Choose heroes: the power of myth. Teach and you shall receive: the power of giving Short Notes: See what others Miss. Rich people acquire assets. The poor and middle class acquire liabilities that they think are assets. Start minding your own business. Keep your daytime job, but start buying real assets, not liabilities. Four broad areas of expertise for financial IQ: Accounting Investing Understanding Markets The Law It is not gambling if you know what you’re doing, it is gambling if you’re just throwing money in a deal and praying. How to create investment: Find opportunity that others missed Raise money Organize smart people “You want to know a little about a lot.” was rich dad’s suggestion. “I can’t afford it!” shuts down your brain. “How can I afford it?” opens up possibilities, excitement and dreams. Greed beats laziness. Every time I have been arrogant, I have lost money. Choose friends carefully: the power of associations. Brokers Rich = You more rich. The sophisticated investor’s first question is: “How fast do I get my money back?” To be the master of money, you need to be smarter than it. Choose heroes: the power of myth If they can do it, so can you Poor people are more greedy than rich people. Some To-Do’s Find someone who has done what you want to do. Take classes, read and attend seminars. Make lots of offer. Jog, walk or drive a certain area once a month for 10 minutes. Look for people who wants to buy first. Then look for someone who wants to sell. Action always beats inaction. Key to Financial Freedom A person’s ability to convert earned income into passive and/or portfolio income. Take Action: Invest on mind & learn to acquire REAL assets. Related links http://www.wikisummaries.org/Rich_Dad,_Poor_Dad http://www.valuespreadsheet.com/value-investing-blog/rich-dad-poor-dad-summary-robert-kiyosaki
http://madamenoire.com/109049/6-lessons-from-rich-dad-poor-dad/ http://goo.gl/jBbePu
more...
No comment yet.
Scooped by Sushil Shrestha
Scoop.it!

Uniqueness Validation With Ripple (Riak On Rails)

I’m a riak newbie who is trying to implement Riak On Rails using Ripple as modeling layer. But while creating User model, I wanted validation for uniqueness of user. Validation such as presence is available with Ripple but I couldn’t find proper validation method directly provided for the uniqueness. So, below is the sample code of User model I developed for validation.

class User include Ripple::Document VALID_EMAIL_REGEX = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]2,)\z/i property :email, String, :presence => true, format: with: VALID_EMAIL_REGEX , :index => true validate :unique_email_address? private def unique_email_address? errors.add(:email, 'The email is already taken.') if User.find_by_index('email', "#self.email").any? end end

This is simple but it was actually difficult to find the available methods in Ripple. In the code above “index: true” enables the property to be indexed automatically. Which later gives us the ability to use “find_by_index” to use the “Secondary Indexes In Riak“.

This should do the trick but you may face some problem while trying to implement the Secondary Indexes with find_by_index. Configuring the Secondary Indexes in the Riak-Server you’re using should fix the problem.

The problem I was facing with Riak-server was that backend being used was “bitcask” whereas secondary indexes (2i) is supported by LevelDB or Memory backend (or one of those in conjunction with the Multi backend.

This can simply be changed by modifying the values in your app.config file.

The task is not yet complete since, the validation is checked every time the save is called. So, it’s not letting us to change other values and save. I’m trying to find the solution for that. Will update this post on success. If you have any suggestions please feel free to comment as I’m always ready to learn…

http://goo.gl/YWhvRG
more...
No comment yet.