Monday, February 21, 2011

Sifr text not resizing when you zoom in with the browser (command + or -)

Hello, If you re-size or re-scale your browser window on the following site that I'm working on the sifr fonts do not change size at all. And even worse if the page is sized down some of the sifr text will get cut off on the edges. http://hokey.squarespace.com/ I'm guessing it's an easy fix. I'm kinda new to sifr. Please help if someone can!

From stackoverflow
  • sIFR 3 does this properly.

    metal-gear-solid : really Mark? cool

Why do these UITableViewCells cause a leak in instruments?

So after a lot of old fashioned comment-out-debugging to narrow down a leak in instruments. The leak occurs when I push a new TableViewController onto the stack.

I found that I'm getting a leak from this code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

if(![feedData isFinishedLoading]){
 [[cell textLabel] setText:@"Loading..."];
 [[cell detailTextLabel] setText:@"..."];
}
else{
 NSDictionary *dict = [[feedData items] objectAtIndex:indexPath.row];
 [[cell textLabel] setText:[dict valueForKey:@"title"]];
 [[cell detailTextLabel] setText:[dict valueForKey:@"description"]];
 [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
}
return cell;
}

This version doesn't leak:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

//  if(![feedData isFinishedLoading]){
//   [[cell textLabel] setText:@"Loading..."];
//   [[cell detailTextLabel] setText:@"..."];
//  }
//  else{
//   NSDictionary *dict = [[feedData items] objectAtIndex:indexPath.row];
//   [[cell textLabel] setText:[dict valueForKey:@"title"]];
//   [[cell detailTextLabel] setText:[dict valueForKey:@"description"]];
//   [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
//  }
return cell;
}

This version does:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

//  if(![feedData isFinishedLoading]){
     [[cell textLabel] setText:@"Loading..."];
     [[cell detailTextLabel] setText:@"..."];
//  }
//  else{
//   NSDictionary *dict = [[feedData items] objectAtIndex:indexPath.row];
//   [[cell textLabel] setText:[dict valueForKey:@"title"]];
//   [[cell detailTextLabel] setText:[dict valueForKey:@"description"]];
//   [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
//  }
return cell;
}

Here's a screen cap of instruments: http://imgur.com/YR8k8

Is the problem in my code somewhere? Or is it a bug in the framework/simulator?

From stackoverflow
  • There is nothing in that leak stack that calls your code so I don't know if you can get rid of it. I know a Big red spike is scary, but it is only 16 bytes. Apple is not perfect and perhaps something in their code is doing it. Maybe you can try using the dot accessors to see if that helps

    cell.textLabel.text = @"Loading...";
    cell.detailTextLabel.ext = @"...";
    

Java - removing headers from .wav

I'm reading a .wav file into a byte array with the following code.

AudioInputStream inputStream = 
    AudioSystem.getAudioInputStream(/*my .wav file */);
int numBytes = inputStream.available();
byte[] buffer = new byte[numBytes];
inputStream.read(buffer, 0, numBytes);
inputStream.close();

Is there a simple way to remove the .wav headers either before or after reading into the byte array?

From stackoverflow
  • Is a wav file header a fixed size? If so inputStream.skip?

  • If correct the .wav header is 44 bytes long, so skip/remove the first 44 and there you have it.

    Don't know for sure though.

  • Here is a good reference on the wave file format.

    Peter Kofler : you have to identify the chunks and remove the headers.

Using Xcode 3.2, which performance tool to see how much memory my iPhone app is using?

Also, is running an app in the simulator sufficient to get a ball park estimate or will I get very different values from running on the device?

From stackoverflow
  • When you run the application using Instruments (Object Allocations) in the simulator, that should give you a very accurate memory usage picture.

  • The default (and a very good) tool is Instruments, which comes with the SDK. Here is Apple's doc on Instruments.

    Memory usage on the simulator is generally the same, although if you are using OpenGL ES, the simulator has significantly less memory errors (and better performance) on the simulator. So the general rule of thumb is: it's ok to test your memory on the simulator, except for OpenGL ES usage.

JavaFX url-proxy?

My computer is running behind proxy. I want to access url from JavaFX. for example say i want to show image from a url. But i haven't seen anyway to provide proxy settings for the connection(?). Please if someone can tell me how to do things in such situation? Thanks

