rulururu

post Sorting table by name (first letters then characters and numbers)

January 6th, 2012

Filed under: DB,SQL — Alex Bylim @ 3:46 am

So we have a problem: we have table with some name field(varchar 100) for example that have such rows:

id name

1 Belex

2 2LOL

3 Alex

so we need to sort this table in ascending order but in way those names starts with number should be after names which starts with letters

so if you make this query:

SELECT * FROM table1 ORDER BY name ASC

You’ll get this

2LOL

Alex

Belex

but we need:

Alex

Belex

2LOL

So here is solution:

SELECT * FROM table 1 ORDER BY ORD(name) < 65 ASC, name ASC

In code above we used function ORD that takes first character integer code and then compare it be less than letter, almost all characters and numbers will have less value, then we make ascending sorting, that is it.

post Error “unrecognized selector” while trying to call extended interface method

July 28th, 2011

Filed under: iOS — Alex Bylim @ 4:39 am

You know you can extend interface by adding some method using category in Objective-C with code similar to this:

@interface NSString (MyCategory)
 
-(void) myMethod:(NSString*)name;
 
@end

You should put this code into header file (for example NSString+MyCategory.h), then implement method in implementation file (NSString+MyCategory.m). Then you try to call myMethod for any NSString instance. But you get error unrecognized selector myMethod, you can think “hm….., why?!!! i’m linked header file “  (with #import “NSString+MyCategory.h”),  even XCode IDE gives you myMethod automatically, but in some reason it does not work. So solution is very simple  you just need to import implementation file along with header file #import “NSString+MyMethod.h”. I can not explain why, but in some way compiler does not link implementation file automatically.

post Do You Get WordPress Plugin Page Error: You do not have sufficient permissions to access this page ?

June 22nd, 2011

Filed under: Wordpress — Alex Bylim @ 9:17 pm

So when you creating plugin and there is admin page for your plugin you can get error You do not have sufficient permissions to access this page . This is easy to fix: in your plugin file  you have such code:

add_action('admin_menu', 'rotator_bar_admin_actions');
 function rotator_bar_admin_actions() {
 add_options_page("WP Rotator Bar", "WP Rotator Bar", 'read', "rotator-bar", "rotator_bar_admin");
}

so 4th option for function add_options_page should be the same name as your main plugin file for example my one is rotator-bar.php, if you have different name there you will get error above

post Error #2176 while trying upload file to amazon s3

May 26th, 2011

Filed under: Flash/Flex — Alex Bylim @ 2:26 am

I were working on uploading files to amazon s3 server, of course I used some ready class for this called AWS3. When I choose some file using FileReference and send it to amazon s3 servers everything ok. But when I’m trying to upload file using ByteArray I get error #2176 saying about some user interaction should be there(mouse click for example) in the same action stack to send file. Very weird stuff, but everybody knows that annoying adobe security policy. What I hade in the code is:

var urlRequest:URLRequest = new URLRequest();
urlRequest.contentType = 'multipart/form-data;';

But this wont work!

So there is very easy solution. Instead of using code above use code below:

var urlRequest:URLRequest = new URLRequest();
urlRequest.requestHeaders.push(new URLRequestHeader('Content-type', 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary()));

You can find UploadPostHelper in the internet.

post Flex masking issue

September 30th, 2010

Filed under: Flash/Flex,MXML — Alex Bylim @ 8:44 pm

Hello! Let’s imagine: you’r making some custom MXML component and want it to have rounded corners or mask it in some different way and you have few such components inside container. After launch component content does not respond and it has similar to “hang” state. I don’t know may be this is some bug or anything else in Flex, but if you have few similar components ( for example MyComponent) in the same container, you will see this issue.

Solution:
To solve this issue just add another wrap(container), for example Canvas, inside you component and put there all your content, and mask this is container instead of actually component.
So your code should looks like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
   <!-- ... any code there ... -->
   <mx:Canvas id="containerToMask" mask="{customMask}">
       <!-- content -->
   </mx:Canvas>
</mx:Canvas>

post Convert Criteria to SQL string

September 3rd, 2010

Filed under: Symfony,Tip — Alex Bylim @ 9:18 pm

If you wanna get SLQ-string representation of Criteria just use toString() method

post How to stretch sidebar(div) vertically (whole height of site) ?

June 9th, 2010

Filed under: CSS,Tip — Alex Bylim @ 5:22 pm

Hey dudes, I know there are a lot of different approaches make two-columns layout, and to make sidebar stretch vertically. But always there is one problem: side bar should fill vertical side area 1) when content longer then sidebar 2) when content shorter then sidebar. So here is how to solve this with CSS:

/* this will allow sidebar stretch vertically in right way */
html, body {
	min-height:100%;
	position: absolute; 
        width:100%;
}
 
/* stretching our sidebar */
#sidebar{
 width: 300px;
 height: auto;
 min-height:100%;
 position:absolute;
 background-color: #555;
}

To make content block is not to hard and you need is to set margin-left the same width as sidebar width

ruldrurd
Next Page »
Powered by WordPress, Web Design by Laurentiu Piron
Entries (RSS) and Comments (RSS)