Tech Sharing

Tech Sharing

Advertisement

Posts Tagged ‘ Tips ’

HTML table word wrap

By on September 21, 2009

I created a table to display a link which consist of a long verification code plus some variable to pass to the web site. There is no any space within the long url and query string. This is not the problem, the problem is on my table, because of the link is in one long string without any space, so when it display on the screen, the table is expanded.


I come across few solution, some people suggest that using the javascript to split the string in to 2 or more row when it excess the string lenght limit. I don’t think this is the best solution, and finally get the solution of control the table using the CSS.


WORD-BREAK:BREAK-ALL;

Syntax:

<table style=”word-wrap: break-word;” width=100>
     <tr>
          <td>long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_string</td>
    </tr>
</table>

Uploading photo to Picasa via Email

By on September 20, 2009

Picasa now allow you to upload the photo in the new way by using email. You may get your photo on your Picasa web album by just sending the photo to to a secret email address, especially useful when you try to upload the photo from your mobile device.


This allows you to stream and caption photos on-the-go.

To get started, follow these steps:

  • Sign in to your Picasa account
  • Click on the Settings link on the top-right corner
  • On the General tabs, go to “Upload photos by email” section and check the “Allow me to upload photos by email.”
  • Enter the “secret word” with lenght between 6-15 characters. As you enter  this word, an email address appears.
  • Click the “Save Change” button
  • Upload your email by attach them to an email message and send it to the newly-created address


Use the email ‘Subject‘ line to add captions or to include the photos in a specific album. If the email ‘Subject’ line matches an existing online album title, your photos will be uploaded to that album. Otherwise the ‘Subject’ line will instead be added as a caption and the photos will be placed in the Drop Box album.


Take note that you can only attach up to 20 MB of photos in JPG, GIF and PNG formats.

Enabled mail upload function in your Picasa Web Album settings

Enabled mail upload function in your Picasa Web Album settings

Try uploading the photo from email to Picasa web album

Try uploading the photo from email to Picasa web albumCheck out the newly uploaded photo using email post

Check out the newly uploaded photo using email post

Check out the newly uploaded photo using email post

Few days back, when I try to log into my Google Analytics to check my blog status, I’m suprise that my blog is not being tracking after I change to the new Masagana WP Theme. After try out few way including deactivate and activate back the analytics plugin, reinstall the plugin, but still no luck to make it work.


I try to google and finally found out that that’s not only my self have this problem, there are a lot of people who using the same blog with me also having the same problem.


I came across a post which highlights the solution to fix this issue.What has caused this issue is that a function has missing or left out from the theme which prevents WP Stats and Google Analytics from working. Apparently, the theme owner has forgotten to insert the function. To fix this issue, you need to edit the footer.php in your theme editor. From your WordPress’s admin panel, navigate to Design > Theme Editor > footer.php.


In the footer.php, just add the following code intot it, I believe the new downloaded Masagana WP Theme footer being encrypted, so just insert the code before the encrypted code to make it work.


<?php wp_footer(); ?>


Once done, update the file. WP Stats and Google Analytics should be working by now.

SQL Server Do's And Dont's

By on August 29, 2009

dataSo, you are now the leader of a SQL Server based project and this is your first one, perhaps migrating from Access. Or maybe you have performance problems with your SQL Server and don’t know what to do next. Or maybe you simply want to know of some design guidelines for solutions using SQL Server and designing Database Access Layers (DAL): this article is for you.



Even if you are not using SQL Server, most of these design guidelines apply to other DBMS, too: Sybase is a very similar environment for the programmer, and Oracle designs may benefit from this too. I won’t show here how to use specific T-SQL tricks, nor won’t give you miracle solutions for your SQL Server problem. This is by no means a complete, closed issue. What I intend to do is give you some advices for a sound design, with lessons learned through the last years of my life, seeing the same design errors being done again and again.

 

Do know your tools

Please, don’t underestimate this tip. This is the best of all of those you’ll see in this article. You’d be surprised of how many SQL Server programmers don’t even know all T-SQL commands and all of those effective tools SQL Server has.

 

“What? I need to spend a month learning all those SQL commands I’ll never use???” you might say. No, you don’t need to. But spend a weekend at MSDN and browse through all T-SQL commands: the mission here is to learn a lot of what can and what can’t be done. And, in the future, when designing a query, you’ll remember “Hey, there’s this command that does exactly what I need”, and then you’ll refer again to MSDN to see its exact syntax.

 

In this article I’ll assume that you already know the T-SQL syntax or can find about it on MSDN.

  [More]

Submit your site to Bing.com

By on June 20, 2009

bing-iconAfter few years of search engine being monopoly by Google, Microsoft has announced their new counter weapons toward Google – called Bing.com


This is just a begining for the search engine war. Now come to another part of the new search engine where all the webmaster or the blog owner should do – get your site to index by the new search engine and gain the traffic from Bing