From stackoverflow
  • Setting proxy in Java/FX

    Webbisshh : +1-Hey thanks may be this can be useful. will try it today!
  • By default, JavaFX will automatically use your Operating Systems proxy settings, this is controlled via the Java Preferences or Java Control panel icons on your Mac or PC.

    You can also set, within Java, the proxy environment variables, but I haven't tried this.

    If you are trying to request an external resource from an unsigned application, Java may prompt you (the user) for permission when it runs.

How to retrieve new row data from INSERT using Oracle DataAccess with Powershell?

I am using Oracle.DataAccess.Client inside Powershell. What I need to do is INSERT a new row of data, then retrieve the auto-generated ID field of the newly-created row for another INSERT command, immediately following. What is the best way to do this? I am pretty new to SQL and Oracle. Here is some of my code:

$conn = "My Connection String"
$sql = "insert into SCM_APPS.MODULES (PACKAGE_ABBREVIATION, FULL_MODULE_NAME) values ('TES', 'Testing')"

$command = New-Object Oracle.DataAccess.Client.OracleCommand($sql,$conn)
$reader = $command.ExecuteReader()

Thanks for any help you can provide!

From stackoverflow
    1. Modify your SQL insert query as following
    
    $sql = "insert into SCM_APPS.MODULES (PACKAGE_ABBREVIATION, FULL_MODULE_NAME) values ('TES', 'Testing') RETURNING module_id INTO :module_id"
    
    1. Add a bind variable to your OracleCommand named "module_id"

    2. Take its value after the command is executed

    JimDaniel : Thanks a million!
    Boris Modylevsky : You are welcome. Thanks you for your question I've added a post on my blog with this question and answer: http://borismod.blogspot.com/2009/09/how-to-retrieve-new-row-data-from.html

How can I turn on and off the bluetooth on iphone sdk programatically?

Hello, how can I tell programatically if the bluetooth is turned on or of on the device? And in ethier case turn it off or on programatically?

thanks

From stackoverflow
  • There's currently no way to interface with Bluetooth unless you join the Made for iPod / Works With iPhone program for some hardware you're developing.

    nico : This is not what I meant. What I'm looking for is something like when you are about to usa an app that uses GameKit, the system promps a window that asks the user if he wants to turn on the bluetooth because te app needs it.
  • Are you talking about the popup that appears when you run the GKTank application while bluetooth is turned off? I suspect this is a function of the PeerPicker class - I haven't seen a way to query the bluetooth status directly.

    However if you attempt to make a bluetooth call when bluetooth is off you'll receive a GKSessionCannotEnableError error code (Bluetooth is not currently available).

How to include files with HTTPS - PHP

I made a form process and broke the code up into different files to stay clean and organized.

Now I am setting up the form for https security.

Do all the files I pull into my page have to be called as https as well? In which case I can no longer use include(); as it no longer allows relative paths?

Is the solution to use file_get_contents();? Or does only the (master) page itself need to be called as https?

From stackoverflow
  • It sounds like you are confusing terminology. HTTPS is the protocol used to request a page from the server using SSL or TLS encryption. That is separate from how you serve the request.

    In your PHP source includes are processed server-side. All of the includes will be done before PHP hands the page off to your web server to be returned over the TLS link.

    file.php:

    <?php
    include 'fileA.php';
    include 'fileB.php';
    ?>
    

    In the example above, the user agent (browser) never sees fileA.php or fileB.php. The page request is returned as a single document. You might request it via https://my-server.com/file.php, in which case that is all you need.

    chris : thank you sir. Someone else had confused me.
  • IF the files are on the same server you don't need to change anything.

    include("file.php");

    Will work just fine.

    Also if you were to include a file from a nother https server, as long as you have the tls libraries setup properly, https isn't a problem

    include("https://anotherserver.com/file.php");

    would work provided the other server serves the PHP and does not execute it.

    chris : I thought as of PHP5 include(); with absolute paths dont work... Is including with https an exception?
    Byron Whitlock : no. The path on the server is differnt than the path on the web site. so site.com/path might be /home/www/html/site.com/path. Include looks at the path of the servers filesystem.
    Frank Farmer : Absolute paths work with include() in PHP 5.

Execute Oracle RAC cluster commands via Solaris RBAC?

Executing Oracle RAC cluster management commands such as $ORA_CRS_HOME/bin/crs_start requires root permissions.

Using Solaris RBAC (Role-Based Access Control), one can give a non-root user permissions to execute those commands, but the commands still fail internally. Example:

