Tuesday, April 24, 2012

seperating strings by -

I have a string hai-welcome.

I need to split the above string using - separator:

mySstring = "hai-welcome"
Seperate as:

firstString = "hai"
secondString = "welcome.

How is it possible that I can use LastPass from more than one computer?

Tell me if I'm wrong: LastPass can never see my passwords, because they are encrypted with a key that stays in my own computer?

Then how is it possible that I can use my passwords from another computer?

My only guess is that the key is the password I use to login to LastPass, or at least it is generated based on it, so it is related in some way. So when I login to LastPass from another computer, they key same key is created in that computer.

https using BasicHttpBinding and ignoring certificate errors

I am using BasicHttpBinding to connect a web service hosted on a secured (https) port. To get it working, I have changed the Security.Mode to TransportWithMessageCredential and Security.Message to BasicHttpMessageCredentialType.Cerificate. I am also calling


with localhost as the subject name.

The issue here is that for unit testing, I have an unsigned certificate from the web server and am supposed to ignore any certificate error thrown during the proxy creation; but I am unable to do so, because I keep getting an error telling me to "specify a certificate". Right now, I am clueless; I appreciate any help here.

Unique CPU ID on Windows via C++

Well I would like to get an unique CPU ID so I can get an UNIQUE identification for each machine.
I did check __cpuid() from windows.h library, but the problem is that the ID it gets, it's the ID of all types of CPU, if you have an I3 Core processor and I have an I3 core processor, it will give the same "Unique ID".

Here is what I came up with to make a CPU ID from the __cpuid() that returns the same information on processors of the same type:

