Skip to main content

Posts

Cleaning up your local branches with ease

Small bash script to that helps you to clean up things 1 2 3 4 5 6 7 8 9 10 11 12 #!/bin/bash for br in $( git for -each-ref --count = 30 --sort = -committerdate refs/heads/ --format = '%(refname:short)' ) ; do echo "Delete branch $br (y/n)?" read -rsn1 input if [ "$input" = "y" ] ; then echo "deleting $br" git br -D $br else echo "skip $br" fi done
Recent posts

Bounds.intersect is bad, mkay?!

I was trying to check when enemy ships are getting out of screen to destroy objects (optimization). First version Vector2 screenSize = new Vector3 (Screen.width, Screen.height, Mathf.Abs (Camera.main.transform.position.z)); Bounds screenBounds = new Bounds (new Vector2(0f,0f), screenSize); Debug.Log ("Ship " + ship.renderer.bounds + " Screen " + screenBounds); if (!ship.renderer.bounds.Intersects (screenBounds)) ship.Destroy (); So apparently this operation is taking significant time to check, end up replacing with this Vector3 screenPos = Camera.main.WorldToScreenPoint( ship.transform.position ); Vector3 screenSize = Camera.main.WorldToScreenPoint( ship.renderer.bounds.size); if (screenPos.x + screenSize.x < 0) ship.Destroy ();

Rules of Fight Code squad

1. You should tell everyone about Fight Code squad 2. If you don't want to annoy people with rules, check rule #1 3. Something that is bigger than it should, call "Pile of shit" 4. Something bigger than "Pile of shit", call "Huge pile of shit" 5. Splitting Huge pile of shit on smaller piles, is not considered refactoring, it's just shitty job. 6. Don't short down variable names, abbreviations was invented by bureaucrats to confuse shit out of regular people. There should be no bureaucrats in Fight Code squad. 7. If method is taking more than 20 lines then you should feel bad, think again. 8. If class/module is taking more than 500 lines, then it's Pile of shit. 9. Readability over Functionality, if you can't read it after hangover, don't write it. 10. If (method|class|module|factory...) is used only once in a code, it shouldn't exist.  11. If method is taking one line, then something should be wrong with wh

Summarize things from the past

So during these days I'm starting to think about old days, trying to remind my self how it was first time exploring new lands of different technologies. I don't like to compare and say: Some coding language A is better than some language B. This is like comparing different ways of thinking. Lets start from deep childhood, year lets say 1994. C++ - there was this awesome blue book, like 400 pages long and cool that it had illustrations. I remember that it took me more than a week to succesfully compile my version of "Hello Word" example to exe file and run it. It was the best day ever. Basic - at 6th grade our computer classes started and during first day I've got this like Basic book for Kids. And during same day I've finished it and was able to write some small stupid stuff. But it was really awesome, it was part of freedom. All possible free time I've spend there going deeper and deeper. Pascal - this was like "Hm, realy? There is something di

Slicehost => Rackspace rage

For my side project Owely.com I've used Slicehost VDS solution, it worked fine, I've liked minimalistic Control Panel and really great tutorials how to setup environment from scratch. I really think they have best knowledge base online. Slicehost wasn't cheapest solution, but there was no complains from my side, they worked like clock, I never considered moving to other hosting provider, so when I've heard that they was acquired by Rackspace already then had this bad feeling. Then thought "ok, may be I'm too worried, may be it's for better" and tried to migrate in new env.  First day There was my mistake trying to use CentOS, I've researched and they say it's more stable and secured, but.... RedHad package manager don't know anything about ImageMagick higher than 6.1 or 6.2 don't remember, for new gems I was required to use >6.3, so I've spend few hours trying to set it up manually, then compile from sources then voodoo mag

Why Magento sucks?!

p.p1 {margin: 0.0px 0.0px 13.0px 0.0px; font: 13.0px Arial; color: #1022a3} p.p2 {margin: 0.0px 0.0px 13.0px 0.0px; font: 13.0px Arial} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; min-height: 15.0px} span.s1 {letter-spacing: 0.0px color: #000000} span.s2 {text-decoration: underline ; letter-spacing: 0.0px} span.s3 {letter-spacing: 0.0px} span.s4 {text-decoration: underline ; letter-spacing: 0.0px color: #1022a3} This post was inspired by  http://www.commercestyle.com/e-commerce/magneto-sucks I don't agree on everything that wrote there, I won't say that is so sucky and hard. It's childish way to say system is too complicated, read the f**king manual, omg is this so hard?! So from perspective technical guy that have a lot of finished high loaded projects on the back, I want to explain my "sucky" point about it.  1) The thing that bothers me for last few weeks is news about Magento acquir

How to kill old Resque workers and don't loose your face

In first thought trivial problem, `god gem` is keeping your Resque workers busy and when you deploy it just ask `god` to kill them by: god remove {group_name}. This is prety common misunderstanding thinking that workers will stop running at same moment, some of them can even live forever trying to establish their life inside your production server and continiously eating memory. One of walkarounds looked like this: in resque.rake create new task namespace :resque task :restart => :environment do    pids = Resque.workers.map(&:worker_pids) || []    pids.uniq!    if pids.any?        system("sudo kill -QUIT #{pids.join(' ')}")        puts "killed: #{pids.join(' ')}"    else        puts "resque wasn't running: #{pids.join(' ')}"    end end end It worked fine till one moment when rake stopped running initilizers before task and that cause ugly(hard) to find error. My idea that I think is more beautiful in kind of