$pfexec /opt/11.1.0/crs/bin/crs_stop SomeArg
CRS-0259: Owner of the resource does not belong to the group.

Is there a complete RBAC solution for Oracle RAC or does the executor need to be root?

EDIT: Note that my original /etc/security/exec_attr contained:

MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start:uid=0
MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start.bin:uid=0

As Martin suggests below, this needed to be changed to add gid=0 as:

MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start:uid=0;gid=0
MyProfile:suser:cmd:::/opt/11.1.0/crs/bin/crs_start.bin:uid=0;gid=0
From stackoverflow
  • Judging from the error (you need to add the exec_attr line to the question), you probably just set the uid, while the command seems to require the gid to be set too.

    David Citron : Yes yes! Great job answering my question even though I didn't quite provide enough info (sorry!) :-P

MYSQL Multiple Select For Same Category?

I have 3 tables (scenes, categories, scenes_categories ) in a many to many relationship.

scenes ( id, title, description ) categories ( id, title ) scenes_categories ( scene_id, category_id )

I'm having problems making a query to select scenes that must match multiple categories. For example, I might want to select scenes that match category 3 AND category 5 AND category 8, but I can't figure out how to get this to work.

So far I've got something like

SELECT scenes.id, scenes.title, scenes.description
FROM scenes
LEFT JOIN scenes_categories ON scenes.id = scenes_categories.scene_id
LEFT JOIN categories ON scenes_categories.category_id = categories.id
WHERE scenes_categories.category_id = '3'
AND scenes_categories.category_id = '5'
AND scenes_categories.category_id = '8'
AND scenes.id = '1'

How can I select for records that must match all the category ID's specified?

From stackoverflow
  • You need to require that a row exists in your many-to-many table for that sceneId, for each categoryId you are requiring: So try this:

    SELECT s.id, s.title, s.description
    FROM scenes s
    WHERE s.id = '1'
       And Exists (Select * From scenes_categories 
                   Where scene_id = s.Id
                      And category_id = '3')
       And Exists (Select * From scenes_categories 
                   Where scene_id = s.Id
                      And category_id = '5')
    
       And Exists (Select * From scenes_categories 
                   Where scene_id = s.Id
                      And category_id = '8')
    

    another option that should work is to do three inner joins instead:

    SELECT s.id, s.title, s.description
    FROM scenes s
      Join scenes_categories c3 
          On c3.scene_id  = s.Id
               And c3.category_id ='3'
      Join scenes_categories c5 
          On c3.scene_id  = s.Id
               And c3.category_id ='5'
      Join scenes_categories c8 
          On c3.scene_id  = s.Id
               And c3.category_id ='8'     
    WHERE s.id = '1'
    
    Zoidberg : Pretty sure he was looking for a dynamic solution here.
    Zoidberg : Sorry, I took off my downvote... didn't realize he didn't want an OR relationship
    Charles Bretana : @zoid, np, thx for 2nd look!
    waywardspooky : Thank you so much! I implemented the second solution you suggested and it worked like a charm; albeit it took me some time to figure out exactly how it works conceptually, haha.
  • Charles Bretana's answer will work, but might want to check the performance of that against this to see which works better for you.

    SELECT * FROM scenes
    INNER JOIN (
      SELECT scene_id
      FROM scenes_categories
      WHERE category_id IN (3,5,8)
      GROUP BY scene_id
      HAVING count(*) = 3
    ) valid ON scenes.id = valid.scene_id
    

    Assuming your SQL is dynamic, this will probably be a bit easier to implement.

How to block a website programatically using DotNet

HAI I am developing a software to run on the server and block the websites on the client systems using the client system name. My application is if I block www.google.com,entire website should be blocked i.e if user types www.google.co.in,it should not show the webpage of google.I have to block not a single url by editing c:\windows\system32\drivers\etc\hosts but the whole website.Thanking u Chaithu

From stackoverflow
  • Have you considered to solve this via firewall rules instead? That would seem more natural to me... An .NET application seems not to be the appropriate technology to implement a web filter. Just for my own curiousity:

    why do you wan't to block sites?

    K

    1. Create simple http proxy solutions with exclusion list (or look for ready to use solution)
    2. Restrict internet access to access only using Your proxy

click row in gridview

hiiiiiiiii I am trying to do the following : I have a gridview and I want to fire a function(C# function) when I click over the row (any where) this my code :

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

    string alertBox = "alert('";
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        alertBox +=e.Row.Cells[0].Text;
        alertBox += "')";
        e.Row.Attributes.Add("onclick", alertBox);
    }
}
public void test()
{
    Response.Write("ffff");
}

