Super Tip: Pass Arguments in your Python Bindings using Lambda Functions

| No Comments »

Problem: Help! How can I pass parameters in my Bindings?

Solution: By using lambda functions in python(Check your PL’s manual for anything similar), you would be able to create on-the-fly functions that returns your bindings with the extra parameters/arguments you want to pass.

Example 1: Passing an argument to a wx Button Event

btn = wx.Button(self, 10, “Button”, (10, 10)) self.Bind(wx.EVT_BUTTON, lambda event: self.OnClick(event, ‘passthis’)) def OnClick(self, event, somearg):    print somearg

Example 2: Passing an argument to Pyhook’s HookManager.KeyUp Event

hook = pyHook.HookManager() hook.KeyUp = lambda event: OnKeyboardEvent(event, ‘Pass Me.’) hm.HookKeyboard() def OnKeyboardEvent(event, myarg)   print myarg

That’s It!


Super Tip: Rasterize a layer with it’s effect in Photoshop

| No Comments »

Problem: Help! My mask clipping isn’t working because of the my layer’s overlay effect! I need to rasterize my effects first but I don’t know how!

Solution:

Step 1: Select the layer with the effects you want rasterized. Step 2: Press Control(CMD for Mac)+Shift+N to create a new layer. Step 3: Add the layer from Step 1 to your selection by holding Shift and clicking on the Layer. Step 4: Press Ctrl(CMD for Mac)+E to merge the two layers and voila! your effects are now rasterized.

__Note__: This tip is especially useful for mask clipping to a layer that have some gradient/color overlays.


A MySQL query to find & replace text in your database

| No Comments »

Problem: Help! I need to replace some words with something else in my database.

Solution: Use the replace() function to do a search and replace query.

UPDATE table_name SET table_field=REPLACE(table_field,"old_text","new_text");

Here’s an example:

UPDATE wp_posts SET post_content=REPLACE(post_content,"localhost","www.cybervaldez.com");

Easy as pie!


How to: Remove those nasty question marks with a diamond symbols that appears in your website

| 3 Comments »

Problem: Help! I’ve pasted some text from Microsoft Word and saved it to my SQL database! Now whenever I print my text there’s a bunch of diamonds with a question mark symbols appearing!

Solution: You are trying to display characters that are outside your page’s character set, you have to tell your browser that you need to display characters from the iso-8859-1 set so it will know how to render them correctly.

Simply put the following inside your website’s <head></head>

<META http-equiv="Content-type" content="text/html; charset=iso-8859-1">

and in PHP(or any other similar language), simply put this at the top of your page(for other languages, look for an identical function):

<? header("Content-type: text/html; charset=iso-8859-1"); ?>

and voila! Your characters should now be displayed correctly.