Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

2013/12/02

#37. Firefox and other browser blocks insecure content

You have a website and firefox or other browsers block your ads or other content?
And it also shows an alert about insecure content?

Maybe you are using https in your website, then probably the cause is that you are serving this content without security (http) and browsers usually complain about it.

A simple way to fix this common mixed content error is removing the protocol from the url, so if you have an url to your content like src="http://yourcontent/contentpage" leave it like src="//yourcontent/contentpage". This way the browser will connect using the same protocol as the container page and allowing the content.

2013/08/27

#36. BlockUI fires ready event in the message content

After playing a little with BlockUI I found out a strange behavior, in my opinion. BlockUI fires the ready event in the elements of the message, if the element contains the typical ready event handler of jquery it may cause some problems as happened in my case.

Here you can check an example of the problem.

You can solve it easily extracting the javascript code of the element to use as message, and, of course, not use javascript inline as the best practices say.




2012/07/28

#25. For a less painful development

I was repairing a component that automatically historifies changes in datasets through an abstraction, found out some problems with wrong assumptions in a rushy development. As this code was not made by me, it felt like in this comic, and repairing the component give me the inspiration to take some guide patterns for future developments in our current project at work.

- make functions as test friendly as possible, decompose when you can
- use tests to assure you do not break anything and even it costs more, make tests that build the data they use, don't depend on a DB that may change in the future, so favor functions that receive simple data so they can be easily testable.
- favor composition over inheritance, it gets simpler to make a change of behaviour and extend it
- put code where should go, if you use an instance in a function too many times to access its fields maybe you should consider to put this function inside the class of the instance, if it is your code.

Follow these simple rules and you will be happier at your work also read Refactoring: Improving the Design of Existing Code, a must read.

2012/03/28

#22. Add Adsense in 3 simple steps to any blog that allows frames


The idea is to use a frame to show AdSense from another website so you can show them in your blog page, in wordpress.com even frames are limited so this solution won't work. Basically, we can achieve it in 3 simple steps:

1. Get the AdSense Javascript code If you know how to get the AdSense Javascript, just skip this step. Otherwise, you should enter the AdSense website, click in "My ads" tab, "Content", "Ad units", and create a new ad unit, configure the block as you wish, so it is compatible to your site layout and get the code to insert AdSense to your page.

2. Create a free page Searching in Google for a free hosting website service, you can use a page in for example a free blog service like Tumblr, where you can add simple web pages to your blog, this pages can be html so you can add anything, at least I tried with ads.

3. Insert an iFrame in your Blog, this might be the hardest part since it requires some basic HTML knowledge. You should access the manual theme customization and select where you want to insert the ads. Then you have to insert the following code snippet:



You should replace "http://youradaddres" with the address of the page you created in the previous step. The width and height parameters should be adjusted for your layout, add some extra space to the teoric size of the ad because if it's too adjusted it may create scrolling bars.

I tried adding to the left bar a Wide Skyscraper type and in each post a Medium Rectangle, we can customize when this ad appears if our template gives us any number to identify the post number. As normally Adsense will only show 3 ads per site.

Also if you want to add ads in your feed you can use feedburner to add it automagically :)

2012/03/06

#21. Java generics, type erasure and lazyness

I've been doing a little personal app in Java, and recently found out that generics in Java erase type information so generics would have retro-compatibility (or at least it's what I learnt from reading this post). I can’t deny that I don’t understand the idea and the drawbacks aren’t much but what’s the meaning of doing something halfway. I was just trying to get the type of a generic variable. I don’t think that this was the only option but probably was the easiest.

2012/02/22

#18. Renew TOR identity in python with vidalia bundle to automate worldwide testing of your website

First of all you need to have the Vidalia Bundle, and configure the torrc config file, find the value HashedControlPassword and uncomment it, next you need to create the hashed password, to do it, you can execute in a command line "tor --hash-password {pass}"
Copy the hash and save it in the config file. Restart Vidalia.
Taken this code from Moshe Basanchig, I've written this code wich authenticates against TOR:



Be careful, you should pass to the function the password you created the hash for, not the hashed string!. Also check out this book, it is a good and fast read:

2012/01/31

#16. Merge CSV to import to Excel

I’m doing some data analysis for a first client (a friend Winking smile), he has some csv files and wants to remove duplicates. Each file is a different category for the data, so he wants a new column to know where it came from. First I tried this simple solution but needed the column and with my lack of scripting knowledge decided to go straight for a little program in .net.

I posted the complete project on Bitbucket or you can view the important part on this gist:

2012/01/30

#15. new year resolutions

One of my new year’s resolutions was to increase my freelance profile. Last week I saw code52 webpage and got inspired, soon I’ll start something and I’ll try to rise my online activity, to get the attention of some possible clients.
Thanks also to Scott Hanselman who also today posted an example of simple freelancing. Thanks for the inspiration!

2012/01/28

#14. My daily WTF

At work some days ago I received an incidence where a user complained about random crashes, doing some code review I found this:
image


Smile

2011/12/01

#11. Comtrend 536+ auto disable/enable wifi

I’ve got the comtrend 536+ from "telefonica", as I have it connected all day, I want to disable wi-fi at night, for some good reasons. The idea is to access to the router with my linux home server, use a script to disable it at certain hours and enable it at others. I opened access through ssh with the router web interface, with this manual you can get a brief idea of some commands, combining nmap and ifconfig in the router we can create a script to automatize this process.
In some days I’ll post the script if it works correctly for anyone to use it.

2011/11/04

#9. W0t...Awww...

Why I need to cast this?¿ Awww...those are the frustrations of programming that sometimes I can’t understand.
image
If getItemList returns a List<I> why .get returns an object?