this is working ..and every time I click over the gridview I found an alert ...but I want to fire C# function(like test function in the code) how to do that thanks

From stackoverflow
  • Make your changes in client script or initiate a postback to the server to run the server method.

  • You can emulate GridView command (for example 'SelectCommand') then catch RowCommand event and call your method. Like this:

    
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    ...
    e.Row.Attributes.Add("onclick", "javascript:__doPostBack('" + GridView1.ClientID + "','SelectCommand$" + e.Row.RowIndex.ToString() + "')")
    ...
    }
    
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
      if (e.CommandName == "SelectCommand") {
        // ...
      }
    }
    
    
    Tadas : So, I was a little bit wrong :). Better emulate a custom command, not Select. See my answer. But my previous suggestion should work too. Try to add javascript: before __doPostBack().
    Tadas : Hmm, I don't know. When you click a row do you get postback?
  • To execute a code-behind method with a postback you would have to manually initiate a postback. Essentially you would be wiring up your own event outside of the GridView control because the "RowClick" event doesn't exist - See Tadas' answer.

    Alternatively you could execute the code-behind method without a postback. You could use an Ajax callback. See Ajax Page Methods in ASP.Net.

Shared Hosting scheduled mail in asp.net

Hai guys, I want to send scheduled mail every morning from my application and my website is on shared hosting.... I am using asp.net 3.5 and mysql

From stackoverflow
  • You dont have much options

    1. Upgrade your hosting.
    2. Develop an aspx page which wil send these emails and open that page periodically from another pc.

    Edit : YOU HAVE ASKED THE SAME QUESTION SOME TIME BACK and I myself have answered and there are other good answeres too. Why are you reposting?

    http://stackoverflow.com/questions/1350634/scheduled-mail-in-asp-net

    RichardOD : Don't you just hate it when that happens!
    Shoban : Yeah ;-) I couldnt stop shouting.

SQL Server -- How to Implement Similar Content

Hello, I have a fulltext index on the title of my articles. When someone views an article i use the title as a search string to search the full text index. I can found that the longer the title gets the less results a get and most of the time I don't get any results even though there are releated content in the database. I have tried putting an index on the description as well but that didn't work either.

From stackoverflow
  • The longer the title gets, the fewer results you get. This gives a hint that you may be searching the index with either an expression or an implied AND, i.e. that you are instructing SQL to find all articles that have all of the words from the referenced doc title.

    Maybe by using an "OR" type construct, you'd find more hits for the suggestion, but I'm a bit suspicious that the relevance of many such hits may be, less than good...

    In the absence of any additional data (other than the full text index), it may be tough to provide a good suggestion feature, but some relatively inexpensive tricks (most of them based on the statistical distribution of various characteristics of the data, in particular within a given article) could help you induce the necessary support data to improve precision with the suggestion feature.

Can XSLT be used to form a plain txt file, not just html?

Lately I have become a huge fan of XSL, XPath and XML, but I've only used it to format outputted html documents, with a head and body sections.

I was wondering if its possible to use good of XSLT to format other types of documents, like plain txt?

From stackoverflow
  • Yes of course - just use

    <xsl:output method="text" indent="yes"/>
    

    instead of

    <xsl:output method="html" indent="yes"/>
    

    Marc

    UPDATE: whitespace and formatting text exactly as needed are always a bit tricky in XSLT. Check out some of those references:

    JL : Thanks Marc, will line breaks occur naturally, same as in the template?
    Pavel Minaev : If you use direct element constructors, whitespace within will be collapsed by the usual rules. `` is space-preserving, and lets you control output at character precision, however.

line height and font size

Hi,

What sets the height of the textbox, line height or font size?

From stackoverflow
  • None

    its

    height
    

    attribute

    <input type="text" class="hei" id="txt1" />
    <style>
    .hei
    {
       height: 40px;
    }
    </style>
    

    font-size: Sets or retrieves a value that indicates the font size used for text in the object.

    line-height: Sets or retrieves the distance between lines in the object

  • input {
        height: 100px;
    }
    
  • the css option height?

  • If it's <input type="text" /> then it's a combination of font-size, line-height and any explicitly declared height attributes.

    For <textarea> it's an explicit height declaration, though I think it's expressed as rows rather than height.

    enkrs :