Saturday, 31 August 2013

arrays does not null from beginning

arrays does not null from beginning

I'm a beginner in C .... I have a little code:
#include <stdio.h>
#include <string.h>
int main(){
char str1[100];
char str2[100];
char str3[100];
char str4[100];
puts(str1)
puts(str2);
puts(str3);
puts(str4);
return 0;
}
I got result
2
èý(
'Q]wØ„ÃîþÿÿÿÀ"bwd&bw
I don't know why my array does not empty from the begin. And I have to set
first element to "\0" to clear content of array. Can anyone explain for
me. Thank a lot.

listview setItemChecked not working properly

listview setItemChecked not working properly

I am having an issue with a listview populated by a merge cursor. I have a
button in my application to select all the entries in my listview. The
function called when the button is pressed is the following:
private void selectAllEntries() {
int numberOfItemsInList = listView.getCount();
for (int i = 0; i < numberOfItemsInList; i++) {
this.listView.setItemChecked(i, true);
}
}
The problem is that not all the entries get checked in the end. Very weird
indeed. After some testing I noticed that if I have 10 entries in the
mergecursor (5 from cursor a and 5 from cursor b), then if I only do
setItemChecked on the first 5 elements everything works okay (those 5
entries get checked), if I do setItemchecked on the last 5 elements again
everything works okay (the entries from cursor b get checked), but if I do
setItemChecked on elements from both cursors then the maximum number of
elements getting checked is the number of elements in cursor a (5 in our
example), with an offset of (number of items I wanted to set - number of
items in cursor a). I'll write down a couple of examples as this is a very
weird behaviour.
Example 1:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, unchecked)
element 3 (from cursor a, unchecked)
element 4 (from cursor a, unchecked)
element 5 (from cursor b, unchecked)
element 6 (from cursor b, unchecked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
setItemChecked(0,true);
setItemChecked(1,true);
setItemChecked(2,true);
setItemChecked(3,true);
setItemChecked(4,true);
Results:
element 0 (from cursor a, checked)
element 1 (from cursor a, checked)
element 2 (from cursor a, checked)
element 3 (from cursor a, checked)
element 4 (from cursor a, checked)
element 5 (from cursor b, unchecked)
element 6 (from cursor b, unchecked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
Example 2:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, unchecked)
element 3 (from cursor a, unchecked)
element 4 (from cursor a, unchecked)
element 5 (from cursor b, unchecked)
element 6 (from cursor b, unchecked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
setItemChecked(5,true);
setItemChecked(6,true);
setItemChecked(7,true);
setItemChecked(8,true);
setItemChecked(9,true);
results:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, unchecked)
element 3 (from cursor a, unchecked)
element 4 (from cursor a, unchecked)
element 5 (from cursor b, checked)
element 6 (from cursor b, checked)
element 7 (from cursor b, checked)
element 8 (from cursor b, checked)
element 9 (from cursor b, checked)
Example 3:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, unchecked)
element 3 (from cursor a, unchecked)
element 4 (from cursor a, unchecked)
element 5 (from cursor b, unchecked)
element 6 (from cursor b, unchecked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
setItemChecked(0,true);
setItemChecked(1,true);
setItemChecked(2,true);
setItemChecked(3,true);
setItemChecked(4,true);
setItemChecked(5,true);
results in
element 0 (from cursor a, unchecked)
element 1 (from cursor a, checked)
element 2 (from cursor a, checked)
element 3 (from cursor a, checked)
element 4 (from cursor a, checked)
element 5 (from cursor b, checked)
element 6 (from cursor b, unchecked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
Example 4:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, unchecked)
element 3 (from cursor a, unchecked)
element 4 (from cursor a, unchecked)
element 5 (from cursor b, unchecked)
element 6 (from cursor b, unchecked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
setItemChecked(0,true);
setItemChecked(1,true);
setItemChecked(2,true);
setItemChecked(3,true);
setItemChecked(4,true);
setItemChecked(5,true);
setItemChecked(6,true);
results:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, checked)
element 3 (from cursor a, checked)
element 4 (from cursor a, checked)
element 5 (from cursor b, checked)
element 6 (from cursor b, checked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
Example 5:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, unchecked)
element 3 (from cursor a, unchecked)
element 4 (from cursor a, unchecked)
element 5 (from cursor b, unchecked)
element 6 (from cursor b, unchecked)
element 7 (from cursor b, unchecked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
setItemChecked(0,true);
setItemChecked(1,true);
setItemChecked(2,true);
setItemChecked(3,true);
setItemChecked(4,true);
setItemChecked(5,true);
setItemChecked(6,true);
setItemChecked(7,true);
results:
element 0 (from cursor a, unchecked)
element 1 (from cursor a, unchecked)
element 2 (from cursor a, unchecked)
element 3 (from cursor a, checked)
element 4 (from cursor a, checked)
element 5 (from cursor b, checked)
element 6 (from cursor b, checked)
element 7 (from cursor b, checked)
element 8 (from cursor b, unchecked)
element 9 (from cursor b, unchecked)
I am using the
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
and
notifyDataSetChanged()
doesn't help either. Any help ?
As a side-note, the
listView.getCount();
always returns the correct number of entries in the view

ExtJS Panel item listener of click event only fires once

ExtJS Panel item listener of click event only fires once

the select listener is only firing once.Than returns and appended property
of firing: false on the second click. How can I prevent this from
happening?
xtype: 'combo',
store: ds,
displayField: 'title',
typeAhead: false,
hideLabel: true,
hideTrigger:true,
anchor: '100%',
minChars: 1,
listConfig: {
loadingText: 'Searching...',
emptyText: 'No matching buildings found.',
// Custom rendering template for each item
getInnerTpl: function() {
return '<div class="search-item">{name}</div>';
}
},
pageSize: 10,
// override default onSelect to do redirect
listeners: {
'select': function(combo, selection) {
console.log('you there?');
var building = selection[0];
if (building) {
retrieveBuildingInfo(Ext.String.format(env_url +
'building.php?id={0}', building.get('id')));
}
},
'expand': function() {
Ext.Msg.alert("test","do you see me");// this
alert never show, when the combo expanded
console.log(this.events.select);
}
}

open source query language with correlated UPDATEs, multiple TABLE UPDATEs by VIEW,

open source query language with correlated UPDATEs, multiple TABLE UPDATEs
by VIEW,

websocket++ (and of course other supporting libs) has provided lightning
fast performance for the little guy.
I now cache data in the application rather than the database (accident),
and it has made me value the database much more.
Before websockets with persistent memory, I thought lag would be best
addressed via nosql; now, I've gone rdbms crazy since users are receiving
new recorded information from the custom cache after it's successfully
written, the application requires human instead of automated interaction
therefore no requirement for ~0us lag, and users otherwiseSELECTing have
to either phantom read or wait for a serialized TRANSACTION to finish. In
other words, I can wait for the database to perform its operations to
maintain acidity.
However, MySQL doesn't allow a TABLE to be UPDATEd with a correlated
subquery. I can use a TEMPTABLE or another TABLE with a FOREIGN, but
that's overkill and/or slow. Also, I've been spoiled by jQuery and crave
1-liners.
MySQL also doesn't allow multiple TABLEs to be UPDATEd through a VIEW.
This is more of a 1-liner issue with a dash of productivity.
Does a query language that does this exist? If so, is there a MySQL plugin
that does this?

Ember.js pushState router takeover Laravel route

Ember.js pushState router takeover Laravel route

I'm developing a Laravel/Ember.js app where Laravel serves a general role
of a backend framework and RESTful data supplier and Ember.js partially
for the client side.
So far it works fine. However I want Ember.js to take control for some of
the sub-urls.
Say I have /members route in Laravel which serves Ember app and I want
sub-consequent URL to take advantage of pushState w/ Ember like so:
/members/add, /members/edit/1 etc.. instead of /members#/add,
/members#/edit/1
With Ember this is easily achieved:
App.Router.reopen({
location: 'history', //instead of 'hash'
rootURL: '/members'
})
and it works fine when I click on the links.
However, when I refresh the page Laravel router kicks in with .htaccess
which tries to serve every url through laravel's index.php in public
folder. Here's Laravel original .htaccess file:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I'm no expert in Apache URL rewriting, so what I need to do is tell
.htaccess to rewrite everything that follows /members (/members/add,
/members/view etc..) back to /members route so Ember.js would take over
and redirect appropriately.
I was trying to do something like this, but it didn't work:
<IfModule mod_rewrite.c>
Options -MultiViews
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_URI} /members
RewriteRule (.*) members
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Any help on this topic of url rewriting is appreciated. Thanks!

how to create action url for hyperlink in liferay?

how to create action url for hyperlink in liferay?

i have a requirement that when i click on hyperlink i will send one
parameter course id it has to go to action method in portlet class.then i
need to display the success and as well as failure message on after
operation done on to browser!
public void DeleteCourses(ActionRequest request,ActionResponse response)
throws IOException,PortletException
{
String cid=request.getParameter("courseId");
long courseId = Long.parseLong(cid);
try {
CourseLocalServiceUtil.deleteCourse(courseId);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
can any one tell me how to create action url for hyperlink?

Friday, 30 August 2013

Is there any tool to translate Lisp code into Python?

Is there any tool to translate Lisp code into Python?

Because I want to use Lisp's syntax and Python's libraries.
Maybe some tools like Parenscript but generates Python code instead of
Javascript.

Thursday, 29 August 2013

Why use setTimeout in deferred

Why use setTimeout in deferred

I tried to understand of how deferred works,so in all of them they use
setTimeout.
this.callbacks;// array of functions reference
this.callbacks.forEach(function(callback){
window.setTimeout(function(){
callback(data);
},0);
});
one example from this questions that use setTimeout
resolve: function (data) {
this.promise.okCallbacks.forEach(function(callback) {
window.setTimeout(function () {
callback(data)
}, 0);
});
},
What is the different between calling functions in loop by setTimeout than
callback(); or callback.call();

Wednesday, 28 August 2013

Invalid operands for binary and

Invalid operands for binary and

I have this "assembly" file (containing only directives)S
// declare protected region as somewhere within the stack
.equiv prot_start, $stack_top & 0xFFFFFF00 - 0x1400
.equiv prot_end, $stack_top & 0xFFFFFF00 - 0x0C00
Combined with this linker script:
SECTIONS {
"$stack_top" = 0x10000;
}
Assembling produces this output
file.s: Assembler messages:
file.s: Error: invalid operands (*UND* and *ABS* sections) for `&' when
setting `prot_start'
file.s: Error: invalid operands (*UND* and *ABS* sections) for `&' when
setting `prot_end'
How can I make this work?

Discount on the product?

Discount on the product?

I have multidimensional array:
$products = array(
array(
'id' => 'sku_123ABC',
'qty' => 1,
'price' => 39.95,
'name' => 'T-Shirt',
),
array(
'id' => 'sku_567ZYX',
'qty' => 1,
'price' => 9.95,
'name' => 'Coffee Mug'
),
array(
'id' => 'sku_965QRS',
'qty' => 1,
'price' => 29.95,
'name' => 'Shot Glass'
)
);
I know how to count total price of products, but what i need is discount,
to look like this way
Any 2 products 10% discount
Any 3 products 20% discount
5 + products 30%discount
The problem I have is that i know how to count numbers of array members,
and i have qty i know that too, but i know how to do that ony counting by
qty or array members? Is theere some solution to apply this discounts on
$products array and display total price

Socks proxy in android

Socks proxy in android

How to Connect SOCKS Proxy connection in android emulator, I am able to
connect successfully SOCKS Proxy Server on system browser but it not work
in emulator, when using System network setting. I have tried
System.setProperty("socksProxyHost", proxyHost);
System.setProperty("socksProxyPort", port);
and also
SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
Proxy httpProxy = new Proxy(Proxy.Type.SOCKS, addr);urlConn =
url.openConnection(httpProxy);
but Falied. I want to connect and consume SOCKS Proxy connection & Web
Service in my App on Device.Thanks in advance.

How to display subscript text in UILabel ios6?

How to display subscript text in UILabel ios6?

I want to display subscript text and superscript text in UILabel. However
I meet a problem. Text is not display full text in Label. It's difficult
to see it. Can you help me? Here is problem: Link image

It is posible to add string with byte?

It is posible to add string with byte?

How to append string and byte array?
String array="$MT!BOOTLOADER";
Byte[] hexdecimal={0x01,0x05,0x0036};

Tuesday, 27 August 2013

Remove an element correctly in GridBagLayout

Remove an element correctly in GridBagLayout

jPanel1 = new JPanel();
GridBagLayout layout = new GridBagLayout();
jPanel1.setLayout(layout);
GridBagConstraints gbc = new GridBagConstraints();
filler = new JLabel();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 1;
gbc.weighty = 1;
jPanel1.add(filler, gbc);
Im trying to remove by doing jPanel1.remove(filler), and placing a new
JLabel in that position after that, but is clearly not working. What am i
doing wrong?
Thanks!

Fine Uploader only works for a single batch of files

Fine Uploader only works for a single batch of files

My Fine Uploader implementation - using the core mode and jQuery - works
fine until I try to upload a second batch of files.
When the first batch of files have been uploaded (successfully), I can
click the button to add files and get the dialog to select files. However,
after I confirm the file(s) selection nothing happens.
This bit of code in the complete handler is causing the trouble:
$('#attachments-upload').button('reset'); // Bootstrap stateful button
#attachments-upload is the id of the button which is set as the button:
option as well:
$('#attachments-list').fineUploader({
uploaderType: 'basic',
button: $(#attachments-upload),
[...]
What's the issue here?

Unix text streams to serve as message queues

Unix text streams to serve as message queues

The UNIX philosophy suggests we built a lot of simple programs that do one
thing well and that we do them with text streams. That is, the standard
input/output channels are sufficient means of messaging.
Console programs cannot only be piped together, they can also be directed
to a file. In doing this, you can essentially queue up messages (text in
files) for later processing. This seems to follow a similar model to
message queues but without all the sophistication.
Richard P. Gabriel suggests that a key advantage of Unix was that it
embodied a design philosophy he termed "worse is better", in which
simplicity of both the interface and the implementation are more important
than any other attributes of the system—including correctness,
consistency, and completeness.
From my perspective, text streams provide about as simple a channel of
communication as possible. This would seem to follow the worse-is-better
philosophy. Couldn't we thus use console applications and files written to
the file system as a poor man's message queue? And if so, has anyone
successfully taken and preferred this approach? I am simply wondering how
practical/feasible it is to substitute text stream processing for message
queues.

Url Blocking SMF Mod (mine) JQuery: .val() doesn't work fine

Url Blocking SMF Mod (mine) JQuery: .val() doesn't work fine

Well, I have this code:
//Url-Block
echo '<script type="text/javascript">
function logged_in() {
return $(\'#userStatus\').val() == \'User\' ? true : false;
}
$(document).ready(function() {
if(!logged_in()) {
$("#url-lock").html("<span style="color:red;font-weight:bold;">[Sólo
los usuarios pueden ver este contenido. <a href="' . $scripturl .
'?action=register">Regístrate</a> o <a href="' . $scripturl .
'?action=login">loguéate</a> para ver dicho
contenido.]</span>").removeAttr("href").wrap("<strong></strong>");
}
});
</script>';
That makes that the guests can't see any link that have [url-lock] bbc
tag... But idk why it doesn't work...
#url-lock works well...
#userStatus too...
So.. Jquery is bad coded, that can I do? I have never programmed in Jquery ;(
The error is here:
function logged_in() {
return $(\'#userStatus\').val() == \'User\' ? true : false;
}
Idk, how to do that it works... :/
Sorry, and thank you!

Changing WooCommerce Display Price Based on User Role & Category

Changing WooCommerce Display Price Based on User Role & Category

I'm looking to display a different price based on a user role (wholesaler,
dealer, etc) AND based on the category.
There's a dynamic pricing plugin that displays these discounts once an
item is added to the cart, but not on the page itself.
Is there a way to use a filter or action to check for the user level,
check the item's category and then change the price dynamically?

Monday, 26 August 2013

Hover to solid background?

Hover to solid background?

I am trying to achieve this effect on my website and am stumped on how to
do it. My goal is to have an image that when you mouse over it a solid
color (with like an opacity of .8) and an icon(and/or text) are displayed
on top. Note: My images are also set up to be responsive, so I'm not sure
if this will create a problem or not. EXAMPLE>>If you click the link
below, and then the computer on the left, and then scroll to the bottom
where there are 9 circles that have hover effects which is similar to my
goal.
http://themeforest.net/item/strand-one-page-parallax-bootstrap-template/full_screen_preview/5445825
Any direction, tutorials, advice would be very much appreciated!

Concatenate a string with curdate in mysql

Concatenate a string with curdate in mysql

pI have the following query: /p precodeINSERT INTO insertlog (Inforamtion)
VALUES ( concat(Row Was Inserted,curdate()); /code/pre pMySQL is returning
an error, but I cannot figure out why. My google searches do not show
examples on how to perform something like this /p

Is XML-RPC safe

Is XML-RPC safe

This is my first question here, so I hope it matches the requirements.
I have a set of web applications on servers, and an end-user has asked us
to enable XML-RPC. The "remote procedure call" portion of XML-RPC scares
me a bit. Are my concerns valid (i.e. is it safe to enable/use XML-RPC)?
From my searches, I can only find information specific to Wordpress
(apparently they deemed XML-RPC safe enough to enable it by default since
their version 3.5).
Thanks!

Angularjs on click refresh view to get latest json data.

Angularjs on click refresh view to get latest json data.

I am using Angularjs and I need to refresh a view only not whole page. How
can i do this using Angularjs.
I have used $http service to get a data from json file and that's why I
need to refresh view to get latest values from json.
Currently if I changed any value in json file it's not reflecting on a
page when I refresh page. every time I need to clear cache to view latest
value.

Where can I find Java prism render possible options and documentation?

Where can I find Java prism render possible options and documentation?

I had problem with my application with Canvas generation ( I'm using
JavaFx ). Setting this option helped:
-Dprism.order=j2d
The thing that is problem to is that I cann't find any documentation for
prism ( Dprism ). Second problem is that I would like to set up this
option via config file.
Properties props = System.getProperties();
props.setProperty("com.sun.prism.order", "j2d");
Code above dosen't work for me.

Sunday, 25 August 2013

Prove that $z_n\rightarrow z=r(cos(A)+isin(A))$ iff $r_n\rightarrow r$ and $A_n\rightarrow A$

Prove that $z_n\rightarrow z=r(cos(A)+isin(A))$ iff $r_n\rightarrow r$ and
$A_n\rightarrow A$

$z_n=r_n(cos(A_n)+isin(A_n))$ and $z=r(cos(A)+isin(A))$
Prove that $z_n\rightarrow z=r(cos(A)+isin(A))$ as $n\rightarrow \infty$
if and only if $r_n\rightarrow r$ and $A_n\rightarrow A$ as $n\rightarrow
\infty$
This is a question I just thought of myself. I was trying to use
$\epsilon$ and $\delta$ definition of the limit but was hard to do.

Closure of interior of closed set

Closure of interior of closed set

If $D$ is a closed set, what is the relation in general between the set
$D$ and the closure of $\operatorname{Int}D$?
We know that $\operatorname{Int}D\subseteq D$, so
$\overline{\operatorname{Int}D}\subseteq \overline{D}$, but since $D$ is
closed, we have $\overline{D}=D$, so that
$\overline{\operatorname{Int}D}\subseteq D$.
Now, is it true as well that $D\subseteq \overline{\operatorname{Int}D}$?
I can't seem to prove it, or give an example of $D$ such that this doesn't
hold.

Writing each line from Textarea in a single document

Writing each line from Textarea in a single document

I want write mulitple lines from a textarea to a mongodb database:
First Line
Second Line
Third Line
etc.
Each line should be written in a single document.
So what I first figured out that I might use the gsub-function for
separating the lines and after that I could write them with an each do -
loop to the database.
And this point I got stuck.
Thanks in Advance for helping

[ Family ] Open Question : My mom always yells,curses and blackmails?

[ Family ] Open Question : My mom always yells,curses and blackmails?

She's always like that? She always curses the worst things to me i can't
even count how many per day and she's always yelling,not a day without her
yelling and like blackmails like she has to go to school for me to arrange
with council or something and she says that this or i won't go a million
times and at end she almost never even keeps her promise? why? i don't
understand? by the way i don't have father so is that it but my friend
also hasn't got father and her mom is really nice while my gossips lies
and things too? i don't understand why :(((????? she's always like "Me me
me me me me me me me me" when i broke my arm and leg she was like "mine is
broken too!!! la la la la" why? i just need some explanation what do i do
about it? when she curses i lose it and start kicking her i didn't do it
before but i just can't stand it?

Cannot mount any file system/USB stick with Nautilus side bar after changing UID of my user

Cannot mount any file system/USB stick with Nautilus side bar after
changing UID of my user

There are a lot of answers in here that describe how to change a user's
UID. This is necessary to match it to my NAS and to ease NFS mounts and
permissions.
BUT: I had to do this on Ubuntu 13.04 and after I changed my user's UID, I
cannot mount ANY devices anymore in Nautilus side bar. In Nautilus when I
click on a different file system that is not mounted or insert a USB
stick, I get the error message: (in German)
"Dieser Ort konnte nicht angezeigt werden" and then (I translate): "You
don't have the required permissions to see the contents of
ad390f97.........."
This is a DIRECT implication I got right after changing the UID and
rebooting. So there must be something wrong in Nautilus that does not like
changing of UIDs!
What is that? I need to get this fixed!

Saturday, 24 August 2013

Node access based on condition

Node access based on condition

I'm adding an event list to a website and I want to limit what anonymous
users see based on a field value, a checkbox "Private event". If the
checkbox is marked then only a subset of the fields for the given event
are shown. Furthermore, after a year of the event I want all fields to
become visible to anonymous users. I took a look at the Access Control
module but couldn't find a way to have this conditional type of access to
fields. Is there another module that I could use?

Binomial Theorem: An Inductive Proof

Binomial Theorem: An Inductive Proof

I'm asked to use the fact that
$\begin{pmatrix}n\\r\end{pmatrix}+\begin{pmatrix}n\\r-1\end{pmatrix}=\begin{pmatrix}n+1\\r\end{pmatrix}$
to show, by induction, that
$$(a+b)^n=\begin{pmatrix}n\\0\end{pmatrix}a^n+\begin{pmatrix}n\\1\end{pmatrix}a^{n-1}b+\cdots+\begin{pmatrix}n\\r\end{pmatrix}a^{n-r}b^r+\begin{pmatrix}n\\n\end{pmatrix}b^n,$$
but I'm not sure where to start. I suspect that for the inductive step I
multiply both sides by $(a+b)$, but from there I'm not sure where to go.

I have to use "sudo" for almost every git / rails command or I get permission denied. How can I fix that?

I have to use "sudo" for almost every git / rails command or I get
permission denied. How can I fix that?

I'm learning rails and as I go through the process of creating the default
app and connecting to github etc. I am forced to use sudo otherwise I get
permission denied errors. I am the admin, I am the only user account on my
computer.
Did I set something up incorrectly?
I even had this problem way back when trying to create/edit .bash_profile
Thanks for your help!

Using GSON to parse a JSON array

Using GSON to parse a JSON array

I have a JSON file like this:
[{ "number" : "3",
"title" : "hello_world",
},
{ "number" : "2",
"title" : "hello_world",
}]
Before when files had a root element i would use:
Wrapper w = gson.ftomJson(JSONSTRING, Wrapper.class);
code but i cant think how to code the Wrapper class as the root element is
an array
I have tried using:
Wrapper[] wrapper = gson.fromJson(jsonLine, Wrapper[].class);
with:
public class Wrapper{
String number;
String title;
}
But havent had any luck. How else can i read this using this method?
P.S i have got this to work using:
JsonArray entries = (JsonArray) new JsonParser().parse(jsonLine);
String title = ((JsonObject)entries.get(0)).get("title");
but i would prefer to know how to do it (if possible) with both methods

Find and replace from Terminal and write to a new file with the replaced values

Find and replace from Terminal and write to a new file with the replaced
values

I have a file template.jou that has the following format:
/codeline1
/codeline2
/var = var
/codeline3
Now I want to replace the var part with different values like A, B and C
and then write the contents of template.jou with the replaced value to a
new file.
I tried the following:
sed -n 's/var/A/gpw A.jou' template.jou
But this only printed the pattern matched line (i.e. /var = A) to the new
file A.jou where I want the full file like this:
/codeline1
/codeline2
/var = A
/codeline3
I've also tried:
sed -i '.bak' 's/var/A/g' template.jou
This replaced the template.jou file with new contents, but I want it to
change filename as well such that the new file is called A.jou.

Friday, 23 August 2013

Facebook app payments stop working after changing SSL certificate

Facebook app payments stop working after changing SSL certificate

My SSL certificate is due to expire in 10 days. I'm using AWS and a load
balancer that forwards HTTPS (port 443) to port 80 on my application
servers.
I uploaded a new certificate to AWS, and I can switch freely between them.
When I visit a test page, I get no problem with either certificate:
https://lb1.cloudstonegame.com/test.html
However, when I enable the new certificate on my live servers, the
Facebook payment window in my application
(https://apps.facebook.com/cloudstone/) stops working. I get this error:
The app you are using is not responding. Please try again later.
On my staging server, everything works fine with the both certificates
using test payments. The same code is running on both staging and live.
Any ideas? Is there some cache on Facebook that I can try to flush? I'm at
a loss.

Hard to find failing tests when using NUnit SouceValueAttribute

Hard to find failing tests when using NUnit SouceValueAttribute

Using NUnit SourceValue attribute when I run the tests bellow I see
Test(TestSpec) (image bellow).

When a test fail it is dificult to know which one failed.
Is there a way to get NUnit to dump which value it is using for each of
the tests?
class C
{
public static int DoIt(int i)
{
return i * i;
}
}
class TestClass
{
public void Test([SourceValue("TestData")] TestSpec testSpec)
{
Assert.Equals(testSpec.Expectation, C.DoIt(testSpec.Value));
}
public static IEnumerable<TestSpec> TestData()
{
return new []
{
new TestSpec(1, 1),
new TestSpec(2, 4),
new TestSpec(3, 9),
new TestSpec(4, 16),
};
}
}
class TestSpec
{
public TestSpec(int expectation, int value)
{
Expectation = expectation;
Value = value;
}
public int Expectation { get; set; }
public int Value { get; set; }
}

How to compile a C# program on OSX?

How to compile a C# program on OSX?

Let's start with level noob because that's where I'm at
// Hello.cs
public class Hello
{
public static void Main()
{
System.Console.WriteLine("OM NOM NOM NOM");
}
}
Guys, I'm on hungry, but I'm on a Mac using OSX. I'm not unfamiliar with
computing machines but I am curious if it's possible to compile this bit
of code using OSX.
Disclaimer I don't want a big fat IDE. I'm basically looking for the
equivalent of
$ gcc hello.c -o hello
$ ./hello
OM NOM NOM NOM
$
But, you know, for C#.



If you recommend a package (e.g., mono) please demonstrate usage! I'm not
marking an answer as accepted until I see a compiled/running Hello World
program.

Makeglossaries breaks down perl

Makeglossaries breaks down perl

Sometimes - I can't reproduce it until know but today, I can't get rid of
it - makeglossaries breaks down here. The problem seems to be perl.exe. I
hope this belongs here. If not, I will migrate to another StackExchange.
I've got a Win XP 64bit SP2 system. I have got Strawberry perl installed
but when running makeglossaries, it uses some perl.exe situated in my Git
folder (D:\Program Files (x86)\Git\bin\perl.exe). The PATH to
D:\Strawberry\perl\bin\perl.exe is set before the Git path.
Running makeglossaries will return the following output which keeps
printing until I force the terminal to quit.
makeglossaries version 2.07 (2013-06-17)
added glossary type 'main' (glg,gls,glo)
added glossary type 'acronym' (alg,acr,acn)
makeindex -s "main.ist" -t "main.glg" -o "main.gls" "main.glo"
D:\Program Files (x86)\Git\bin\perl.exe: *** fork: can't reserve memory
for stack 0x410000 - 0x610000, Win32 error 0
0 [main] perl.exe" 5496 sync_with_child: child 8144(0x300) died before
initialization with status code 0x1
91 [main] perl.exe" 5496 sync_with_child: *** child state watingin for lonjmp
...
The number before [main] is increasing and the child is getting other
names, the rest is repeating infinitely. Anybody knows, what is happening
here?
makeindex alone works like it should.

Multiple commands using a .command script at launch

Multiple commands using a .command script at launch

I'm trying to figure out why this command script isn't working.
killall Google\ Chrome;
open /Application/Google\ Chrome.app -args --disable-restore-session-state
. I am trying to kill any instance of Chrome that happens to open on
startup. Then launch Chrome with an argument. I have to run the script
twice to get Chrome to launch. Can anyone help?

Thursday, 22 August 2013

I have a compressed tiff image file with six images compressed (not in multi pages) . I have offset and length of data for each image

I have a compressed tiff image file with six images compressed (not in
multi pages) . I have offset and length of data for each image

I have to read a tiff image which is compressed of 6 images and separate
the images into 6 different tiff files. To identify the different images I
am getting offset values like this from a xml file. First image
:data_offset :0 data_length :7827 Second Image: data_offset :7827
data_length :9624 Third Image: data_offset :17451 ( i.e 7827+9624)
data_length :5713 Fourth Image: data_offset :23164 (7827+9624+5713)
data_length :9624 … similarly for all 6 images. I have offset and length
of individual images.How to split the original tiff file into different
tiff image as per offsate and length. The code I am using belo is reading
the original tiff file and coping the same file.Output is the tiff file
with single image.
public class TiffImageReader {
public static void main(String[] args) throws FileNotFoundException,
IOException {
File file = new File("C://DS.tiff");
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
try {
for (int readNum; (readNum = fis.read(buf)) != -1;) {
//Writes to this byte array output stream
bos.write(buf, 0, readNum);
System.out.println("read " + readNum + " bytes,");
}
} catch (IOException ex) {
Logger.getLogger(ConvertImage.class.getName()).log(Level.SEVERE,
null, ex);
}
byte[] bytes = bos.toByteArray();
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
Iterator<?> readers = ImageIO.getImageReadersByFormatName("tiff");
ImageReader reader = (ImageReader) readers.next();
Object source = bis;
ImageInputStream iis = ImageIO.createImageInputStream(source);
reader.setInput(iis, true);
ImageReadParam param = reader.getDefaultReadParam();
Image image = reader.read(0, param);
BufferedImage bufferedImage = new
BufferedImage(image.getWidth(null), image.getHeight(null),
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bufferedImage.createGraphics();
g2.drawImage(image, null, null);
File imageFile = new File("C:// DSCOPY.tiff");
ImageIO.write(bufferedImage, "tiff", imageFile);
System.out.println(imageFile.getPath());
}
}
If I make byte to 1 and put on echeck at first offset 7827 and try to
write the image ..Its showing ArrayOutofIndex.. "for (int readNum;
(readNum = fis.read(buf)) !== 7827;)" How to use offset and length to
split my file. Plz help.

Why doesn't this replace() replace "my"?

Why doesn't this replace() replace "my"?

Could someone explain why the replace() below doesn't replace "my"
$(function() {
var str = "put image in my gallery";
str = str.replace(/ my | in /g, " ");
});
There's a jsfiddle here.
Thanks.

Controlling user privileges when using VLine

Controlling user privileges when using VLine

I'm using VLine in a custom app with imported users, and am wondering if
there's any way to limit the users a specific user is allowed to initiate
a call with?

I want to initialize 1000 of strings for my project?is there any way to do programetically?

I want to initialize 1000 of strings for my project?is there any way to do
programetically?

I want to initialize 1000 of strings in ma app list wise
public static final String[] IMAGES = {"1","2","3","4","5","6",......"1000"};

How to reduce code duplication using method combination but keeping possible early return

How to reduce code duplication using method combination but keeping
possible early return

I got a set of classes which represent a message that has to be handled.
But there is only a limited amount of open spots for handlers. Therefore
any "dipatch" of a handler handling an message object has to check first
whether there is a free spot.
If there is -> dispatch.
If there is not -> do not dispatch and return corresponding message
As this part of the code will be the same in any dispatch method I figured
it would be best to use the method combination facility to enforce that,
but I cannot figure out how.
In my current code base I tried to use a :before method, but apparently
you cannot use return in such context:
(defclass message () ((msg :initarg :msg :reader msg)))
(defclass message-ext (message)
((univ-time :initarg :univ-time :reader univ-time)))
(defparameter *open-handler* nil)
(defgeneric handle (message)
(:documentation "handle the given message appropriately"))
(defmethod handle :before ((message message))
(when (> (length *open-handler*) 1)
(return :full)))
(defmethod handle ((message message))
(push (FORMAT nil "dispatched handler") *open-handler*))
(defmethod handle ((message-ext message-ext))
(push (FORMAT nil "dispatched ext handler") *open-handler*))
(handle (make-instance 'message :msg "allemeineentchen"))
(handle (make-instance 'message-ext
:msg "rowrowrowyourboat"
:univ-time (get-universal-time)))
(handle (make-instance 'message-ext
:msg "gentlydownthestreet"
:univ-time (get-universal-time)))
Execution of a form compiled with errors.
Form:
(RETURN-FROM NIL FULL)
Compile-time error:
return for unknown block: NIL
[Condition of type SB-INT:COMPILED-PROGRAM-ERROR]
Restarts:
0: [RETRY] Retry SLIME interactive evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "worker" RUNNING
{100594F743}>)
Backtrace:
0: ((SB-PCL::FAST-METHOD HANDLE :BEFORE (MESSAGE)) #<unavailable
argument> #<unavailable argument> #<unavailable argument>)
1: ((SB-PCL::EMF HANDLE) #<unavailable argument> #<unavailable argument>
#<MESSAGE-EXT {1005961733}>)
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (HANDLE (MAKE-INSTANCE 'MESSAGE-EXT
:MSG "gentlydownthestreet" :UNIV-TIME (GET-UNIVERSAL-TIME)))
#<NULL-LEXENV>)
3: (EVAL (HANDLE (MAKE-INSTANCE 'MESSAGE-EXT :MSG "gentlydownthestreet"
:UNIV-TIME (GET-UNIVERSAL-TIME))))
4: ((LAMBDA () :IN SWANK:INTERACTIVE-EVAL))
Is this approach even sane, and if yes how can I do it in a working
fashion? (I did already try return-from with the same result)

Error: Matrix dimensions must agree

Error: Matrix dimensions must agree

I wrote the following MATLAB code to perform STFT. However I get an error
stating
Matrix dimensions must agree.
This is the code
[wave,fs]=wavread('40.wav'); % read file into memory */
wave = sum(wave,2); % making the signal one channel
w_length = 1024; % Number of samples per stft slice
L = length(wave);
windowing = hamming(w_length); %Windowing function
points_rem = L - floor(L/w_length)*w_length;
if points_rem >0
points_to_zero_pad = w_length - points_rem;
else
points_to_zero_pad = 0;
end
for i = L+1 : L+points_to_zero_pad
wave(i) = 0;
i = i+1;
end
No_of_windows = (length(wave)-w_length)/(w_length*0.5);
for i = 1:No_of_windows
starting = (i-1)*(512)+1;
ending = starting + No_of_windows-1 ;
data_sub = wave(starting:ending).*windowing;
sub_fft = fft(data_sub);
figure(1)
plot(sub_fft);
end
If I however try to plot only one data sub using the following code
instead of the 2nd for loop I don't get any errors.
starting = 1;
ending = starting+w_length-1;
data_sub = wave(starting:ending).*windowing;
sub_fft = fft(data_sub);
figure(1)
plot(sub_fft);
What can I do to solve this?
I also want to plot the FFT of all subsections... How can I do that using
plot?
Thank you

Web application and/or browser extension to find if a link is submitted to common discussion sites

Web application and/or browser extension to find if a link is submitted to
common discussion sites

Does anyone know of any type of tool that can be used to give a list of
places (if any) where a given link has been submitted in order to find
additional discussion about those things?

Wednesday, 21 August 2013

Latest update break ability to log in

Latest update break ability to log in

I am running Ubuntu 12.04.3 on a 64-bit machine with an nvidia graphics card.
Today I installed updates which included updates to one of the Nvidia
packages. After it got done building the new modules with dkms I logged
out but could not get the greet. So I rebooted and was thrown to a command
line. If I tried to restart lightdm from /etc/init.d/lightdm I was just
shown the boot logging screen. If I tried to run start lightmd I just got
"restart: Unknown instance:"
So I uninstalled nvidia-* and then installed nvidia-common nvidia-settings
and nvidia-304. Finally I ran sudo nvidia-xconfig. After it installed and
I rebooted I can now get the lightdm greet. However, no matter which
desktop I choose the screen just goes black and then brings me back to the
greeter. I have tried Unity, Unity-2D, Gnome, and Gnome Classic (No
Effects) all with the same result.
I do not see any problems reported in /var/log/lightdm/lightdm.log,
however /var/log/lightdm/x-0-greeter-log does show the following, which I
am not 100% sure is relevant.
[+0.96s] CRITICAL: ido_calendar_menu_item_set_date: assertaion
'IDO_IS_CALENDAR_MENU_ITEM(Menuitem)' failed

Apache - Dynamic Subfolders

Apache - Dynamic Subfolders

How does YouTube make folders dynamic? For example you can access people's
channels in the root directory, like:
http://youtube.com/PewDiePie
Making a new folder for each channel is most obviously not how they do it,
and they also have links like:
http://youtube.com/PewDiePie/about
Is this done with htaccess, Apache, or is it something with PHP that I
should ask on StackOverflow?

I have a c# form which is to allow the user to specify a differential equation (dy/dt = -lambda*y) to solve (see below for rest...)

I have a c# form which is to allow the user to specify a differential
equation (dy/dt = -lambda*y) to solve (see below for rest...)

both exactly and approximately (by entering desired values of the intital
condition, time step and lambda into textBoxes). zedGraph is then used to
graph the exact and approximate solutions. The problem is that the label
and textBox for timeStep (which I added after adding the zedGraph section)
and the 'draw graph' button are superimposed on the graph, partially
obscuring it. The textBoxes and labels for lambda and the initial
condition were added o the program before the zedGraph part and don't get
superimposed. Is there a way to stop the timeStep label and textBox
frombeing superimposed without having to write the program again and
adding the textBox before the zedGraph section?

How to add background image using CSS?

How to add background image using CSS?

i am will create a web page and I want to add background image using CSS.
But when i was add background image it's not work. I need your help
It's my file directory at folder name Source
css file
Source/assets/css/style.css
my image on
Source/assets/img/header.png
and this my html address
Source/index.html
HTML
<div id="container">
<div class="mainheader">
<nav class="menu">
<ul>
<li></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div><!-- mainheader-->
</div><!-- container -->
CSS
.mainheader {
margin: 0 auto;
background:url(assets/img/header.png);

Template issue in Qt

Template issue in Qt

I try to use template for defining some class as follows:
.h
template <class T>
class QVecTemp
{
public:
static QVector<QVector<T>> SplitVector<T>(QVector<T>, int);
private:
};
.cpp
#include "QVecTemp.h"
template <class T>
QVector<QVector<T>> QVecTemp::SplitVector<T>(QVector<T> items, int clustNum)
{
QVector<QVector<T>> allGroups = new QVector<QVector<T>>();
//split the list into equal groups
int startIndex = 0;
int groupLength = (int)qRound((float)items.count() / (float)clustNum);
while (startIndex < items.count())
{
QVector<T> group = new QVector<T>();
group.AddRange(items.GetRange(startIndex, groupLength));
startIndex += groupLength;
//adjust group-length for last group
if (startIndex + groupLength > items.count())
{
groupLength = items.Count - startIndex;
}
allGroups.Add(group);
}
//merge last two groups, if more than required groups are formed
if (allGroups.count() > clustNum && allGroups.count() > 2)
{
allGroups[allGroups.count() - 2].append(allGroups.last());
allGroups.remove(allGroups.count() - 1);
}
return (allGroups);
}
On static QVector<QVector<T>> SplitVector<T>(QVector<T>, int); I get the
following errors:
error: '>>' should be '> >' within a nested template argument list
error: expected ';' at end of member declaration
error: expected unqualified-id before '<' token
What is actually the problem ? and how can i solve it?

Invalid resource selected while importing WSDL created in Jdeveloper

Invalid resource selected while importing WSDL created in Jdeveloper

I have created a DBadapter service in Jdeveloper and now I want to create
a business service in eclipse and integrate this buisness service with the
DBAdapter.
So, I have imported .wsdl,.jca and .xml files from DBAdapter and placed
them in respective folders in Oracle service bus project. Now, in my
business service, i have selected Service type as WSDL Web Service, and I
have given the path of WSDL present in my OSB project.
But , here I am getting an error as "Invalid Resource Selected". I am not
sure what am I doing wrong here.
Appreciate all suggestions
Regards Anurag

Generating a list of file names from the current project from a silverlight application?

Generating a list of file names from the current project from a
silverlight application?

I'm having some trouble trying to get a list of files stored within a
folder that's stored within my Silverlight application client project. I'm
trying to collect a list of file names of images to dynamically create
URIs based on the files within that folder. All I need is a list of the
file names.
I've tried:
App.GetResourceStream(new Uri(PathName));
and this works fine for getting files I know the name of. But I haven't
found a way of returning a list of files yet.
My project is called TestWebsite The the files would be stored within
"TestWebsite\Images\ConceptArt\" and all the files will be of the same
image format e.i. '.jpg'
I have also tried this:
var result =
Directory.EnumerateFiles(@"C:\Users\UserName\Pictures\ConceptArt\",
"*.JPG");
but this needs access which seems more trouble than it's worth.

Tuesday, 20 August 2013

Text not all displayed by the time new form has been created

Text not all displayed by the time new form has been created

i built a program by using c#, and i wanted to make a new form (like
microsoft word, excel etc), and i already can achieve it, however, the
text are not all displayed by the time i command to create a new form.
Here is the image before new form created:
And here is the image after new form created:
I was wondering, why the text and the menu "File" not displayed after i
create a new form? i already called this function that contains all the
text and the textboxes, but only textboxes that come out:
private void AddObjects(object sender, EventArgs e, Form theForm)
{
textBoxQuantityContainer = new List<NumericUpDown>();
textBoxCodeContainer = new List<TextBox>();
textBoxDescContainer = new List<TextBox>();
textBoxSubTotalContainer = new List<TextBox>();
textBoxTotalContainer = new List<TextBox>();
textBoxAllTotalContainer = new TextBox();
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT [Code] FROM
[Data]", conn);
dReader = cmd.ExecuteReader();
AutoCompleteStringCollection codesCollection = new
AutoCompleteStringCollection();
while (dReader.Read())
{
string numString = dReader[0].ToString().PadLeft(4, '0');
codesCollection.Add(numString);
}
dReader.Close();
conn.Close();
if (firstForm.comboBox1.SelectedIndex == 0)
{
label1.Text = "Code:";
label1.Location = new Point(60, 125);
label2.Text = "Welcome to the Selling System.";
label2.Location = new Point(600, 30);
label3.Text = "Quantity:";
label3.Location = new Point(155, 125);
label4.Text = "Description:";
label4.Location = new Point(580, 125);
label5.Text = "Sub Total on Rp:";
label5.Location = new Point(1020, 125);
label6.Text = "Total on Rp:";
label6.Location = new Point(1210, 125);
label7.Text = "Total on Rp:";
label7.Location = new Point(1080, 580);
}
else if (firstForm.comboBox1.SelectedIndex == 1)
{
label1.Text = "Kode:";
label1.Location = new Point(60, 125);
label2.Text = "Selamat datang di Selling System.";
label2.Location = new Point(600, 30);
label3.Text = "Banyaknya:";
label3.Location = new Point(145, 125);
label4.Text = "Keterangan:";
label4.Location = new Point(580, 125);
label5.Text = "Sub Total di Rp:";
label5.Location = new Point(1020, 125);
label6.Text = "Total di Rp:";
label6.Location = new Point(1210, 125);
label7.Text = "Total di Rp:";
label7.Location = new Point(1080, 580);
}
//****TextBox for Code****
for (int y = 0; y <= 16; y++)
{
textBoxCodeContainer.Add(new TextBox());
textBoxCodeContainer[y].Size = new Size(100, 50);
textBoxCodeContainer[y].Location = new Point(25, 150 + (y
* 25));
textBoxCodeContainer[y].TextChanged += new
System.EventHandler(this.textBox_TextChanged);
textBoxCodeContainer[y].AutoCompleteMode =
AutoCompleteMode.Suggest;
textBoxCodeContainer[y].AutoCompleteSource =
AutoCompleteSource.CustomSource;
textBoxCodeContainer[y].AutoCompleteCustomSource =
codesCollection;
theForm.Controls.Add(textBoxCodeContainer[y]);
}
//****TextBox for Quantity****
for (int y = 0; y <= 16; y++)
{
textBoxQuantityContainer.Add(new NumericUpDown());
textBoxQuantityContainer[y].Size = new Size(100, 50);
textBoxQuantityContainer[y].Location = new Point(125, 150
+ (y * 25));
textBoxQuantityContainer[y].TextChanged += new
System.EventHandler(this.textBox_TextChanged);
textBoxQuantityContainer[y].Maximum = 1000;
theForm.Controls.Add(textBoxQuantityContainer[y]);
}
//****TextBox for Description****
for (int y = 0; y <= 16; y++)
{
textBoxDescContainer.Add(new TextBox());
textBoxDescContainer[y].Size = new Size(750, 50);
textBoxDescContainer[y].Location = new Point(225, 150 + (y
* 25));
theForm.Controls.Add(textBoxDescContainer[y]);
}
//****TextBox for Sub Total****
for (int y = 0; y <= 16; y++)
{
textBoxSubTotalContainer.Add(new TextBox());
textBoxSubTotalContainer[y].Size = new Size(175, 50);
textBoxSubTotalContainer[y].Location = new Point(975, 150
+ (y * 25));
theForm.Controls.Add(textBoxSubTotalContainer[y]);
}
//****TextBox for Total****
for (int y = 0; y <= 16; y++)
{
textBoxTotalContainer.Add(new TextBox());
textBoxTotalContainer[y].Size = new Size(175, 50);
textBoxTotalContainer[y].Location = new Point(1150, 150 +
(y * 25));
textBoxTotalContainer[y].TextChanged += new
System.EventHandler(this.textBox_TextChanged);
theForm.Controls.Add(textBoxTotalContainer[y]);
}
//****TextBox for Total All****
textBoxAllTotalContainer.Size = new Size(175, 50);
textBoxAllTotalContainer.Location = new Point(1150, 575);
textBoxAllTotalContainer.TextChanged += new
System.EventHandler(this.textBox_TextChanged);
theForm.Controls.Add(textBoxAllTotalContainer);
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
AddNewForm(sender, e);
}
private void AddNewForm(object sender, EventArgs e)
{
this.Hide();
Form newForm = new Form();
AddObjects(sender, e, newForm);
newForm.ShowDialog();
}
Thanks in advance!

Comparison of 2 string variables in shell script

Comparison of 2 string variables in shell script

Consider there is a variable line and variable word:
line = 1234 abc xyz 5678
word = 1234
I want to print the line if it contains the word. How do I do this using
shell script? I tried all the suggested solutions given in previous
questions. For example, the following code always passed even if the word
was not in the line.
if [ "$line"==*"$word"*]; then
echo $line
fi
Please help. Thanks.

How to use phpthumb with codeigniter

How to use phpthumb with codeigniter

While I can find other questions like this, I can find none that actually
has the answer. I want to be able to do something like this
<img src="phpthumb_path/phpthumb.php?src=test.pdf&amp;w=500">
The goal of which is to take a pdf that I know the loctaion of and output
it to the screen as a thumbnail. My application is written in codeigniter
and I can't figure out how to get phpthumb working. I am aware that there
a lot of other ways to do this, but unless they are codeigniter specific
with complete instruction as to how to do them they aren't of any use to
me. I've seen the code above on several forums, with no explanation as to
how to integrate the library. I would think having the php thumb path
would be enough, but I can't seem to get it to work and I have verified
that I have the correct path.

Parenthesized repetitions in Python regular expressions

Parenthesized repetitions in Python regular expressions

I have the following string (say the variable name is "str")
(((TEST (4 5 17 33 38 45 93 101 104 108 113 116 135 146 148)) (TRAIN (0 1
2 3 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 34 35 36 37 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
85 86 87 88 89 90 91 92 94 95 96 97 98 99 100 102 103 105 106 107 109 110
111 112 114 115 117 118 119 120 121 122 123 124 125 126 127 128 129 130
131 132 133 134 136 137 138 139 140 141 142 143 144 145 147 149 150 151)))
((TEST (19 35 46 47 48 56 59 61 65 69 71 84 105 107 130)) (TRAIN (0 1 2 3
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34 36 37 38 39 40 41 42 43 44 45 49 50 51 52 53 54 55 57 58 60 62 63
64 66 67 68 70 72 73 74 75 76 77 78 79 80 81 82 83 85 86 87 88 89 90 91 92
93 94 95 96 97 98 99 100 101 102 103 104 106 108 109 110 111 112 113 114
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 131 132 133
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
151)))'
from which I would like to get
['TEST (4 5 17 33 38 45 93 101 104 108 113 116 135 146 148)', 'TEST (19 35
46 47 48 56 59 61 65 69 71 84 105 107 130)']
using re.findall() function in Python.
I tried the following
m = re.findall(r'TEST\s\((\d+\s?)*\)', str)
for which I get the result
['148', '130']
which is a list of only the last numbers of each set of numbers I want. I
don't know why my regexp is wrong. Can someone please help me fix this
problem?
Thanks!

How to group by one column but select last value

How to group by one column but select last value

This is my database for messages
I want to group by receiver_id and this is my SQL
SELECT * FROM messages WHERE sender_id=2
ORDER BY created_at DESC
GROUP BY receiver_id
HAVING COUNT(receiver_id)>=1
It's working but it always shows subject "Bok" and created_at=2013-08-19
20:49:22 I would like to show latest created_at and subject, in this
example 2013-08-20 14:29:41
This is my output

store values in multiple table with circular dependency in rails

store values in multiple table with circular dependency in rails

I have created Three tables with attributes are following:
Table name: um_org_data , attributes: id, org_name, org_description,
webdomain
Table name: addresses , attributes: id, offc_addr, um_org_datum_id
Table name: phone_nos , attributes: offc_ph, offc_ext, address_id
Now I want that my organization with a name has multiple address means
Organization 1:M addresses and address has multiple telephone numbers
means address 1:M telephone_no
The code from my controllers are following:
um_org_datum.rb
class UmOrgDatum < ActiveRecord::Base
attr_accessible :org_description, :org_name, :webdomain, :addresses,
:addresses_attributes
has_many :addresses
accepts_nested_attributes_for :addresses
end
addresses.rb
class Address < ActiveRecord::Base
attr_accessible :offc_addr
belongs_to :um_org_datum
has_many :phone_nos
accepts_nested_attributes_for :phone_nos
end
phone_no.rb
class PhoneNo < ActiveRecord::Base
attr_accessible :offc_ph, :offc_ext
belongs_to :address
end
as association with organization and addresses is working fine... but
having problem in creating multiple telephone numbers.
the code for my view is as following:
<%= simple_nested_form_for(@um_org_datum) do |f| %>
<%= f.error_notification %>
<div class="container">
<div class="row">
<div class="span3 pull-right">
<div class="well">
<h2>Heading</h2>
<p>Sample text</p>
</div>
</div>
<div class="span9">
<%= simple_nested_form_for(@um_org_datum, :validate => true, :html
=> { :class => 'form-horizontal' }) do |f| %>
<div class="control-group">
<label class="control-label">Organization Name&nbsp;</label>
<div class="controls">
<div class="input-prepend">
<%= f.text_field :org_name, required: true, :autofocus =>
true %>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">Orgazination Description&nbsp;</label>
<div class="controls">
<%= f.text_area :org_description, :cols => "100", :rows =>
"10" %>
</div>
</div>
<div class="control-group">
<label class="control-label">Web Domain&nbsp;</label>
<div class="controls">
<div class="input-prepend">
<%= f.text_field :webdomain, required: true, :autofocus =>
true %>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">Office Address</label>
<div class="controls">
<%= f.link_to_add "<i class='icon-plus'></i>".html_safe,
:addresses%>
<%= f.fields_for :addresses do |task_form| %>
<div class="input-prepend">
<%= task_form.text_field :offc_addr, :label => false,
:placeholder => 'Office Address'%>
<div class="control-group">
<label class="control-label">Telephone</label>
<div class="controls">
<%= f.link_to_add "<i
class='icon-plus'></i>".html_safe, :phone_nos%>
<%= f.fields_for :phone_nos do |task_form| %>
<div class="input-prepend">
<%= task_form.text_field :offc_ph, :label =>
false, :placeholder => 'Office Address'%>
</div>
<div class="input-prepend">
<%= task_form.text_field :offc_ext, :label
=> false, :placeholder => 'Office
Extension'%>
</div>
<div class="input-prepend">
&nbsp;&nbsp;
<%= task_form.link_to_remove "<i
class='icon-remove'></i>".html_safe%>
<% end %>
</div>
</div>
<div class="input-prepend">
&nbsp;&nbsp;
<%= task_form.link_to_remove "<i
class='icon-remove'></i>".html_safe%>
<% end %>
</div>
</div>
<div class="control-group">
<label class="control-label">Office Phone Number&nbsp;</label>
<div class="controls">
<div class="input-prepend">
<%= f.text_field :offc_ph, required: true, :autofocus =>
true %>
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<% if @um_org_datum.id == nil%>
<button class="btn btn-primary" type="submit">Submit</button>
<% else %>
<button class="btn btn-primary" type="submit">Update</button>
<% end %>
<a class="btn" href="/um_org_data"
style="text-color:black">Cancel</a>
</div>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
Now what i want to do is that i have three tables which are circular
dependent on each other.... organization table which has primary key that
uses in addresses table as foreign key and has own primary key which is
used in phone_nos table as foreign key.
I wants a form in which when click on + button under address show
telephone label with + button where user can add multiple telephones
against single address.. all is that.

Monday, 19 August 2013

Using yodlee with php and nusaop library

Using yodlee with php and nusaop library

With the soap server ("https://sdkeval2.yodlee.com/yodsoap/service"). We
are getting below error: HTTP Error: Couldn't open socket connection to
server (http://XX.XX.XX:8080/yodsoap/services/CobrandLoginService/), Error
(110): Connection timed out

How to adjust legend in a row in R?

How to adjust legend in a row in R?

I have one plot and i need to adjust legends in a row. How can i do it?
plot(x,y)
legend(c("x","y"))
I need legend should be in one line
----- x --------- y
Regards

Not going in for loop

Not going in for loop

I have the following code
ArrayList<Integer> Analysis = new ArrayList<>();
ArrayList<Integer> designInitialBuild = new ArrayList<>();
ArrayList<Integer> Production = new ArrayList<>();
ArrayList<Integer> Strategy = new ArrayList<>();
ArrayList<Integer> Testing = new ArrayList<>();
System.out.println("jTableLength: " + jTable1.getRowCount());
for(int xn=0;xn==jTable1.getRowCount();xn++){
System.out.println(jTable1.getModel().getValueAt(xn, 3).toString());
switch(jTable1.getModel().getValueAt(xn, 3).toString()){
case "Analysis":
Analysis.add(xn);
break;
case "Design & Initial Build":
designInitialBuild.add(xn);
break;
case "Production":
Production.add(xn);
System.out.println("Production");
break;
case "Strategy":
Strategy.add(xn);
break;
case "Testing":
Testing.add(xn);
break;
default:
System.out.println("I am Broken");
break;
}
}
System.out.println(Production.size());
When I debug the code it shows that the variable xn has a value of -8, it
never goes into the for loop and does the first "println" Before the loop
where I did System.out.println("jTableLength: " + jTable1.getRowCount());
it displays 48..... i'm so very confused.

JSON Processing Using Python

JSON Processing Using Python

I'm trying to download a json file, save the file, and iterate through the
json file in order to extract all information and save it is variables.
I'm then going to format a message in csv format to send the data to
another system. My problem is the json data. It appears to be a dictionary
within a list and I'm not sure how to process it.
Here's the json:
[ {
"ipAddress" : "",
"feedDescription" : "Botted Node Feed",
"bnFeedVersion" : "1.1.4",
"generatedTs" : "2013-08-01 12:00:10.360+0000",
"count" : 642903,
"firstDiscoveredTs" : "2013-07-21 19:07:20.627+0000",
"lastDiscoveredTs" : "2013-08-01 00:34:41.052+0000",
"threatType" : "BN",
"confidence" : 82,
"discoveryMethod" : "spamtrap",
"indicator" : true,
"supportingData" : {
"behavior" : "spamming",
"botnetName" : null,
"spamtrapData" : {
"uniqueSubjectCount" : 88
},
"p2pData" : {
"connect" : null,
"port" : null
}
}
}, {
"ipAddress" : "",
"feedDescription" : "Botted Node Feed",
"bnFeedVersion" : "1.1.4",
"generatedTs" : "2013-08-01 12:00:10.360+0000",
"count" : 28,
"firstDiscoveredTs" : "2013-07-19 03:19:08.622+0000",
"lastDiscoveredTs" : "2013-08-01 01:44:04.009+0000",
"threatType" : "BN",
"confidence" : 40,
"discoveryMethod" : "spamtrap",
"indicator" : true,
"supportingData" : {
"behavior" : "spamming",
"botnetName" : null,
"spamtrapData" : {
"uniqueSubjectCount" : 9
},
"p2pData" : {
"connect" : null,
"port" : null
}
}
}, {
"ipAddress" : "",
"feedDescription" : "Botted Node Feed",
"bnFeedVersion" : "1.1.4",
"generatedTs" : "2013-08-01 12:00:10.360+0000",
"count" : 160949,
"firstDiscoveredTs" : "2013-07-16 18:52:33.881+0000",
"lastDiscoveredTs" : "2013-08-01 03:14:59.452+0000",
"threatType" : "BN",
"confidence" : 82,
"discoveryMethod" : "spamtrap",
"indicator" : true,
"supportingData" : {
"behavior" : "spamming",
"botnetName" : null,
"spamtrapData" : {
"uniqueSubjectCount" : 3
},
"p2pData" : {
"connect" : null,
"port" : null
}
}
} ]
My code:
download = 'https:URL.BNfeed20130801.json'
request = requests.get(download, verify=False)
out = open(fileName, 'w')
for row in request:
if row.strip():
for column in row:
out.write(column)
else:
continue
out.close()
time.sleep(4)
jsonRequest = request.json()
for item in jsonRequest:
print jsonRequest[0]['ipAddress']
print jsonRequest[item]['ipAddress'] --I also tried this
When I do the above it just prints the same IP over and over again. I've
put in the print statement for testing purposes only. Once I figure out to
to access the different elements of the JSON I will store it in variables
and then use these variables accordingly. Any help is greatly appreciated.
Thanks in advance for any help. I'm using Python 2.6 on Linux.

javascript is not working in updatepanel(after a button click)

javascript is not working in updatepanel(after a button click)

how i can resolve this problem? java scripts is not working after post back
this is my .aspx file and .js fil
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script src="JavaFarsi.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"
onresolvescriptreference="ScriptManager1_ResolveScriptReference">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
After pressing the button JavaScript is not working :(
<br />
<asp:Label ID="Label1" runat="server" Text="This is a Persian Textbox:
"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" lang="fa"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit !!!! :)" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

FBLoginView customise of UIAlertView Button?

FBLoginView customise of UIAlertView Button?

I have a UIAlertView which contains two buttons, one for twitter sharing,
another for facebook.
For twitter, I simply call a method, but for facebook it need FBLoginView
to sign in.
I have customised FBLoginView before, as a UIButton, but here how can use
FBLoginView on UIAlertView button.

Sunday, 18 August 2013

Unified Communicator Advanced API

Unified Communicator Advanced API

We have Mitel Unified Communicator Advanced and I see in their
documentation at the link below that there is an API for it. I'd like to
pop a questionnaire every time an external phone call ends. Does anyone
have any information on this? I can't seem to find anything other than
mentions in marketing materials.
http://www.mitel.com/resources/728_2894-51010603RI-EN_final_lr.pdf

Why do wmaker icons shrink?

Why do wmaker icons shrink?

I find myself spending too much time getting the wmakers icons right. When
I start an application from the commandline I get an Icon, which I can
attach to the dock or the clip. Good.
However, when the application is not running, the icon shrinks to about
half the size. The tile keeps its original size (48x48) but the image in
it gets smaller. This small image does not look good.
I can work around this, by explicitly specifying an icon (rightClick ->
settings). But it just takes too much time to browse through all the
available icons (unless there is a fast way I am not aware of). I would be
happy if wmaker just kept the icon it originally displayed.
Seems like I do not fully understand, how wmaker can display an icon of a
running application just fine, but sometimes requires configuration, when
the application is not running.
So why do wmaker icons shrink and what can be done to avoid spending too
much time in getting the icons right?

ActionBarSherlock Tabs with Fragments not correctly

ActionBarSherlock Tabs with Fragments not correctly

I've started a small application that I'm modeling after ABS: Fragments ->
Tabs and Pager.
In my app, I've created a main activity that looks like this:
public class MainActivity extends SherlockFragmentActivity {
TabHost mTabHost;
ViewPager mViewPager;
TabsAdapter mTabsAdapter;
ConfigDBHelper sily_db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTabHost = (TabHost)findViewById(android.R.id.tabhost);
mTabHost.setup();
mViewPager = (ViewPager)findViewById(R.id.pager);
mTabsAdapter = new TabsAdapter(this,mTabHost,mViewPager);
mTabsAdapter.addTab(mTabHost.newTabSpec("home").setIndicator("Home"),
MainSupport.CountingFragment.class, null);
/*
mTabsAdapter.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
LoaderCursorSupport.CursorLoaderListFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
LoaderCustomSupport.AppListFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
*/
if (savedInstanceState != null) {
mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
}
The code, eventually, will contain multiple tabs - but for now, I've
created only 1.
My activity_main layout file is fragment_tabs_pager.xml from ABS renamed.
My MainSupport is FragmentStackSupport.java but renamed.
When I run my application, instead of seeing a "tab" at the top of the
screen, I'm seeing the one and only tab in the MIDDLE of the view -
covering both the fragment_stack.xml layout AND the hello_world.xml
layout.
My suspicion is I've got a missing or incorrect directive someplace, but
am unsure where. Especially as I skipped past the SimpleList.java module
that is in the samples.
Any ideas?

XML validation against many XSD's of inocrrect XML doc not report any errors in Java?

XML validation against many XSD's of inocrrect XML doc not report any
errors in Java?

I am validating an XML doc in Java with Xerces, but don't get any errors.
However, the XML doc contains errors and when I validate it with for
example XMLSply editor, the errors are correctly reported.
I can't find what I am doing wrong. I think I do include all XSD schemas
that are required to validate correctly.
Please some advice? The code snippet:
SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
factory.setErrorHandler(new ErrorHandlerDefault());
Schema schema = factory.newSchema(createSchemaSources());
validator = schema.newValidator().validate("file.xml";
The XSD's that I use to validate:
private Source[] createSchemaSources() throws IOException {
Source[] sources = new Source[5];
sources[0] =
createSource("http://www.nltaxonomie.nl/7.0/domein/bd/tuples/bd-bedr-tuples.xsd");
sources[1] =
createSource("http://www.nltaxonomie.nl/7.0/domein/bd/tuples/bd-bedr-tuples.xsd");
sources[2] =
createSource("http://www.nltaxonomie.nl/7.0/domein/bd/tuples/bd-burg-tuples.xsd");
sources[3] =
createSource("http://www.nltaxonomie.nl/7.0/basis/sbr/types/nl-types.xsd");
sources[4] =
createSource("http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd");
return sources;
}
A small snippet of the xml file being validated (too big to list all):
<bd-burgers:CommutingExpensesDaysPerWeekCount unitRef="uu_513"
contextRef="cc_711">2</bd-burgers:CommutingExpensesDaysPerWeekCount>
This entry contains an error, namely:
Numeric item <bd-burgers:CommutingExpensesDaysPerWeekCount> has neither a
'precision' nor a 'decimals' attribute.
This is correctly reported by XMLSpy but not by my Java code :(... So what
am I doing wrong here? I though I was forgetting an XSD file, but
"CommutingExpensesDaysPerWeekCount" is defined in
"http://www.nltaxonomie.nl/7.0/basis/bd/items/bd-burgers.xsd", that is
contained int he above xsd's, that corresponds to the type
"nonNegativeIntegerItemType" contained in
"http://www.nltaxonomie.nl/7.0/basis/sbr/types/nl-types.xsd", also
contained in the xsd's above, and that extends "monetaryItemType" and is
defined in "http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd", which
xsd is also contained in the above validation.
Any idea why my Java validation not reports any errors?
BTW: it does report an error if I change the above XML snippet in:
<bd-burgers:CommutingExpensesAccordingToTableTotalAmount>841.0</bd-burgers:CommutingExpensesAccordingToTableTotalAmount>
That is: removing all attributes. I then get a correct Validation error
saying that the contextRef is missing.

MVC4 Routes issues when searching parameters are null or blank

MVC4 Routes issues when searching parameters are null or blank

I am facing the issue with routes and showing exception. it is due to when
parameters are null or blank - here when title is blank then issue.
Issue URL :
http://{ParentURL}/Admin/Menu/AddEdit/299921b2-3d7b-4e0a-b23e-5838f9b78654/1
- when Title is blank
Working Fine URL :
http://{ParentURL}/Admin/Menu/AddEdit/Test/299921b2-3d7b-4e0a-b23e-5838f9b78654/1
-> Here Test Is Title
context.MapRoute(
"AdminOperation",
"Admin/{controller}/{action}/{title}/{id}/{pageno}",
new { action = "AddEdit", id = UrlParameter.Optional,
pageno = UrlParameter.Optional, title =
UrlParameter.Optional }
);
please help me on it.
Regards

jquery toggle not working dropdown

jquery toggle not working dropdown

i used jquery toggle in dropdown widget but toggle not working with click.
code is:
var DropHeight = jQuery('.extrabox').outerHeight();
var Dt = jQuery('.extrabox');
jQuery('.extrabox').css("top","-"+DropHeight+"px");
jQuery('.icon-bookmark').toggle(function(e) {
$Dt.animate({'top': 0}, {duration: '800', easing: 'easeInOutExpo'});
}, function() {
$Dt.animate({'top': -DropHeight}, {duration: '800', easing:
'easeInOutExpo'});
});
Demo: http://jsfiddle.net/K4bR7/2/

Saturday, 17 August 2013

HTML/CSS/JavaScript/Jquery issue

HTML/CSS/JavaScript/Jquery issue

I'm trying to learn programming from various online tutorials, and I've
been trying to figure out this issue for about the last three days with no
success. I have three files (myindex.html, stylesheet.css, and jscript.js)
and I'm trying to make sure that everything is properly linked up before I
start experimenting with different things.
MyIndex.html file contains:
<!DOCTYPE>
<HTML>
<head></head>
<title>Mary</title>
<link href="stylesheet.css" type="text/css" rel="stylesheet"></link>
<script type="text/javascript"
src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'></script>
<body>
<div ID="contact">Hello</div>
</body>
</HTML>
my stylesheet.css file contains:
#contact {
height: 100px;
width: 100px;
background-color: #517F8F;
border-radius: 25px;
border: 2px solid blue;
text-align: center;
display: block;
vertical-align: middle;
line-height: 100px;
}
my jscript.js file contains:
$(document).ready(function(){
$('#contact').click(function(){
$(this).hide();
}();
});
I keep dragging the file into chrome to see if it will work. It shows the
div element, but won't hide it when clicked. After much frustration, I
entered all of the info into jsfiddle and it says it works properly and in
the result window if I click the element, it hides like it's supposed to.
I'm using sublime to edit it, but I've also tried notepad++. I can't
figure out why it's not working correctly when I drag the index file into
the browser. I know this is probably a silly question, and I sincerely
appreciate any advise.

How to Automatically replace Lines of Code?

How to Automatically replace Lines of Code?

I would imagine this question has been answered before however I am unable
to find an answer for it so I figured I'd ask here.
If there is already a term for this, please inform me of it - thanks!
Anyways, currently I have bullets created as such:
bullet.create(x, y, xChange, yChange);
I would like to be able to enter
bullet.create(x, y, 40 <angle>, 5 <speed>);
or some such and then run it through a program to calculate xChange and
yChange from the Angle and Speed (Which I already have) and have it edit
the java file itself, as opposed to outputting into the console.
TL;DR: How do I pull information from a java file, run it through an
equation, and replace the input code with the equation's output?
Thanks!

C#: Why does .ToString() append text faster to an int converted to string?

C#: Why does .ToString() append text faster to an int converted to string?

This is from C# in a nutshell book
StringBuilder sb = new StringBuilder();
for(int i =0;i<50;i++)
sb.Append ( i+",");
//Outputs 0,1,2,3.............49,
However , it then says "the expression i + "," means that we are still
repeatedly concatenating strings, howver this only incurs a small
performance cost as strings are small"
Then it says that changing it to the lines below makes it faster
for(int i =0;i<50;i++) {
sb.Append(i.ToString());
sb.Append(",");
}
But why is that faster? Now we have an extra step where i is being
converted to a string? What is actually going under the hood here?There
isn't any more explanation in the rest of the chapter.

Why is my Nginx package not upgraded?

Why is my Nginx package not upgraded?

I'm trying to upgrade my nginx install to 1.3+. I already added the PPA
for nginx/development and updated with apt-get update.
I ran this command to install nginx:
me@server:~$ sudo apt-get install nginx
... snip ...
Unpacking nginx (from .../nginx_1.5.0-1~ppa1~raring_all.deb) ...
Setting up nginx (1.5.0-1~ppa1~raring) ...
However:
me@server:~$ nginx -v
nginx version: nginx/1.2.6 (Ubuntu)
It looks like it installed nginx 1.5, but installed it someplace wacky. I
have no idea how to find it if it did. What am I doing wrong?

How to cut a string given some parameters

How to cut a string given some parameters

public int cut(int b){
String str1;
b = 0;
Scanner str = new Scanner(System.in);
System.out.println("Write your string: ");
str1 = str.next();
Scanner in = new Scanner (System.in);
System.out.println("Write a number: ");
int num1 = in.nextInt();
System.out.println("Write another number: ");
int num2 = in.nextInt();
System.out.println(str1.substring(num1, num2));
return b;
}
This is my code so far. I want for a user to write a string and write from
where to where he wants to cut the string he just entered. The part I
can't get is getting that substring.

create new column on dataset clojure

create new column on dataset clojure

I need help with formatting data in clojure.
I am reading data into a clojure script from an Oracle DB with this query
SELECT location, time, date FROM centralEventTable WHERE time BETWEEN
12/08/2013 and 14/08/2013
the data from the result set called "Result" is then being used to get a
Map of all location's like so;
(map (keyword :location) Result)
I then need to loop through the location names, create a new column called
ApplicationName and assign an application name to each tuple based on the
data contained in location.
The data I want to be able to present in a table format is
ApplicationName, Location, Time and Date.

Video Chat application in PHP using RTMP

Video Chat application in PHP using RTMP

I need to create a video chatting application in PHP. I am thinking to
setup the RTMP server on my own server and then implement audio and video
chatting. So, issue is that i am confused about the way how to implement
this idea. So can anyone suggest me which RTMP server shall i use and any
php library for chatting.

Friday, 16 August 2013

Are these proofs on partial orders correct?

Are these proofs on partial orders correct?

I'm trying to prove whether the following are true or false for partial
orders $P_1$ and $P_2$ over the same set $S$.
1) $P_1$ ¡È $P_2$ is reflexive?
True, since $P_1$ and $P_2$ contains all the pairs { ($x,x$) : $x$ in
$S$}, we know the union also does. Thus $P_1$ ¡È $P_2$ is reflexive. That
set of ($x,x$) elements is called ¦¤, or the diagonal of $S$.
2) $P_1$ ¡È $P_2$ is transitive?
False, since $x¡Üy$ and $y¡Üz$ in $P_1$ ¡È $P_2$. How do we know $x¡Üy$ is
from $P_1 and $y¡Üz$ isn't from $P_2? There's nothing guaranteeing that we
have $x¡Üz$.
3) $P_1$ ¡È $P_2$ is antisymmetric?
False, for all we know, $x¡Üy$ in $P_1$ and $y¡Üx$ in $P_2$. That would be
the complete opposite of asymetry - symmetry (for those two elements, at
least).

Saturday, 10 August 2013

Regarding iPhone App interface design

Regarding iPhone App interface design

Help Regarding iOS(iPhone App) design guidelines,
I need some help regarding interface design. In one my app (targetting
both android and iOS), so user interface is custom.The main navigation in
app is done through drawer like facebook, path. In one of drawer, I have
to show three different views, but one view at a time, a default option in
such case would be to use segment controller. But I like to customize that
behaviour too, by allowing swipping too, to switch between different
views. Effectively users can switch between different view by swipping the
view, and by taping on button too.
Here is my concern, since its not a default behaviour of iOS app, also I m
giving two swipping behaviour in one of my screen, i.e one for showing the
drawer menu, and one for swipping the views too, that i can handle by
showing drawer from screen border swipe only, and from another part swipe
i will swipe the view.
But is this kind of customisation is allowed as per apple HIG.

PHP :replace single digit number with pre leading 0

PHP :replace single digit number with pre leading 0

i have the string for example , hello77boss2america-9-22-fr99ee-9 , From
this string all the single digit must be converted to pre leading 0...for
example result must be like hello77boss02america-09-22-fr99ee-09
I am new to php kindly guide me please.I tried below code
str_replace("(0-9)","0",$num);

Using trusted certificate on Windows with OpenSSL

Using trusted certificate on Windows with OpenSSL

I'm using OpenSSL on Windows and would like to use a certificate in
Windows Certificate Storage as a trusted CA container with
CASSL_CTX_load_verify_locations(). Unfortunately, OpenSSL only supports
PEM files and don't allow direct access to the Windows Certificate
Storage. How can I make this work on Windows, do I have to use the Windows
CryptoAPI and dump the certificate as a PEM file to disk or is there a
better way of doing this?

Read from one MySQL server, write to another

Read from one MySQL server, write to another

I'd like an application to read data from a read replica of a production
server, but write changes to a separate server--a sort of change log. Is
this possible? If not, what should I be doing instead?
It's important that changes on the production server synchronize with the
development server in realtime, if they're separate.
All production tables will be running on InnoDB.

Friday, 9 August 2013

stuck with Javascript infinite while loop

stuck with Javascript infinite while loop

My apologies for the n00b question, I've tried looking through infinite
loop related issues but they're way more complex:
var replay = 1;
while (replay = 1) {
replay = prompt("Yes(1) or No(0) ?");
}
How come this is an infinite loop?
I thought this while loop would only continue iterating while the replay
variable has a value of 1.
However it doesn't stop even when user input is 0, or anything else for
that matter.
Thanks in advance for any of your input!

Return the result of swapping the two lower-order bytes of X

Return the result of swapping the two lower-order bytes of X

pProblem and solution:/p precode/** Return the result of swapping the two
lower-order bytes of X. * For example, if X is 0x12345678, then swap(X) is
0x12347856. */ static int swapLower(int X) { /* Solution */ int lower = X
amp; 0x0000ffff; int upper = X amp; 0xffff0000; return upper | (0xffff
amp; ((lower lt;lt; 8) | (lower gt;gt; 8))); } /code/pre pI am confused
about how to understand the solution. I tried working through the logic
but I did not understand./p pAlso, I don't know how to come up with the
solution in the first place!/p pEDIT:/p pstrongProperties:/strong/p
precodex amp; 1 = x x amp; 0 = 0 x | 1 = 1 x | 0 = x /code/pre pcodeint
lower = X amp; 0x0000ffff = X amp; 0b0000000000000000111111111111/code.
Therefore, codeint lower =/code 0000000000000000xsub15/sub ...
xsub0/sub./p pcodeint upper = X amp; 0xffff0000 = X amp;
0b1111111111110000000000000000/code. Therefore, codeint upper =/code
xsub31/sub ... xsub16/sub0000000000000000./p pstronglower lt;lt; 8/strong
= 0000000000000000xsub15/sub ... xsub0/sub lt;lt; 8 =
00000000xsub23/sub...xsub8/sub00000000/p pstronglower 8/strong =
0000000000000000xsub15/sub ... xsub0/sub 8 =
0000000000000000xsub15/sub...xsub8/sub/p pstrong(lower lt;lt; 8) | (lower
8)/strong = 00000000xsub23/sub...xsub8/sub00000000 |
0000000000000000xsub15/sub...xsub8/sub/p