PostId int64 13 11.8M | PostCreationDate stringlengths 19 19 | OwnerUserId int64 3 1.57M | OwnerCreationDate stringlengths 10 19 | ReputationAtPostCreation int64 -33 210k | OwnerUndeletedAnswerCountAtPostTime int64 0 5.77k | Title stringlengths 10 250 | BodyMarkdown stringlengths 12 30k | Tag1 stringlengths 1 25 ⌀ | Tag2 stringlengths 1 25 ⌀ | Tag3 stringlengths 1 25 ⌀ | Tag4 stringlengths 1 25 ⌀ | Tag5 stringlengths 1 25 ⌀ | PostClosedDate stringlengths 19 19 ⌀ | OpenStatus stringclasses 5 values | unified_texts stringlengths 47 30.1k | OpenStatus_id int64 0 4 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
539,864 | 02/12/2009 03:17:47 | 8,678 | 09/15/2008 16:34:57 | 88 | 8 | any way to detect a TimeStamp column in a DataTable from SQL Server (fillSchema???) | When updating a datatable from a "select * from sometable", I am iterating the columns in the datatable to dynamically create an update or insert statement, based on datatable.rowstate and DataTable.PrimaryKey.
However, I can't seem to find any property that indicates whether a column is a TimeStamp in SQL Server and must therefore be ignored in the update statement!!! | sql-server | sql-server-2005 | ado.net | visual-studio | null | null | open | any way to detect a TimeStamp column in a DataTable from SQL Server (fillSchema???)
===
When updating a datatable from a "select * from sometable", I am iterating the columns in the datatable to dynamically create an update or insert statement, based on datatable.rowstate and DataTable.PrimaryKey.
However, I can't seem to find any property that indicates whether a column is a TimeStamp in SQL Server and must therefore be ignored in the update statement!!! | 0 |
5,149,216 | 03/01/2011 00:27:44 | 635,633 | 02/26/2011 15:37:05 | 1 | 2 | Submit and download data to a website from iOS | So in my app, I want my users to be able to fill out some information and have it uploaded to me website/server. The user can upload their info and look at other peoples info. I would like to keep the list of people in an array so I can fill a UITableView with the list of people's names. The basic information is just text and I can put that into an array or dictionary or something. But then how should I get it on my website.
Then, how do I download that data and more from the website.
my website is through Yahoo small business and I have written plists and uploaded them in the file manager and then read the arrays from there.
Thanks in advance. | iphone | file-upload | upload | download | nsurl | null | open | Submit and download data to a website from iOS
===
So in my app, I want my users to be able to fill out some information and have it uploaded to me website/server. The user can upload their info and look at other peoples info. I would like to keep the list of people in an array so I can fill a UITableView with the list of people's names. The basic information is just text and I can put that into an array or dictionary or something. But then how should I get it on my website.
Then, how do I download that data and more from the website.
my website is through Yahoo small business and I have written plists and uploaded them in the file manager and then read the arrays from there.
Thanks in advance. | 0 |
1,609,563 | 10/22/2009 19:52:02 | 84,478 | 03/30/2009 06:51:36 | 2,025 | 62 | using the URI codeigniter library | I'm just learning codeigniter, and I seem to have run into something that is a little strange. I'm using the URI routing feature but need to get the URI segments of the re-routed URI.
This is one of the routes:
$route['content'] = "site/display/main template/content";
and when visiting `http://lipsum.localhost/content` it loads the controller, but it won't let me use the URI class:
class Site extends Controller {
function display($template, $page) {
echo "display<br>";
$this->load->library('uri');
echo $this->uri->rsegment(1, 0)."<br>";
echo $this->uri->rsegment(2, 0)."<br>";
echo $this->uri->rsegment(3, 0)."<br>";
echo $this->uri->rsegment(4, 0)."<br>";
}
}
when I visit the page, it just displays
<pre>
display
0
0
0
0
</pre>
Basically this code should load a template and then pass `$page` to it so it can load a section of a website. So 'content' might use 'main template' as the template, and then pass 'content' to it as the page to load. But I also want to be able to pass '/products/whatever' to it, etc -- so I want to cycle through the URI segments to get the full "path" to the page. How can I make it work? And, why is what I have not working? | php | codeigniter | null | null | null | null | open | using the URI codeigniter library
===
I'm just learning codeigniter, and I seem to have run into something that is a little strange. I'm using the URI routing feature but need to get the URI segments of the re-routed URI.
This is one of the routes:
$route['content'] = "site/display/main template/content";
and when visiting `http://lipsum.localhost/content` it loads the controller, but it won't let me use the URI class:
class Site extends Controller {
function display($template, $page) {
echo "display<br>";
$this->load->library('uri');
echo $this->uri->rsegment(1, 0)."<br>";
echo $this->uri->rsegment(2, 0)."<br>";
echo $this->uri->rsegment(3, 0)."<br>";
echo $this->uri->rsegment(4, 0)."<br>";
}
}
when I visit the page, it just displays
<pre>
display
0
0
0
0
</pre>
Basically this code should load a template and then pass `$page` to it so it can load a section of a website. So 'content' might use 'main template' as the template, and then pass 'content' to it as the page to load. But I also want to be able to pass '/products/whatever' to it, etc -- so I want to cycle through the URI segments to get the full "path" to the page. How can I make it work? And, why is what I have not working? | 0 |
9,757,581 | 03/18/2012 10:28:16 | 1,071,529 | 11/29/2011 14:53:54 | 1 | 0 | Program received signal SIGABRT(FORTRAN) | I have problem with this code when I run inversion script.I have tried to debug with gdb:
Starting program: /home/milenko/fg77/f2/bin/inverse_2d
INVERSE: calculate slowness update using LSQR and regularization
open: No such file or directory
apparent state: unit 48 named stop.in
lately writing sequential formatted external IO
Program received signal SIGABRT, Aborted.
0x0012d422 in __kernel_vsyscall ()
| gdb | fortran | null | null | null | null | open | Program received signal SIGABRT(FORTRAN)
===
I have problem with this code when I run inversion script.I have tried to debug with gdb:
Starting program: /home/milenko/fg77/f2/bin/inverse_2d
INVERSE: calculate slowness update using LSQR and regularization
open: No such file or directory
apparent state: unit 48 named stop.in
lately writing sequential formatted external IO
Program received signal SIGABRT, Aborted.
0x0012d422 in __kernel_vsyscall ()
| 0 |
4,377,811 | 12/07/2010 14:39:00 | 533,802 | 12/07/2010 14:39:00 | 1 | 0 | Using dynamic xpath in XSLT | I am using a variable say xpathvar in the XSLT whose value will be supplied at the time of call to XSLT. How can i achieve this?
My XSLT file looks like -
<xsl:param name="xpathvar"/>
<xsl:param name="keyxpath"/>
<xsl:template match="/">
<listofResults>
<xsl:for-each select="$xpathvar">
<keyvalues><xsl:value-of select="xalan:evaluate(substring-before($keyxpath,'||'))"/></keyvalues>
<keyvalues><xsl:value-of select="xalan:evaluate(substring-after($keyxpath,'||'))"/></keyvalues>
</xsl:for-each>
</listofResults>
</xsl:template>
</xsl:stylesheet>
If I mention the variable in the for-each, it throws error. Please guide how can I achieve this.
Thanks! | xslt | null | null | null | null | null | open | Using dynamic xpath in XSLT
===
I am using a variable say xpathvar in the XSLT whose value will be supplied at the time of call to XSLT. How can i achieve this?
My XSLT file looks like -
<xsl:param name="xpathvar"/>
<xsl:param name="keyxpath"/>
<xsl:template match="/">
<listofResults>
<xsl:for-each select="$xpathvar">
<keyvalues><xsl:value-of select="xalan:evaluate(substring-before($keyxpath,'||'))"/></keyvalues>
<keyvalues><xsl:value-of select="xalan:evaluate(substring-after($keyxpath,'||'))"/></keyvalues>
</xsl:for-each>
</listofResults>
</xsl:template>
</xsl:stylesheet>
If I mention the variable in the for-each, it throws error. Please guide how can I achieve this.
Thanks! | 0 |
10,349,410 | 04/27/2012 10:59:32 | 1,004,684 | 10/20/2011 07:39:56 | 1 | 0 | how to block the windows.name property when loading a page in IE | I want to delete the name of the current tab of IE using C#.
as per my knowleage for issue I hv to set window.name property value is null.. or any other..
http://ip-check.info/ plz run this url in IE. and start test you can see the "Tab Name" row in red color and I want green...
for solve it, use JonDoFox for Firefox and "Window name easrer" extension for chrom....but for IE what can I do.????
plz. help me
thanks | internet-explorer | null | null | null | null | 04/27/2012 20:31:03 | not a real question | how to block the windows.name property when loading a page in IE
===
I want to delete the name of the current tab of IE using C#.
as per my knowleage for issue I hv to set window.name property value is null.. or any other..
http://ip-check.info/ plz run this url in IE. and start test you can see the "Tab Name" row in red color and I want green...
for solve it, use JonDoFox for Firefox and "Window name easrer" extension for chrom....but for IE what can I do.????
plz. help me
thanks | 1 |
8,157,210 | 11/16/2011 19:06:08 | 732,650 | 04/30/2011 18:34:37 | 296 | 12 | Calls to GPU kernel from a multithreaded C++ application? | I'm re-implementing some sections of an image processing library that's multithreaded C++ using pthreads. I'd like to be able to invoke a CUDA kernel in every thread and trust the device itself to handle kernel scheduling, but I know better than to count on that behavior. Does anyone have any experience with this type of issue? | c++ | multithreading | cuda | pthreads | null | null | open | Calls to GPU kernel from a multithreaded C++ application?
===
I'm re-implementing some sections of an image processing library that's multithreaded C++ using pthreads. I'd like to be able to invoke a CUDA kernel in every thread and trust the device itself to handle kernel scheduling, but I know better than to count on that behavior. Does anyone have any experience with this type of issue? | 0 |
7,511,140 | 09/22/2011 07:29:23 | 700,011 | 04/09/2011 14:01:48 | 21 | 3 | Chef and Vagrant on FreeBSD a NoOp? | I'm curious: did anybody manage Chef and Vagrant to do _real_ job on FreeBSD? Or this platform isn't appreciated in DevOps? Then, why? | freebsd | sysadmin | chef | vagrant | null | 09/22/2011 15:00:08 | not a real question | Chef and Vagrant on FreeBSD a NoOp?
===
I'm curious: did anybody manage Chef and Vagrant to do _real_ job on FreeBSD? Or this platform isn't appreciated in DevOps? Then, why? | 1 |
11,517,850 | 07/17/2012 07:28:47 | 1,163,513 | 01/22/2012 14:03:52 | 84 | 6 | PHP Script Execution | I am trying to generate a very large csv file having 130K records but script continues to exceute for near about 6 minutes and after than a blank page will be returned.
Same script works perfectly fine for 70k records.
I have already increased max_execution_time to 1000 and memory_limit to 2048M.
What might be possible reasons for this to happen.
Any help would be highly appreciable.
| php | execution | null | null | null | null | open | PHP Script Execution
===
I am trying to generate a very large csv file having 130K records but script continues to exceute for near about 6 minutes and after than a blank page will be returned.
Same script works perfectly fine for 70k records.
I have already increased max_execution_time to 1000 and memory_limit to 2048M.
What might be possible reasons for this to happen.
Any help would be highly appreciable.
| 0 |
8,898,770 | 01/17/2012 17:10:40 | 14,731 | 09/17/2008 02:21:49 | 4,679 | 111 | Forwarding mouseMoved() events to JTree nodes? | If I place a JCheckBox outside of a JTree it plays an animation when I hover over it. When I place the same JCheckbox inside a JTree node, it no longer receives any mouseMoved() events and no animation is played. I tried forwarding these events from the JTree to the JCheckBox but nothing shows up.
I'm guessing the problem is that the same JCheckBox instance is "stamped" by a JTree (once per node). When I forward mouseMoved() event to the shared instance, it doesn't know where to repaint itself.
Any ideas? | java | swing | mouseover | jtree | null | null | open | Forwarding mouseMoved() events to JTree nodes?
===
If I place a JCheckBox outside of a JTree it plays an animation when I hover over it. When I place the same JCheckbox inside a JTree node, it no longer receives any mouseMoved() events and no animation is played. I tried forwarding these events from the JTree to the JCheckBox but nothing shows up.
I'm guessing the problem is that the same JCheckBox instance is "stamped" by a JTree (once per node). When I forward mouseMoved() event to the shared instance, it doesn't know where to repaint itself.
Any ideas? | 0 |
4,715,761 | 01/17/2011 17:02:21 | 248,258 | 01/11/2010 17:39:26 | 595 | 13 | Is EULA itself copyrighted? | I have written a small computer program and want to sell it for personal or commercial use. Neither I have legal expertise nor I can afford lawyers hefty fees to write EULA for me. I am wondering how can I get/right EULA?
Can I copy some other company's EULA by making little changes, like company name, address or other minor things to best fit my needs and distributed with my product? or EULA itself is also copyrighted and there is no way except to right my own EULA from scratch? | eula | null | null | null | null | null | open | Is EULA itself copyrighted?
===
I have written a small computer program and want to sell it for personal or commercial use. Neither I have legal expertise nor I can afford lawyers hefty fees to write EULA for me. I am wondering how can I get/right EULA?
Can I copy some other company's EULA by making little changes, like company name, address or other minor things to best fit my needs and distributed with my product? or EULA itself is also copyrighted and there is no way except to right my own EULA from scratch? | 0 |
10,082,392 | 04/10/2012 02:27:57 | 1,323,046 | 04/10/2012 02:12:59 | 1 | 0 | How to use django-filebrowser rename a file before uploading it to a folder | like django's upload_to
def upload_to(instance, filename):
filename = time.strftime('%Y%m%d%H%M%S')
ym = time.strftime('%Y%m')
return 'uploads/%s/%s.jpg' % (ym,filename)
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
photo = models.ImageField(u"Image (Upload)",upload_to=upload_to)
file saved 'uploads/%s/%s.jpg'
but change for
photo = FileBrowseField("Image", max_length=200, directory="uploads/", extensions=[".jpg"], blank=True, null=True)
How to rename a file before uploading it to a folder
like django's upload_to
| django | upload | django-filebrowser | null | null | null | open | How to use django-filebrowser rename a file before uploading it to a folder
===
like django's upload_to
def upload_to(instance, filename):
filename = time.strftime('%Y%m%d%H%M%S')
ym = time.strftime('%Y%m')
return 'uploads/%s/%s.jpg' % (ym,filename)
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
photo = models.ImageField(u"Image (Upload)",upload_to=upload_to)
file saved 'uploads/%s/%s.jpg'
but change for
photo = FileBrowseField("Image", max_length=200, directory="uploads/", extensions=[".jpg"], blank=True, null=True)
How to rename a file before uploading it to a folder
like django's upload_to
| 0 |
5,740,517 | 04/21/2011 06:44:20 | 655,814 | 06/05/2010 17:53:34 | 154 | 2 | Load PDF from assets folder in android | I have a pdf in my assets folder. I want to load in my activity using a webview. Is it possible. or is there anyother way of doing that. | android | null | null | null | null | null | open | Load PDF from assets folder in android
===
I have a pdf in my assets folder. I want to load in my activity using a webview. Is it possible. or is there anyother way of doing that. | 0 |
7,813,005 | 10/18/2011 20:05:03 | 18,927 | 09/19/2008 14:55:09 | 1,055 | 29 | Why is .NET Framework 4 split into two pieces? | Does anyone know why the .NET Framework version 4 is split into Client Profile and Extended?
Microsoft cites two reasons for having the Client Profile
Can be serviced separately.
Does not need the .NET Framework 4 Extended component of the .NET Framework.
These seem flimsy at best to me, and I need to explain why I want both Client Profile and Extended installed on all our client desktops. My best answer now is "I don't know even know why Microsoft split them in the first place" | .net | null | null | null | null | null | open | Why is .NET Framework 4 split into two pieces?
===
Does anyone know why the .NET Framework version 4 is split into Client Profile and Extended?
Microsoft cites two reasons for having the Client Profile
Can be serviced separately.
Does not need the .NET Framework 4 Extended component of the .NET Framework.
These seem flimsy at best to me, and I need to explain why I want both Client Profile and Extended installed on all our client desktops. My best answer now is "I don't know even know why Microsoft split them in the first place" | 0 |
3,045,472 | 06/15/2010 13:18:15 | 367,288 | 06/15/2010 13:12:06 | 1 | 0 | City Culture/History Information | Is there a provider who would provide information about a city's - it's history, Climate, Major religions, Language Distribution, important attractions ..
I checked stackoverflow earlier and from this I see an option of using Wikipedia - either scrape the screen or use DBPedia, WEX and others.
I would like to know if there is any provider available and who has exposed it as a Web Service API/XML Feed etc so develpers can query and extract information. | cultureinfo | null | null | null | null | 11/30/2011 03:15:57 | off topic | City Culture/History Information
===
Is there a provider who would provide information about a city's - it's history, Climate, Major religions, Language Distribution, important attractions ..
I checked stackoverflow earlier and from this I see an option of using Wikipedia - either scrape the screen or use DBPedia, WEX and others.
I would like to know if there is any provider available and who has exposed it as a Web Service API/XML Feed etc so develpers can query and extract information. | 2 |
11,348,079 | 07/05/2012 15:53:24 | 1,504,174 | 07/05/2012 13:39:20 | 1 | 0 | how do I get all items from a iteration combobox | I used to use getItems get all items in a dropdownList.
http://dev.developer.rallydev.com/developer/iteration-dropdown
but in the API 2.0 I can't find equivalent function to get all items from the iterations combobox.
Any idea?
anthoer issue:
using getRawValue returns only the iteration name, how could I get also the iteration start date and end date?
| rally | null | null | null | null | null | open | how do I get all items from a iteration combobox
===
I used to use getItems get all items in a dropdownList.
http://dev.developer.rallydev.com/developer/iteration-dropdown
but in the API 2.0 I can't find equivalent function to get all items from the iterations combobox.
Any idea?
anthoer issue:
using getRawValue returns only the iteration name, how could I get also the iteration start date and end date?
| 0 |
5,323,775 | 03/16/2011 10:13:36 | 662,253 | 03/16/2011 10:08:27 | 1 | 0 | how to give the user a full permissions in linux redhat 5 | I have created the user "tungsten" now I want to give full permissions to the user
in linux redhat 5
Regards,
Chinta kiran | linux | redhat | null | null | null | 03/16/2011 12:13:18 | off topic | how to give the user a full permissions in linux redhat 5
===
I have created the user "tungsten" now I want to give full permissions to the user
in linux redhat 5
Regards,
Chinta kiran | 2 |
9,375,208 | 02/21/2012 09:40:14 | 850,710 | 07/18/2011 19:29:23 | 24 | 3 | Write hyperlink inside the Zend Form and use routes? | I am having a Log-in form and want to add a "Lost Password" Link inside. I found out that you can use the description to do so. But I have now started to change everything to work with routes and would like to use this also for the Forgot Password Link. is there any chance to do this? I can't find a solution, anyone of you who knows how to do it?
$password = new Zend_Form_Element_Password('login_password', array(
'label' => 'Password',
'description' => '<a href="account/lost">Forgot Password ?</a>',
'required' => true,
));
$password->getDecorator('description')->setOptions(array('escape' => false, 'placement' => 'APPEND')); | zend-framework | null | null | null | null | null | open | Write hyperlink inside the Zend Form and use routes?
===
I am having a Log-in form and want to add a "Lost Password" Link inside. I found out that you can use the description to do so. But I have now started to change everything to work with routes and would like to use this also for the Forgot Password Link. is there any chance to do this? I can't find a solution, anyone of you who knows how to do it?
$password = new Zend_Form_Element_Password('login_password', array(
'label' => 'Password',
'description' => '<a href="account/lost">Forgot Password ?</a>',
'required' => true,
));
$password->getDecorator('description')->setOptions(array('escape' => false, 'placement' => 'APPEND')); | 0 |
9,545,718 | 03/03/2012 11:22:25 | 1,188,979 | 02/04/2012 06:33:14 | 1 | 0 | How do i sample audio in c#? | How do i sample an audio wave at a particular sampling rate and then get values from the audio wave? Im using accord.net platform, naudio.net and alvas.audio in my project. how do i sample the audio file? Later stages in my project involve detection of song, speech, silence, etc | c# | audio | signal-processing | multimedia | naudio | 07/16/2012 00:01:06 | not a real question | How do i sample audio in c#?
===
How do i sample an audio wave at a particular sampling rate and then get values from the audio wave? Im using accord.net platform, naudio.net and alvas.audio in my project. how do i sample the audio file? Later stages in my project involve detection of song, speech, silence, etc | 1 |
10,408,529 | 05/02/2012 06:06:33 | 1,302,996 | 03/30/2012 10:15:40 | 6 | 0 | setup user profiles using the SharePoint User Profile Service in sp2010 | I am developing a website in sharepoint 2010,
i m very much new to sharepoint,
i am asked to create user profiles in sharepoint,
so i went to
Central administration-> Application Management -> Manage Service Applications
->new -> create new user profile services applicaton.
but my problem is how to proceed further,
what to fill in the new pop up,
can you please guide me since i want to do it without any mistake,
thanks
shradha
| vb.net | sharepoint2010 | user-profile | null | null | 05/03/2012 19:15:44 | not a real question | setup user profiles using the SharePoint User Profile Service in sp2010
===
I am developing a website in sharepoint 2010,
i m very much new to sharepoint,
i am asked to create user profiles in sharepoint,
so i went to
Central administration-> Application Management -> Manage Service Applications
->new -> create new user profile services applicaton.
but my problem is how to proceed further,
what to fill in the new pop up,
can you please guide me since i want to do it without any mistake,
thanks
shradha
| 1 |
3,783,314 | 09/23/2010 23:57:10 | 445,102 | 09/11/2010 13:34:27 | 3 | 0 | Yii requirement status... | I try to upload my first small project on new VPS (Linux+php-5.3.3+ apache) and found these problem don't know why any help will be appreciated plz.
1- I have to lowercase all my folders in my project to work on Linux system with php+apache.
2- Strange problem is getting error in calling modlules function if like this....Post::xxx if change to post::xxx its ok I mean everything should be in lowercase otherwise give error like Post.PHP not found.
3- CDbConnection failed to open the DB connection: could not find driver?
4- I did run yii/requirements and got all below services/status FAILED and rest PASSED.
- DOM extension
- PDO MySQL extension
- PDO PostgreSQL extension
- Memcache extension
- APC extension
- Mcrypt extension
- SOAP extension
- GD extension
Any suggestion how make above services PASSED. as Im running MySQL db.
I look forward to hear soon.
| yii | null | null | null | null | null | open | Yii requirement status...
===
I try to upload my first small project on new VPS (Linux+php-5.3.3+ apache) and found these problem don't know why any help will be appreciated plz.
1- I have to lowercase all my folders in my project to work on Linux system with php+apache.
2- Strange problem is getting error in calling modlules function if like this....Post::xxx if change to post::xxx its ok I mean everything should be in lowercase otherwise give error like Post.PHP not found.
3- CDbConnection failed to open the DB connection: could not find driver?
4- I did run yii/requirements and got all below services/status FAILED and rest PASSED.
- DOM extension
- PDO MySQL extension
- PDO PostgreSQL extension
- Memcache extension
- APC extension
- Mcrypt extension
- SOAP extension
- GD extension
Any suggestion how make above services PASSED. as Im running MySQL db.
I look forward to hear soon.
| 0 |
10,974,225 | 06/11/2012 03:25:18 | 990,689 | 10/12/2011 03:45:00 | 8 | 0 | How to read user input and store it into a string variable and display it to screen in Allegro? | Sorry, I'm new to allegro and I can't seem to find a clear explanation on the internet. | c++ | allegro | null | null | null | 06/11/2012 15:00:58 | not a real question | How to read user input and store it into a string variable and display it to screen in Allegro?
===
Sorry, I'm new to allegro and I can't seem to find a clear explanation on the internet. | 1 |
8,415,747 | 12/07/2011 13:04:18 | 760,807 | 05/19/2011 09:53:31 | 2,224 | 25 | How to implement deterministic malloc | Say I have two instances of an application, with the same inputs and same execution sequence. Therefore, one instance is a redundant one and is used for comparing results with the other instance, as a kind of reliability mechanism.
Now, I want all memory allocations and deallocations to happen in exactly the same manner in the two processes. What is the easiest way to achieve that? Write my own malloc and free? And what about memories allocated with other functions such as mmap? | c | linux | x86 | malloc | null | null | open | How to implement deterministic malloc
===
Say I have two instances of an application, with the same inputs and same execution sequence. Therefore, one instance is a redundant one and is used for comparing results with the other instance, as a kind of reliability mechanism.
Now, I want all memory allocations and deallocations to happen in exactly the same manner in the two processes. What is the easiest way to achieve that? Write my own malloc and free? And what about memories allocated with other functions such as mmap? | 0 |
1,848,977 | 12/04/2009 18:57:54 | 39,040 | 11/19/2008 17:53:34 | 235 | 15 | Data compression algorithms books? | I'm looking for a good book on data compression algorithms (huffman, LZW etc), preferably with example code (on CD or website) in C, C++ or python. | books | compression | null | null | null | 09/19/2011 06:47:14 | not constructive | Data compression algorithms books?
===
I'm looking for a good book on data compression algorithms (huffman, LZW etc), preferably with example code (on CD or website) in C, C++ or python. | 4 |
8,015,799 | 11/04/2011 21:13:48 | 1,030,287 | 11/04/2011 19:03:01 | 1 | 0 | General purpose programming language | I think this question should have useful information for future readers as well.
What I'm after:
I'm after a general purpose language that I use to **program for myself**. I am not interested in performance but more so in **minimal development time**. I would ideally like the tool to be **cross-platform** as I mainly use GNU/Linux (although **I'm prepared to switch OS if I have to**).
What I have:
I know **C, C++ and C#**. I've looked at **Python** and I think it would fit the bill well too. So currently I'm trying to choose between C# and Python.
What I like about C#:
It compiles to an executable which is native to the OS and no need for other tools. You can also simply double click it so if you have to write something for someone technically illiterate you can with minimal issues on their side. It also is all-in-one and provides an very intuitive GUI designer. As a positive, you can choose whether or not to supply the source code or just an executable.
What I like about Python:
I really haven't used it much but it is really fast to get something done, it has syntax similar to Matlab and seems to be whidely used in science/engineering communities. It is also cross-platform so I can run it anywhere. Python also seems to be a good tool to know with C/C++ so it adds nicely to my set of skills.
So what I don't like about the above is:
C#: Slower development time than Python and doesn't run on Linux. I'm not sure .NET is a general purpose plafrom - it is very powerful and to know how to use it you need to learn a substantial amount of things (easy things but many) and knowing .NET well and using it just as a general purpose tool seems a waste - after all it's a whole platform.
Python: Doesn't come with a native GUI builder so I'll have to learn a new one but (this is also a positive I suppose as you can pick among many with no difficulty).
Please comment on the above. I'm not limiting myself to these two so any suggestions are wellcome but please do state why I would choose them over the above. | c# | .net | c++ | python | c | 11/04/2011 21:16:18 | off topic | General purpose programming language
===
I think this question should have useful information for future readers as well.
What I'm after:
I'm after a general purpose language that I use to **program for myself**. I am not interested in performance but more so in **minimal development time**. I would ideally like the tool to be **cross-platform** as I mainly use GNU/Linux (although **I'm prepared to switch OS if I have to**).
What I have:
I know **C, C++ and C#**. I've looked at **Python** and I think it would fit the bill well too. So currently I'm trying to choose between C# and Python.
What I like about C#:
It compiles to an executable which is native to the OS and no need for other tools. You can also simply double click it so if you have to write something for someone technically illiterate you can with minimal issues on their side. It also is all-in-one and provides an very intuitive GUI designer. As a positive, you can choose whether or not to supply the source code or just an executable.
What I like about Python:
I really haven't used it much but it is really fast to get something done, it has syntax similar to Matlab and seems to be whidely used in science/engineering communities. It is also cross-platform so I can run it anywhere. Python also seems to be a good tool to know with C/C++ so it adds nicely to my set of skills.
So what I don't like about the above is:
C#: Slower development time than Python and doesn't run on Linux. I'm not sure .NET is a general purpose plafrom - it is very powerful and to know how to use it you need to learn a substantial amount of things (easy things but many) and knowing .NET well and using it just as a general purpose tool seems a waste - after all it's a whole platform.
Python: Doesn't come with a native GUI builder so I'll have to learn a new one but (this is also a positive I suppose as you can pick among many with no difficulty).
Please comment on the above. I'm not limiting myself to these two so any suggestions are wellcome but please do state why I would choose them over the above. | 2 |
5,255,896 | 03/10/2011 05:34:42 | 652,929 | 03/10/2011 05:34:42 | 1 | 0 | Face problem in share my link in facebook and twitter | I have face a problem to share my link in Facebook and twitter my link look like htt://www.examplesite.com/?refby=237551 this thank you | php | facebook | twitter | null | null | 03/10/2011 15:58:19 | not a real question | Face problem in share my link in facebook and twitter
===
I have face a problem to share my link in Facebook and twitter my link look like htt://www.examplesite.com/?refby=237551 this thank you | 1 |
7,755,588 | 10/13/2011 14:21:28 | 656,925 | 08/12/2010 02:22:36 | 1,098 | 30 | C++ compared to PHP - creating a collection of static functions | In PHP I use
class static_function
{
public static function func1()
{
$a=1;
return $a;
}
}
and call via
static_function::func1();
With C++, I try
class static_function
{
public static int func1()
{
int a = 1;
return a;
}
};
and call via
static_function::func1();
C++ compile error is
expected ':' before static
| php | c++ | null | null | null | 10/14/2011 02:38:03 | not a real question | C++ compared to PHP - creating a collection of static functions
===
In PHP I use
class static_function
{
public static function func1()
{
$a=1;
return $a;
}
}
and call via
static_function::func1();
With C++, I try
class static_function
{
public static int func1()
{
int a = 1;
return a;
}
};
and call via
static_function::func1();
C++ compile error is
expected ':' before static
| 1 |
1,939,238 | 12/21/2009 10:06:06 | 235,919 | 12/21/2009 10:06:06 | 1 | 0 | Which ones of the following CMS tools is the easiest to develop with? | We need some easy way to manage web sites at our company, and we are evaluating some CMS tools for this purpose.
We do not yet know what features the sites will need to have (but it will definitely be something with lots of functionalities), so we are looking for something with lots of features and **more importantly to be easily extensible** (if it does not have some feature, we at least want to be able to build-it by ourselves).
We have no experience with Content Management Systems but we do with Java, so it has to be something written in Java. We evaluated some tools and from our perspective the following seem the promising of them:
- OpenCMS dotCMS (Community Edition vs Enterprise Edition)
- InfoGlue
- Alfresco (EE vs CE)
- Magnolia (EE vs EE Pro vs CE)
- Jahia (CE vs EE)
Since we have no experience with either one of them, we were wondering if someone of you who have can share some information about how good they are or how easily they can be used and extended.
I know similar questions have been asked on SO and I also know **this is highly subjective** and people will vote for closing it as soon as it is posted, but for us it is important to know what difficulties other people have been facing in using the above tools (we don’t want to walk a path that takes nowhere if other people already know it leads nowhere).
Others could then vote on the posted answers if they agree or not.
From your experience, **which from the above mentioned CMSs** is the more easily extensible, the easier to use, the easiest to learn etc?
Thank you and Happy Holidays to all.
| content-management-system | discussion | professional-experience | java | null | 06/20/2012 14:57:51 | not constructive | Which ones of the following CMS tools is the easiest to develop with?
===
We need some easy way to manage web sites at our company, and we are evaluating some CMS tools for this purpose.
We do not yet know what features the sites will need to have (but it will definitely be something with lots of functionalities), so we are looking for something with lots of features and **more importantly to be easily extensible** (if it does not have some feature, we at least want to be able to build-it by ourselves).
We have no experience with Content Management Systems but we do with Java, so it has to be something written in Java. We evaluated some tools and from our perspective the following seem the promising of them:
- OpenCMS dotCMS (Community Edition vs Enterprise Edition)
- InfoGlue
- Alfresco (EE vs CE)
- Magnolia (EE vs EE Pro vs CE)
- Jahia (CE vs EE)
Since we have no experience with either one of them, we were wondering if someone of you who have can share some information about how good they are or how easily they can be used and extended.
I know similar questions have been asked on SO and I also know **this is highly subjective** and people will vote for closing it as soon as it is posted, but for us it is important to know what difficulties other people have been facing in using the above tools (we don’t want to walk a path that takes nowhere if other people already know it leads nowhere).
Others could then vote on the posted answers if they agree or not.
From your experience, **which from the above mentioned CMSs** is the more easily extensible, the easier to use, the easiest to learn etc?
Thank you and Happy Holidays to all.
| 4 |
2,924,867 | 05/27/2010 20:59:47 | 352,371 | 05/27/2010 20:59:47 | 1 | 0 | How much PHP do I need to know to design wordpress themes | So I want to start developing Wordpress themes, but I don't know PHP. How much knowledge should I have of PHP before I begin Wordpress development? Can anyone recommend any PHP books? | php | wordpress | themes | recomendations | null | 07/31/2012 04:01:57 | not a real question | How much PHP do I need to know to design wordpress themes
===
So I want to start developing Wordpress themes, but I don't know PHP. How much knowledge should I have of PHP before I begin Wordpress development? Can anyone recommend any PHP books? | 1 |
1,218,914 | 08/02/2009 13:36:40 | 135,960 | 07/09/2009 22:49:09 | 366 | 26 | Eclipse C++ compilation warning problem | Here a code to demonstrate a problem:
class A {
public:
A():
m_b(1),
m_a(2)
{}
private:
int m_a;
int m_b;
};
This is an output on *Console* view:
make all
Building file: ../test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test.d" -MT"test.d" -o"test.o" "../test.cpp"
../test.cpp: In constructor 'A::A()':
../test.cpp:9: warning: 'A::m_b' will be initialized after
../test.cpp:8: warning: 'int A::m_a'
../test.cpp:3: warning: when initialized here
Finished building: ../test.cpp
The problem is that in *Problems* view I'll see 3 separate warnings (lines in output containing warning word), while indeed there're 4 lines in output describing a one problem.
Is there're something I'm missing?
Additional question. Maybe it's in Eclipse spirit, but is there a way to make *Console* view clickable as most IDE does (e.g. Visual Studio, emacs ...)
Thanks
Dima
| eclipse | compilation | cdt | c++ | null | null | open | Eclipse C++ compilation warning problem
===
Here a code to demonstrate a problem:
class A {
public:
A():
m_b(1),
m_a(2)
{}
private:
int m_a;
int m_b;
};
This is an output on *Console* view:
make all
Building file: ../test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test.d" -MT"test.d" -o"test.o" "../test.cpp"
../test.cpp: In constructor 'A::A()':
../test.cpp:9: warning: 'A::m_b' will be initialized after
../test.cpp:8: warning: 'int A::m_a'
../test.cpp:3: warning: when initialized here
Finished building: ../test.cpp
The problem is that in *Problems* view I'll see 3 separate warnings (lines in output containing warning word), while indeed there're 4 lines in output describing a one problem.
Is there're something I'm missing?
Additional question. Maybe it's in Eclipse spirit, but is there a way to make *Console* view clickable as most IDE does (e.g. Visual Studio, emacs ...)
Thanks
Dima
| 0 |
8,564,749 | 12/19/2011 17:00:37 | 1,106,243 | 12/19/2011 15:58:27 | 1 | 0 | Dynamic table with multiple datepickers | I have a web form which has dynamic table using repeating rows. New rows are added by calling the addRow function below:
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
I would like one datepicker (or more) in each row. Datepicker from here:
http://www.frequency-decoder.com/2011/10/11/unobtrusive-accessible-datepicker-widgit-v6
I need the following script for each datepicker:
<script>
datePickerController.createDatePicker({
// Associate the text input to a DD/MM/YYYY date format
formElements:{"formInputName":"%Y-%m-%d"}
});
</script>
How can I easily execute this script for each table row that is added? I'm aware that using <script> in innerHTML does not work. Please see the attached image for the desired result.
http://i.stack.imgur.com/HHn2w.jpg
Thanks for your help! | php | javascript | jquery | null | null | null | open | Dynamic table with multiple datepickers
===
I have a web form which has dynamic table using repeating rows. New rows are added by calling the addRow function below:
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
I would like one datepicker (or more) in each row. Datepicker from here:
http://www.frequency-decoder.com/2011/10/11/unobtrusive-accessible-datepicker-widgit-v6
I need the following script for each datepicker:
<script>
datePickerController.createDatePicker({
// Associate the text input to a DD/MM/YYYY date format
formElements:{"formInputName":"%Y-%m-%d"}
});
</script>
How can I easily execute this script for each table row that is added? I'm aware that using <script> in innerHTML does not work. Please see the attached image for the desired result.
http://i.stack.imgur.com/HHn2w.jpg
Thanks for your help! | 0 |
11,290,149 | 07/02/2012 08:28:10 | 1,495,490 | 07/02/2012 08:12:26 | 1 | 0 | reading NFC Program | From News I know NFC.I am interested in NFC.So I develop program about NFC by using Samsung I9250. But I am in trouble when I develop NFCV program.I have develop MifareUltralight Card project by using the internet method.But this method do not suppot NFCV.Can you help me?My Andorid is 4.0.3 | java | android | nfc | null | null | 07/03/2012 03:31:37 | not a real question | reading NFC Program
===
From News I know NFC.I am interested in NFC.So I develop program about NFC by using Samsung I9250. But I am in trouble when I develop NFCV program.I have develop MifareUltralight Card project by using the internet method.But this method do not suppot NFCV.Can you help me?My Andorid is 4.0.3 | 1 |
7,060,610 | 08/15/2011 00:07:41 | 564,669 | 11/10/2010 13:09:27 | 1 | 0 | What are the best books on Cloud Computing? | I want to start in this field, and I have no experience with it, I just do web apps for long time, any ideas about best books for newbie? | books | cloud | computing | null | null | 08/15/2011 00:22:45 | not constructive | What are the best books on Cloud Computing?
===
I want to start in this field, and I have no experience with it, I just do web apps for long time, any ideas about best books for newbie? | 4 |
3,233,419 | 07/13/2010 00:48:16 | 380,524 | 06/30/2010 21:05:30 | 3 | 0 | Which is the most frequent uses of type in C++ | Which is the most frequent uses of type in C++?
int?
bool?
pointer?
....
thanks | c++ | null | null | null | null | 07/13/2010 00:50:35 | not a real question | Which is the most frequent uses of type in C++
===
Which is the most frequent uses of type in C++?
int?
bool?
pointer?
....
thanks | 1 |
7,328,780 | 09/07/2011 04:12:07 | 917,146 | 08/29/2011 04:41:55 | 13 | 0 | Project management software web based | im currently looking for a new project management software, something very similar to redmine. But instead of being coding in ruby i would really love it to be done in php. I was using redmine but after my last system update it broke rails and iv just spent the last two days trying to fix the errors, it seems to be once i fix one error theres another error. So yeah iv just decided that I dont want to be spending any more time fixing redmine.
So any ideas or suggestions? | php | project-management | redmine | null | null | 09/07/2011 07:37:19 | off topic | Project management software web based
===
im currently looking for a new project management software, something very similar to redmine. But instead of being coding in ruby i would really love it to be done in php. I was using redmine but after my last system update it broke rails and iv just spent the last two days trying to fix the errors, it seems to be once i fix one error theres another error. So yeah iv just decided that I dont want to be spending any more time fixing redmine.
So any ideas or suggestions? | 2 |
11,580,433 | 07/20/2012 13:32:37 | 1,298,610 | 03/28/2012 15:37:19 | 301 | 25 | Comparing Numbers when those Numbers are strings | Here is a brief bit of background information:
Whilst designing a Rule Engine to compare various aspects of a form to desired Inputs i stumbled across the problem of having to check if a number was larger than another number, easy enough with the > and < operators right? Wrong, the type of these two that i have to compare are strings, they have to be strings, its not something that can change.
So wishing to see where the Engine would fail so i would know where to begin i told it to compare "100" to "10,000", you can imagine my surprise when it properly calculated that 10k was larger, then i realised DUH its just comparing string lengths, so i compared 1001 to 1000, again it got it correct, 1001 is larger.
But i was adamant that this should NOT work, so i kept hitting the engine with all sorts of scenarios determined to watch it fail. After a colleague pointed out that the system was capable of comparing 1001 and 1000 as file names and properly ordering, the newest thought was that it compared aschii character values of some sort, testing continued. This WOULD fail, i couldn't accept that it was capable of properly calculating which was greater numerically when both were strings.
So my next thought was that it was lining up the first character of each and comparing values through each part of the string. I finally succeeded when i tested 11,111 to 9,999 and it deemed that 9,999 was greater. Perfect, i was near enough happy that it compared 1 to 9, and 9 won on each time, simple fix, prefix the shorter string with 0's.
Ran this new theory through the engine and once again it was happily calculating which was larger.
However I'm still not convinced, there must be other pitfalls to this type of comparison, but im running short of comparisons to test to prove my theory. So my question to you over-flowers is what scenarios do you think this could fail on?
Have you yourselves tried this before? comparing numbers when they are strings and what were the pitfalls you faced? have i covered them all or am i overlooking some major pitfalls?
I'm not convinced this method is fool proof (note however that i didn't test strings such as 100d to 10000 because there is validation to be sure of that)
Thanks in advance!
NOTE: i did do some googling and searching and i dont think it is covered by any question here, yes some are similar but they are concerned about not wanting numbers in the string, not wanting a string of only numbers, so i deemed this different enough to post.
Note 2: My specific question is where will numeric comparisons fail when using strings of numbers instead of ints | c# | string | comparison | null | null | 07/20/2012 23:04:06 | too localized | Comparing Numbers when those Numbers are strings
===
Here is a brief bit of background information:
Whilst designing a Rule Engine to compare various aspects of a form to desired Inputs i stumbled across the problem of having to check if a number was larger than another number, easy enough with the > and < operators right? Wrong, the type of these two that i have to compare are strings, they have to be strings, its not something that can change.
So wishing to see where the Engine would fail so i would know where to begin i told it to compare "100" to "10,000", you can imagine my surprise when it properly calculated that 10k was larger, then i realised DUH its just comparing string lengths, so i compared 1001 to 1000, again it got it correct, 1001 is larger.
But i was adamant that this should NOT work, so i kept hitting the engine with all sorts of scenarios determined to watch it fail. After a colleague pointed out that the system was capable of comparing 1001 and 1000 as file names and properly ordering, the newest thought was that it compared aschii character values of some sort, testing continued. This WOULD fail, i couldn't accept that it was capable of properly calculating which was greater numerically when both were strings.
So my next thought was that it was lining up the first character of each and comparing values through each part of the string. I finally succeeded when i tested 11,111 to 9,999 and it deemed that 9,999 was greater. Perfect, i was near enough happy that it compared 1 to 9, and 9 won on each time, simple fix, prefix the shorter string with 0's.
Ran this new theory through the engine and once again it was happily calculating which was larger.
However I'm still not convinced, there must be other pitfalls to this type of comparison, but im running short of comparisons to test to prove my theory. So my question to you over-flowers is what scenarios do you think this could fail on?
Have you yourselves tried this before? comparing numbers when they are strings and what were the pitfalls you faced? have i covered them all or am i overlooking some major pitfalls?
I'm not convinced this method is fool proof (note however that i didn't test strings such as 100d to 10000 because there is validation to be sure of that)
Thanks in advance!
NOTE: i did do some googling and searching and i dont think it is covered by any question here, yes some are similar but they are concerned about not wanting numbers in the string, not wanting a string of only numbers, so i deemed this different enough to post.
Note 2: My specific question is where will numeric comparisons fail when using strings of numbers instead of ints | 3 |
11,663,137 | 07/26/2012 05:46:43 | 469,721 | 10/07/2010 23:48:56 | 35 | 3 | OOP: using class vs instance (Python) | I'm asking this question with regards to Python, though it's probably applicable to most OOP languages. When I only expect to use the data model only once in any program, I could either make a class with class/static methods and attributes or just make a regular class and instantiate it once and only use that one copy. In this case, which method is better and why?
With python, I could also write a module and use it like I would a class. In this case, which way is better and why? | python | oop | null | null | null | 07/27/2012 02:34:05 | not constructive | OOP: using class vs instance (Python)
===
I'm asking this question with regards to Python, though it's probably applicable to most OOP languages. When I only expect to use the data model only once in any program, I could either make a class with class/static methods and attributes or just make a regular class and instantiate it once and only use that one copy. In this case, which method is better and why?
With python, I could also write a module and use it like I would a class. In this case, which way is better and why? | 4 |
7,750,279 | 10/13/2011 06:35:56 | 899,656 | 08/17/2011 23:58:52 | 848 | 75 | What is the best way to store application data accessible from all user accounts? | I need to store some data so it can be accessed by the application from any user account.
The amount of data is not big, just several strings.
The storage does not have to be secure, although it would be beneficial. A least the users without admin permission should not be able to spoil it.
I would not mind if the application would require to provide admin password to store the data or remove it. However, when application is launched from another user account without admin rights, it should be able to read this data not asking for any passwords.
Should I use keychain or /Library/Application Support/ folder or maybe something else? | objective-c | osx | cocoa | security | keychain | null | open | What is the best way to store application data accessible from all user accounts?
===
I need to store some data so it can be accessed by the application from any user account.
The amount of data is not big, just several strings.
The storage does not have to be secure, although it would be beneficial. A least the users without admin permission should not be able to spoil it.
I would not mind if the application would require to provide admin password to store the data or remove it. However, when application is launched from another user account without admin rights, it should be able to read this data not asking for any passwords.
Should I use keychain or /Library/Application Support/ folder or maybe something else? | 0 |
8,196,015 | 11/19/2011 17:52:14 | 1,055,557 | 11/19/2011 17:43:53 | 1 | 0 | Adview in listview not visible (android) | I am follow google's listview tutorial (http://developer.android.com/resources/tutorials/views/hello-listview.html) and I'm trying to ad an adview to my listview (so that it always stays on top), but I can't get it working. I've tried relativelayout and linear but I can't get it working. I've tried replacing the adview with a button but the buttons doesn't show up either. Right now I'm using this code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="bannerID"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
<ListView android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
This code looks good in the graphical layout but when I run the app it gets covered my the textview in list_item.xml. Anyone have any idea how to get this working? Would really appreciate it.
| android | listview | adview | null | null | null | open | Adview in listview not visible (android)
===
I am follow google's listview tutorial (http://developer.android.com/resources/tutorials/views/hello-listview.html) and I'm trying to ad an adview to my listview (so that it always stays on top), but I can't get it working. I've tried relativelayout and linear but I can't get it working. I've tried replacing the adview with a button but the buttons doesn't show up either. Right now I'm using this code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="bannerID"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
<ListView android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
This code looks good in the graphical layout but when I run the app it gets covered my the textview in list_item.xml. Anyone have any idea how to get this working? Would really appreciate it.
| 0 |
2,536,396 | 03/29/2010 07:36:08 | 298,099 | 03/20/2010 17:24:24 | 7 | 0 | who is connected through who php mysql |
i want to create something like
person1 is connected to person2 is connected with person3
Does anybody know a tutorial where this is explained? | mysql | php | null | null | null | 04/22/2012 13:27:13 | too localized | who is connected through who php mysql
===
i want to create something like
person1 is connected to person2 is connected with person3
Does anybody know a tutorial where this is explained? | 3 |
5,296,793 | 03/14/2011 09:30:56 | 495,745 | 11/03/2010 09:50:30 | 174 | 9 | Strange behavior with table td padding CSS | If I apply a TD padding with the following CSS:
<code>#maincontent table td, #maincontent table th {padding: .333em 0 .333em .25em;}</code>
… in Safari and IE the padding is applied to the TD as it should — BUT NOT on Firefox.
If I apply the TD-padding in the CSS only to the TD — and not the th — the padding is not set in all Browsers:
<code>#maincontent table td {padding: .333em 0 .333em .25em;}</code>
AND if I change the order of the td/th, it does also not work (in all browsers):
<code>#maincontent table th, #maincontent table td {padding: .333em 0 .333em .25em;}</code>
Why does this behave that strange!? … I do not set anything else to the table (only a <code>* {margin: 0; padding: 0;}</code> css-reset) and a 100% width and 1em-margin to the table-element itself. But nothing else on td, th, tr, tbody or something else in the table. | css | table | null | null | null | null | open | Strange behavior with table td padding CSS
===
If I apply a TD padding with the following CSS:
<code>#maincontent table td, #maincontent table th {padding: .333em 0 .333em .25em;}</code>
… in Safari and IE the padding is applied to the TD as it should — BUT NOT on Firefox.
If I apply the TD-padding in the CSS only to the TD — and not the th — the padding is not set in all Browsers:
<code>#maincontent table td {padding: .333em 0 .333em .25em;}</code>
AND if I change the order of the td/th, it does also not work (in all browsers):
<code>#maincontent table th, #maincontent table td {padding: .333em 0 .333em .25em;}</code>
Why does this behave that strange!? … I do not set anything else to the table (only a <code>* {margin: 0; padding: 0;}</code> css-reset) and a 100% width and 1em-margin to the table-element itself. But nothing else on td, th, tr, tbody or something else in the table. | 0 |
4,269,590 | 11/24/2010 17:20:43 | 866,721 | 11/24/2010 16:24:38 | 1 | 2 | How can I build own Payment Gateway in PHP. | I want to build my own payment gateway and provide functionality like paypal.
Please help me. | php | null | null | null | null | 11/24/2010 17:33:15 | off topic | How can I build own Payment Gateway in PHP.
===
I want to build my own payment gateway and provide functionality like paypal.
Please help me. | 2 |
10,229,270 | 04/19/2012 13:36:19 | 1,297,670 | 03/28/2012 08:56:03 | 1 | 0 | How to identify different images in a row of a ListView? | I need to implement a UI which displays many images(more than 1000). The layout of the images like this:
(image1) (image2) (image3)
( image4 ) ( image5 )
( image6 ) ( image7 )
...
( imageN ) ( imageN+1)
I want to show these images in a ListView and I know how to do that. But, I don't know how to identify which image is clicked after showing them. I need to display a big image after clicking the little image in the ListView. Any answer will be appreciated. | android | null | null | null | null | 04/25/2012 11:28:14 | not a real question | How to identify different images in a row of a ListView?
===
I need to implement a UI which displays many images(more than 1000). The layout of the images like this:
(image1) (image2) (image3)
( image4 ) ( image5 )
( image6 ) ( image7 )
...
( imageN ) ( imageN+1)
I want to show these images in a ListView and I know how to do that. But, I don't know how to identify which image is clicked after showing them. I need to display a big image after clicking the little image in the ListView. Any answer will be appreciated. | 1 |
10,282,603 | 04/23/2012 14:33:10 | 455,268 | 04/23/2010 07:17:28 | 494 | 11 | htaccess - rewrite URL to include CSS and JS | RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)\.(css|js|htc|pdf|jpg|jpeg|gif|png|ico)$ [NC]
RewriteRule ^(.*)$ index.php?path=$1 [QSA,L]
This .htaccess redirects everything to `index.php?path=SOMETHING` where I can pick it up (SOMETHING path) and show appropriate content (views).
The problem is with including `.css/.js` files.
If I use `www.website.com/something` everything works (css path is like `/css/style.css` and it's searching in the `www.website.com/css/style.css`). But if I use `www.website.com/something/2` everything crashes because it's searching in `www.website.com/something/css/style.css` folder.
How to set root (?) everytime to `www.website.com` (whatever path is)? So I **should still have acccess to my 'path' variable** but everything should point to the website root and not `/some/...` path when including my files. | .htaccess | null | null | null | null | null | open | htaccess - rewrite URL to include CSS and JS
===
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)\.(css|js|htc|pdf|jpg|jpeg|gif|png|ico)$ [NC]
RewriteRule ^(.*)$ index.php?path=$1 [QSA,L]
This .htaccess redirects everything to `index.php?path=SOMETHING` where I can pick it up (SOMETHING path) and show appropriate content (views).
The problem is with including `.css/.js` files.
If I use `www.website.com/something` everything works (css path is like `/css/style.css` and it's searching in the `www.website.com/css/style.css`). But if I use `www.website.com/something/2` everything crashes because it's searching in `www.website.com/something/css/style.css` folder.
How to set root (?) everytime to `www.website.com` (whatever path is)? So I **should still have acccess to my 'path' variable** but everything should point to the website root and not `/some/...` path when including my files. | 0 |
9,307,091 | 02/16/2012 07:20:49 | 1,157,598 | 01/19/2012 03:13:45 | 1 | 0 | Do i have to pay a fee to set up a git server for private or commercial use? | Do i have to pay a fee to set up a git server for private or commercial use?
Thanks in advance for my stupid question. | git | licensing | null | null | null | 02/16/2012 08:50:24 | off topic | Do i have to pay a fee to set up a git server for private or commercial use?
===
Do i have to pay a fee to set up a git server for private or commercial use?
Thanks in advance for my stupid question. | 2 |
9,835,482 | 03/23/2012 07:26:43 | 1,365,428 | 03/19/2012 08:36:08 | 1 | 1 | how create a box like this in css3 | Images link is
http://imageshack.us/photo/my-images/42/readmoren.png/
Please check to this link and see the readmore image.
I want to look like this in css3
| html | css | null | null | null | 04/26/2012 12:34:08 | not a real question | how create a box like this in css3
===
Images link is
http://imageshack.us/photo/my-images/42/readmoren.png/
Please check to this link and see the readmore image.
I want to look like this in css3
| 1 |
4,386,245 | 12/08/2010 10:05:28 | 299,048 | 03/22/2010 13:35:28 | 189 | 24 | Close multiple branches in TortoiseHg | I use TortoiseHg 1.1 and in our team we tend to create named branches for each case we work on then merge with default when we're done. Unfortunately most of the named branches don't get closed. This isn't a huge problem but it's annoying when you try and filter by the branch you are currently working on and there is a massive list of old branches to search through.
So is there an easy way in TortoiseHg or from the command line to close multiple branches quickly without having to manually commit and close on each branch? | mercurial | tortoisehg | null | null | null | null | open | Close multiple branches in TortoiseHg
===
I use TortoiseHg 1.1 and in our team we tend to create named branches for each case we work on then merge with default when we're done. Unfortunately most of the named branches don't get closed. This isn't a huge problem but it's annoying when you try and filter by the branch you are currently working on and there is a massive list of old branches to search through.
So is there an easy way in TortoiseHg or from the command line to close multiple branches quickly without having to manually commit and close on each branch? | 0 |
4,276,914 | 11/25/2010 12:12:20 | 520,099 | 11/25/2010 12:00:21 | 1 | 0 | c# Multiple Task application with Access DB problem | I’ve got a problem with an application running on .NET 4 Task class threads. It’s bit complicated now, but I’ll try to explain how it’s working.
App ought to connect with multiple devices using zkemkeeper (COM library), it should run on 6 parallel threads, which are getting data from devices and inserting them to MS Access DataBase in proper form.
Main thread is starting with button click, it is creating an object used to connect both with db and devices. Next, it creates 6 threads of Task class, each of them is sending it’s task (my class OrderTask<T>) to singletone instance of ProcessInspector<T> (T is the type defining records). Inspector is running own threads as children (TaskCreationOptions.AttachedToParent), which are going to collect data from device. Immediately is set a continuation of thread, which, after returning result by thread, is putting collection of data into db.
Threads are working quite well, they are adding records as they should do, etc.
Problem is, that after second button push … AND ONLY after second, first time is working without errors… application is breaking with exception. After all tasks and finishing the main thread. Exception is one of 3 this group (they are being threw randomly):
- Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (most common error)
- System.Runtime.InteropServices.SEHException Additional Information External Component has thrown an Exception. (it happens)
- FatalExecutionEngineError was detected (it used to be, but didn’t occured for a while)
InnerException is always null.
I didn’t manage to find a place that is returning exception, i’m getting info, that source code for this part ins not availble.
It might help, fact that class DBService i got partly done, but with usage of CZKEMClass and I couldn’t compile because of an error:
Error 1 Interop type 'zkemkeeper.CZKEMClass' cannot be embedded. Use the applicable interface instead.
I found a solution for this by using CZKEM instead of CZKEMClass, but there is possibility that it made app unstable.
Even with this error application is doing it’s work (appropriate records inserted to db), before shutting down.
I’m asking for any help, any hints that can direct me to the solution. I’m completely stuck with this and don’t have any ideas how to fix it. Application has to work multiple times and have to be stable. I spent two days trying solve this… searching everywhere with no success…
Thanks in advance
Source code:
public partial class Window1 : Window
{
try
{
db = new DBService();
Collection<Task> threads = new Collection<Task>();
Collection<OrderedTask<Event>> tasks = new Collection<OrderedTask<Event>>();
for (int i = 0; i < 6; i++)
{
int id;
Thread thread = null;
lock (locker)
{
id = i;
}
tasks.Add(new OrderedTask<Event>("Device no " + id.ToString(), this, (x) => //function getting records from device
{
return db.getRecord(id, db.FPmachine[id]);
}, (x) => //function that has to continue the previous adding results to db
{
try
{
Console.WriteLine(((Event)x).makeInsert());
db.insertRecord(x);
}
catch (Exception ex)
//handle exception
}
, db.events(id)));//iteration count depending of number of records
threads.Add(ThreadMultiStart(tasks.Distinct().Last(), id));
}
try
{
foreach (Task t in watki)
t.Wait();
}
catch (AggregateException aggr)
// handle exception
}
catch (Exception exc)
// handle exception
finally
{
db.Dispose(); //disposing devices
ProcessInspector<Event>.Instance.Dispose();//disposing progress window,etc.
}
}
private Task ThreadMultiStart(OrderedTask<Event> task, int id)
{
Task t = Task.Factory.StartNew(() =>
{
ProcessInspector<Event>.Instance.addMultiTask(task);
ProcessInspector<Event>.Instance._barrier.SignalAndWait(); //waiting for the rest of threads
});
return t;
}
}
//////////////////////////////////////////////////////////////
class OrderedTask<T>
{
/// <summary> static object used to lock statment
public static readonly object locker = new object();
public OrderedTask(string name, System.Windows.Window win, FunctionFirst fun,FunctionCon fun_con, int todo)
{
//fields init
}
/// <summary> function delegate
public delegate T FunctionFirst(int iteration);
/// <summary> delegate to function continuation
public delegate void FunctionCon(T obj);
/// <summary> delegate instance
private FunctionFirst FunctionIteration;
/// <summary> delegate instance
private FunctionCon FunctionContinuation;
/// <summary> Task type threads - thread pool
public Task<Collection<T>> Thr;
/// <summary> Task type threads - coninuations - thread pool
public Task<T> ThrCon;
/// <summary> Rezultat obliczeń ustawiony przez WaitResult()
public Collection<T> Result;
/// <summary> Tworzenie i odpalenie zadania równoległego
public void CreateMultiTask()
{
CancellationToken token = cancelSource.Token;
Thr = Task.Factory.StartNew(() => runMulti(), TaskCreationOptions.AttachedToParent);
ThrCon = Thr.ContinueWith(ant => Continue());
}
/// <summary> Waiting for results setting Result field
public void WaitResult()
{
Result = Thr.Result;
}
/// <summary> Task
private Collection<T> runMulti()
{
Collection<T> ret = new Collection<T>();
try
{
ProcessInspector<T>.Instance.CurrentTask = this;
Done = 0;
for (int i = 0; i < ToDo; i++)
{
ret.Add(FunctionIteration(i));//adding result to collection
Done++;
ProcessInspector<T>.Instance.updateProgress();// showing progress
}
return ret;
}
catch (AggregateException aggr)
// handle exception
}
///<summary>Task coninuation
public T Continue()
{
try
{
foreach (T x in Thr.Result)
{
FunctionContinuation(x);
token.ThrowIfCancellationRequested();
}
return default(T);
}
catch(AggregateException aggr)
// handle exception
}
}
////////////////////////////////////////////////
/// <summary> Class managing tasks
/// Singleton!
class ProcessInspector<T> : IDisposable
{
/// <summary> getter of instance
public static ProcessInspector<T> Instance
{
get
{
return instance;
}
}
/// <summary> init of ProgressBar and disposed bool field
public void initilize()
{
NewProgressBar();
disposed = false;
}
static bool flagStart = false;
/// <summary> init
private void start()
{
lock (OrderedTask<T>.locker)
{
if (!flagStart)
{
flagaStart = true;
initilize();
}
}
}
#region Progress
/// <summary> Creatiung progress window
private void NewProgressBar()
{
try
{
ProgressWindowThread = new Thread(() =>
{
ProgressWindow = new Progress();
ProgressWindow.Show();
ProgressWindow.Closed += (sender, e) =>
{
ProgressWindow.Dispatcher.InvokeShutdown();
};
System.Windows.Threading.Dispatcher.Run();
});
}
catch (Exception e)
// handle exception
ProgressWindowThread.SetApartmentState(ApartmentState.STA);
ProgressWindowThread.Start();
}
#endregion
#region Tasks
/// <summary> current task
public OrderedTask<T> CurrentTask;
/// <summary> FIFO queue of tasks
private ConcurrentQueue<OrderedTask<T>> Tasks;
/// <summary> queue of tasks continuations
private ConcurrentQueue<Task> TasksContinuations;
/// <summary> Adding Task to queue and waiting to finish
public void addMultiTask(OrderedTask<T> task)
{
try
{
Tasks.Enqueue(task);
start(); //init if this is first thread
task.CreateMultiTask(); //creating thread and starting it (continuation too)
T wynik = task.WatekCon.Result; //Waiting for continuation results
lock (OrderedTask<T>.locker)
{
Tasks.TryDequeue(out CurrentTask);
}
}
catch (AggregateException e)
// handle exception
}
///<summary>barrier stopping threads until all finish (in Window1)
public Barrier _barrier = new Barrier(6);
#endregion
/// <summary> if disposed
bool disposed = false;
/// <summary> disposing
public void Dispose()
{
Dispose(true);
}
private void Dispose(bool disposing)
{
lock (OrderedTask<T>.locker)
{
if (!this.disposed)
{
flagaStart = false;
ProgressDelegate deleg = new ProgressDelegate(ProgressWindow.Close);
if (ProgressWindowDispatcher != null)
ProgressWindowDispatcher.BeginInvoke(deleg, DispatcherPriority.Send, null);
foreach (OrderedTask<T> task in Tasks)
{
if ((task!=null)&&(task.Watek.Status == System.Threading.Tasks.TaskStatus.Running))
{
task.cancelSource.Cancel();
}
}
disposed = true;
}
}
}
}
/////////////////////////////
class DBService : IDisposable
{
volatile public CZKEM[] FPmachine = new CZKEM[6]; // object communicating with device
volatile ArrayList ar_ID = new ArrayList(); // some data lists
volatile ArrayList ar_bg = new ArrayList(); //
static string cs = "";
/// <summary> opening and checking connections, db and devices
public DBService()
{
bool con=false;
try
{
readCS(); // connection string reading
accessTest(); //chcecking Access db connection
getUserNo(); //getting data to ar_ID i ar_bg
con= connection(); // connecting devices
}
catch (Exception e)
// handle exception
}
#region privy
/// <summary> reading connection string file
private bool readCS()
{
try
{
using (StreamReader srxxx = new StreamReader("cs.ini"))
{
//not imporatant code
}
}
catch (Exception e)
// handle exception
}
/// <summary> checking Access db
private bool accessTest()
{
OleDbConnection conn = null;
try
{
conn = new OleDbConnection(cs);
try
{
conn.Open();
}
catch (Exception ex)
// handle exception
if (conn.State == ConnectionState.Open)
{
conn.Close();
return true;
}
else
{
throw new Exception("DB connection error");
}
}
catch (Exception e)
// handle exception
}
/// <summary> getting data from db 1
private void getUserNo()
{
OleDbCommand cmd=null;
OleDbConnection cn=null;
OleDbDataReader rdr = null;
//opening and closing db connection
}
/// <summary> connecting with devices
private bool connection()
{
OleDbConnection cn = null;
OleDbCommand cmd = null;
OleDbDataReader rdr = null;
string IP="";
//connect
}
#endregion
#region public
/// <summary> closing connections to devices
public void connection_end(int idDev)
{
try
{
FPmachine[idDev].Disconnect();
}
catch (Exception e)
// handle exception
}
/// <summary> getting records count from device
public int events(int idDev)
{
//code
}
/// <summary> getting records from device returns as an prepared object
public Event getRecord(int idDev,CZKEM Machine)
{
//code
}
/// <summary> inserting record
public bool insertRecord(Event ev)
{
//opening and closing db connection
}
#endregion
#region IDisposable Members
public void Dispose()
{
try
{
foreach (CZKEM machine in FPmachine)
machine.Disconnect();
}
catch (Exception ex)
// handle exception
GC.Collect();
}
#endregion
}
/// <summary> class storing records
class Event
{
}
| multithreading | ms-access | c#-4.0 | null | null | null | open | c# Multiple Task application with Access DB problem
===
I’ve got a problem with an application running on .NET 4 Task class threads. It’s bit complicated now, but I’ll try to explain how it’s working.
App ought to connect with multiple devices using zkemkeeper (COM library), it should run on 6 parallel threads, which are getting data from devices and inserting them to MS Access DataBase in proper form.
Main thread is starting with button click, it is creating an object used to connect both with db and devices. Next, it creates 6 threads of Task class, each of them is sending it’s task (my class OrderTask<T>) to singletone instance of ProcessInspector<T> (T is the type defining records). Inspector is running own threads as children (TaskCreationOptions.AttachedToParent), which are going to collect data from device. Immediately is set a continuation of thread, which, after returning result by thread, is putting collection of data into db.
Threads are working quite well, they are adding records as they should do, etc.
Problem is, that after second button push … AND ONLY after second, first time is working without errors… application is breaking with exception. After all tasks and finishing the main thread. Exception is one of 3 this group (they are being threw randomly):
- Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (most common error)
- System.Runtime.InteropServices.SEHException Additional Information External Component has thrown an Exception. (it happens)
- FatalExecutionEngineError was detected (it used to be, but didn’t occured for a while)
InnerException is always null.
I didn’t manage to find a place that is returning exception, i’m getting info, that source code for this part ins not availble.
It might help, fact that class DBService i got partly done, but with usage of CZKEMClass and I couldn’t compile because of an error:
Error 1 Interop type 'zkemkeeper.CZKEMClass' cannot be embedded. Use the applicable interface instead.
I found a solution for this by using CZKEM instead of CZKEMClass, but there is possibility that it made app unstable.
Even with this error application is doing it’s work (appropriate records inserted to db), before shutting down.
I’m asking for any help, any hints that can direct me to the solution. I’m completely stuck with this and don’t have any ideas how to fix it. Application has to work multiple times and have to be stable. I spent two days trying solve this… searching everywhere with no success…
Thanks in advance
Source code:
public partial class Window1 : Window
{
try
{
db = new DBService();
Collection<Task> threads = new Collection<Task>();
Collection<OrderedTask<Event>> tasks = new Collection<OrderedTask<Event>>();
for (int i = 0; i < 6; i++)
{
int id;
Thread thread = null;
lock (locker)
{
id = i;
}
tasks.Add(new OrderedTask<Event>("Device no " + id.ToString(), this, (x) => //function getting records from device
{
return db.getRecord(id, db.FPmachine[id]);
}, (x) => //function that has to continue the previous adding results to db
{
try
{
Console.WriteLine(((Event)x).makeInsert());
db.insertRecord(x);
}
catch (Exception ex)
//handle exception
}
, db.events(id)));//iteration count depending of number of records
threads.Add(ThreadMultiStart(tasks.Distinct().Last(), id));
}
try
{
foreach (Task t in watki)
t.Wait();
}
catch (AggregateException aggr)
// handle exception
}
catch (Exception exc)
// handle exception
finally
{
db.Dispose(); //disposing devices
ProcessInspector<Event>.Instance.Dispose();//disposing progress window,etc.
}
}
private Task ThreadMultiStart(OrderedTask<Event> task, int id)
{
Task t = Task.Factory.StartNew(() =>
{
ProcessInspector<Event>.Instance.addMultiTask(task);
ProcessInspector<Event>.Instance._barrier.SignalAndWait(); //waiting for the rest of threads
});
return t;
}
}
//////////////////////////////////////////////////////////////
class OrderedTask<T>
{
/// <summary> static object used to lock statment
public static readonly object locker = new object();
public OrderedTask(string name, System.Windows.Window win, FunctionFirst fun,FunctionCon fun_con, int todo)
{
//fields init
}
/// <summary> function delegate
public delegate T FunctionFirst(int iteration);
/// <summary> delegate to function continuation
public delegate void FunctionCon(T obj);
/// <summary> delegate instance
private FunctionFirst FunctionIteration;
/// <summary> delegate instance
private FunctionCon FunctionContinuation;
/// <summary> Task type threads - thread pool
public Task<Collection<T>> Thr;
/// <summary> Task type threads - coninuations - thread pool
public Task<T> ThrCon;
/// <summary> Rezultat obliczeń ustawiony przez WaitResult()
public Collection<T> Result;
/// <summary> Tworzenie i odpalenie zadania równoległego
public void CreateMultiTask()
{
CancellationToken token = cancelSource.Token;
Thr = Task.Factory.StartNew(() => runMulti(), TaskCreationOptions.AttachedToParent);
ThrCon = Thr.ContinueWith(ant => Continue());
}
/// <summary> Waiting for results setting Result field
public void WaitResult()
{
Result = Thr.Result;
}
/// <summary> Task
private Collection<T> runMulti()
{
Collection<T> ret = new Collection<T>();
try
{
ProcessInspector<T>.Instance.CurrentTask = this;
Done = 0;
for (int i = 0; i < ToDo; i++)
{
ret.Add(FunctionIteration(i));//adding result to collection
Done++;
ProcessInspector<T>.Instance.updateProgress();// showing progress
}
return ret;
}
catch (AggregateException aggr)
// handle exception
}
///<summary>Task coninuation
public T Continue()
{
try
{
foreach (T x in Thr.Result)
{
FunctionContinuation(x);
token.ThrowIfCancellationRequested();
}
return default(T);
}
catch(AggregateException aggr)
// handle exception
}
}
////////////////////////////////////////////////
/// <summary> Class managing tasks
/// Singleton!
class ProcessInspector<T> : IDisposable
{
/// <summary> getter of instance
public static ProcessInspector<T> Instance
{
get
{
return instance;
}
}
/// <summary> init of ProgressBar and disposed bool field
public void initilize()
{
NewProgressBar();
disposed = false;
}
static bool flagStart = false;
/// <summary> init
private void start()
{
lock (OrderedTask<T>.locker)
{
if (!flagStart)
{
flagaStart = true;
initilize();
}
}
}
#region Progress
/// <summary> Creatiung progress window
private void NewProgressBar()
{
try
{
ProgressWindowThread = new Thread(() =>
{
ProgressWindow = new Progress();
ProgressWindow.Show();
ProgressWindow.Closed += (sender, e) =>
{
ProgressWindow.Dispatcher.InvokeShutdown();
};
System.Windows.Threading.Dispatcher.Run();
});
}
catch (Exception e)
// handle exception
ProgressWindowThread.SetApartmentState(ApartmentState.STA);
ProgressWindowThread.Start();
}
#endregion
#region Tasks
/// <summary> current task
public OrderedTask<T> CurrentTask;
/// <summary> FIFO queue of tasks
private ConcurrentQueue<OrderedTask<T>> Tasks;
/// <summary> queue of tasks continuations
private ConcurrentQueue<Task> TasksContinuations;
/// <summary> Adding Task to queue and waiting to finish
public void addMultiTask(OrderedTask<T> task)
{
try
{
Tasks.Enqueue(task);
start(); //init if this is first thread
task.CreateMultiTask(); //creating thread and starting it (continuation too)
T wynik = task.WatekCon.Result; //Waiting for continuation results
lock (OrderedTask<T>.locker)
{
Tasks.TryDequeue(out CurrentTask);
}
}
catch (AggregateException e)
// handle exception
}
///<summary>barrier stopping threads until all finish (in Window1)
public Barrier _barrier = new Barrier(6);
#endregion
/// <summary> if disposed
bool disposed = false;
/// <summary> disposing
public void Dispose()
{
Dispose(true);
}
private void Dispose(bool disposing)
{
lock (OrderedTask<T>.locker)
{
if (!this.disposed)
{
flagaStart = false;
ProgressDelegate deleg = new ProgressDelegate(ProgressWindow.Close);
if (ProgressWindowDispatcher != null)
ProgressWindowDispatcher.BeginInvoke(deleg, DispatcherPriority.Send, null);
foreach (OrderedTask<T> task in Tasks)
{
if ((task!=null)&&(task.Watek.Status == System.Threading.Tasks.TaskStatus.Running))
{
task.cancelSource.Cancel();
}
}
disposed = true;
}
}
}
}
/////////////////////////////
class DBService : IDisposable
{
volatile public CZKEM[] FPmachine = new CZKEM[6]; // object communicating with device
volatile ArrayList ar_ID = new ArrayList(); // some data lists
volatile ArrayList ar_bg = new ArrayList(); //
static string cs = "";
/// <summary> opening and checking connections, db and devices
public DBService()
{
bool con=false;
try
{
readCS(); // connection string reading
accessTest(); //chcecking Access db connection
getUserNo(); //getting data to ar_ID i ar_bg
con= connection(); // connecting devices
}
catch (Exception e)
// handle exception
}
#region privy
/// <summary> reading connection string file
private bool readCS()
{
try
{
using (StreamReader srxxx = new StreamReader("cs.ini"))
{
//not imporatant code
}
}
catch (Exception e)
// handle exception
}
/// <summary> checking Access db
private bool accessTest()
{
OleDbConnection conn = null;
try
{
conn = new OleDbConnection(cs);
try
{
conn.Open();
}
catch (Exception ex)
// handle exception
if (conn.State == ConnectionState.Open)
{
conn.Close();
return true;
}
else
{
throw new Exception("DB connection error");
}
}
catch (Exception e)
// handle exception
}
/// <summary> getting data from db 1
private void getUserNo()
{
OleDbCommand cmd=null;
OleDbConnection cn=null;
OleDbDataReader rdr = null;
//opening and closing db connection
}
/// <summary> connecting with devices
private bool connection()
{
OleDbConnection cn = null;
OleDbCommand cmd = null;
OleDbDataReader rdr = null;
string IP="";
//connect
}
#endregion
#region public
/// <summary> closing connections to devices
public void connection_end(int idDev)
{
try
{
FPmachine[idDev].Disconnect();
}
catch (Exception e)
// handle exception
}
/// <summary> getting records count from device
public int events(int idDev)
{
//code
}
/// <summary> getting records from device returns as an prepared object
public Event getRecord(int idDev,CZKEM Machine)
{
//code
}
/// <summary> inserting record
public bool insertRecord(Event ev)
{
//opening and closing db connection
}
#endregion
#region IDisposable Members
public void Dispose()
{
try
{
foreach (CZKEM machine in FPmachine)
machine.Disconnect();
}
catch (Exception ex)
// handle exception
GC.Collect();
}
#endregion
}
/// <summary> class storing records
class Event
{
}
| 0 |
6,313,724 | 06/11/2011 02:39:25 | 651,174 | 03/09/2011 08:26:41 | 338 | 2 | Database structure for users and media | Supposing a large number of users and a large number of videos, what would be a better way to structure the database of the following two options:
Option one --
class UserProfile(models.Model)
user = models.ForeignKey(User, unique=True)
videos = models.ManyToManyField(Video, blank=True)
class Video(models.Model)
title = models.CharField(max_length=256)
file = models.FileField(...)
Option two --
class UserProfile(models.Model)
user = models.ForeignKey(User, unique=True)
class Video(models.Model)
uploaded_by = models.ForeignKey(User)
title = models.CharField(max_length=256)
file = models.FileField(...)
| database | django | django-models | null | null | null | open | Database structure for users and media
===
Supposing a large number of users and a large number of videos, what would be a better way to structure the database of the following two options:
Option one --
class UserProfile(models.Model)
user = models.ForeignKey(User, unique=True)
videos = models.ManyToManyField(Video, blank=True)
class Video(models.Model)
title = models.CharField(max_length=256)
file = models.FileField(...)
Option two --
class UserProfile(models.Model)
user = models.ForeignKey(User, unique=True)
class Video(models.Model)
uploaded_by = models.ForeignKey(User)
title = models.CharField(max_length=256)
file = models.FileField(...)
| 0 |
9,965,396 | 04/01/2012 15:02:00 | 895,339 | 08/15/2011 17:16:24 | 13 | 0 | Enbaling viewport pinch-zoom in Phonegap Android application has no effect | I need to be able to turn pinch-zoom on and off using the viewport setting on my Android PhoneGap app.
But I'm unable to get viewport to affect pinch-zooming at all when using PhoneGap. I cannot turn on Pinch-zoom, but when browsing with the Android Native browser to the webpage everything works fine.
I have spent a lot of time searching for a solution, without any result.
I created a very simple index.html for testing, having viewport setting like:
<meta name="viewport" content="user-scalable=yes" />
As some has suggested I have also tried the viewport:
<meta name="viewport" content="user-scalable=1" />
Other solutions for Android PhoneGap would be to enable Android Native Pinch-Zoom which have been suggested here:
http://stackoverflow.com/questions/4668344/zoom-in-phonegap-for-android
But this will not work for me, since I need to be able to control the pinch-zoom from javascript. I.e. I need to be able to use javascript to change the viewport setting, to control when pinch-zoom is available (user-scalable=yes / user-scalable=no)
Please observe that other viewport settings like "initial-scale" and "target-densitydpi" seems to work fine. For example setting initial-scale=2 starts the app zoomed.
(I'm currently testing pinch-zoom on PhoneGap 1.4.1 and HTC Desire HD Android 2.3.3)
I'm beginning to think I have missed something obvious, since I find so little information about similar problems...
The minial index.html:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Minimal AppLaud App</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8">
var onDeviceReady = function() {
document.getElementById("devready").innerHTML = "OnDeviceReady fired.";
};
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
</script>
</head>
<body onload="init();" id="stage" class="theme">
<h2>Minimal AppLaud App</h2>
<p> LOTS OF TEXT WHICH HAVE BEEN REMOVED HERE </p>
<p><span id="devready">onDeviceReady not fired.</span></p>
</body>
</html>
Appreciate any ideas that you might have!
| android | phonegap | null | null | null | null | open | Enbaling viewport pinch-zoom in Phonegap Android application has no effect
===
I need to be able to turn pinch-zoom on and off using the viewport setting on my Android PhoneGap app.
But I'm unable to get viewport to affect pinch-zooming at all when using PhoneGap. I cannot turn on Pinch-zoom, but when browsing with the Android Native browser to the webpage everything works fine.
I have spent a lot of time searching for a solution, without any result.
I created a very simple index.html for testing, having viewport setting like:
<meta name="viewport" content="user-scalable=yes" />
As some has suggested I have also tried the viewport:
<meta name="viewport" content="user-scalable=1" />
Other solutions for Android PhoneGap would be to enable Android Native Pinch-Zoom which have been suggested here:
http://stackoverflow.com/questions/4668344/zoom-in-phonegap-for-android
But this will not work for me, since I need to be able to control the pinch-zoom from javascript. I.e. I need to be able to use javascript to change the viewport setting, to control when pinch-zoom is available (user-scalable=yes / user-scalable=no)
Please observe that other viewport settings like "initial-scale" and "target-densitydpi" seems to work fine. For example setting initial-scale=2 starts the app zoomed.
(I'm currently testing pinch-zoom on PhoneGap 1.4.1 and HTC Desire HD Android 2.3.3)
I'm beginning to think I have missed something obvious, since I find so little information about similar problems...
The minial index.html:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Minimal AppLaud App</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8">
var onDeviceReady = function() {
document.getElementById("devready").innerHTML = "OnDeviceReady fired.";
};
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
</script>
</head>
<body onload="init();" id="stage" class="theme">
<h2>Minimal AppLaud App</h2>
<p> LOTS OF TEXT WHICH HAVE BEEN REMOVED HERE </p>
<p><span id="devready">onDeviceReady not fired.</span></p>
</body>
</html>
Appreciate any ideas that you might have!
| 0 |
10,639,191 | 05/17/2012 15:57:12 | 1,223,807 | 02/21/2012 16:11:07 | 1 | 5 | Text Animation to display characters one at a time | I want to implement an animation in such a way that characters of a word appears one at a time when a button is clicked. For example , Bat should be displayed as b , a , t one at a time with a delay. Which is the best way to implement it ? I had a look at the TextSwitcher API Demo , but it switches only on a click each time. The word should be an input from a character array . Any suggestions, useful links will be greatly appreciated. | android | animation | null | null | null | 05/18/2012 11:47:46 | not a real question | Text Animation to display characters one at a time
===
I want to implement an animation in such a way that characters of a word appears one at a time when a button is clicked. For example , Bat should be displayed as b , a , t one at a time with a delay. Which is the best way to implement it ? I had a look at the TextSwitcher API Demo , but it switches only on a click each time. The word should be an input from a character array . Any suggestions, useful links will be greatly appreciated. | 1 |
10,029,352 | 04/05/2012 13:16:38 | 1,295,995 | 03/27/2012 15:43:43 | 15 | 0 | Php Login issue | Following is my php login script, I don't know is it secure process. But there are one problem. If i write any password then it's say ok and go to user panel page. where is the wrong in my code, can anyone tell me the right direction
<?php
if(isset($_POST['action']) && isset($_POST['action']) == 'Log In')
{
$uname = mysql_real_escape_string(trim(htmlspecialchars($_POST['uname'])));
$pass = mysql_real_escape_string(trim(htmlspecialchars($_POST['pass'])));
$crytpass = hash('sha512','$pass');
$err = array();
include_once("toplevel/content/manage/dbcon/dbcon.php");
// check username
$check_uname = mysql_query("SELECT uname FROM members WHERE uname = '$uname'");
$num_uname = mysql_num_rows($check_uname);
// check password
$check_pass = mysql_query("SELECT pass FROM members WHERE pass = '$crytpass'");
$num_pass = mysql_num_rows($check_pass);
/// userid
$userid = mysql_query("SELECT userid FROM members");
$re = mysql_fetch_array($userid);
$userid = (int) $re['userid'];
if(isset($uname) && isset($pass))
{
if(empty($uname) && empty($pass))
$err[] = "All field required";
else
{
// username validation process....
if(empty($uname))
$err[] = "Username required";
else
{
if($num_uname == 0)
$err[] = "Username is not correct";
}
// password validaiton process...
if(empty($pass))
$err[] = "Password required";
else
{
if($num_pass == 0)
$err[] = "Password is not correct";
}
}
}
if(!empty($err))
{
foreach($err as $er)
{
echo "<font color=red>$er<br></font>";
}
}
else
{
include("user/include/newsession.php");
header("Location:user/index.php");
}
}
?> | php | null | null | null | null | 04/19/2012 11:50:15 | too localized | Php Login issue
===
Following is my php login script, I don't know is it secure process. But there are one problem. If i write any password then it's say ok and go to user panel page. where is the wrong in my code, can anyone tell me the right direction
<?php
if(isset($_POST['action']) && isset($_POST['action']) == 'Log In')
{
$uname = mysql_real_escape_string(trim(htmlspecialchars($_POST['uname'])));
$pass = mysql_real_escape_string(trim(htmlspecialchars($_POST['pass'])));
$crytpass = hash('sha512','$pass');
$err = array();
include_once("toplevel/content/manage/dbcon/dbcon.php");
// check username
$check_uname = mysql_query("SELECT uname FROM members WHERE uname = '$uname'");
$num_uname = mysql_num_rows($check_uname);
// check password
$check_pass = mysql_query("SELECT pass FROM members WHERE pass = '$crytpass'");
$num_pass = mysql_num_rows($check_pass);
/// userid
$userid = mysql_query("SELECT userid FROM members");
$re = mysql_fetch_array($userid);
$userid = (int) $re['userid'];
if(isset($uname) && isset($pass))
{
if(empty($uname) && empty($pass))
$err[] = "All field required";
else
{
// username validation process....
if(empty($uname))
$err[] = "Username required";
else
{
if($num_uname == 0)
$err[] = "Username is not correct";
}
// password validaiton process...
if(empty($pass))
$err[] = "Password required";
else
{
if($num_pass == 0)
$err[] = "Password is not correct";
}
}
}
if(!empty($err))
{
foreach($err as $er)
{
echo "<font color=red>$er<br></font>";
}
}
else
{
include("user/include/newsession.php");
header("Location:user/index.php");
}
}
?> | 3 |
10,445,865 | 05/04/2012 09:05:10 | 1,374,460 | 05/04/2012 08:26:19 | 1 | 0 | Get remote Windows Registries using Ruby | I wonder if there's some simple methods to get registry information from remote windows machine. I use Win32::Registry::HKEY_LOCAL_MACHINE.open("....") to retrieve registries, but it can only work for local machine. One method is creating a DRb connection between local and remote machine, and then spawn a process on remote machine to call the same ruby code(Win32::Registry...), but it's cumbersome. Are there some simple solutions? Thanks! | ruby | registry | remote | null | null | null | open | Get remote Windows Registries using Ruby
===
I wonder if there's some simple methods to get registry information from remote windows machine. I use Win32::Registry::HKEY_LOCAL_MACHINE.open("....") to retrieve registries, but it can only work for local machine. One method is creating a DRb connection between local and remote machine, and then spawn a process on remote machine to call the same ruby code(Win32::Registry...), but it's cumbersome. Are there some simple solutions? Thanks! | 0 |
1,657,220 | 11/01/2009 13:58:26 | 151,938 | 08/06/2009 17:23:13 | 2 | 0 | Multilingual alert messages in JavaScript | I have a php Web Application Multilingual,
I have a php variable which can tell the current language of the Web Application,
I need to validate user inputs in client side, and error messages are shown with JavaScript alerts
for example if the php language variable is "french", I need the alert as "bonjour"
if the php language variable is "english", I need the alert as "hello"
any ideas
| javascript | multilingual | null | null | null | null | open | Multilingual alert messages in JavaScript
===
I have a php Web Application Multilingual,
I have a php variable which can tell the current language of the Web Application,
I need to validate user inputs in client side, and error messages are shown with JavaScript alerts
for example if the php language variable is "french", I need the alert as "bonjour"
if the php language variable is "english", I need the alert as "hello"
any ideas
| 0 |
5,298,592 | 03/14/2011 12:29:39 | 236,989 | 11/18/2009 14:39:52 | 110 | 3 | Javascript Errors on Page | http://development1.interactone.com/lynx/store/index.php/general-cleaning/demo-product.html
Trying to figure out what is causing the javascript errors on this page with no luck. Also it is preventing the other javascripts from executing, i.e. the tabs not being formatted, add to cart button not working. Any feedback is appreciated, thanks
| javascript | null | null | null | null | null | open | Javascript Errors on Page
===
http://development1.interactone.com/lynx/store/index.php/general-cleaning/demo-product.html
Trying to figure out what is causing the javascript errors on this page with no luck. Also it is preventing the other javascripts from executing, i.e. the tabs not being formatted, add to cart button not working. Any feedback is appreciated, thanks
| 0 |
8,739,514 | 01/05/2012 08:20:02 | 944,124 | 09/14/2011 08:09:38 | 11 | 0 | change image when mouse over an image using #map | I have added database connection to this site and make dynamic.But the design of the website had done before.I just joined the database connection.During this everything is going well.I had added the caresoul jquery.But i can't change the image of menu(i.e. menu,company profile etc.) when mouse hover.I have tried all possible things i can but could not solved it.I saw that the menus are designed with #map.So i can't succeed.Please help me solving this problem .Thank u in advance.....
The link is....
[link of the site][1]
[1]: http://ppr.rj45tech.info
please help...... | php | hover | mouse | null | null | 01/05/2012 15:05:13 | not a real question | change image when mouse over an image using #map
===
I have added database connection to this site and make dynamic.But the design of the website had done before.I just joined the database connection.During this everything is going well.I had added the caresoul jquery.But i can't change the image of menu(i.e. menu,company profile etc.) when mouse hover.I have tried all possible things i can but could not solved it.I saw that the menus are designed with #map.So i can't succeed.Please help me solving this problem .Thank u in advance.....
The link is....
[link of the site][1]
[1]: http://ppr.rj45tech.info
please help...... | 1 |
10,309,399 | 04/25/2012 04:33:28 | 870,505 | 07/30/2011 09:15:25 | 322 | 16 | In Geocouch, how can I get all objects by lon/lat coordinates? | I.e. all objects that contains this coordinates (for polygons) or cross their (for lines)? | couchdb | geospatial | null | null | null | null | open | In Geocouch, how can I get all objects by lon/lat coordinates?
===
I.e. all objects that contains this coordinates (for polygons) or cross their (for lines)? | 0 |
10,437,771 | 05/03/2012 19:04:00 | 882,978 | 08/07/2011 17:26:07 | 75 | 0 | SQL , how not to count 0 values | am trying to find a total vote using this code, I have 12 criteria;
So am adding up the TOTAL for each SHOP_ID and then dividing by 12( the amount of columns used to make total). COUNT(shop_id) finds the number of shops, So for example if I have 2 shop_id inputs one with a total of 0 ( 12 entries of 0) and the other a total of 60 which is divided by the 12 criteria's then divided by shop_id count of 2
(60/12)/2 = 2.5
I would like the result to be 5. Some how not counting the column's with 0 in the division.
$sel = mysql_query("SELECT SUM(comfort + service + ambience + mood + spacious + experience + cleanliness+ price + drinks + food + music + toilets)/(12)/COUNT(shop_id) as total FROM ratings WHERE shop_id = $shop_id");
if(mysql_num_rows($sel) > 0){
while($data = mysql_fetch_assoc($sel)){
$total = $total + $data['total'];
$rows++;
}
$perc = ($total/$rows);
return round($perc,2);
} else {
return '0';
} | php | mysql | query | null | null | null | open | SQL , how not to count 0 values
===
am trying to find a total vote using this code, I have 12 criteria;
So am adding up the TOTAL for each SHOP_ID and then dividing by 12( the amount of columns used to make total). COUNT(shop_id) finds the number of shops, So for example if I have 2 shop_id inputs one with a total of 0 ( 12 entries of 0) and the other a total of 60 which is divided by the 12 criteria's then divided by shop_id count of 2
(60/12)/2 = 2.5
I would like the result to be 5. Some how not counting the column's with 0 in the division.
$sel = mysql_query("SELECT SUM(comfort + service + ambience + mood + spacious + experience + cleanliness+ price + drinks + food + music + toilets)/(12)/COUNT(shop_id) as total FROM ratings WHERE shop_id = $shop_id");
if(mysql_num_rows($sel) > 0){
while($data = mysql_fetch_assoc($sel)){
$total = $total + $data['total'];
$rows++;
}
$perc = ($total/$rows);
return round($perc,2);
} else {
return '0';
} | 0 |
8,045,956 | 11/08/2011 04:27:39 | 908,924 | 08/24/2011 05:03:09 | 6 | 0 | TypeError: 'float' object is not subscriptable When trying to make a histogram in matplotlib | When I try and run the following code
import matplotlib.pyplot as plt
import math
import numpy as np
from numpy.random import normal
masses = []
f = open( 'myfile.txt','r')
f.readline()
for line in f:
if line != ' ':
line = line.strip() # Strips end of line character
columns = line.split() # Splits into coloumn
mass = columns[8] # Column which contains mass values
mass = float(mass)
masses.append(mass)
mass = math.log10(mass)
#print(mass)
#gaussian_numbers = #normal(size=1000)
plt.hist(mass, bins = 50, normed = True)
plt.title("Gaussian Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
I get this error
Traceback (most recent call last):
File "C:\Documents and Settings\Khary\My Documents\Python\HALOMASS_READER_PLOTTER.py", line 23, in <module>
plt.hist(mass, bins = 50, normed = True)
File "C:\Python32\lib\site-packages\matplotlib\pyplot.py", line 2191, in hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, **kwargs)
File "C:\Python32\lib\site-packages\matplotlib\axes.py", line 7606, in hist
if isinstance(x, np.ndarray) or not iterable(x[0]):
TypeError: 'float' object is not subscriptable
Can one not use floats when doing histograms or am I missing something else? Any and all help would be appreciated. Thank you
| python | matplotlib | histogram | null | null | null | open | TypeError: 'float' object is not subscriptable When trying to make a histogram in matplotlib
===
When I try and run the following code
import matplotlib.pyplot as plt
import math
import numpy as np
from numpy.random import normal
masses = []
f = open( 'myfile.txt','r')
f.readline()
for line in f:
if line != ' ':
line = line.strip() # Strips end of line character
columns = line.split() # Splits into coloumn
mass = columns[8] # Column which contains mass values
mass = float(mass)
masses.append(mass)
mass = math.log10(mass)
#print(mass)
#gaussian_numbers = #normal(size=1000)
plt.hist(mass, bins = 50, normed = True)
plt.title("Gaussian Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
I get this error
Traceback (most recent call last):
File "C:\Documents and Settings\Khary\My Documents\Python\HALOMASS_READER_PLOTTER.py", line 23, in <module>
plt.hist(mass, bins = 50, normed = True)
File "C:\Python32\lib\site-packages\matplotlib\pyplot.py", line 2191, in hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, **kwargs)
File "C:\Python32\lib\site-packages\matplotlib\axes.py", line 7606, in hist
if isinstance(x, np.ndarray) or not iterable(x[0]):
TypeError: 'float' object is not subscriptable
Can one not use floats when doing histograms or am I missing something else? Any and all help would be appreciated. Thank you
| 0 |
11,561,861 | 07/19/2012 13:24:52 | 1,537,925 | 07/19/2012 12:48:33 | 1 | 0 | Could I ask the Zygote to tun my application as root? | this is my first question at StockExchange, so I'd like to start by thanking the community for all the most valuable help in all sorts of topics I have found here passively over the past few years.
I have been asking the same question as many others, whether I could obtain superuser privileges in a Java Android application and/or its own JNI. The answer seems to be that it's only possible to run a "su" subshell and command line commands from there, which is neither neat nor very practical. I am willing to accept this resolution but still I'd like to answer this "what if" scenario.
Reading through Android sources near java.com.android.server.am.ActivityManagerService, java.android.os.Process and the dalvik_system_Zygote.cpp file, it seems to me that during application launch, the application record is examined for the UID and (a list of) GID(s) and all these values are passed to the Zygote through a socket. Z subsequently picks the data up and passes it, without further checks, to setuid() posterior to a fork() call. Therefore, it seems to me that if the Activity Manager pathway was altered, a simple passing of --setuid=0 and perhaps --setgid=0 to the Zygote socket should result in running my Activity with the root UID.
It all seems almost too simple, I suspect that something would go wrong along the way. Unfortunately, there's too much code and new stuff for an inexperienced programmer like me to actually go and try. Has anyone gone this way, or is there any obvious reason why this would NOT work? | android | root | null | null | null | null | open | Could I ask the Zygote to tun my application as root?
===
this is my first question at StockExchange, so I'd like to start by thanking the community for all the most valuable help in all sorts of topics I have found here passively over the past few years.
I have been asking the same question as many others, whether I could obtain superuser privileges in a Java Android application and/or its own JNI. The answer seems to be that it's only possible to run a "su" subshell and command line commands from there, which is neither neat nor very practical. I am willing to accept this resolution but still I'd like to answer this "what if" scenario.
Reading through Android sources near java.com.android.server.am.ActivityManagerService, java.android.os.Process and the dalvik_system_Zygote.cpp file, it seems to me that during application launch, the application record is examined for the UID and (a list of) GID(s) and all these values are passed to the Zygote through a socket. Z subsequently picks the data up and passes it, without further checks, to setuid() posterior to a fork() call. Therefore, it seems to me that if the Activity Manager pathway was altered, a simple passing of --setuid=0 and perhaps --setgid=0 to the Zygote socket should result in running my Activity with the root UID.
It all seems almost too simple, I suspect that something would go wrong along the way. Unfortunately, there's too much code and new stuff for an inexperienced programmer like me to actually go and try. Has anyone gone this way, or is there any obvious reason why this would NOT work? | 0 |
5,724,622 | 04/20/2011 01:32:48 | 266,012 | 02/04/2010 08:42:17 | 225 | 0 | how to configure php curl_init function | How exactly do I initiate curl_init function? | php | null | null | null | null | 04/20/2011 02:10:15 | not a real question | how to configure php curl_init function
===
How exactly do I initiate curl_init function? | 1 |
2,036,415 | 01/10/2010 07:21:46 | 9,296 | 09/15/2008 18:19:56 | 1,042 | 125 | Building a Network Appliance Prototype Using a standard PC with Linux and Two NIC's | I am willing to build a prototype of network appliance.
This appliance is suppose to transparently manipulate Ethernet packets. It suppose to have two network interface cards having one card connected to the outside leg (i.e. **eth0**) and the other to the inside leg (i.e. **eth1**).
In a typical network layout as in the attached image, it will be placed between the router and the LAN's switch.
My plans are to write a software that hooks at the kernel driver level and do whatever I need to do to incoming and outgoing packets.
For instance, an "outgoing" packet (at eth1) would be manipulated and passed over to the other NIC (eth0) which then should be transported over to the next hope
My questions are:
1. Is this doable?
2. Those NIC's will have no IP address, is that should be a problem?
Thanks in advance for your answers.
(And no, there is no such device yet in the market, so please, "why reinvent the wheel" style of answers are irrelevant)
![typical network diagram][1]
[1]: http://img163.imageshack.us/img163/1249/stackpost.png | linux-device-driver | network-programming | hardware | startup | null | null | open | Building a Network Appliance Prototype Using a standard PC with Linux and Two NIC's
===
I am willing to build a prototype of network appliance.
This appliance is suppose to transparently manipulate Ethernet packets. It suppose to have two network interface cards having one card connected to the outside leg (i.e. **eth0**) and the other to the inside leg (i.e. **eth1**).
In a typical network layout as in the attached image, it will be placed between the router and the LAN's switch.
My plans are to write a software that hooks at the kernel driver level and do whatever I need to do to incoming and outgoing packets.
For instance, an "outgoing" packet (at eth1) would be manipulated and passed over to the other NIC (eth0) which then should be transported over to the next hope
My questions are:
1. Is this doable?
2. Those NIC's will have no IP address, is that should be a problem?
Thanks in advance for your answers.
(And no, there is no such device yet in the market, so please, "why reinvent the wheel" style of answers are irrelevant)
![typical network diagram][1]
[1]: http://img163.imageshack.us/img163/1249/stackpost.png | 0 |
8,404,510 | 12/06/2011 18:01:07 | 11,173 | 09/16/2008 05:51:30 | 3,949 | 105 | Am I the only one confused by the names Iteratee, Enumerator, and Enumeratee? | I love iteratees as a paradigm for IO, but... seriously what the heck is up with these names?
I get confused enough remembering whether I am a lessor or a lessee, and this is even worse.
I am having trouble developing a relationship with these names. Could someone explain their origin? The definition `data Stream a = Chunks [a] | EOF` is worse, if anything. That isn't a stream, it's just a little piece of one!
It seems like if `Iteratee`s consume things, `Enumerator`s produce them, and `Enumeratee`s do both that names like `Sink`, `Source`, and `Transformer` or `Consumer`, `Producer`, and `Transformer` might be better choices? Is there some reason apart from convention why these names wouldn't fit the concepts well?
Of all the eleventy-seven variations on this theme out there, I'm intrigued by [John Millikin's take on this old Haskell-Cafe thread about a variation which statically eliminates the "divergent iteratee" problem](http://www.opensubscriber.com/message/haskell-cafe@haskell.org/14463096.html) (the problem of an iteratee that returns Continue in response to EOF), but my problems with the names apply to pretty much all of the versions I have yet seen. | haskell | naming | iteratee | null | null | 12/06/2011 18:29:38 | not constructive | Am I the only one confused by the names Iteratee, Enumerator, and Enumeratee?
===
I love iteratees as a paradigm for IO, but... seriously what the heck is up with these names?
I get confused enough remembering whether I am a lessor or a lessee, and this is even worse.
I am having trouble developing a relationship with these names. Could someone explain their origin? The definition `data Stream a = Chunks [a] | EOF` is worse, if anything. That isn't a stream, it's just a little piece of one!
It seems like if `Iteratee`s consume things, `Enumerator`s produce them, and `Enumeratee`s do both that names like `Sink`, `Source`, and `Transformer` or `Consumer`, `Producer`, and `Transformer` might be better choices? Is there some reason apart from convention why these names wouldn't fit the concepts well?
Of all the eleventy-seven variations on this theme out there, I'm intrigued by [John Millikin's take on this old Haskell-Cafe thread about a variation which statically eliminates the "divergent iteratee" problem](http://www.opensubscriber.com/message/haskell-cafe@haskell.org/14463096.html) (the problem of an iteratee that returns Continue in response to EOF), but my problems with the names apply to pretty much all of the versions I have yet seen. | 4 |
10,169,413 | 04/16/2012 06:09:46 | 847,280 | 07/15/2011 22:34:02 | 30 | 0 | can i receive an information another app? | i'm studying iOS programming.
i have a program, i will call this program is aProgram.
and i don't have any source about aProgram, but my iphone was installed this application.
and i make a program called myProgram.
there's a button in myProgram. when i clicked the button, aProgram will be launched.
and yes i use [[UIApplication sharedApplication] openURL: url];
url is parse by json code.
anyway i clicked the button, aProgram is launched.
aProgram has a function, which is write mail.
aProgram's that button is clicked, it sends to server to information
(i heard that would be a json code too)
and my question is
when i click that write mail button in aProgram,
can myProgram be caught any data from aProgram?
if it can, tell me how can i do that. help me | iphone | objective-c | ios | xcode | null | null | open | can i receive an information another app?
===
i'm studying iOS programming.
i have a program, i will call this program is aProgram.
and i don't have any source about aProgram, but my iphone was installed this application.
and i make a program called myProgram.
there's a button in myProgram. when i clicked the button, aProgram will be launched.
and yes i use [[UIApplication sharedApplication] openURL: url];
url is parse by json code.
anyway i clicked the button, aProgram is launched.
aProgram has a function, which is write mail.
aProgram's that button is clicked, it sends to server to information
(i heard that would be a json code too)
and my question is
when i click that write mail button in aProgram,
can myProgram be caught any data from aProgram?
if it can, tell me how can i do that. help me | 0 |
143,939 | 09/27/2008 16:25:27 | 10,651 | 09/16/2008 00:42:34 | 109 | 17 | What's a good IDE to use for Lua? | I've got things minimally working in Scite... and a quick browse tells me that there is an Eclipse plugin and several other standalone editors, in addition to other general purpose editors with Lua capability.
Out of that, what do people recommend? Particularly, what do people who program primarily in Lua like to use? | ide | editor | lua | null | null | 07/16/2012 20:05:36 | not constructive | What's a good IDE to use for Lua?
===
I've got things minimally working in Scite... and a quick browse tells me that there is an Eclipse plugin and several other standalone editors, in addition to other general purpose editors with Lua capability.
Out of that, what do people recommend? Particularly, what do people who program primarily in Lua like to use? | 4 |
5,979,734 | 05/12/2011 14:39:50 | 750,735 | 05/12/2011 14:27:11 | 1 | 0 | Algorithm and Java | how can we build a directed graph representing the adjacency structure of the words, and run BFS on it.
the program should take two file names as arguments. The first is a data file, and the second a test file. The output should be the distances between the words in the test file. For example, here is a sample run:
| algorithm | null | null | null | null | 05/12/2011 14:48:25 | not a real question | Algorithm and Java
===
how can we build a directed graph representing the adjacency structure of the words, and run BFS on it.
the program should take two file names as arguments. The first is a data file, and the second a test file. The output should be the distances between the words in the test file. For example, here is a sample run:
| 1 |
8,420,493 | 12/07/2011 18:26:05 | 981,138 | 10/05/2011 20:14:17 | 3 | 0 | MySql - DROP table 'whatever' if exist ELSE create table 'whatever'? | I simply want to drop the table 'whatever' if it exist and then recreate table 'whatever' in a single query if possible.
DROP TABLE IF EXISTS `whatever` ELSE
CREATE TABLE `whatever`
Any idea ? | mysql | drop | exists | else | create-table | null | open | MySql - DROP table 'whatever' if exist ELSE create table 'whatever'?
===
I simply want to drop the table 'whatever' if it exist and then recreate table 'whatever' in a single query if possible.
DROP TABLE IF EXISTS `whatever` ELSE
CREATE TABLE `whatever`
Any idea ? | 0 |
5,762,248 | 04/23/2011 04:51:01 | 721,428 | 04/23/2011 04:51:01 | 1 | 0 | Newbie here... Question about existing network capabilities in programs like Digital Audio Workstations | I was wondering first) is it possible to develop a network that allows someone to work on one file on two or more separate computers at once, and in real time? And second) what kind of time frame would someone be looking at to program that?
Essentially, I'm doing a marketing planning presentation, and I need to budget a programming project for a hypothetical company.
Thanks! | network-programming | null | null | null | null | 04/27/2011 03:19:15 | off topic | Newbie here... Question about existing network capabilities in programs like Digital Audio Workstations
===
I was wondering first) is it possible to develop a network that allows someone to work on one file on two or more separate computers at once, and in real time? And second) what kind of time frame would someone be looking at to program that?
Essentially, I'm doing a marketing planning presentation, and I need to budget a programming project for a hypothetical company.
Thanks! | 2 |
4,716,116 | 01/17/2011 17:45:39 | 401,912 | 07/26/2010 03:33:57 | 3 | 1 | What is the best file compression of random binary data that you can achieve? | Specifically, what programs are out there and what has the highest compression ratio? I tried Googling it, but it seems experience would trump search results, so I ask. | data | random | binary | compression | null | null | open | What is the best file compression of random binary data that you can achieve?
===
Specifically, what programs are out there and what has the highest compression ratio? I tried Googling it, but it seems experience would trump search results, so I ask. | 0 |
9,042,673 | 01/28/2012 03:18:20 | 1,034,912 | 11/08/2011 03:47:43 | 35 | 1 | Where can I universally store initial setup files for a windows service for deployment? | I am creating a windows service (in C#) which will be deployed to various clients. When the windows service starts, it will look for a setup XML file.
Where can I 'universally' put this setup file?
This location will be hardcoded and must work with various clients. Some may have windowXp, some Windows 7, some windows 2003, Windows 2008R2. The problem with windows service is that when the service starts, it has no idea where the services' exe program is.
Thanks for any advice! | windows | deployment | service | setup | ini | null | open | Where can I universally store initial setup files for a windows service for deployment?
===
I am creating a windows service (in C#) which will be deployed to various clients. When the windows service starts, it will look for a setup XML file.
Where can I 'universally' put this setup file?
This location will be hardcoded and must work with various clients. Some may have windowXp, some Windows 7, some windows 2003, Windows 2008R2. The problem with windows service is that when the service starts, it has no idea where the services' exe program is.
Thanks for any advice! | 0 |
7,607,935 | 09/30/2011 08:40:09 | 968,205 | 09/28/2011 01:59:18 | 1 | 0 | Primefaces Autocomplete still needs Javascript? | Does primefaces autocomplete still needs javascript to work? | autocomplete | jsf-2.0 | primefaces | null | null | 07/11/2012 19:29:23 | not a real question | Primefaces Autocomplete still needs Javascript?
===
Does primefaces autocomplete still needs javascript to work? | 1 |
7,761,514 | 10/13/2011 23:16:45 | 202,294 | 11/04/2009 03:30:08 | 92 | 7 | WordPress PHP code where does it go? | I am new to Wordpress and trying to figure it all out.
The pages and posts are all HTML, but I was told that I can have my own PHP code rather than static HTML.
I created some tables in my WordPress database and I would like to use PHP to query it and create my dynamic data.
How do I do that ? where is the PHP code goes ?
Thanks in advance | php | wordpress | null | null | null | 10/14/2011 00:41:50 | not a real question | WordPress PHP code where does it go?
===
I am new to Wordpress and trying to figure it all out.
The pages and posts are all HTML, but I was told that I can have my own PHP code rather than static HTML.
I created some tables in my WordPress database and I would like to use PHP to query it and create my dynamic data.
How do I do that ? where is the PHP code goes ?
Thanks in advance | 1 |
3,636,635 | 09/03/2010 14:18:13 | 427,390 | 08/22/2010 01:54:20 | 15 | 0 | Help finding a (graduate) paper or project topic! | For a computer security graduate class:
http://pastebin.com/NdA6kGQ6
That is what the professor has stated about the paper/project. I would prefer something more hands on like a project, but for the life of me can't think of something interesting. I am throwing it out there and trying to get some ideas flowing.
Any ideas at all?
I think critical infrastructure protection sounds interesting. RFID security is appealing. I have no idea how I would center a paper around it though.
I can use any ideas or thoughts for paper topics, project ideas etc. I can code in C and willing to put the time in for a nice project. | project | paper | graduate-school | null | null | 09/05/2010 01:05:00 | off topic | Help finding a (graduate) paper or project topic!
===
For a computer security graduate class:
http://pastebin.com/NdA6kGQ6
That is what the professor has stated about the paper/project. I would prefer something more hands on like a project, but for the life of me can't think of something interesting. I am throwing it out there and trying to get some ideas flowing.
Any ideas at all?
I think critical infrastructure protection sounds interesting. RFID security is appealing. I have no idea how I would center a paper around it though.
I can use any ideas or thoughts for paper topics, project ideas etc. I can code in C and willing to put the time in for a nice project. | 2 |
10,682,020 | 05/21/2012 08:43:39 | 1,395,859 | 05/15/2012 10:09:17 | 17 | 1 | Adding new .aspx item in our project through our program? | I have a Tree View in my application. If i add a node(Parent or Child) then the node should be add and corresponding .aspx page should also be added to our project... For example
My tree contains 'Programming' as parent Node and 'c','c++','C#'.. as child node. And one textbox to add more nodes. If i insert 'java' and click add button then that (java) should be added as child node and 'java.aspx' page should be added in our project.
Can we do this?? | c# | asp.net | sql-server-2008 | null | null | null | open | Adding new .aspx item in our project through our program?
===
I have a Tree View in my application. If i add a node(Parent or Child) then the node should be add and corresponding .aspx page should also be added to our project... For example
My tree contains 'Programming' as parent Node and 'c','c++','C#'.. as child node. And one textbox to add more nodes. If i insert 'java' and click add button then that (java) should be added as child node and 'java.aspx' page should be added in our project.
Can we do this?? | 0 |
8,766,814 | 01/07/2012 02:22:10 | 551,190 | 12/22/2010 12:40:42 | 45 | 1 | Efficient C++ for ARM | I will give internal training about C++ on ARM, focusing on programming tips and hints, and I searched some webpages like:
- [Embedded C interview Questions for Embedded Systems Engineers][1]
- [Efficient C for ARM][2]
all of above are mainly for C on ARM, in that I am wondering they apply to C++ as well, say struct padding and etc
can you help me on that, T.H.X
[1]: http://www.quickembeddedtips.com/embedded-c-interview-questions-embedded-systems-engineers
[2]: http://www.davespace.co.uk/arm/efficient-c-for-arm/index.html | c++ | arm | null | null | null | 01/07/2012 04:47:57 | off topic | Efficient C++ for ARM
===
I will give internal training about C++ on ARM, focusing on programming tips and hints, and I searched some webpages like:
- [Embedded C interview Questions for Embedded Systems Engineers][1]
- [Efficient C for ARM][2]
all of above are mainly for C on ARM, in that I am wondering they apply to C++ as well, say struct padding and etc
can you help me on that, T.H.X
[1]: http://www.quickembeddedtips.com/embedded-c-interview-questions-embedded-systems-engineers
[2]: http://www.davespace.co.uk/arm/efficient-c-for-arm/index.html | 2 |
10,076,351 | 04/09/2012 16:29:59 | 885,515 | 08/09/2011 08:24:00 | 141 | 17 | Image Uploader + HTML editor | i need a HTML editor with image uploader for a php site help me to get the best. is there any jquery plugin for this | php | jquery | image-uploading | html-editor | text-formatting | 04/09/2012 16:50:19 | not a real question | Image Uploader + HTML editor
===
i need a HTML editor with image uploader for a php site help me to get the best. is there any jquery plugin for this | 1 |
9,706,044 | 03/14/2012 16:33:28 | 1,269,521 | 03/14/2012 16:18:56 | 1 | 0 | Simple C++ TCP/IP using streams (Windows) | What I need is a solution, that would let me (and my programming contest teamates) use TCP/IP in C++ under Windows in the simplest possible way. Some task will probably require a completely synchronous text communication with the server. The best option would be some DOS command or programme, that would redirect oll in/out communication of the application and send/receive it via TCP, like the Linux netcat:
> cool_proxy 123.122.121.43 1234 abc.exe
And inside the programme:
int query;
cin >> query;
cout << "The answer is " << (query+123);
However, Windows netcat seems to miss that feature... If this ain't possible, some other simple option could help:
Some_cool_sockect scs("123.122.121.42:1234");
scs.connect();
int query;
scs >> query;
scs << "The answer is " << (query+123);
It doesn't need to reach high performances; just simple, fully synchronous half-duplex TCP. I can handle TCP quite fluently in C#, so I could write some kind of a proxy, but maybe this thing already exists :)
| c++ | windows | proxy | stream | netcat | null | open | Simple C++ TCP/IP using streams (Windows)
===
What I need is a solution, that would let me (and my programming contest teamates) use TCP/IP in C++ under Windows in the simplest possible way. Some task will probably require a completely synchronous text communication with the server. The best option would be some DOS command or programme, that would redirect oll in/out communication of the application and send/receive it via TCP, like the Linux netcat:
> cool_proxy 123.122.121.43 1234 abc.exe
And inside the programme:
int query;
cin >> query;
cout << "The answer is " << (query+123);
However, Windows netcat seems to miss that feature... If this ain't possible, some other simple option could help:
Some_cool_sockect scs("123.122.121.42:1234");
scs.connect();
int query;
scs >> query;
scs << "The answer is " << (query+123);
It doesn't need to reach high performances; just simple, fully synchronous half-duplex TCP. I can handle TCP quite fluently in C#, so I could write some kind of a proxy, but maybe this thing already exists :)
| 0 |
11,289,794 | 07/02/2012 08:02:37 | 1,478,501 | 06/24/2012 18:33:18 | 1 | 0 | Debugging project ,Javascript alert pop up | [1]:http:http://a6.sphotos.ak.fbcdn.net/hphotos-ak-ash3/599860_256909517757063_1635978898_n.jpg "tool"
My project application running well, just when debugging project and popup alert. i really no idea to solve this question.? please help..
OS:windows 7
Browser
run code behind=yes | javascript | asp.net | dhtmlx | null | null | 07/02/2012 09:00:16 | not a real question | Debugging project ,Javascript alert pop up
===
[1]:http:http://a6.sphotos.ak.fbcdn.net/hphotos-ak-ash3/599860_256909517757063_1635978898_n.jpg "tool"
My project application running well, just when debugging project and popup alert. i really no idea to solve this question.? please help..
OS:windows 7
Browser
run code behind=yes | 1 |
10,169,524 | 04/16/2012 06:22:01 | 1,238,164 | 02/28/2012 15:06:15 | 48 | 7 | How to force start animation if view out of window | I have a scroll view with several views and only one view can be expanded. When another view gets expanded the already expanded view gets shrunk. But the animation for the not visible item on the screen gets started only when the view gets visible.
So is there a way to force start the animation?
Setting the height for not visible item causes unwanted jumping of scroll Y if the view is on top and view on bottom gets expanded. | android | android-animation | null | null | null | null | open | How to force start animation if view out of window
===
I have a scroll view with several views and only one view can be expanded. When another view gets expanded the already expanded view gets shrunk. But the animation for the not visible item on the screen gets started only when the view gets visible.
So is there a way to force start the animation?
Setting the height for not visible item causes unwanted jumping of scroll Y if the view is on top and view on bottom gets expanded. | 0 |
10,101,124 | 04/11/2012 06:41:50 | 1,278,338 | 02/23/2012 04:37:06 | 191 | 5 | CS5001:Does not have an entry point defined | Why do I get a CS5001: does not have an entry point defined error when compiling? | c# | null | null | null | null | null | open | CS5001:Does not have an entry point defined
===
Why do I get a CS5001: does not have an entry point defined error when compiling? | 0 |
10,231,145 | 04/19/2012 15:11:08 | 221,194 | 11/30/2009 08:24:34 | 1,419 | 60 | Resize UIImage for UIPrintInteractionController | I'm currently working on a possibility to print the content of a view via Airprint.
For this feature I'm creating a UIImage from the view and send it to UIPrintInteractionController.
The problem is that the image is resized to the full resolution of the paper and not it's original size (approx. 300x500px). Does anybody know how to create a proper page from my image.
Here is the code:
/** Create UIImage from UIScrollView**/
-(UIImage*)printScreen{
UIImage* img = nil;
UIGraphicsBeginImageContext(scrollView.contentSize);
{
CGPoint savedContentOffset = scrollView.contentOffset;
CGRect savedFrame = scrollView.frame;
scrollView.contentOffset = CGPointZero;
scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
scrollView.backgroundColor = [UIColor whiteColor];
[scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];
img = UIGraphicsGetImageFromCurrentImageContext();
scrollView.contentOffset = savedContentOffset;
scrollView.frame = savedFrame;
scrollView.backgroundColor = [UIColor clearColor];
}
UIGraphicsEndImageContext();
return img;
}
/** Print view content via AirPrint **/
-(void)doPrint{
if ([UIPrintInteractionController isPrintingAvailable])
{
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
UIImage *image = [(ReservationOverView*)self.view printScreen];
NSData *myData = [NSData dataWithData:UIImagePNGRepresentation(image)];
if(pic && [UIPrintInteractionController canPrintData: myData] ) {
pic.delegate =(id<UIPrintInteractionControllerDelegate>) self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputPhoto;
printInfo.jobName = [NSString stringWithFormat:@"Reservation-%@",self.reservation.reservationID];
printInfo.duplex = UIPrintInfoDuplexNone;
pic.printInfo = printInfo;
pic.showsPageRange = YES;
pic.printingItem = myData;
//pic.delegate = self;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
}
};
[pic presentAnimated:YES completionHandler:completionHandler];
}
}
}
I've tried to resize the image manually, but this does not work properly. | iphone | uiimage | airprint | null | null | null | open | Resize UIImage for UIPrintInteractionController
===
I'm currently working on a possibility to print the content of a view via Airprint.
For this feature I'm creating a UIImage from the view and send it to UIPrintInteractionController.
The problem is that the image is resized to the full resolution of the paper and not it's original size (approx. 300x500px). Does anybody know how to create a proper page from my image.
Here is the code:
/** Create UIImage from UIScrollView**/
-(UIImage*)printScreen{
UIImage* img = nil;
UIGraphicsBeginImageContext(scrollView.contentSize);
{
CGPoint savedContentOffset = scrollView.contentOffset;
CGRect savedFrame = scrollView.frame;
scrollView.contentOffset = CGPointZero;
scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
scrollView.backgroundColor = [UIColor whiteColor];
[scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];
img = UIGraphicsGetImageFromCurrentImageContext();
scrollView.contentOffset = savedContentOffset;
scrollView.frame = savedFrame;
scrollView.backgroundColor = [UIColor clearColor];
}
UIGraphicsEndImageContext();
return img;
}
/** Print view content via AirPrint **/
-(void)doPrint{
if ([UIPrintInteractionController isPrintingAvailable])
{
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
UIImage *image = [(ReservationOverView*)self.view printScreen];
NSData *myData = [NSData dataWithData:UIImagePNGRepresentation(image)];
if(pic && [UIPrintInteractionController canPrintData: myData] ) {
pic.delegate =(id<UIPrintInteractionControllerDelegate>) self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputPhoto;
printInfo.jobName = [NSString stringWithFormat:@"Reservation-%@",self.reservation.reservationID];
printInfo.duplex = UIPrintInfoDuplexNone;
pic.printInfo = printInfo;
pic.showsPageRange = YES;
pic.printingItem = myData;
//pic.delegate = self;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
}
};
[pic presentAnimated:YES completionHandler:completionHandler];
}
}
}
I've tried to resize the image manually, but this does not work properly. | 0 |
6,234,119 | 06/04/2011 01:34:25 | 783,539 | 06/04/2011 01:17:42 | 1 | 0 | VB.Net Replacing Specific Values in a Large Text File | I have some large csv files (1.5gb each) where I need to replace specific values. The method I'm currently using is terribly slow and I'm fairly certain that there should be a way to speed this up but I'm just not experienced enough to know what I should be doing. This is my first post and I tried searching through to find something relevant but didn't come across anything. Any help would be appreciated.
My other thought would be to break the file into chunks so that I can read the entire thing into memory, do all of the replacements there and then output to a consolidated file. I tried this but the way I did it actually ended up seeming slower than my current method.
Thanks!
Sub Main()
Dim fName As String = "2009.csv"
Dim wrtFile As String = "2009.1.csv"
Dim lRead
Dim lwrite As String
Dim strRead As New System.IO.StreamReader(fName)
Dim strWrite As New System.IO.StreamWriter(wrtFile)
Dim bulkWrite As String
bulkWrite = ""
Do While strRead.Peek <> -1
lRead = Split(strRead.ReadLine(), ",")
If lRead(9) = "5MM+" Then lRead(9) = "5000000"
If lRead(9) = "1MM+" Then lRead(9) = "1000000"
lwrite = ""
For i = LBound(lRead) To UBound(lRead)
lwrite = lwrite & lRead(i) & ","
Next
strWrite.WriteLine(lwrite)
Loop
strRead.Close()
strWrite.Close()
End Sub
| vb.net | streamwriter | null | null | null | null | open | VB.Net Replacing Specific Values in a Large Text File
===
I have some large csv files (1.5gb each) where I need to replace specific values. The method I'm currently using is terribly slow and I'm fairly certain that there should be a way to speed this up but I'm just not experienced enough to know what I should be doing. This is my first post and I tried searching through to find something relevant but didn't come across anything. Any help would be appreciated.
My other thought would be to break the file into chunks so that I can read the entire thing into memory, do all of the replacements there and then output to a consolidated file. I tried this but the way I did it actually ended up seeming slower than my current method.
Thanks!
Sub Main()
Dim fName As String = "2009.csv"
Dim wrtFile As String = "2009.1.csv"
Dim lRead
Dim lwrite As String
Dim strRead As New System.IO.StreamReader(fName)
Dim strWrite As New System.IO.StreamWriter(wrtFile)
Dim bulkWrite As String
bulkWrite = ""
Do While strRead.Peek <> -1
lRead = Split(strRead.ReadLine(), ",")
If lRead(9) = "5MM+" Then lRead(9) = "5000000"
If lRead(9) = "1MM+" Then lRead(9) = "1000000"
lwrite = ""
For i = LBound(lRead) To UBound(lRead)
lwrite = lwrite & lRead(i) & ","
Next
strWrite.WriteLine(lwrite)
Loop
strRead.Close()
strWrite.Close()
End Sub
| 0 |
8,929,310 | 01/19/2012 16:08:04 | 831,346 | 07/06/2011 10:18:19 | 15 | 0 | Silverlight for Mac and Is Silverlight dead? | so i have been writing a prototype application in Silverlight for the last 3 months, although I am enjoying the technology and it has been very useful for the current task, I have read and been told from varies sources that the technology could no longer be supported and HTML5 is the way forward? Was just wondering if there was some solid information on this from Microsoft and if so where it could be found? Done some googling and just found blogs with sparse info.
Also if anyone one had any thoughts on the state of the mac version of silverlight? I have run some tests so far and the applications performance is really poor compared to silverlight running on windows.
Thank you for your time.
| silverlight | html5 | null | null | null | 01/19/2012 19:12:26 | not constructive | Silverlight for Mac and Is Silverlight dead?
===
so i have been writing a prototype application in Silverlight for the last 3 months, although I am enjoying the technology and it has been very useful for the current task, I have read and been told from varies sources that the technology could no longer be supported and HTML5 is the way forward? Was just wondering if there was some solid information on this from Microsoft and if so where it could be found? Done some googling and just found blogs with sparse info.
Also if anyone one had any thoughts on the state of the mac version of silverlight? I have run some tests so far and the applications performance is really poor compared to silverlight running on windows.
Thank you for your time.
| 4 |
1,325,829 | 08/25/2009 02:55:38 | 3,834 | 08/31/2008 06:25:52 | 2,373 | 102 | Where is the .net framework error log location | My application exits for no reason, most likely due to errors in the profiler I used because it interferes with all the CLR runtime stuff. The issue is is there any file at any location where .Net framework logs these kind of errors? | .net | error-logging | null | null | null | null | open | Where is the .net framework error log location
===
My application exits for no reason, most likely due to errors in the profiler I used because it interferes with all the CLR runtime stuff. The issue is is there any file at any location where .Net framework logs these kind of errors? | 0 |
7,308,684 | 09/05/2011 13:19:02 | 535,351 | 12/07/2010 21:20:17 | 4 | 0 | Load more cells problem | i use MWFeedParser library to parse xml.
when i change the numberOfRowsInSection to +1 (return [itemsToDisplay count] +1;)
to make the last cell row for the Load more option my app crash in this line:
MWFeedItem *item = [itemsToDisplay objectAtIndex:indexPath.row];
any idea why this happens?
| iphone | xml | parsing | uitableview | uitableviewcell | null | open | Load more cells problem
===
i use MWFeedParser library to parse xml.
when i change the numberOfRowsInSection to +1 (return [itemsToDisplay count] +1;)
to make the last cell row for the Load more option my app crash in this line:
MWFeedItem *item = [itemsToDisplay objectAtIndex:indexPath.row];
any idea why this happens?
| 0 |
3,704,887 | 09/13/2010 22:26:57 | 424,581 | 08/18/2010 22:01:34 | 39 | 2 | NHibernate check for changed to prompt for save | I was wondering if there is any sort of functionality in NHibernate to check if changes have been made to an object sense it has been loaded that would require a write to the DB to save.
I have some other pieces like currently selected elements and so forth that may change but if they do it makes no difference in terms of actual data.
Failing that what is a good way in WPF/C# to check if there are changes that need to be saved so I can prompt the user before they exit.
Thanks | c# | wpf | nhibernate | saving | null | null | open | NHibernate check for changed to prompt for save
===
I was wondering if there is any sort of functionality in NHibernate to check if changes have been made to an object sense it has been loaded that would require a write to the DB to save.
I have some other pieces like currently selected elements and so forth that may change but if they do it makes no difference in terms of actual data.
Failing that what is a good way in WPF/C# to check if there are changes that need to be saved so I can prompt the user before they exit.
Thanks | 0 |
9,435,915 | 02/24/2012 18:17:44 | 945,175 | 09/14/2011 17:19:19 | 58 | 2 | async file upload click | i want to fire file open dialogue of ajax async file upload using javascript
is it possible something like below
Example:
var a= fileupload.click();
above syntax works for asp.net file upload control but not for async file upload.
| asp.net | asp.net-ajax | null | null | null | null | open | async file upload click
===
i want to fire file open dialogue of ajax async file upload using javascript
is it possible something like below
Example:
var a= fileupload.click();
above syntax works for asp.net file upload control but not for async file upload.
| 0 |
7,306,314 | 09/05/2011 09:42:51 | 563,282 | 01/04/2011 23:29:27 | 362 | 13 | jQuery window resize issue | I have a small function that runs on load and window resize.. but the window resize is not working. Pretttty sure that the syntax is correct.. 'cause I've run functions off of window resize before. Can't quite figure it out?
live site here:
http://guit.dhut.ch/
JavaScript:
(function( $ ){
$.fn.respond = function() {
/* initialize function on window load and resize */
$(document).ready(function() {
dimensions();
});
$(window).load(function() {
dimensions();
});
$(window).resize(function() {
dimensions();
});
/* declare variables */
var pic = this
var browserWidth = $(window).width();
var imgRatio = this.width() / this.height()
var availableHeight = ($(window).height() - $('header').height() - $('footer').height() - 80)
var browserRatio = browserWidth / availableHeight
/* set image's height or width depending on the browser window's size */
function dimensions() {
if (browserRatio >= imgRatio ) {
/* if the browser is landscape, set the image's height to fill the available space */
//$('body').css('background', 'green');
pic.height(availableHeight).width('auto');
} else {
/* if the browser is portrait, set the image's width to fill the browser width less margins */
//$('body').css('background', 'red');
pic.width(browserWidth - 40).height('auto');
}
center();
};
/* horizontally center content */
function center() {
pic.css('margin-left', (browserWidth - pic.width())/2);
};
};
})( jQuery ); | jquery | load | resize | window | document-ready | null | open | jQuery window resize issue
===
I have a small function that runs on load and window resize.. but the window resize is not working. Pretttty sure that the syntax is correct.. 'cause I've run functions off of window resize before. Can't quite figure it out?
live site here:
http://guit.dhut.ch/
JavaScript:
(function( $ ){
$.fn.respond = function() {
/* initialize function on window load and resize */
$(document).ready(function() {
dimensions();
});
$(window).load(function() {
dimensions();
});
$(window).resize(function() {
dimensions();
});
/* declare variables */
var pic = this
var browserWidth = $(window).width();
var imgRatio = this.width() / this.height()
var availableHeight = ($(window).height() - $('header').height() - $('footer').height() - 80)
var browserRatio = browserWidth / availableHeight
/* set image's height or width depending on the browser window's size */
function dimensions() {
if (browserRatio >= imgRatio ) {
/* if the browser is landscape, set the image's height to fill the available space */
//$('body').css('background', 'green');
pic.height(availableHeight).width('auto');
} else {
/* if the browser is portrait, set the image's width to fill the browser width less margins */
//$('body').css('background', 'red');
pic.width(browserWidth - 40).height('auto');
}
center();
};
/* horizontally center content */
function center() {
pic.css('margin-left', (browserWidth - pic.width())/2);
};
};
})( jQuery ); | 0 |
8,917,244 | 01/18/2012 20:54:18 | 708,678 | 04/14/2011 20:00:45 | 305 | 0 | Using objects from one class in another class | I have two classes Teacher and Student. I am trying to get teacher to use the class functions in students. The problem I am having is that I need the number of student object being used in Teacher to be random. I thought I figures this out in the constructor, but I had to declare new student object in every function of teacher that I use student. So that just creates a new student object which does me no good. Here is my code
class Teacher
{
private bool absence;
private bool level;
private static int uniqueID = 0;
private ArrayList arrayList = new ArrayList();
private ArrayList arrayList1 = new ArrayList();
private int id = 0;
private int numPages;
private char present;
Random random = new Random();
int randomLevel = random.Next(20, 30);//this line does not work, if I could then I would just use randomLevel in the in the line below for creating my student objects
Student student = new Student();
int maybe;
public Teacher()
{
int randomLevel = random.Next(1, 3);
id = uniqueID;
absence = false;
level = (randomLevel % 2 == 0);
uniqueID++;
randomLevel = random.Next(20, 30);
Student[] student = new Student[randomLevel];
maybe = randomLevel;
for (int i = 0; i < randomLevel; i++)
{
student[i] = new Student();
}
}
and here is a function in teacher that uses student
public void addPages()//Come back need to add specific child
{
int choice = 0;
Console.WriteLine("Enter the student ID");
choice = int.Parse(Console.ReadLine());
Student[] student= new Student[maybe];//If i get rid of this line then how will I choose which student object to use. However this created a new student object and I do not want to do that
student[choice] = new Student();
int number = 0;
if (student[choice].absent())
{
number = student[choice].excused();
}
else
{
Console.WriteLine("How many pages did the student read today? ");
number = int.Parse(Console.ReadLine());
}
student[choice].add(number);
}
Is there a way to get the random to work in the declaration area above the constructor? | c# | homework | class | null | null | null | open | Using objects from one class in another class
===
I have two classes Teacher and Student. I am trying to get teacher to use the class functions in students. The problem I am having is that I need the number of student object being used in Teacher to be random. I thought I figures this out in the constructor, but I had to declare new student object in every function of teacher that I use student. So that just creates a new student object which does me no good. Here is my code
class Teacher
{
private bool absence;
private bool level;
private static int uniqueID = 0;
private ArrayList arrayList = new ArrayList();
private ArrayList arrayList1 = new ArrayList();
private int id = 0;
private int numPages;
private char present;
Random random = new Random();
int randomLevel = random.Next(20, 30);//this line does not work, if I could then I would just use randomLevel in the in the line below for creating my student objects
Student student = new Student();
int maybe;
public Teacher()
{
int randomLevel = random.Next(1, 3);
id = uniqueID;
absence = false;
level = (randomLevel % 2 == 0);
uniqueID++;
randomLevel = random.Next(20, 30);
Student[] student = new Student[randomLevel];
maybe = randomLevel;
for (int i = 0; i < randomLevel; i++)
{
student[i] = new Student();
}
}
and here is a function in teacher that uses student
public void addPages()//Come back need to add specific child
{
int choice = 0;
Console.WriteLine("Enter the student ID");
choice = int.Parse(Console.ReadLine());
Student[] student= new Student[maybe];//If i get rid of this line then how will I choose which student object to use. However this created a new student object and I do not want to do that
student[choice] = new Student();
int number = 0;
if (student[choice].absent())
{
number = student[choice].excused();
}
else
{
Console.WriteLine("How many pages did the student read today? ");
number = int.Parse(Console.ReadLine());
}
student[choice].add(number);
}
Is there a way to get the random to work in the declaration area above the constructor? | 0 |
9,984,109 | 04/02/2012 21:29:00 | 1,122,870 | 12/30/2011 11:48:42 | 26 | 0 | open source projects in c for gsoc | I am just familiar with the the C language and have no prior experience on working on a open source project. I saw some gsoc organizations and their pre-requisities, and it turned out to be quite overwhelming, since most of them relied on other languages and skill sets and since I am a beginner.So, I would like to ask what are some of the open source projects(especially those that take part in gsoc regularly) which depend majorly on C and are beginner friendly.
Also what are some of the things that I can learn in addition to C, which are used a lot in open source projects, i mean to say things like gtk etc which are quite prevalant.
ps:i am not aiming for this year's gsoc, so am in no hurry! | c | open-source | googlecode | null | null | 04/02/2012 21:42:14 | not a real question | open source projects in c for gsoc
===
I am just familiar with the the C language and have no prior experience on working on a open source project. I saw some gsoc organizations and their pre-requisities, and it turned out to be quite overwhelming, since most of them relied on other languages and skill sets and since I am a beginner.So, I would like to ask what are some of the open source projects(especially those that take part in gsoc regularly) which depend majorly on C and are beginner friendly.
Also what are some of the things that I can learn in addition to C, which are used a lot in open source projects, i mean to say things like gtk etc which are quite prevalant.
ps:i am not aiming for this year's gsoc, so am in no hurry! | 1 |
8,174,022 | 11/17/2011 20:43:05 | 373,207 | 06/22/2010 13:19:39 | 35 | 11 | undeclared identifier error with correct include and declaration | I'm creating an application in Qt
i get a compilation error: error C2065: 'callDialog' : undeclared identifier
in my CategoryDialog class, witch look like this:
#include "ui_categorydialog_new.h"
#include "calldialog.h"
#include "questionsdialog.h"
#include "../objects/call.h"
#include "../webservice/dataconnector.h"
#include "../webservice/dataconngetter.h"
namespace Ui {
class CategoryDialog;
}
class CategoryDialog : public QDialog
{
Q_OBJECT
public:
explicit CategoryDialog(QWidget *parent = 0) : QDialog(parent), ui(new Ui::CategoryDialog){
ui->setupUi(this);
}
~CategoryDialog()
{
delete ui;
}
private slots:
void on_btn_back_clicked()
{
ui->btn_back->setEnabled(false);
DataConnGetter::getConnector()->setCallAbort(call->getId()); //get errormessage back and show errormessage when nessesary
QStackedWidget* dialogStack = (QStackedWidget*)this->parentWidget();
CallDialog* callDialog = ((CallDialog*)dialogStack->widget(1)); //TODO 005 replace indexes with enums > more clear
callDialog->updateCalls(false);
dialogStack->setCurrentIndex(1);
ui->btn_back->setEnabled(true);
}
the CallDialog class looks like this
#include <QDialog>
#include <QString>
#include <QList>
#include <QSound>
#include <QtDebug>
#include <QStringList>
#include <QPushButton>
#include <QStackedWidget>
#include <QtAlgorithms>
#include <QLabel>
#include <typeinfo>
#include "ui_calldialog.h"
#include "callbutton.h"
#include "categorydialog_new.h"
#include "../settings/consts.h"
#include "../webservice/dataconnector.h"
#include "../webservice/dataconngetter.h"
#include "../settings/programsettings.h"
#include "../webservice/pollingservice.h"
class PollingService;
namespace Ui {
class CallDialog;
}
class CallDialog : public QDialog
{
Q_OBJECT
public:
// explicit CallDialog(QWidget *parent = 0);
// ~CallDialog();
// void initCalls();
// void updateCalls(bool sound);
// void enablePoller();
explicit CallDialog(QWidget *parent = 0) : QDialog(parent), ui(new Ui::CallDialog)
{
ui->setupUi(this);
installEventFilter(this);
notice the correct include in the CategoryDialog
they do include each others (maybe cyclic dependency problem?)
I tried with forward declaring CallDialog. didn't help.
the files are only the .h files with implementation directly inside
| c++ | compilation | include | declaration | null | null | open | undeclared identifier error with correct include and declaration
===
I'm creating an application in Qt
i get a compilation error: error C2065: 'callDialog' : undeclared identifier
in my CategoryDialog class, witch look like this:
#include "ui_categorydialog_new.h"
#include "calldialog.h"
#include "questionsdialog.h"
#include "../objects/call.h"
#include "../webservice/dataconnector.h"
#include "../webservice/dataconngetter.h"
namespace Ui {
class CategoryDialog;
}
class CategoryDialog : public QDialog
{
Q_OBJECT
public:
explicit CategoryDialog(QWidget *parent = 0) : QDialog(parent), ui(new Ui::CategoryDialog){
ui->setupUi(this);
}
~CategoryDialog()
{
delete ui;
}
private slots:
void on_btn_back_clicked()
{
ui->btn_back->setEnabled(false);
DataConnGetter::getConnector()->setCallAbort(call->getId()); //get errormessage back and show errormessage when nessesary
QStackedWidget* dialogStack = (QStackedWidget*)this->parentWidget();
CallDialog* callDialog = ((CallDialog*)dialogStack->widget(1)); //TODO 005 replace indexes with enums > more clear
callDialog->updateCalls(false);
dialogStack->setCurrentIndex(1);
ui->btn_back->setEnabled(true);
}
the CallDialog class looks like this
#include <QDialog>
#include <QString>
#include <QList>
#include <QSound>
#include <QtDebug>
#include <QStringList>
#include <QPushButton>
#include <QStackedWidget>
#include <QtAlgorithms>
#include <QLabel>
#include <typeinfo>
#include "ui_calldialog.h"
#include "callbutton.h"
#include "categorydialog_new.h"
#include "../settings/consts.h"
#include "../webservice/dataconnector.h"
#include "../webservice/dataconngetter.h"
#include "../settings/programsettings.h"
#include "../webservice/pollingservice.h"
class PollingService;
namespace Ui {
class CallDialog;
}
class CallDialog : public QDialog
{
Q_OBJECT
public:
// explicit CallDialog(QWidget *parent = 0);
// ~CallDialog();
// void initCalls();
// void updateCalls(bool sound);
// void enablePoller();
explicit CallDialog(QWidget *parent = 0) : QDialog(parent), ui(new Ui::CallDialog)
{
ui->setupUi(this);
installEventFilter(this);
notice the correct include in the CategoryDialog
they do include each others (maybe cyclic dependency problem?)
I tried with forward declaring CallDialog. didn't help.
the files are only the .h files with implementation directly inside
| 0 |
10,362,107 | 04/28/2012 09:04:37 | 987,818 | 10/10/2011 13:53:03 | 151 | 1 | ObjC: Best use an NSArray or NSDictionnary for this (zBuffer)? | Say I have a collection of "node" instances. An integer property call zIndex will be used to group them.
What are the pros/cons for storing them in :
1) An array of arrays
2) A dictionary of arrays
In pseudo code, I would describe the expected result like this:
zBuffer[100] = [node1, node 2];
zBuffer[105] = [playerNode, collectable1];
zBuffer[110] = [foreground1, foreground2];
And I'm wondering about what zBuffers should be...
I tried with an NSMutableArray:
[zBuffer objectAtIndex:zOrder]
But it fails if the array contains no data for that index (like out-of-bound exception).
Thanks for your advices!
J | objective-c | arrays | nsarray | hashmap | nsdictionary | null | open | ObjC: Best use an NSArray or NSDictionnary for this (zBuffer)?
===
Say I have a collection of "node" instances. An integer property call zIndex will be used to group them.
What are the pros/cons for storing them in :
1) An array of arrays
2) A dictionary of arrays
In pseudo code, I would describe the expected result like this:
zBuffer[100] = [node1, node 2];
zBuffer[105] = [playerNode, collectable1];
zBuffer[110] = [foreground1, foreground2];
And I'm wondering about what zBuffers should be...
I tried with an NSMutableArray:
[zBuffer objectAtIndex:zOrder]
But it fails if the array contains no data for that index (like out-of-bound exception).
Thanks for your advices!
J | 0 |
7,844,324 | 10/21/2011 02:21:17 | 297,776 | 03/19/2010 23:09:51 | 6,561 | 102 | How to send messages between Akka remote actors? | I want to build a **very** simple chat application which should work without some central server using Akka remote actors.
I basically want to start up one instance of the application with IP address A.
Then I want to start an instance of the application with IP address A _and_ telling it that the remote instance is at IP address B.
How would I set that that up? The Akka documentation usually covers only client/server use cases and even basic things left me completely confused, e. g. where to use `Actor.actorOf` vs. `Actor.register` vs. `Actor.remote`.
My code looks currently like this:
import collection.mutable.{ArrayBuffer, HashSet}
import akka.actor.Actor
sealed trait Event
/** Join tells the peer that there is a new peer and
* requests a list of known peers and messages. */
case class Join(user: String, ipAddress: String) extends Event
/** Join tells the peer that there is a new peer. */
case class Register(user: String, ipAddress: String) extends Event
case class Leave(user: String, ipAddress: String) extends Event
case object GetChatLog extends Event
case object GetPeers extends Event
case class ChatLog(log: Seq[Message]) extends Event
case class Peers(peers: Seq[Peer]) extends Event
case class Message(sender: String, time: Long, message: String) extends Event
class ChatPeer(val name: String, ipAddress: String) extends Actor {
val chat = Actor.remote.actorFor("chat:service", ipAddress, 2552) //This is not what I want...
val messages = ArrayBuffer[Message]()
val peers = HashSet[Peer]()
def join = {
(chat ? Join(name, ipAddress)).as[(Seq[Peer], Seq[Message])]
}
def register = chat ! Register(name, ipAddress)
def leave = chat ! Leave(name, ipAddress)
def send(message: String) = {
val msg = Message(name, System.currentTimeMillis(), message)
messages += msg
chat ! msg
}
def getMessages = (chat ? GetChatLog).as[ChatLog]
.getOrElse(throw new Exception("Couldn't get the chat log from ChatServer"))
def getPeers = (chat ? GetPeers).as[Peers]
.getOrElse(throw new Exception("Couldn't get the peers from ChatServer"))
def receive = {
case msg@Message(from, time, message) =>
println(msg)
messages += msg
case GetChatLog =>
self reply messages
case GetPeers =>
self reply peers
case Join =>
peers += Peer(name, ipAddress)
self reply ((peers, messages))
case Register(user, ipAddress) =>
peers += Peer(user, ipAddress)
case Leave(user, ipAddress) =>
peers -= Peer(user, ipAddress)
}
}
case class Peer(name: String, ipAddress: String)
| scala | networking | messaging | actor | akka | null | open | How to send messages between Akka remote actors?
===
I want to build a **very** simple chat application which should work without some central server using Akka remote actors.
I basically want to start up one instance of the application with IP address A.
Then I want to start an instance of the application with IP address A _and_ telling it that the remote instance is at IP address B.
How would I set that that up? The Akka documentation usually covers only client/server use cases and even basic things left me completely confused, e. g. where to use `Actor.actorOf` vs. `Actor.register` vs. `Actor.remote`.
My code looks currently like this:
import collection.mutable.{ArrayBuffer, HashSet}
import akka.actor.Actor
sealed trait Event
/** Join tells the peer that there is a new peer and
* requests a list of known peers and messages. */
case class Join(user: String, ipAddress: String) extends Event
/** Join tells the peer that there is a new peer. */
case class Register(user: String, ipAddress: String) extends Event
case class Leave(user: String, ipAddress: String) extends Event
case object GetChatLog extends Event
case object GetPeers extends Event
case class ChatLog(log: Seq[Message]) extends Event
case class Peers(peers: Seq[Peer]) extends Event
case class Message(sender: String, time: Long, message: String) extends Event
class ChatPeer(val name: String, ipAddress: String) extends Actor {
val chat = Actor.remote.actorFor("chat:service", ipAddress, 2552) //This is not what I want...
val messages = ArrayBuffer[Message]()
val peers = HashSet[Peer]()
def join = {
(chat ? Join(name, ipAddress)).as[(Seq[Peer], Seq[Message])]
}
def register = chat ! Register(name, ipAddress)
def leave = chat ! Leave(name, ipAddress)
def send(message: String) = {
val msg = Message(name, System.currentTimeMillis(), message)
messages += msg
chat ! msg
}
def getMessages = (chat ? GetChatLog).as[ChatLog]
.getOrElse(throw new Exception("Couldn't get the chat log from ChatServer"))
def getPeers = (chat ? GetPeers).as[Peers]
.getOrElse(throw new Exception("Couldn't get the peers from ChatServer"))
def receive = {
case msg@Message(from, time, message) =>
println(msg)
messages += msg
case GetChatLog =>
self reply messages
case GetPeers =>
self reply peers
case Join =>
peers += Peer(name, ipAddress)
self reply ((peers, messages))
case Register(user, ipAddress) =>
peers += Peer(user, ipAddress)
case Leave(user, ipAddress) =>
peers -= Peer(user, ipAddress)
}
}
case class Peer(name: String, ipAddress: String)
| 0 |
388,059 | 12/23/2008 03:02:39 | 21,632 | 09/24/2008 12:13:26 | 5,645 | 193 | Rosetta Stone: Lambda expressions | How are anonymous functions/lambda expressions expressed in various programming languages? Are the syntax and semantics especially useful or not useful in that language? Are there any programming languages for which true anonymous functions aren't possible?
Like other [Rosetta Stone questions][1], responses should start with the name of the language being demonstrated, and the demo should (hopefully) be interesting to people seeking new languages to learn.
[1]: http://stackoverflow.com/questions/tagged/rosetta-stone | rosetta-stone | lambda | language-agnostic | syntax | null | 07/10/2012 17:59:17 | not constructive | Rosetta Stone: Lambda expressions
===
How are anonymous functions/lambda expressions expressed in various programming languages? Are the syntax and semantics especially useful or not useful in that language? Are there any programming languages for which true anonymous functions aren't possible?
Like other [Rosetta Stone questions][1], responses should start with the name of the language being demonstrated, and the demo should (hopefully) be interesting to people seeking new languages to learn.
[1]: http://stackoverflow.com/questions/tagged/rosetta-stone | 4 |
3,268,528 | 07/16/2010 20:13:14 | 364,712 | 06/11/2010 16:08:06 | 36 | 1 | misunderstoold on TreeSet - my mistake | Well all the questions I have been asking regarding TreeSet, I have wasted your valuable time. I am really sorry because I believe I mis-understood. It doesn't help when you got no one to talk to about this assignment. The real question was related to anagram assignment. In the first question it ask "To the Anagram class add a new public instance method called LetterSet() that takes a string as an argument and returns the characters in the argument as a set. I believe I have done right. But tell me if I am wrong. Then it asks to create empty instance in the constructor which I have done. So far it has not asked to add any letters to the Table. The reason I have used statics in my previous questions because all the examples I have given were based on public static void methodname. Feel free wipe of all the points I have gained, I don't deserve it. Here is what I have done...
public class Anagram
{
private static Set<String> Table = new TreeSet<String>();
public Anagram()
{
super();
this.Table = new TreeSet<String>();
}
public Set<String> LetterSet(String phrase)
{
return anagramTable;
}
}
| java | null | null | null | null | 07/17/2010 01:49:51 | not a real question | misunderstoold on TreeSet - my mistake
===
Well all the questions I have been asking regarding TreeSet, I have wasted your valuable time. I am really sorry because I believe I mis-understood. It doesn't help when you got no one to talk to about this assignment. The real question was related to anagram assignment. In the first question it ask "To the Anagram class add a new public instance method called LetterSet() that takes a string as an argument and returns the characters in the argument as a set. I believe I have done right. But tell me if I am wrong. Then it asks to create empty instance in the constructor which I have done. So far it has not asked to add any letters to the Table. The reason I have used statics in my previous questions because all the examples I have given were based on public static void methodname. Feel free wipe of all the points I have gained, I don't deserve it. Here is what I have done...
public class Anagram
{
private static Set<String> Table = new TreeSet<String>();
public Anagram()
{
super();
this.Table = new TreeSet<String>();
}
public Set<String> LetterSet(String phrase)
{
return anagramTable;
}
}
| 1 |
8,150,906 | 11/16/2011 11:26:56 | 1,034 | 08/11/2008 16:29:38 | 1,862 | 30 | How to set up vertex attributes in OpenGL? | I am trying to create a VBO for a simple rectangle. The GL is set up to use the core profile (GL: 3.2, GLSL: 1.5, inside an NSView in Cocoa).
I spent hours trying to figure out how to draw a simple rectangle in OpenGL. It seems really hard to find any decent tutorials on the core profile. The best I could find was [this tutorial](http://en.wikipedia.org/wiki/Vertex_Buffer_Object).
I adapted it to my needs and came up with the following code:
GLfloat vertices[] = { 1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, -1.0 };
glGenBuffers(1, &vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, vertexVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*3*4, vertices, GL_STATIC_DRAW);
glVertexAttribPointer(VERTEX_POS, 3, GL_FLOAT, GL_FALSE, 0, 0); // VERTEX_POS = 0
glEnableVertexAttribArray(VERTEX_POS); // fails
However, this is throwing an error when calling `glEnableVertexAttribArray`: `INVALID_OPERATION`. [The documentation](http://www.opengl.org/sdk/docs/man/xhtml/glEnableVertexAttribArray.xml) suggests that this error is produced if the aforementioned call is made between a `glBegin` and `glEnd`. This is not the case. I mean, as far as I know, `glBegin` and `glEnd` are not even supported in the core profile.
Thus, I am at a loss. How can I draw this stupid rectangle (or at least initialize it)? | vbo | opengl-3 | null | null | null | null | open | How to set up vertex attributes in OpenGL?
===
I am trying to create a VBO for a simple rectangle. The GL is set up to use the core profile (GL: 3.2, GLSL: 1.5, inside an NSView in Cocoa).
I spent hours trying to figure out how to draw a simple rectangle in OpenGL. It seems really hard to find any decent tutorials on the core profile. The best I could find was [this tutorial](http://en.wikipedia.org/wiki/Vertex_Buffer_Object).
I adapted it to my needs and came up with the following code:
GLfloat vertices[] = { 1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, -1.0 };
glGenBuffers(1, &vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, vertexVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*3*4, vertices, GL_STATIC_DRAW);
glVertexAttribPointer(VERTEX_POS, 3, GL_FLOAT, GL_FALSE, 0, 0); // VERTEX_POS = 0
glEnableVertexAttribArray(VERTEX_POS); // fails
However, this is throwing an error when calling `glEnableVertexAttribArray`: `INVALID_OPERATION`. [The documentation](http://www.opengl.org/sdk/docs/man/xhtml/glEnableVertexAttribArray.xml) suggests that this error is produced if the aforementioned call is made between a `glBegin` and `glEnd`. This is not the case. I mean, as far as I know, `glBegin` and `glEnd` are not even supported in the core profile.
Thus, I am at a loss. How can I draw this stupid rectangle (or at least initialize it)? | 0 |
8,139,113 | 11/15/2011 15:51:43 | 982,636 | 10/06/2011 17:04:37 | 1 | 0 | Need help in choosing a joomla extension | Our website is a "portal of interesting articles".
The articles links are being collected by us (the system members) from all over the web and published with our rating and a possibility for the visitors to rate it also.
All of that is build under a **hierarchical category structure** and tags (tags are the next QA). We are looking for a joomla extension that will able the visitors to add their own "interesting articles" to our articles DB, like we are doing.
No need to add that it needs to be easy to use and be automatically insert to the **site hierarchical category stricture.**
If it possible we would also wish to add a Tagging option.
Meaning that the user will be **obligate** to categorize his article and Tag it to some other categories that he/she sees fit.
We will be gratitude for any advice.
Thanks.
| joomla | joomla1.7 | null | null | null | 11/17/2011 12:05:12 | not constructive | Need help in choosing a joomla extension
===
Our website is a "portal of interesting articles".
The articles links are being collected by us (the system members) from all over the web and published with our rating and a possibility for the visitors to rate it also.
All of that is build under a **hierarchical category structure** and tags (tags are the next QA). We are looking for a joomla extension that will able the visitors to add their own "interesting articles" to our articles DB, like we are doing.
No need to add that it needs to be easy to use and be automatically insert to the **site hierarchical category stricture.**
If it possible we would also wish to add a Tagging option.
Meaning that the user will be **obligate** to categorize his article and Tag it to some other categories that he/she sees fit.
We will be gratitude for any advice.
Thanks.
| 4 |
9,761,982 | 03/18/2012 20:26:09 | 872,020 | 07/31/2011 23:43:23 | 15 | 0 | Twitter Application Authorization | I have a Twitter application that sends out predefined tweets every time I update a certain page, and at the moment it only tweets to my Twitter since it's the only one that has the application authorized. The web app is meant to be linked to multiple Twitters by having the users authorizing it to tweet to their twitter. I would like for the users to be able to click a link and it will authorize the application for them, sending them to a page where it let's them know what the app does and how to unauthorized it. I basically need help creating the authorization script/page. Can someone assist me in doing this (with php)? | php | application | twitter | oauth | authorization | 03/19/2012 12:49:40 | not a real question | Twitter Application Authorization
===
I have a Twitter application that sends out predefined tweets every time I update a certain page, and at the moment it only tweets to my Twitter since it's the only one that has the application authorized. The web app is meant to be linked to multiple Twitters by having the users authorizing it to tweet to their twitter. I would like for the users to be able to click a link and it will authorize the application for them, sending them to a page where it let's them know what the app does and how to unauthorized it. I basically need help creating the authorization script/page. Can someone assist me in doing this (with php)? | 1 |
4,351,240 | 12/04/2010 00:48:01 | 86,252 | 04/02/2009 15:10:26 | 61 | 1 | Using Silvlight, custom EF POCO, custom Validation - leveraging Metadata and its not working in Silverlight 4 | I am using metadata validation for both my MVC and SIlverlight together. However, the classes for silverlight arent working, and I think its due to the MetadataTypeAttribute that doesn't exist for silverlight 4. This seems to be the only thing holding by this part of my project... I am trying to avoid doing everthing custom as I dont like to reinvent the wheel, however the validation classes dont seem to render expected results..:
**Here is my solution for CLR:**
var metadataAttrib = this.GetType().GetCustomAttributes(typeof(MetadataTypeAttribute), true).OfType<MetadataTypeAttribute>().FirstOrDefault();
var buddyClassOrModelClass = metadataAttrib != null ? metadataAttrib.MetadataClassType : this.GetType();
var buddyClassProperties = TypeDescriptor.GetProperties(buddyClassOrModelClass).Cast<PropertyDescriptor>();
var modelClassProperties = TypeDescriptor.GetProperties(this.GetType()).Cast<PropertyDescriptor>();
var brokenRules = from buddyProp in buddyClassProperties
join modelProp in modelClassProperties on buddyProp.Name equals modelProp.Name
from attribute in buddyProp.Attributes.OfType<ValidationAttribute>()
where !attribute.IsValid(modelProp.GetValue(this))
select new BrokenRule() { FieldName = buddyProp.Name, ErrorMessage = attribute.FormatErrorMessage("") };
brokenRulesList = brokenRules.ToList();
... And here is the code for Silverlight
var metadataAttrib = this.GetType().GetCustomAttributes(typeof(MetadataTypeAttribute), true).OfType<MetadataTypeAttribute>().FirstOrDefault();
var buddyClassOrModelClass = metadataAttrib != null ? metadataAttrib.MetadataClassType : this.GetType();
var buddyClassProperties = buddyClassOrModelClass.GetType().GetProperties();
var modelClassProperties = this.GetType().GetProperties();
var validationContext = new ValidationContext(this, null, null);
var validationResults = from buddyProp in buddyClassProperties
join modelProp in modelClassProperties on buddyProp.Name equals modelProp.Name
from attribute in buddyProp.GetCustomAttributes(true).OfType<ValidationAttribute>().Cast<ValidationAttribute>()
where buddyProp.Name == modelProp.Name
select attribute.GetValidationResult(modelProp, validationContext);
brokenRulesList = new List<BrokenRule>();
foreach (ValidationResult vr in validationResults)
{
foreach (string memberName in vr.MemberNames)
brokenRulesList.Add(new BrokenRule() { FieldName = memberName, ErrorMessage = vr.ErrorMessage });
}
... However, the silverlight code is not working.. Here is the test case...
[MetadataType(typeof(UserMetadata))]
public partial class User
{
public partial class UserMetadata
{
[Required(ErrorMessageResourceName = "UserIDValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
public System.Guid ID { get; set; }
public Nullable<int> UID { get; set; }
[Display(Name="UserUsernameLabel", Description="Username", ResourceType=typeof(AppResources))]
[Required(ErrorMessageResourceName = "UserUsernameValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
[StringLength(70, ErrorMessageResourceName="UserUsernameValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
public string Username { get; set; }
[Display(Name="UserFirstNameLabel", Description="First Name", ResourceType=typeof(AppResources))]
[StringLength(90, ErrorMessageResourceName="UserFirstNameValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
public string FirstName { get; set; }
}
I made a class for silverlight which lets it compile, but its not working - as expected..
using System;
using System.Reflection;
namespace System.ComponentModel.DataAnnotations
{
public class MetadataTypeAttribute : Attribute
{
public MetadataTypeAttribute(Type t)
{
MetadataClassType = t;
}
public Type MetadataClassType
{
get;
set;
}
}
}
**Does anyone know how to simply leverage to metadata classes for silverlight? Why the metadatatypeattribute isn't there I dont know. Any suggestions?**
| silverlight | reflection | metadatatype | null | null | null | open | Using Silvlight, custom EF POCO, custom Validation - leveraging Metadata and its not working in Silverlight 4
===
I am using metadata validation for both my MVC and SIlverlight together. However, the classes for silverlight arent working, and I think its due to the MetadataTypeAttribute that doesn't exist for silverlight 4. This seems to be the only thing holding by this part of my project... I am trying to avoid doing everthing custom as I dont like to reinvent the wheel, however the validation classes dont seem to render expected results..:
**Here is my solution for CLR:**
var metadataAttrib = this.GetType().GetCustomAttributes(typeof(MetadataTypeAttribute), true).OfType<MetadataTypeAttribute>().FirstOrDefault();
var buddyClassOrModelClass = metadataAttrib != null ? metadataAttrib.MetadataClassType : this.GetType();
var buddyClassProperties = TypeDescriptor.GetProperties(buddyClassOrModelClass).Cast<PropertyDescriptor>();
var modelClassProperties = TypeDescriptor.GetProperties(this.GetType()).Cast<PropertyDescriptor>();
var brokenRules = from buddyProp in buddyClassProperties
join modelProp in modelClassProperties on buddyProp.Name equals modelProp.Name
from attribute in buddyProp.Attributes.OfType<ValidationAttribute>()
where !attribute.IsValid(modelProp.GetValue(this))
select new BrokenRule() { FieldName = buddyProp.Name, ErrorMessage = attribute.FormatErrorMessage("") };
brokenRulesList = brokenRules.ToList();
... And here is the code for Silverlight
var metadataAttrib = this.GetType().GetCustomAttributes(typeof(MetadataTypeAttribute), true).OfType<MetadataTypeAttribute>().FirstOrDefault();
var buddyClassOrModelClass = metadataAttrib != null ? metadataAttrib.MetadataClassType : this.GetType();
var buddyClassProperties = buddyClassOrModelClass.GetType().GetProperties();
var modelClassProperties = this.GetType().GetProperties();
var validationContext = new ValidationContext(this, null, null);
var validationResults = from buddyProp in buddyClassProperties
join modelProp in modelClassProperties on buddyProp.Name equals modelProp.Name
from attribute in buddyProp.GetCustomAttributes(true).OfType<ValidationAttribute>().Cast<ValidationAttribute>()
where buddyProp.Name == modelProp.Name
select attribute.GetValidationResult(modelProp, validationContext);
brokenRulesList = new List<BrokenRule>();
foreach (ValidationResult vr in validationResults)
{
foreach (string memberName in vr.MemberNames)
brokenRulesList.Add(new BrokenRule() { FieldName = memberName, ErrorMessage = vr.ErrorMessage });
}
... However, the silverlight code is not working.. Here is the test case...
[MetadataType(typeof(UserMetadata))]
public partial class User
{
public partial class UserMetadata
{
[Required(ErrorMessageResourceName = "UserIDValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
public System.Guid ID { get; set; }
public Nullable<int> UID { get; set; }
[Display(Name="UserUsernameLabel", Description="Username", ResourceType=typeof(AppResources))]
[Required(ErrorMessageResourceName = "UserUsernameValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
[StringLength(70, ErrorMessageResourceName="UserUsernameValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
public string Username { get; set; }
[Display(Name="UserFirstNameLabel", Description="First Name", ResourceType=typeof(AppResources))]
[StringLength(90, ErrorMessageResourceName="UserFirstNameValidationMessage", ErrorMessageResourceType = typeof(AppResources))]
public string FirstName { get; set; }
}
I made a class for silverlight which lets it compile, but its not working - as expected..
using System;
using System.Reflection;
namespace System.ComponentModel.DataAnnotations
{
public class MetadataTypeAttribute : Attribute
{
public MetadataTypeAttribute(Type t)
{
MetadataClassType = t;
}
public Type MetadataClassType
{
get;
set;
}
}
}
**Does anyone know how to simply leverage to metadata classes for silverlight? Why the metadatatypeattribute isn't there I dont know. Any suggestions?**
| 0 |
7,934,484 | 10/28/2011 20:22:32 | 293,585 | 03/14/2010 21:44:31 | 172 | 1 | FFMPEG convert flv to mp4 without losing quality | Currently I'm converting .flv flash files to .webm and .mp4 files to be used with an HTML5 video player.
_
I use this ffmpeg command for WEBM: `ffmpeg -i filename.flv -vcodec libvpx -acodec libvorbis filename.webm`
which works great and *the file size stays relatively the same* (imporatant).
_
**For MP4 I'm using the following:** `ffmpeg -i filename.flv -sameq -ar 22050 filename.mp4`
It converts to .mp4 fine and prevents any quality loss but the file size almost triples in size.
**What ffmpeg formula could be used to convert to MP4 without losing too much quality and preventing a much higher file size?** | ffmpeg | mp4 | null | null | null | 11/20/2011 00:51:15 | off topic | FFMPEG convert flv to mp4 without losing quality
===
Currently I'm converting .flv flash files to .webm and .mp4 files to be used with an HTML5 video player.
_
I use this ffmpeg command for WEBM: `ffmpeg -i filename.flv -vcodec libvpx -acodec libvorbis filename.webm`
which works great and *the file size stays relatively the same* (imporatant).
_
**For MP4 I'm using the following:** `ffmpeg -i filename.flv -sameq -ar 22050 filename.mp4`
It converts to .mp4 fine and prevents any quality loss but the file size almost triples in size.
**What ffmpeg formula could be used to convert to MP4 without losing too much quality and preventing a much higher file size?** | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.