Click here to submit your website to Bing and get’s index by Bing, so that your website can be found.


Besides that, Bing also has the webmaster tools like the Google webmaster tools. Click here to create a web master center account to submit your site and get index and explore to the search engine faster



Bing home page

Bing home page

Advance SQL Injection

By on June 17, 2009

sqlinjectionThere are a lot of web site attacking method now a days, one of the most attacking method that we can easily found is the SQL Injection.


First of all, before you know about the SQL Injection, you may need to know what is SQL. Structured Query Language (‘SQL’) is a textual language used to interact with relational databases.


There are many varieties of SQL; most dialects that are in common use at the moment are loosely based around SQL-92, the most recent ANSI standard. The typical unit of execution of SQL is the ‘query’, which is a collection of statements that typically return a single ‘result set’. SQL statements can modify the structure of databases (using Data Definition Language statements, or ‘DDL’) and manipulate the contents of databases (using Data Manipulation Language statements, or ‘DML’). In this paper, we will be specifically discussing Transact-SQL, the dialect of SQL used by Microsoft SQL Server.


SQL Injection occurs when an attacker is able to insert a series of SQL statement into a ‘query’ by manipulating data input into an application.


The attacker may use the try and error method to study the database table structure and may inject the statement either to read, delete, edit your data in database or more  dangerous is they may take control ovre your database server.


The following PDF file explain the SQL injection in more detail, you may download, study and understanding the most common SQL Injection technique use by the attacker.


Advance SQL Injection (538)


Trim a string in Javascript

By on June 13, 2009


Trim is a good features when you try to delete the space at the left most, right most or both the left most and right most of the string. The following trim function is ultilize the javascript Regular expression for the trim function


Left Trim

function ltrim(str){

    return str.replace(/^s+/, ”);

}


Right Trim

function rtrim(str) {

    return str.replace(/s+$/, ”);

}


All trim

function alltrim(str) {

    return str.replace(/^s+|s+$/g, ”);

}


database-symbolI try to google, call, msn my friend to find out the solution when I stay back in my office until late night yesterday. But still no luck after few hours of trying.


Thinking of gave up when back to office this morning, but one of my friend suddently send me the solution via MSN. That’s the best present I received by today. I’m not sure how many people will looking for this kind of solution, but any way, will post here to share with all and you may take it if you need it.


Basically the idea is that you put all your select, update or delete statment into the variable and use the execute command to execute the whole variable.

My problem:

I have a formula store in a table which is A+B*C+D. My A = 1, B=2, C=3, D=4.


I managed to replace all my variable with the integer using cursor (This maybe not a good solution, but this is not the main discussion in this post)


The finally answer I get is 1+2*3+4. But the bad thing is in the varchar datatype. I only manage to disply 1+2*3+4 but not the answer of 11.


The solution as below:


Declare @MathFomula Varchar(100)

Set @MathFormula = ‘1+2*3+4’

Exec(‘SELECT ‘ + @MathFormula  + ‘ AS Result’


Output: 11


* Remember that * and / will calculate at first before + and –


execute-math-in-sql


Window Run Command

By on May 22, 2009

I believe most of the advance computer user will know how to ultilize the window run command. But for the normal user may not ultilized it but more prefer to click by mouse.

runcommandwindow

The most common use command is [cmd] and also [notepad]. By using the window run command, you may just press on [Window Key] + [R] on your keyboard and type the command.


The following are some of the window run command that you may or may not use, but I suggest if possible try to remember the most common use which will help you to save your time and also reduce the movement of your hand.


Accessibility Controls
access.cpl


Add Hardware Wizard
hdwwiz.cpl


Add/Remove Programs
appwiz.cpl


Administrative Tools
control admintools


Automatic Updates
wuaucpl.cpl


Bluetooth Transfer Wizard
fsquirt


Calculator
calc


Certificate Manager
certmgr.msc


Character Map
charmap


Check Disk Utility
chkdsk


Clipboard Viewer
clipbrd


Command Prompt
cmd


Component Services
dcomcnfg


Computer Management
compmgmt.msc


Date and Time Properties
timedate.cpl


DDE Shares
ddeshare


Device Manager
devmgmt.msc


Direct X Control Panel (If Installed)*
directx.cpl


Direct X Troubleshooter
dxdiag


Disk Cleanup Utility
cleanmgr


Disk Defragment
dfrg.msc


Disk Management
diskmgmt.msc


[More]

I just found out this usefu function in MSSQL when I try to Google for the solution to replace the null value with something else. So that I no need to do the checking again in my application. The function is call


NULLIF and ISNULL


This 2 functions are actually work opposite with each other.

NULLIF(ColumnName, ValueToCompare) accept 2 parameters, and will return the NULL value if both the expression match.


IFNULL(ColumnName, NewValue) accept 2 parameters, the first parameters is the string that you wish you check with, and the 2nd parameter that you wish to replace with.