std::string GetCPUID(){

int CPUInfo[4] = {-1};
__cpuid(CPUInfo, 0);
if (CPUInfo[0] < 4)
return ""; //Error on retrieving

stringstream st;
for(int i = 0; i <= 3; i++){
st << CPUInfo[i];

return st.str();


I also checked a program called "Hardware ID Extractor" that works fine, it actually returns a UNIQUE CPU ID as the GUI as I wanted, so they made available a DLL so we can extract the CPU ID it generated , I tried everything with the cleanest code with the DLL and following their example but it seems that it returns nothing when ran on Windows 7. a lot of other people were complaining about this on Windows 7 via the DLL, even though the GUI on windows 7 returns the correct CPU ID.

Showing my work in the Hardware ID Extractor,

Here is the site where I downloaded the DLL (Where I chose the link of C++, VB, .NET): http://www.soft.tahionic.com/download-hdd_id/free-download/free%20download.html

And here is the DLL itself to download: http://www.soft.tahionic.com/download-hdd_id/free-download/DLL%20compressed/HardwareIDExtractorC.dll

This is the code I got from Hardware ID Extractor (I'm using Visual Studio 2008):

#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;

int main (){

char* (__stdcall *GetIDESerialNumber)(BYTE);

if (DllInst == NULL) DllInst = LoadLibrary("C:\\HardwareIDExtractorC.dll");
if (DllInst) {
GetIDESerialNumber = (char* (__stdcall*)(BYTE))GetProcAddress(DllInst, "GetIDESerialNumber");

//Now call the imported function
cout << "SN: " << GetIDESerialNumber(0); // 0 = first IDE hard drive in your system
printf("Not Loaded");


return 0;

In the visual studio output it shows that the DLL was executed by saying:

'Test.exe': Loaded 'C:\HardwareIDExtractorC.dll', Binary was not built with debug information.

And the program output that I get is: Not loaded

Someone know what I can do to get a CPU ID Unique, like in the application Hardware ID Extractor? I need to get a CPU ID because if I get HDD information, the user may format their Hard Drive and the program will stop working, as I'm designing it to work only that specified computer.

I'm using Windows 7 32 bits Ultimate and Intel I3 Core Processor (if that helps in anyway).

I hope I was clear in my question.
Thanks in advance!

Send data to an android device through a text input form php

Here is the idea:

enter image description here

The user types in a command which it has to be send to an android device.

Then the android device runs the command and returns the result to the php page which displays the result in the page!

I have tried with sockets but with no luck(i wanted to keep a connection alive until the closure of the page).

I know how to run commands in my android device:

Runtime.getRuntime().exec( command,args);

And I also know how to send data to the php server:

HttpPost httppost = new HttpPost(""); 


The problem is that I want to send data to the android device first via the text box after pressing the submit button.

Is there a way to do this? Is HttpPost a wrong way to do this?

I have tried so many things like:

URL url = new URL(SERVER_URL);
URLConnection connection = url.openConnection();


Flex keyboard Event

I jus want to know, In Flex Datagrid If the pressed key is Enter, stop the propagation and dispatch a fake Tab Event.

Any suggesstion,

Base64 Encoding Images in CSS

I am writing a little project to parse a CSS file, and base64 encode all the background images.

While I am able to parse the CSS correctly, it seems that everytime I try to convert the image file into a base64Encoded string, the string returned is always exactly the same.

What am I doing wrong?

Here's the encoder. Please assume that all image paths are passing correctly to the method. In this instance, all images are fully qualified urls, so the first section of the method is what is doing the conversion.

Public Sub EncodeImage(ByVal _File As String)
If _File.StartsWith("http") OrElse _File.StartsWith("https") Then
Using _wc As New WebClient()
_wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20101203 Firefox/3.6.13")
_wc.DownloadFile(_File, "c:\temp.png")
Dim _d As Byte() = _wc.DownloadData(_File)
ImageStrings.Add(New ImageTyping() With {
.SourceFile = _File,
.Base64String = Convert.ToBase64String(_d)
_d = Nothing
End Using
Using _fs As New FileStream(_File, IO.FileMode.Open)
Using _br As New BinaryReader(_fs)
Dim _i As Byte() = _br.ReadBytes(_fs.Length)
ImageStrings.Add(New ImageTyping() With {
.SourceFile = _File,
.Base64String = Convert.ToBase64String(_i)
_i = Nothing
End Using
End Using
End If
End Sub

Each and every string returned from this is: iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAAGXcA1uAAAAKUlEQVRIx2P4//+/DwwzUJUzoiRGNYxqGNUwGDSMWjBqwagFoxbQAAMAfS9kqktT8qQAAAAASUVORK5CYII=

Bring a view back to other iphone

I want to place a view(firstView) back to another view(secondView). SecondView is basically a barchart using CGContext. I guess i can't use bringViewToFront there. So I need to place firstView back to secondView. Is there some default function to place a view back to some other view?



Best way to go from tuple pairs of numbers to one tuple of all the individual numbers

How can i get this

nums = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8)]

to this?

[0, 1, 2, 3, 4, 5, 6, 7, 8]

I did:

>>> zip(*nums)[0]
(0, 1, 2, 3, 4, 5, 6, 7)

But it gives me everything except the last element and then i had to use some bad code to get it to the correct result so i was looking for an elegant solution.

Handling component links and retrieving the values from the fields of linked component in Dreamweaver TBB

I am working on Dreamweaver TBBs in SDL Tridion 2011 SP1.

I am unaware of handling component links in Dreamweaver TBBs.

Consider my Component name is "A" which has link to another component "B".

Component A source looks like this:

<Content xmlns="Some UUID">
<Name xlink:type="simple" xlink:href="tcm:184-1897"
xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="B"></Name>

Component B source is:

<Content xmlns="Some other UUID">
<first>first field</first>
<second>second field</second>

I want to write a DWT TBB which can access the fields in the linked component B from Component A.

I want to use RenderComponentField rendition method.

Do I need to add any extentions to it, will I be able apply SiteEdit on it.

Please share your views on it.

Thank you.

how to fix this issue with advanced search codeignitor

i want to build advanced search script but i have this error with search_all function in the model

A PHP Error was encountered

Severity: 4096

Message: Object of class CI_DB_mysql_result could not be converted to string

Filename: models/search_model.php

Line Number: 129

i have four fildes
1- input text to write the book name
2- select box for the author
3- select box for the publisher
3-select box for the section

the model is

class search_model extends CI_Model
function __construct()
/* This function get all search in database sort by order asc.*/

function get_new_one($id)



return $result->row();


function show_new($id)

$result=$this->db->query("SELECT * , COUNT( d_comments_search.cn_new_id ) as count

FROM d_search

left JOIN d_comments_search ON d_search.ne_id = d_comments_search.cn_new_id and d_search.ne_hide='1'

inner join d_search_category on d_search_category.nc_id = d_search.ne_category_id and d_search_category.nc_hide= '1'

and d_search.ne_id= $id group by d_search.ne_id");

return $result->row() ;


function generate_results($keyword,$row=0){
$result1 = $this->db->query("SELECT bo_id,bo_name,bo_state,bo_about FROM d_book where (bo_name like '%$keyword%' or bo_about like '%$keyword%') and bo_state = '1' limit $row,20");
$result2 = $this->db->query("SELECT au_id,au_name,au_state,au_info FROM d_author where (au_name like '%$keyword%' or au_info like '%$keyword%') and au_state = '1' limit $row,20");
$result3 = $this->db->query("SELECT pub_id,pub_name,pub_state,pub_info FROM d_publishing where (pub_name like '%$keyword%' or pub_info like '%$keyword%') and pub_state = '1' limit $row,20");
$results = array_merge($result1->result_array(),$result2->result_array(),$result3->result_array());

return $results;


// get total number of users
function getNumUsers($keyword)
$result1 = $this->db->query("SELECT bo_id,bo_name,bo_state,bo_about FROM d_book where (bo_name like '%$keyword%' or bo_about like '%$keyword%') and bo_state = '1'");
$result1 = $result1->num_rows();
$result2 = $this->db->query("SELECT au_id,au_name,au_state,au_info FROM d_author where (au_name like '%$keyword%' or au_info like '%$keyword%') and au_state = '1'");
$result2 = $result2->num_rows();
$result3 = $this->db->query("SELECT pub_id,pub_name,pub_state,pub_info FROM d_publishing where (pub_name like '%$keyword%' or pub_info like '%$keyword%') and pub_state = '1'");
$result3 = $result3->num_rows();
return $result1 + $result2 + $result3;
//////////////////////////////////end paging///////////////////

function get_publishing()
return $result;

function get_author()
return $result;

function get_section()
return $result;

function search_name()
return $this->db->get('d_book')->result_array();


function search_all() {
$publish = $this->input->post('publish');
$author = $this->input->post('author');
$sec_name = $this->input->post('section');

$sql = $this->db->query("SELECT * FROM `d_book`");
$searches = array();
if ($publish != 'choose')
$searches[] = "`bo_pub_id` = '$publish'";
if ($author != 'choose')
$searches[] = "`bo_au_id` = '$author'";
if ($sec_name != 'choose')
$searches[] = "`bo_sec_id` = '$sec_name'";
if (count($searches) > 0) {
$sql .= "WHERE " . implode(" AND ", $searches);
$sql .= ';';



this is controller

class Search extends front_end {
var $temp;

function __construct(){
//echo $this->input->post("keyboard");


public function index()

* This function display all search
* @param integer $row
public function overview($row=0)
$this->form_validation->set_rules('keyword', 'كلمة البحث', 'trim|required|xss_clean|htmlspecialchars');
//echo $this->session->flashdata('keyword');
if ($this->session->flashdata('keyword') != ''){
//$this->session->set_flashdata('keyword', $this->input->post("keyword"));
$data = $this->temp;

$this->view('search/site/results', $data);

* This function generate result of search
* @param string $keyword
* @param integer $row
public function generate_results($keyword,$row=0){
$config['base_url'] = base_url().'search/search/overview/';
$config['total_rows'] = $this->search->getNumUsers($keyword);
$config['per_page'] = '20';
$config['uri_segment'] = '4';
$data['page'] = $row;
$data['results'] = $this->search->generate_results($keyword,$row);
$data['total_rows'] = $this->search->getNumUsers($keyword);
$this->temp = $data;


* This function display detail of new
* @param integer $id
public function show($id)
$this->view('site/new', $data);

* This function store keyword to use in search
private function store_keyword(){
$this->session->set_userdata('keyword', $this->input->post("keyword"));

public function search_form()

public function search_adv()
$data['result1'] = '';
$data['result2'] = '';
$data['result3'] = '';
$data['result4'] = '';
if($data['bo_name'] == NULL and $data['section']== NULL and $data['publish']==NULL and $data['author']== NULL){
if(isset($data['bo_name']) and $data['bo_name']!= NULL)
$data['result1'] = $this->search->search_name();
if(isset($data['section']) and $data['section'] != NULL)
if(isset($data['publish']) and $data['publish'] != NULL)
if(isset($data['author']) and $data['author']!= NULL)
$data['no_results'] = '';
if(! $data['result1'] && !$data['result2'] && !$data['result3'] && !$data['result4']){
$data['no_results'] = TRUE;
$data['no_results'] = FALSE;

/* End of file dashboard.php */

Clipboard monitoring on Mac OS X | Java

I'm having troubles getting data from the system clipboard on Mac OS X.
What I'm trying to do is to listen to the system clipboard and print the content of the clipboard each time new [text based] information is put into it.

The problem: bellow code works perfectly fine on Windows 7 and openSuse Linux machines, however when I try running the same code on Mac OS X the program fails to print the new content of the clipboard until focus is given to the application. [Nothing is printed until I click on the application icon on the dock...]

My source code:

import java.awt.Toolkit;  
import java.awt.datatransfer.*;
import java.io.IOException;

public class ClipboardListener extends Thread implements ClipboardOwner {

Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

public void run(){
Transferable selection = systemClipboard.getContents(this);

public void gainOwnership(Transferable t){
try {this.sleep(100);}
catch (InterruptedException e) {e.printStackTrace();}
systemClipboard.setContents(t, this);

public void lostOwnership(Clipboard clipboard, Transferable contents) {
try {System.out.println((String) clipboard.getData(DataFlavor.stringFlavor));}
catch (UnsupportedFlavorException e) {}
catch (IOException e) {}

public class myApp {

public static void main(String[] args){
ClipboardListener listener = new ClipboardListener();


What I'm missing/doing wrong?

I found similar problem posted here: Java thread goes to sleep when not in focus on OSX
However using the command "java -jar myApp.jar &" didn't work as a workaround for me.

can i get to related textbox code in ollydbg?

how i can get to related text-box code in ollydbg?

example : i need text-box code in ollydbg but don't find this.
can this into the memory?
this program design by adobe director and need activation code, this code is unique and related to hardware id

thank you

Best pratices for Filtering CoreData records via UiControls

Im building an app where users will be able to filter through a set of photos based on 4 parameters:

param1 and param2 can be one of three possible values respectively. param3 and param4 can contain multiple 'tags' if you will that describe the photo. I have the ui setup where for param1/param2 a series of uiswitches represents each of the three chooses for each param. If you turn one value on, the other two will turn off. However all off should return all photos assuming no values for param3 or param4 are set

Params3/4 have UiButtons that can be made selected/normal. Any selected should be added to the filtering to narrow results.

I can't seem to figure out how I should write the filtering logic to be most effective. Essentially on any control change, I need to rewrite the predicate filter but I can't seem to wrap my head around how I can link the separate param filters together.

For param3/4 I'd also like to add a disabled state for uibuttons that have no records, or no records based on the currently selected buttons.

Can anyone help point me in the right direction?

Get and set value of TextField

I have this code for view:

App.TodoView = Em.View.extend({
labelView: Em.TextField.extend({

createNew:function () {

and this template:

{{#view App.TodoView}}    
{{view labelView}}
{{#view Em.Button target="parentView" action="createNew"}}Add{{/view}}

And I get the following error:

Uncaught TypeError: Object (subclass of Ember.TextField) has no method 'get'

I want to use insertNewLine method too, so I can set the value of the Em.TextField in template.

Parse and translate classic ASP & ASP.NET website

I have a site with a bunch of (pretty ugly) classic asp pages, as well as a number of ASP.NET web forms pages. I need to be able to set it up so the user can flip a switch and translate the whole site to French.

Unfortunately, the requesting client does not want us to use something simple like google translate, they want to be in control of the dictionary to prevent errors in grammar, etc. This means I have to overcome two problems.

First, I need to parse out all of the hard coded text on the website that would be visible to the client and put it into a spreadsheet so they can translate it to their liking and send it back. I was trying to use the Html Agility Pack to do this with the classic code, but was having trouble handling cases where there are server tags (which there are an obscene amount of).

Second, I need a solution that will use this dictionary to translate the text, in both classic and ASP.NET.

I'm thinking the dictionary will be in XML, and could do the translation on the client side, so it will not have to deal with the server tags issue and will work in both classic and .NET, but I'm completely open to suggestion. If anyone has any ideas or knows of any kind of solution that will help me with one or both of my problems, I'd greatly appreciate any help. Thanks

Repeating Button - If you keep it depressed, it keeps firing a function

I am not sure what to call this, all I can think of is a Repeater Button.

I want to press a button and it fires a function immediately once, eg MyZoom(InOrOut).

But if I keep the mouse button depressed it will keep firing that MyZoom(InOrOut) every one tenth of a second until I release the mouse button.

As you can probably guess from the function name, I will have 2 buttons, a zoom in and a zoom out. They will call MyZoom(-1) to make it smaller and MyZoom(1) to make it bigger.

<button onclick="MyZoom(-1);">Zoom Out</button>
<button onclick="MyZoom(1);">Zoom In</button>

How can I change this to include the repeating effect?

How to load php file through jQuery without advertising your technology

Nowadays, Developers and Professionals tend to use PHP templates because of two reasons. They are manageable and secondly, we don't need to advertise our technology as there are no question marks and .php extensions within the URL.

But how to make non-advertisement of your technology possible while sending a jQuery Ajax request to load a PHP file in a div. I mean we would, have to write $.get('phpfile.php') within the script and one can say that voa he is using PHP hmmmm.

Simply, I want to ask is there is any way of loading a PHP through request without advertising your technology as above told.

Some coding will be honored.

Issues about stepping through the code of a process on mac os x

In by debugger process, by using ptrace(PT_STEP,childPid,0,0), tell the OS to restart the child process, but stop it after it executes the next instruction.

But seems that the result is not right. Child process do not executes the next instruction,but in my debugger process, i called wait(&statue) after the call:ptrace(PT_STEP,childPid,0,0).

while (WIFSTOPPED(wait_status)) {
if (ptrace(PT_STEP, child, 0, 0) < 0) {
//Read the data using vm_read at address:0x10046 in process debugie's memory space,compare with the orig value.
//But, the new value is always same as the orig value!!!

In debugie process, i set: data= data*10; the data's address is 0x10046.
After several steps,the new value should be different from the orig value, i changed data's value several time in debugie process.

I test it on Mac os x, but it's a virtual machine(Virtual Box).

Java: Format double to String with K, M, B

999 to 999
1000 to 1k

1500000 to 1.5m

and so on, I would like to not lose any precision at all

Also, need to convert them back to their original value

1.5m to 1500000

The highest it would go is 11 digits max