Javascript return enclosing function
I have a simple scenario in which I check if something exists before
adding it, if it does, I return the function (hence exiting). I use this
pattern many times and I would like to decouple it in another simple
function.
function onEvent(e){
if( this.has(e) )
return
this.add(e);
// More logic different on an event-basis
}
I would like to decouple it like so:
function safeAdd(e){
if( this.has(e) )
return
this.add(e);
}
function onEvent(e){
safeAdd(e);
// More logic
}
But obviously doing so just returns safeAdd and doesn't exit from onEvent,
and the rest of the logic gets executed anyways.
I know I could do something like:
function safeAdd(e){
if( this.has(e) )
return false
this.add(e);
return true
}
function onEvent(e){
if( !safeAdd(e) )
return
// More logic
}
But, since I repeat this a lot, I would like to be as concise as possible.
Saturday, 31 August 2013
Selecting distinct within a select statment.
Selecting distinct within a select statment.
Hi in the following select statement I want to select the distinct values
b.bId for one of the column and not working. Statement is
select
a.sId
,distinct b.bId
from tlocal a
left outer join ts b on (b.id=a.mainId)
where
a.id=@xId;
I have to select the distinct in the select statement since this is
returning values in a stored procedure. Let me know please, thanks
Hi in the following select statement I want to select the distinct values
b.bId for one of the column and not working. Statement is
select
a.sId
,distinct b.bId
from tlocal a
left outer join ts b on (b.id=a.mainId)
where
a.id=@xId;
I have to select the distinct in the select statement since this is
returning values in a stored procedure. Let me know please, thanks
how migrate to ember.js existing page with lot of js
how migrate to ember.js existing page with lot of js
I have start to make a full application using jquery ui and jsplumb. I
want ot make an application which use a lot of ajax and manage model on
client side. I have start to code it manaually. And I discover ember js
and angular. It fit perfectely to my need to have model on client side and
do ajax to save load data. I choose ember for different reason
(handlebars, no intrusive attribut, ...) I have read the documentation and
few tutorial. I see how we make a page and fill it with data from
controler/model. But where do we put code to make the view dynamic. I
mean, we have jqueryui and all things which add dragNDrop, effect,...
which manipulate DOM. I know that ember try to avoid that and prefer
template over dom manipulation but I have ever code that with jquery js
and do not see how to migrate that code to ember. To sum up: I need drag
and drop/ dom manipulation when click on button or when drop element. I
need to handle dbl click to load modal window (loaded in ajax) and del key
to delete content in dom. All this things are easy with jquery/jqueryUI
but do not see where to put that in ember.
My code is to big to be paste here.
Is it possible to load JS script to manage each view ? this js must only
be linked to the view content. To avoid id/class selector colision between
pages.
I have start to make a full application using jquery ui and jsplumb. I
want ot make an application which use a lot of ajax and manage model on
client side. I have start to code it manaually. And I discover ember js
and angular. It fit perfectely to my need to have model on client side and
do ajax to save load data. I choose ember for different reason
(handlebars, no intrusive attribut, ...) I have read the documentation and
few tutorial. I see how we make a page and fill it with data from
controler/model. But where do we put code to make the view dynamic. I
mean, we have jqueryui and all things which add dragNDrop, effect,...
which manipulate DOM. I know that ember try to avoid that and prefer
template over dom manipulation but I have ever code that with jquery js
and do not see how to migrate that code to ember. To sum up: I need drag
and drop/ dom manipulation when click on button or when drop element. I
need to handle dbl click to load modal window (loaded in ajax) and del key
to delete content in dom. All this things are easy with jquery/jqueryUI
but do not see where to put that in ember.
My code is to big to be paste here.
Is it possible to load JS script to manage each view ? this js must only
be linked to the view content. To avoid id/class selector colision between
pages.
Using summary function in R and applying to particular cases
Using summary function in R and applying to particular cases
Just self-learning R at the moment and have gotten a little stuck. I have
a dataset and I want to summarize (find mean, max, etc) but only selecting
those cases that have a particular value on a certain variable.
Alternatively, I guess the same outcome could be done by summarizing only
certain rows in the dataset (ie summarize only rows 1 thru 20).
Could someone lend a helping hand? Thanks so much
Just self-learning R at the moment and have gotten a little stuck. I have
a dataset and I want to summarize (find mean, max, etc) but only selecting
those cases that have a particular value on a certain variable.
Alternatively, I guess the same outcome could be done by summarizing only
certain rows in the dataset (ie summarize only rows 1 thru 20).
Could someone lend a helping hand? Thanks so much
R: return one TRUE / FALSE from a group of boolean values
R: return one TRUE / FALSE from a group of boolean values
Suppose:
mu.iter <- c(3,3,3,3)
mu <- c(1,4,1,4)
> abs(mu.iter - mu) > 1.5
[1] TRUE FALSE TRUE FALSE
Instead of four TRUE/FALSE values, I just want one TRUE / FALSE value,
such that it only returns TRUE when all 4 are TRUE and FALSE otherwise.
The reason is that I want to put this into a while-loop.
Suppose:
mu.iter <- c(3,3,3,3)
mu <- c(1,4,1,4)
> abs(mu.iter - mu) > 1.5
[1] TRUE FALSE TRUE FALSE
Instead of four TRUE/FALSE values, I just want one TRUE / FALSE value,
such that it only returns TRUE when all 4 are TRUE and FALSE otherwise.
The reason is that I want to put this into a while-loop.
Approved method to navigate between pages on same website
Approved method to navigate between pages on same website
I have researched many places to find an answer to this question, but they
never quite answer my real question: What is the best/approved way to move
to a new page within the same website? I have read that it is bad to use
window.location because search engines will think you are hiding
something. But, when I don't want to open a new window (window.open), then
I don't know how else to do it. I use href anchors in links and form
actions, where appropriate. But when I have menus or buttons with onclick,
then I need something else.
Here's an snippet of my code:
my javascript: (with one option commented)
function gotoCat() {
var catcdF = document.catSelect.catcd.value;
<?php
echo
"window.location.href='http://www.mysite.org".$pgmdir."services/busMenu.php?catF='+catcdF;
";
/*
echo
"window.open('http://www.mysite.org".$pgmdir."services/busMenu.php?catF='+catcdF,'','resizable=1,scrollbars=1,toolbar=1,top=50,left=300,width=950,height=800,location=0');
";
*/
?>
}
My dynamic SELECT list in a form (within PHP):
echo " <select name='catcd' id='catcd' size='8' onclick=gotoCat() > \n";
// display list of categories
if ($numcats == 0) { // print message text only
echo "<option value='0' >".$catMsg."</option> \n";
}
else {
for ($i=1; $i<=$numcats; $i++) {
$catcd_db = $catAry[$i][1];
$catName_db = $catAry[$i][2];
echo "<option value='".$catcd_db."'> ".$catName_db." </option> \n";
}
}
echo "</select>";
So, as you can see, I just want a method to allow the user a choice and
then automatically go to the correct web page once selected. This is not
always in a select list. Often it's when they want to exit or get an
error:
if (mysqli_connect_errno()) {
echo "<br/> <p style='text-align:center;'> <button type='button'
class='buttonStyle' style='padding: 4px 20px;' value='Exit' ";
echo
"onClick=\"window.location.href='http://www.mysite.org/services/catSelbus.php?rc=1&func=Rev'\"
> ";
echo "Exit </button></p> ";
}
I cannot use "go back" because they need to go to a prior page, not the
form they came from.
So, unless my navigation methods are really off-the-mark, I guess I need
to know the acceptable method for using javascript onClick to move to the
next page in the same website. Is window.location okay, or should I use
something else?
Any opinions or suggestions are welcome!
I have researched many places to find an answer to this question, but they
never quite answer my real question: What is the best/approved way to move
to a new page within the same website? I have read that it is bad to use
window.location because search engines will think you are hiding
something. But, when I don't want to open a new window (window.open), then
I don't know how else to do it. I use href anchors in links and form
actions, where appropriate. But when I have menus or buttons with onclick,
then I need something else.
Here's an snippet of my code:
my javascript: (with one option commented)
function gotoCat() {
var catcdF = document.catSelect.catcd.value;
<?php
echo
"window.location.href='http://www.mysite.org".$pgmdir."services/busMenu.php?catF='+catcdF;
";
/*
echo
"window.open('http://www.mysite.org".$pgmdir."services/busMenu.php?catF='+catcdF,'','resizable=1,scrollbars=1,toolbar=1,top=50,left=300,width=950,height=800,location=0');
";
*/
?>
}
My dynamic SELECT list in a form (within PHP):
echo " <select name='catcd' id='catcd' size='8' onclick=gotoCat() > \n";
// display list of categories
if ($numcats == 0) { // print message text only
echo "<option value='0' >".$catMsg."</option> \n";
}
else {
for ($i=1; $i<=$numcats; $i++) {
$catcd_db = $catAry[$i][1];
$catName_db = $catAry[$i][2];
echo "<option value='".$catcd_db."'> ".$catName_db." </option> \n";
}
}
echo "</select>";
So, as you can see, I just want a method to allow the user a choice and
then automatically go to the correct web page once selected. This is not
always in a select list. Often it's when they want to exit or get an
error:
if (mysqli_connect_errno()) {
echo "<br/> <p style='text-align:center;'> <button type='button'
class='buttonStyle' style='padding: 4px 20px;' value='Exit' ";
echo
"onClick=\"window.location.href='http://www.mysite.org/services/catSelbus.php?rc=1&func=Rev'\"
> ";
echo "Exit </button></p> ";
}
I cannot use "go back" because they need to go to a prior page, not the
form they came from.
So, unless my navigation methods are really off-the-mark, I guess I need
to know the acceptable method for using javascript onClick to move to the
next page in the same website. Is window.location okay, or should I use
something else?
Any opinions or suggestions are welcome!
Friday, 30 August 2013
Why can I execute an Android application with which is compiled against API 17 on a phone running API level 10?
Why can I execute an Android application with which is compiled against
API 17 on a phone running API level 10?
I am building an Android application which I compile against API-17:
project.properties contains
target=android-17
I am slightly confused because I can download and execute the application
on an Android phone running Gingerbread 3.3.6, API 10. Can perhaps someone
clarify?
API 17 on a phone running API level 10?
I am building an Android application which I compile against API-17:
project.properties contains
target=android-17
I am slightly confused because I can download and execute the application
on an Android phone running Gingerbread 3.3.6, API 10. Can perhaps someone
clarify?
Thursday, 29 August 2013
Express used to print simple message
Express used to print simple message
Express program ::
var express = require('express')
, async = require('async')
, http = require('http')
, mysql = require('mysql');
var app = express();
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: "root",
database: 'restaurants'
});
connection.connect();
// all environments
app.set('port', process.env.PORT || 7004);
app.get('/restaurant/:Key',function(request,response,next){
var keyName=request.query.Key;
response.end("Hello, " + keyName + ".");
} );
app.get('/',function(request,response,next){
response.end("Hello");
} );
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
Output Test
I have used a simulation test from POSTMAN browser extension of chrome to
simulate get request , I have posted the output in the image below, How
can i resolve this?
Express program ::
var express = require('express')
, async = require('async')
, http = require('http')
, mysql = require('mysql');
var app = express();
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: "root",
database: 'restaurants'
});
connection.connect();
// all environments
app.set('port', process.env.PORT || 7004);
app.get('/restaurant/:Key',function(request,response,next){
var keyName=request.query.Key;
response.end("Hello, " + keyName + ".");
} );
app.get('/',function(request,response,next){
response.end("Hello");
} );
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
Output Test
I have used a simulation test from POSTMAN browser extension of chrome to
simulate get request , I have posted the output in the image below, How
can i resolve this?
Oracle stored procedure - can I assign value to the variable in declaration block?
Oracle stored procedure - can I assign value to the variable in
declaration block?
I am writing a stored procedure in oracle and I would like to assign a
value to variable right from the start:
CREATE PROCEDURE proc
(
param1
, param2
)
AS
variable1 INT AS SELECT MAX(value) FROM table WHERE field = param1;
BEGIN
...
Is it allowed or should I do it in executable block?
declaration block?
I am writing a stored procedure in oracle and I would like to assign a
value to variable right from the start:
CREATE PROCEDURE proc
(
param1
, param2
)
AS
variable1 INT AS SELECT MAX(value) FROM table WHERE field = param1;
BEGIN
...
Is it allowed or should I do it in executable block?
Book Review Required for Drupal for Education and E-Learning - Second Edition
Book Review Required for Drupal for Education and E-Learning - Second Edition
Packt is looking for people interested in reviewing the book Drupal for
Education and E-Learning - Second Edition Drupal for Education and
E-Learning - Second Edition on their blog/ amazon The book is written by
James G. Robertson and Bill Fitzgerald
If interested, please let me know at – sabyasachir@packtpub.com or leave a
comment below with your email ID, I will provide you with the e-copy of
the book. Note : Limited copies available. Thanks and regards
Packt is looking for people interested in reviewing the book Drupal for
Education and E-Learning - Second Edition Drupal for Education and
E-Learning - Second Edition on their blog/ amazon The book is written by
James G. Robertson and Bill Fitzgerald
If interested, please let me know at – sabyasachir@packtpub.com or leave a
comment below with your email ID, I will provide you with the e-copy of
the book. Note : Limited copies available. Thanks and regards
Wednesday, 28 August 2013
Sharing small data using Windows shared memory
Sharing small data using Windows shared memory
I'm looking for advice and suggestions for storing small amounts of data
(only a few bytes) in a shared memory segment on Windows.
Right now, whenever we map shared memory, we round the mapping size up to
the nearest 4KB so we get a multiple of pages mapped.
mem_size = ((mem_size + 4095) / 4096) * 4096;
However, I want to map enough memory to share a named integer between
processes. Or more specifically, many differently-named integers between
processes. About a thousand integers, all with different names and each
one mapped by one or more processes is what I'm looking at.
I don't want to round 4 bytes up to 4KB because this would be a huge
waste. After creating a thousand or so of these, I would have used about a
thousand pages when I only needed one.
But I am worried about the overhead of creating a named memory segment for
just 4 bytes. Will the OS be "reasonable" enough to try and fit the
different mappings onto the same page where possible? (There are no
guarantees, I know). Or will this quickly blow out?
I had considered mapping one huge block of memory, but the individual
integers still need to be referred to by name. Maintaining a hash table
inside shared memory seems like I'd just be duplicating the work of the
OS.
Is there an alternative to the CreateFileMapping/OpenFileMapping and
MapViewOfFile technique that would be more suited to sharing very small
amounts of data between processes? Or am I worrying over nothing?
I'm looking for advice and suggestions for storing small amounts of data
(only a few bytes) in a shared memory segment on Windows.
Right now, whenever we map shared memory, we round the mapping size up to
the nearest 4KB so we get a multiple of pages mapped.
mem_size = ((mem_size + 4095) / 4096) * 4096;
However, I want to map enough memory to share a named integer between
processes. Or more specifically, many differently-named integers between
processes. About a thousand integers, all with different names and each
one mapped by one or more processes is what I'm looking at.
I don't want to round 4 bytes up to 4KB because this would be a huge
waste. After creating a thousand or so of these, I would have used about a
thousand pages when I only needed one.
But I am worried about the overhead of creating a named memory segment for
just 4 bytes. Will the OS be "reasonable" enough to try and fit the
different mappings onto the same page where possible? (There are no
guarantees, I know). Or will this quickly blow out?
I had considered mapping one huge block of memory, but the individual
integers still need to be referred to by name. Maintaining a hash table
inside shared memory seems like I'd just be duplicating the work of the
OS.
Is there an alternative to the CreateFileMapping/OpenFileMapping and
MapViewOfFile technique that would be more suited to sharing very small
amounts of data between processes? Or am I worrying over nothing?
submit form to new tab and close modal
submit form to new tab and close modal
I am submitting a form to a new tab from a modal window. I want the form
to submit, the modal to close, and the parent of the modal to refresh. The
new tab opens fine and the modal does not close. I am using this same js
in a modal php script with RefWin() as the last line and when the script
ends, the modal closes and the parent refreshes. The modal window is a
jquery plugin and I do want to use javascript to close the modal. I have
attempted using onsubmit and onclick and neither work. I know there is a
simple answer to this and I am stumped... appreciate some assistance.
<script>
function reloadSource() {
var p_ref=parent.location.href;
parent.location.href=(p_ref);
}
function RefWin() {
window.open('', '_self', '');
window.close();
reloadSource();
}
</script>
<form action="https://www.paymentgate.com/process/" method="POST"
target="_new">
<input type="text" name="v1" maxlength="200" value="100.00" />
<input type="text" name="v2" maxlength="200" value="Software" />
<input type="image" name="submit"
src="http://www.myurl.com/img/paybutton.gif" border="0"
onsubmit="RefWin();" />
</form>
I am submitting a form to a new tab from a modal window. I want the form
to submit, the modal to close, and the parent of the modal to refresh. The
new tab opens fine and the modal does not close. I am using this same js
in a modal php script with RefWin() as the last line and when the script
ends, the modal closes and the parent refreshes. The modal window is a
jquery plugin and I do want to use javascript to close the modal. I have
attempted using onsubmit and onclick and neither work. I know there is a
simple answer to this and I am stumped... appreciate some assistance.
<script>
function reloadSource() {
var p_ref=parent.location.href;
parent.location.href=(p_ref);
}
function RefWin() {
window.open('', '_self', '');
window.close();
reloadSource();
}
</script>
<form action="https://www.paymentgate.com/process/" method="POST"
target="_new">
<input type="text" name="v1" maxlength="200" value="100.00" />
<input type="text" name="v2" maxlength="200" value="Software" />
<input type="image" name="submit"
src="http://www.myurl.com/img/paybutton.gif" border="0"
onsubmit="RefWin();" />
</form>
AngularJS $http response long execution
AngularJS $http response long execution
I am using Angular and $http request to get data from server. It is mock
data in the same server directory but it return response in 20 sec. It is
way to long. The request is executed on application start up. I have tried
to execute the same query using jQuery $.ajax, and it worked in 10 ms. But
I am want to get rid of jQuery. Why AngularJs $http is taking so long?
I am using Angular and $http request to get data from server. It is mock
data in the same server directory but it return response in 20 sec. It is
way to long. The request is executed on application start up. I have tried
to execute the same query using jQuery $.ajax, and it worked in 10 ms. But
I am want to get rid of jQuery. Why AngularJs $http is taking so long?
Jquery works after inspect element is done in chrome
Jquery works after inspect element is done in chrome
Website link:
http://50.87.144.37/~projtest/team/design/Cece/
Jquery:
$(document).ready(function(){
var pgHeight = $(window).height();
//alert(pgHeight);
$('.sitewid').css('min-height',pgHeight-150)
var ltHeight = $('.mainImg').height();
$('.left').css('height',ltHeight);
$('.links').css('height',ltHeight);
var dHeight1 = $('.mainImg').height();
})
$(window).resize(function(){
setTimeout(function(){
var lt1Height = $('.mainImg').height();
//alert(lt1Height);
$('.left').css('height',lt1Height);
$('.right').css('height',lt1Height);
$('.links').css('height',lt1Height);
$('.social').css('top',lt1Height/2.8);
},50);
})
Html:
<div id="container">
<div class="sitewid">
<div id="header">...</div>
<div id="content" class="mainPg">
<img class="mainImg" src="images/bnw.jpg" alt=" ">
<div class="left">...</div>
<div class="right mainRHeight">...</div>
<p class="cls"></p>
</div>
<div id="footer">...</div>
</div>
This is a responsive design. The page works fine in Firefox but when
viewed in Chrome and other webkit browsers, the jquery does not works as
it is supposed to. The class "mainImg" will be a dynamic image. So the
.left and .right are getting its height and that height is assigned to
both the sections. When I inspect element in chrome or double click on
ipad screen, the content gets into the desired position(s) but it is shown
in haphazard manner when the page first loads. What am I doing wrong here?
The script syntax is in head tag. I have learned jQuery myself so I am
sure I am missing something here because I have faced this issue prior to
this project too. :/
Website link:
http://50.87.144.37/~projtest/team/design/Cece/
Jquery:
$(document).ready(function(){
var pgHeight = $(window).height();
//alert(pgHeight);
$('.sitewid').css('min-height',pgHeight-150)
var ltHeight = $('.mainImg').height();
$('.left').css('height',ltHeight);
$('.links').css('height',ltHeight);
var dHeight1 = $('.mainImg').height();
})
$(window).resize(function(){
setTimeout(function(){
var lt1Height = $('.mainImg').height();
//alert(lt1Height);
$('.left').css('height',lt1Height);
$('.right').css('height',lt1Height);
$('.links').css('height',lt1Height);
$('.social').css('top',lt1Height/2.8);
},50);
})
Html:
<div id="container">
<div class="sitewid">
<div id="header">...</div>
<div id="content" class="mainPg">
<img class="mainImg" src="images/bnw.jpg" alt=" ">
<div class="left">...</div>
<div class="right mainRHeight">...</div>
<p class="cls"></p>
</div>
<div id="footer">...</div>
</div>
This is a responsive design. The page works fine in Firefox but when
viewed in Chrome and other webkit browsers, the jquery does not works as
it is supposed to. The class "mainImg" will be a dynamic image. So the
.left and .right are getting its height and that height is assigned to
both the sections. When I inspect element in chrome or double click on
ipad screen, the content gets into the desired position(s) but it is shown
in haphazard manner when the page first loads. What am I doing wrong here?
The script syntax is in head tag. I have learned jQuery myself so I am
sure I am missing something here because I have faced this issue prior to
this project too. :/
How can received sms in android?
How can received sms in android?
I am new to android and i am using android 2.1 for some sms_receive thing:
when an sms received,it won't work... I have a force close, help!
public class SmsReceiverActivity extends Activity {
private static final String SHORTCODE = "55443";
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] messages = (Object[]) bundle.get("pdus");
SmsMessage[] sms = new SmsMessage[messages.length];
//Create messages for each incoming PDU
for (int n = 0; n < messages.length; n++) {
sms[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
for (SmsMessage msg: sms) {
//Verify if the message came from our known sender
if (TextUtils.equals(msg.getOriginatingAddress(), "SHORTCODE")) {
Toast.makeText(context, "Received message from the
mothership: " +
msg.getMessageBody(),Toast.LENGTH_SHORT).show();
}
}
}
android manifest:
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<application android:label="@string/app_name">
<activity
android:name=".SmsReceiver"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".SMSReceiver" android:enabled="true">
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
when installing program and I want running it,I have a force close and
this is my LogCat:
08-26 12:36:58.531: D/AndroidRuntime(700): Shutting down VM
08-26 12:36:58.531: W/dalvikvm(700): threadid=3: thread exiting with
uncaught exception (group=0x4001b188)
08-26 12:36:58.573: E/AndroidRuntime(700): Uncaught handler: thread main
exiting due to uncaught exception
08-26 12:36:58.621: E/AndroidRuntime(700): java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{com.example.smsreceiver/com.example.smsreceiver.SmsReceiver}:
java.lang.ClassNotFoundException: com.example.smsreceiver.SmsReceiver in
loader dalvik.system.PathClassLoader@44c07980
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.os.Looper.loop(Looper.java:123)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.main(ActivityThread.java:4363)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.reflect.Method.invokeNative(Native Method)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.reflect.Method.invoke(Method.java:521)
08-26 12:36:58.621: E/AndroidRuntime(700): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-26 12:36:58.621: E/AndroidRuntime(700): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-26 12:36:58.621: E/AndroidRuntime(700): at
dalvik.system.NativeStart.main(Native Method)
08-26 12:36:58.621: E/AndroidRuntime(700): Caused by:
java.lang.ClassNotFoundException: com.example.smsreceiver.SmsReceiver in
loader dalvik.system.PathClassLoader@44c07980
08-26 12:36:58.621: E/AndroidRuntime(700): at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
08-26 12:36:58.621: E/AndroidRuntime(700): ... 11 more
08-26 12:36:58.651: I/dalvikvm(700): threadid=7: reacting to signal 3
08-26 12:36:58.651: E/dalvikvm(700): Unable to open stack trace file
'/data/anr/traces.txt': Permission denied
I am new to android and i am using android 2.1 for some sms_receive thing:
when an sms received,it won't work... I have a force close, help!
public class SmsReceiverActivity extends Activity {
private static final String SHORTCODE = "55443";
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] messages = (Object[]) bundle.get("pdus");
SmsMessage[] sms = new SmsMessage[messages.length];
//Create messages for each incoming PDU
for (int n = 0; n < messages.length; n++) {
sms[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
for (SmsMessage msg: sms) {
//Verify if the message came from our known sender
if (TextUtils.equals(msg.getOriginatingAddress(), "SHORTCODE")) {
Toast.makeText(context, "Received message from the
mothership: " +
msg.getMessageBody(),Toast.LENGTH_SHORT).show();
}
}
}
android manifest:
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<application android:label="@string/app_name">
<activity
android:name=".SmsReceiver"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".SMSReceiver" android:enabled="true">
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
when installing program and I want running it,I have a force close and
this is my LogCat:
08-26 12:36:58.531: D/AndroidRuntime(700): Shutting down VM
08-26 12:36:58.531: W/dalvikvm(700): threadid=3: thread exiting with
uncaught exception (group=0x4001b188)
08-26 12:36:58.573: E/AndroidRuntime(700): Uncaught handler: thread main
exiting due to uncaught exception
08-26 12:36:58.621: E/AndroidRuntime(700): java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{com.example.smsreceiver/com.example.smsreceiver.SmsReceiver}:
java.lang.ClassNotFoundException: com.example.smsreceiver.SmsReceiver in
loader dalvik.system.PathClassLoader@44c07980
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.os.Looper.loop(Looper.java:123)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.main(ActivityThread.java:4363)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.reflect.Method.invokeNative(Native Method)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.reflect.Method.invoke(Method.java:521)
08-26 12:36:58.621: E/AndroidRuntime(700): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-26 12:36:58.621: E/AndroidRuntime(700): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-26 12:36:58.621: E/AndroidRuntime(700): at
dalvik.system.NativeStart.main(Native Method)
08-26 12:36:58.621: E/AndroidRuntime(700): Caused by:
java.lang.ClassNotFoundException: com.example.smsreceiver.SmsReceiver in
loader dalvik.system.PathClassLoader@44c07980
08-26 12:36:58.621: E/AndroidRuntime(700): at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-26 12:36:58.621: E/AndroidRuntime(700): at
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-26 12:36:58.621: E/AndroidRuntime(700): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
08-26 12:36:58.621: E/AndroidRuntime(700): ... 11 more
08-26 12:36:58.651: I/dalvikvm(700): threadid=7: reacting to signal 3
08-26 12:36:58.651: E/dalvikvm(700): Unable to open stack trace file
'/data/anr/traces.txt': Permission denied
Tuesday, 27 August 2013
Rails 3 session variable not deleting right away using cache storage in production
Rails 3 session variable not deleting right away using cache storage in
production
I am using the cache store for session storage in Rails 3. In production
deleting a session variable doesn't seem to be reflected until the request
has completed. That makes sense for cookie storage, but not for cache
storage. Also, this isn't a problem in staging which makes me think it's a
config issue. I'm not sure what config parameter would cause this, though.
Any ideas?
Here's the action code. The variable is cleared because the user can add
more things to the session while the first request is being processed, but
the session variable can't overlap between requests.
id_list = session[:batch_select_ids]
#Clear the session variable
session.delete(:batch_select_ids)
Thanks.
production
I am using the cache store for session storage in Rails 3. In production
deleting a session variable doesn't seem to be reflected until the request
has completed. That makes sense for cookie storage, but not for cache
storage. Also, this isn't a problem in staging which makes me think it's a
config issue. I'm not sure what config parameter would cause this, though.
Any ideas?
Here's the action code. The variable is cleared because the user can add
more things to the session while the first request is being processed, but
the session variable can't overlap between requests.
id_list = session[:batch_select_ids]
#Clear the session variable
session.delete(:batch_select_ids)
Thanks.
Regular expression that match decimal places
Regular expression that match decimal places
I have this code to test if a value entered in a INPUT is numeric:
$("#price").val().match(/^\d+$/);
I need some help rewriting this function to allow decimal places either
with colon or dot meaning for example 230.00 is allowed and 230,00 is
allowed too. Also the decimal places could be four or less. Any?
I have this code to test if a value entered in a INPUT is numeric:
$("#price").val().match(/^\d+$/);
I need some help rewriting this function to allow decimal places either
with colon or dot meaning for example 230.00 is allowed and 230,00 is
allowed too. Also the decimal places could be four or less. Any?
Cross domain requests not working in SignalR 2.0.0-rc1
Cross domain requests not working in SignalR 2.0.0-rc1
I recently upgraded a project from SignalR 2.0.0-beta1 to 2.0.0-rc1. I
understand that in RC1, configuration of support for cross domain requests
changed. I've updated my project to use the new syntax however I'm now
getting the following error when attempting to communicate with my hub:
XMLHttpRequest cannot load
=1377623738064">http://localhost:8080/negotiate?connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&clientProtocol=1.3&=1377623738064.
Origin http://localhost:7176 is not allowed by
Access-Control-Allow-Origin.
The client site is running at http://localhost:7176 and the hub is
listening via a console application at http://localhost:8080. Am I missing
something here? Cross domain requests were working before I upgraded to
RC1.
CONSOLE APP ENTRY POINT
static void Main(string[] args)
{
var chatServer = new ChatServer();
string endpoint = "http://localhost:8080";
chatServer.Start(endpoint);
Console.WriteLine("Chat server listening at {0}...", endpoint);
Console.ReadLine();
}
CHATSERVER CLASS
public class ChatServer
{
public IDisposable Start(string url)
{
return WebApp.Start<Startup>(url);
}
}
STARTUP CONFIGURATION
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
map.RunSignalR(new HubConfiguration { EnableJSONP = true });
});
}
}
I recently upgraded a project from SignalR 2.0.0-beta1 to 2.0.0-rc1. I
understand that in RC1, configuration of support for cross domain requests
changed. I've updated my project to use the new syntax however I'm now
getting the following error when attempting to communicate with my hub:
XMLHttpRequest cannot load
=1377623738064">http://localhost:8080/negotiate?connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&clientProtocol=1.3&=1377623738064.
Origin http://localhost:7176 is not allowed by
Access-Control-Allow-Origin.
The client site is running at http://localhost:7176 and the hub is
listening via a console application at http://localhost:8080. Am I missing
something here? Cross domain requests were working before I upgraded to
RC1.
CONSOLE APP ENTRY POINT
static void Main(string[] args)
{
var chatServer = new ChatServer();
string endpoint = "http://localhost:8080";
chatServer.Start(endpoint);
Console.WriteLine("Chat server listening at {0}...", endpoint);
Console.ReadLine();
}
CHATSERVER CLASS
public class ChatServer
{
public IDisposable Start(string url)
{
return WebApp.Start<Startup>(url);
}
}
STARTUP CONFIGURATION
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
map.RunSignalR(new HubConfiguration { EnableJSONP = true });
});
}
}
How to set window position to locate it to the top of the screen on MFC?
How to set window position to locate it to the top of the screen on MFC?
I'm trying to set position of new dialog in MFC, what i do:
SetWindowPos(&this->wndTopMost, 0,0,0,0, SWP_NOSIZE);
in the InitDialog() of this window, but after execution, this window
appears on center of my screen... What am i doing wrong?
I'm trying to set position of new dialog in MFC, what i do:
SetWindowPos(&this->wndTopMost, 0,0,0,0, SWP_NOSIZE);
in the InitDialog() of this window, but after execution, this window
appears on center of my screen... What am i doing wrong?
Windows 8 : Force a static IP adress only for a specific network
Windows 8 : Force a static IP adress only for a specific network
I am a developer. I need to have a static IP adress when I'm at my office,
and would like to use my DHCP at home.
Making a reservation on the office's DHCP isn't possible (the router they
have doesn't allow that).
I've looked up through Google to see if there is something that could suit
my needs but haven't found any (Maybe it's because I don't know the name
of the technology I'm looking for).
So my question is: Is there a way to automaticly switch from a static
address to a dynamic depending on the network?
I am a developer. I need to have a static IP adress when I'm at my office,
and would like to use my DHCP at home.
Making a reservation on the office's DHCP isn't possible (the router they
have doesn't allow that).
I've looked up through Google to see if there is something that could suit
my needs but haven't found any (Maybe it's because I don't know the name
of the technology I'm looking for).
So my question is: Is there a way to automaticly switch from a static
address to a dynamic depending on the network?
Monday, 26 August 2013
Using xslt, how to add an xml node that starts before the first occurrence, and ends after the last occurrence of an item?
Using xslt, how to add an xml node that starts before the first
occurrence, and ends after the last occurrence of an item?
I have an xml that looks like this:
<ShoppingList>
<MoneyIHaveToSpend>20.00</MoneyIHaveToSpend>
<Item>
<Name>Apples</Name>
<Price>1.00</Price>
</Item>
<Item>
<Name>Oranges</Name>
<Price>1.00</Price>
</Item>
<AdditionalInfo>...</AdditionalInfo>
</ShoppingList>
I would like to wrap the "items" into a GroceryList, like so:
<ShoppingList>
<MoneyIHaveToSpend>20.00</MoneyIHaveToSpend>
<GroceryList>
<Item>
<Name>Apples</Name>
<Price>1.00</Price>
</Item>
<Item>
<Name>Oranges</Name>
<Price>1.00</Price>
</Item>
</GroceryList>
<AdditionalInfo>...</AdditionalInfo>
</ShoppingList>
How would I go about doing that using xslt? There is only one sub-list
inside of "ShoppingList".
occurrence, and ends after the last occurrence of an item?
I have an xml that looks like this:
<ShoppingList>
<MoneyIHaveToSpend>20.00</MoneyIHaveToSpend>
<Item>
<Name>Apples</Name>
<Price>1.00</Price>
</Item>
<Item>
<Name>Oranges</Name>
<Price>1.00</Price>
</Item>
<AdditionalInfo>...</AdditionalInfo>
</ShoppingList>
I would like to wrap the "items" into a GroceryList, like so:
<ShoppingList>
<MoneyIHaveToSpend>20.00</MoneyIHaveToSpend>
<GroceryList>
<Item>
<Name>Apples</Name>
<Price>1.00</Price>
</Item>
<Item>
<Name>Oranges</Name>
<Price>1.00</Price>
</Item>
</GroceryList>
<AdditionalInfo>...</AdditionalInfo>
</ShoppingList>
How would I go about doing that using xslt? There is only one sub-list
inside of "ShoppingList".
What is correct "has not been yet" or "has not yet been"?
What is correct "has not been yet" or "has not yet been"?
I wrote "this software has not been yet registered". Am I right?
I wrote "this software has not been yet registered". Am I right?
Gnome is not working properly after messing around with compiz
Gnome is not working properly after messing around with compiz
I fixed tearing for my tv and something went wrong.
Im using multiple screens. I turned of opengl and composite in compiz
config. Now all my windows do not work, i can se programs in the bottom
navbar but just firefox is displayed.
I cant see terminals and "CompizConfig settings" etc..
I tried to fix the problem by resetting compiz(i think its what this does):
gconftool-2 --recursive-unset /apps/compiz
It did not have any effect. What am i doing wrong here? can i somehow
reinstall/reset this?
I fixed tearing for my tv and something went wrong.
Im using multiple screens. I turned of opengl and composite in compiz
config. Now all my windows do not work, i can se programs in the bottom
navbar but just firefox is displayed.
I cant see terminals and "CompizConfig settings" etc..
I tried to fix the problem by resetting compiz(i think its what this does):
gconftool-2 --recursive-unset /apps/compiz
It did not have any effect. What am i doing wrong here? can i somehow
reinstall/reset this?
stubbornly floating to the right although there is no command
stubbornly floating to the right although there is no command
http://jsfiddle.net/6j7zC why is the adminbox floating although there is
no command?
.adminbox
{
width: 200px;
height: 17px;
margin-top: 20px;
padding: 20px;
font-size: 12px;
color: white;
background-color: black;
font-size: 12px;
font-family:"Gears of Peace";
}
http://jsfiddle.net/6j7zC why is the adminbox floating although there is
no command?
.adminbox
{
width: 200px;
height: 17px;
margin-top: 20px;
padding: 20px;
font-size: 12px;
color: white;
background-color: black;
font-size: 12px;
font-family:"Gears of Peace";
}
Sunday, 25 August 2013
Handler in android giving error
Handler in android giving error
I am using handler in my code to update the app on every specific time
interval.
For that i written follwing code:
public class Messages extends Activity {
protected Handler handler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_messages);
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
String id = intent.getStringExtra(MainActivity.EXTRA_ID);
String[] lst = null;
ListView lm=(ListView)findViewById(R.id.listView1);
TextView tv = (TextView)findViewById(R.id.textView1);
tv.setText("Welcome " + message);
handler.postDelayed(new UpdateTask(),500);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.messages, menu);
return true;
}
class UpdateTask implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
setContentView(R.layout.activity_messages);
Intent intent = getIntent();
String message =
intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
String id = intent.getStringExtra(MainActivity.EXTRA_ID);
String[] lst = null;
ListView lm=(ListView)findViewById(R.id.listView1);
TextView tv = (TextView)findViewById(R.id.textView1);
tv.setText("Welcome " + message);
CallSoap cs=new CallSoap();
lst=cs.GetMessage(id);
ArrayAdapter<String> adpt = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,lst);
lm.setAdapter(adpt);
handler.postDelayed(this, 500);
}
}
}
But it is giving me error on :
ArrayAdapter<String> adpt = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,lst);
Text: Constructor ArrayAdapter is undefined.
Please help me.
I am using handler in my code to update the app on every specific time
interval.
For that i written follwing code:
public class Messages extends Activity {
protected Handler handler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_messages);
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
String id = intent.getStringExtra(MainActivity.EXTRA_ID);
String[] lst = null;
ListView lm=(ListView)findViewById(R.id.listView1);
TextView tv = (TextView)findViewById(R.id.textView1);
tv.setText("Welcome " + message);
handler.postDelayed(new UpdateTask(),500);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.messages, menu);
return true;
}
class UpdateTask implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
setContentView(R.layout.activity_messages);
Intent intent = getIntent();
String message =
intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
String id = intent.getStringExtra(MainActivity.EXTRA_ID);
String[] lst = null;
ListView lm=(ListView)findViewById(R.id.listView1);
TextView tv = (TextView)findViewById(R.id.textView1);
tv.setText("Welcome " + message);
CallSoap cs=new CallSoap();
lst=cs.GetMessage(id);
ArrayAdapter<String> adpt = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,lst);
lm.setAdapter(adpt);
handler.postDelayed(this, 500);
}
}
}
But it is giving me error on :
ArrayAdapter<String> adpt = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,lst);
Text: Constructor ArrayAdapter is undefined.
Please help me.
Is it a myth that id reuse in an html document is a w3c standard violation?
Is it a myth that id reuse in an html document is a w3c standard violation?
I was inspecting the way a certain webpage alternated between colors in
their divs and found this:
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
Thinking this was an example of html that wouldn't validate, I ran it
through the w3c validator (http://validator.w3.org/). It did have errors,
but none were regarding non-uniqueness of the ids. Everything I've read
has stated that ids must be unique within a webpage. What's the real story
here?
I was inspecting the way a certain webpage alternated between colors in
their divs and found this:
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
<div class="row8 inline clearfix" id="light-orange">...</div>
<div class="row8 inline clearfix" id="light-pink">...</div>
Thinking this was an example of html that wouldn't validate, I ran it
through the w3c validator (http://validator.w3.org/). It did have errors,
but none were regarding non-uniqueness of the ids. Everything I've read
has stated that ids must be unique within a webpage. What's the real story
here?
Automaticaly commit when updating pacemaker configuration
Automaticaly commit when updating pacemaker configuration
I'm trying to automate the administration of my servers which are running
corosync/pacemaker. For that I generate a file containing the modifs that
needs to be applied to the configuration. To apply this file I usualy do :
crm configure load update path_to_file
It works fine when I do it myself. But whenever there is a warning
generated by the config, crm ask if I really want's to commit the changes.
As far as I'm trying to automate this task I'd like to get rid of this
question and directly commit the changes. Is-it possible ?
I'm trying to automate the administration of my servers which are running
corosync/pacemaker. For that I generate a file containing the modifs that
needs to be applied to the configuration. To apply this file I usualy do :
crm configure load update path_to_file
It works fine when I do it myself. But whenever there is a warning
generated by the config, crm ask if I really want's to commit the changes.
As far as I'm trying to automate this task I'd like to get rid of this
question and directly commit the changes. Is-it possible ?
Making sure that opening app from widget does initialization
Making sure that opening app from widget does initialization
I have a widget, and whenever it is clicked, my app opens. I want to make
sure it loads the correct item (the item that the widget shows). My
current code for setting up the intent looks like this:
intent.putExtra(NuggetActivity.DAY_NUMBER, todayLong);
intent.putExtra(FROM_WIDGET, true);
PendingIntent pendingIntent = PendingIntent.getActivity(context, (int)
todayLong, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.container,pendingIntent);
The app loads fine when the app is loaded from onCreate() onwards, but not
when the app resumed (through onResume()).
Is there some flag I can set in my intent to make sure that onCreate()
gets called, or is there some other way to solve this?
I have a widget, and whenever it is clicked, my app opens. I want to make
sure it loads the correct item (the item that the widget shows). My
current code for setting up the intent looks like this:
intent.putExtra(NuggetActivity.DAY_NUMBER, todayLong);
intent.putExtra(FROM_WIDGET, true);
PendingIntent pendingIntent = PendingIntent.getActivity(context, (int)
todayLong, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.container,pendingIntent);
The app loads fine when the app is loaded from onCreate() onwards, but not
when the app resumed (through onResume()).
Is there some flag I can set in my intent to make sure that onCreate()
gets called, or is there some other way to solve this?
Saturday, 24 August 2013
The primary selection criteria for choosing FM vs. AM is dynamic range
The primary selection criteria for choosing FM vs. AM is dynamic range
The primary reason for selecting FM over AM is the ability of FM to
support a greater dynamic range by spreading the information across a wide
range of frequencies, and using more 'horizontal information carrying
capacity'.
Trying to increase the dynamic range of an AM signal would require
impractical levels of power to be used to represent the same information
carrying capacity in a 'vertical' or amplitude modulated scenario?
Yay or nay.
The primary reason for selecting FM over AM is the ability of FM to
support a greater dynamic range by spreading the information across a wide
range of frequencies, and using more 'horizontal information carrying
capacity'.
Trying to increase the dynamic range of an AM signal would require
impractical levels of power to be used to represent the same information
carrying capacity in a 'vertical' or amplitude modulated scenario?
Yay or nay.
Replacing a href element with jQuery
Replacing a href element with jQuery
I have to change part of the link.
Exactly I have to change "/?" to "/all?" in every a href on the site.
I was reading something about that, but nothing works.
Can you help me?
Greetings.
I have to change part of the link.
Exactly I have to change "/?" to "/all?" in every a href on the site.
I was reading something about that, but nothing works.
Can you help me?
Greetings.
What Is This Explaining?
What Is This Explaining?
Working through Rails Tutorial; I'm in the Rails Console mode, or rather,
Development Mode, by running 'rails console'. I'm following Hartl's great
tutorial, and I'm presented with:
NoMethodError: undefined method `empty?' for nil:NilClass
from (irb):7
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in
`start'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in
`start'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands.rb:64:in
`<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
when I run: 'nil.empty?'
and in Hartl's tutorial it shows this as being presented after running the
command:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
My question is, what is all the additional details with my directory, and
the different folders (what it looks like)?
Learning Rails, thanks for the tips.
Working through Rails Tutorial; I'm in the Rails Console mode, or rather,
Development Mode, by running 'rails console'. I'm following Hartl's great
tutorial, and I'm presented with:
NoMethodError: undefined method `empty?' for nil:NilClass
from (irb):7
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in
`start'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in
`start'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands.rb:64:in
`<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
when I run: 'nil.empty?'
and in Hartl's tutorial it shows this as being presented after running the
command:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
My question is, what is all the additional details with my directory, and
the different folders (what it looks like)?
Learning Rails, thanks for the tips.
Help with a simple problem involving a functional inequality (trying to prove Gronwall's inequality)
Help with a simple problem involving a functional inequality (trying to
prove Gronwall's inequality)
So while trying to prove Grownwall's inequality, my proof led me to the
following statement: $h'(x) \le h(x)g(x)$.
Now when $h'(x)=h(x)g(x)$ the following holds: $h(x)=k \exp G(x)$, where
$k$ is a constant number. Can I conclude from this that $h(x) \le k \exp
G(x)$ (since $h'(x)<h(x)g(x)$)?
prove Gronwall's inequality)
So while trying to prove Grownwall's inequality, my proof led me to the
following statement: $h'(x) \le h(x)g(x)$.
Now when $h'(x)=h(x)g(x)$ the following holds: $h(x)=k \exp G(x)$, where
$k$ is a constant number. Can I conclude from this that $h(x) \le k \exp
G(x)$ (since $h'(x)<h(x)g(x)$)?
How to Create a Custom Pivot Title Style
How to Create a Custom Pivot Title Style
I would like to be able to create a custom pivot page title style in my
application, so that I may use it across multiple pages. Essentially I
just want the title of the Pivot to be centered with a certain font size
and type. Originally I was using an Image for my title but I really need a
text title instead. How might I go about doing this? I've already tried
setting this within App.xaml and using it within my MainPage.xaml but so
far I don't have anything working.
App.xaml (original)
<Style x:Key="ApplicationName" TargetType="Image">
<Setter Property="Height" Value="50"/>
<Setter Property="Width" Value="92.85"/>
<Setter Property="Margin" Value="-3,0,0,0"/>
<Setter Property="Source" Value="/Assets/ApplicationTitle.png"/>
</Style>
MainPage.xaml
<phone:Pivot x:Name="mainPagePivotControl" Style="{StaticResource
PivotStyle}">
<phone:Pivot.TitleTemplate>
<DataTemplate>
<Image Style="{StaticResource ApplicationName}"/>
</DataTemplate>
</phone:Pivot.TitleTemplate>
...
</phone:Pivot>
I would like to be able to create a custom pivot page title style in my
application, so that I may use it across multiple pages. Essentially I
just want the title of the Pivot to be centered with a certain font size
and type. Originally I was using an Image for my title but I really need a
text title instead. How might I go about doing this? I've already tried
setting this within App.xaml and using it within my MainPage.xaml but so
far I don't have anything working.
App.xaml (original)
<Style x:Key="ApplicationName" TargetType="Image">
<Setter Property="Height" Value="50"/>
<Setter Property="Width" Value="92.85"/>
<Setter Property="Margin" Value="-3,0,0,0"/>
<Setter Property="Source" Value="/Assets/ApplicationTitle.png"/>
</Style>
MainPage.xaml
<phone:Pivot x:Name="mainPagePivotControl" Style="{StaticResource
PivotStyle}">
<phone:Pivot.TitleTemplate>
<DataTemplate>
<Image Style="{StaticResource ApplicationName}"/>
</DataTemplate>
</phone:Pivot.TitleTemplate>
...
</phone:Pivot>
Nested Single Query for concatenation of specific column in multiple row in single column
Nested Single Query for concatenation of specific column in multiple row
in single column
i have currently working on sql server and writing a stored procedure to
retrieve some data. My requirement is as follows:
Table A:PersonId,FirstName,LastName,Address,CourseId
(Primary Key For Table B,Foreign Key Here)
Table B:CourseDescription,CourseId
now for each course there might be multiple student enrolled to that
course.my requirement is to concatenate each student LastName,FirstName.if
there are 3 or more student in a course we have to set another flag value
as 'Y' in the result.I've done with Stored proc using temp table , and
updating it step by step. my stored proc algo is like this: temp table has
column:
SeqId,CourseId,CourseDescription,StudentNameConcat,IsMoreThan3
First i update course id,description.then from this table i looped based
on sequence id(SeqId) and retrieve list of student name as column value
and concat it in declared variable.
This approach is not good because it is not a set based approach.and i
believe there must be an alternative approach for it in a single query
using inner query or loop join.I'm still reading and trying to implement
it in a single query.But still not getting any clue.
in single column
i have currently working on sql server and writing a stored procedure to
retrieve some data. My requirement is as follows:
Table A:PersonId,FirstName,LastName,Address,CourseId
(Primary Key For Table B,Foreign Key Here)
Table B:CourseDescription,CourseId
now for each course there might be multiple student enrolled to that
course.my requirement is to concatenate each student LastName,FirstName.if
there are 3 or more student in a course we have to set another flag value
as 'Y' in the result.I've done with Stored proc using temp table , and
updating it step by step. my stored proc algo is like this: temp table has
column:
SeqId,CourseId,CourseDescription,StudentNameConcat,IsMoreThan3
First i update course id,description.then from this table i looped based
on sequence id(SeqId) and retrieve list of student name as column value
and concat it in declared variable.
This approach is not good because it is not a set based approach.and i
believe there must be an alternative approach for it in a single query
using inner query or loop join.I'm still reading and trying to implement
it in a single query.But still not getting any clue.
Renamed folder still shows up in Explorer - How to clear Windows Folder Cache?
Renamed folder still shows up in Explorer - How to clear Windows Folder
Cache?
I have renamed "Downloads" folder to "OldDownloads" from my D: Drive, and
when I issue dir command in command line, I see that Downloads folder is
renamed to OldDownloads and when I try to issue command "cd downloads" I
get an error.
However, when I open Windows Explorer, I still see Downloads folder and I
dont see OldDownloads folder.
When I double click on any file inside "Downloads" folder, I get an error
saying file does not exist. I wrote a custom c# command line program to
access file from "OldDownloads" folder, I can access it fine.
It seems, folder is successfully renamed, but however Windows Explorer
still remembers old folder name and gives wrong path to programs.
Cache?
I have renamed "Downloads" folder to "OldDownloads" from my D: Drive, and
when I issue dir command in command line, I see that Downloads folder is
renamed to OldDownloads and when I try to issue command "cd downloads" I
get an error.
However, when I open Windows Explorer, I still see Downloads folder and I
dont see OldDownloads folder.
When I double click on any file inside "Downloads" folder, I get an error
saying file does not exist. I wrote a custom c# command line program to
access file from "OldDownloads" folder, I can access it fine.
It seems, folder is successfully renamed, but however Windows Explorer
still remembers old folder name and gives wrong path to programs.
Captions and labels for my tables, listings, images
Captions and labels for my tables, listings, images
I'm writing my master thesis and I have a lot of short tables, listings,
etc. in the text.
I would use figures for them like this:
\begin{figure}[h!]
\begin{lstlisting}[mathescape]
... my listing here ...
\end{lstlisting}
\caption{... caption ...}
\label{... label ...}
\end{figure}
\begin{figure}[h!]
\begin{tabular}{|l|l|}
... my table here ...
\end{tabular}
\caption{... caption ...}
\label{... label ...}
\end{figure}
etc, but the fact that LaTeX moves them to another page (even though they
are sometimes very short) makes the text hardly readable.
I would need LaTeX to keep them at exactly the same spot (if they fit
there) or at the top of the next page (otherwise). It is my understanding
that I should not use figures in this case. But, on the other hand, I
would like to keep the captions, labels and numberings for them to still
be able to address them.
How do I do that?
I'm writing my master thesis and I have a lot of short tables, listings,
etc. in the text.
I would use figures for them like this:
\begin{figure}[h!]
\begin{lstlisting}[mathescape]
... my listing here ...
\end{lstlisting}
\caption{... caption ...}
\label{... label ...}
\end{figure}
\begin{figure}[h!]
\begin{tabular}{|l|l|}
... my table here ...
\end{tabular}
\caption{... caption ...}
\label{... label ...}
\end{figure}
etc, but the fact that LaTeX moves them to another page (even though they
are sometimes very short) makes the text hardly readable.
I would need LaTeX to keep them at exactly the same spot (if they fit
there) or at the top of the next page (otherwise). It is my understanding
that I should not use figures in this case. But, on the other hand, I
would like to keep the captions, labels and numberings for them to still
be able to address them.
How do I do that?
Can "Apple" be an adjective? [duplicate]
Can "Apple" be an adjective? [duplicate]
This question already has an answer here:
"Employee" in the phrase "employee ID" is a determiner, not an
adjective—right? 4 answers
Is this noun used as an adjective? 3 answers
What role is the word "apple" playing in the sentence "I ate the apple
pie." Is apple an adjective? Or are apple and pie treated together as one
noun. Is this true of all words used like this? Can "foot" be used as an
adjective if I refer to someone as "that foot guy?" Thanks!
This question already has an answer here:
"Employee" in the phrase "employee ID" is a determiner, not an
adjective—right? 4 answers
Is this noun used as an adjective? 3 answers
What role is the word "apple" playing in the sentence "I ate the apple
pie." Is apple an adjective? Or are apple and pie treated together as one
noun. Is this true of all words used like this? Can "foot" be used as an
adjective if I refer to someone as "that foot guy?" Thanks!
Friday, 23 August 2013
sum of two independent exponential distribution
sum of two independent exponential distribution
let $Y_1\sim \exp(\lambda_1)$ and $Y_2\sim \exp(\lambda_2)$ and $V=Y_1+Y_2$
Show that the pdf of $p_V(x)$ of $V$ has the following form
$$p_V(x)=\frac{e^\frac{-v}{\lambda_1}-e^\frac{-v}{\lambda_2}}{\lambda_1-\lambda_2};\quad
v\ge0$$
My attempt:
distribution of $Y_i$,
$$p_{Y_i}(y_i)=\frac{1}{\lambda_i}e^\frac{-{y_i}}{\lambda_i};\quad
x\ge0;\quad i=1,2$$
joint distribution of $Y_1$ and $Y_2$,
$$p_{Y_1,Y_2}(y_1,y_2)=\frac{1}{\lambda_1\lambda_2}e^{\frac{-{y_1}}{\lambda_1}-\frac{{y_2}}{\lambda_2}};\quad
{y_1},{y_2}\ge0$$
Given, $V=Y_1+Y_2$
let $U=Y_2$
So the Jacobian of Transformation is $1$
and hence joint distribution of $V$ and $U$,
$$p_{V,U}(v,u)=\frac{1}{\lambda_1\lambda_2}e^{\frac{-{v-u}}{\lambda_1}-\frac{{u}}{\lambda_2}};\quad
{v},{u}\ge0$$
so the distribution of $v$ $$p_{V}(v)=\int_0^\infty
p_{V,U}(v,u)du=\frac{e^\frac{-v}{\lambda_1}}{\lambda_1-\lambda_2};\quad
v\ge0$$
which doesn't match with the result.
let $Y_1\sim \exp(\lambda_1)$ and $Y_2\sim \exp(\lambda_2)$ and $V=Y_1+Y_2$
Show that the pdf of $p_V(x)$ of $V$ has the following form
$$p_V(x)=\frac{e^\frac{-v}{\lambda_1}-e^\frac{-v}{\lambda_2}}{\lambda_1-\lambda_2};\quad
v\ge0$$
My attempt:
distribution of $Y_i$,
$$p_{Y_i}(y_i)=\frac{1}{\lambda_i}e^\frac{-{y_i}}{\lambda_i};\quad
x\ge0;\quad i=1,2$$
joint distribution of $Y_1$ and $Y_2$,
$$p_{Y_1,Y_2}(y_1,y_2)=\frac{1}{\lambda_1\lambda_2}e^{\frac{-{y_1}}{\lambda_1}-\frac{{y_2}}{\lambda_2}};\quad
{y_1},{y_2}\ge0$$
Given, $V=Y_1+Y_2$
let $U=Y_2$
So the Jacobian of Transformation is $1$
and hence joint distribution of $V$ and $U$,
$$p_{V,U}(v,u)=\frac{1}{\lambda_1\lambda_2}e^{\frac{-{v-u}}{\lambda_1}-\frac{{u}}{\lambda_2}};\quad
{v},{u}\ge0$$
so the distribution of $v$ $$p_{V}(v)=\int_0^\infty
p_{V,U}(v,u)du=\frac{e^\frac{-v}{\lambda_1}}{\lambda_1-\lambda_2};\quad
v\ge0$$
which doesn't match with the result.
decltype and member type
decltype and member type
I am trying to get the member type after decltype and define a variable y.
struct s
{
typedef int val_type;
};
int main()
{
s x;
decltype(x)::val_type y;
}
In the above program, the compiler complains:
'val_type' : is not a member of '`global namespace''
However, decltype(x) does get type s. Why couldn't I follow val_type after
it to get the member type?
I am trying to get the member type after decltype and define a variable y.
struct s
{
typedef int val_type;
};
int main()
{
s x;
decltype(x)::val_type y;
}
In the above program, the compiler complains:
'val_type' : is not a member of '`global namespace''
However, decltype(x) does get type s. Why couldn't I follow val_type after
it to get the member type?
How can I include address bar variable in this javascript line?
How can I include address bar variable in this javascript line?
Can someone please tell me how I can add in the address bar variable to my
javascript?
The website address reads: www.example.com/index.php?user=74
and the javascript that needs to include 'user = 74' is:
xmlhttp.open("GET","../profile/" + pageName + ".php",true);
Can someone please tell me how I can add in the address bar variable to my
javascript?
The website address reads: www.example.com/index.php?user=74
and the javascript that needs to include 'user = 74' is:
xmlhttp.open("GET","../profile/" + pageName + ".php",true);
Resize /home on CentOS vmware guest
Resize /home on CentOS vmware guest
I have a new vmware guest, let's say I want to extend it from 100 GB to
300 GB
My question is how to insert all the 200gb into /home? Where can I start?
df -h displays:
I have a new vmware guest, let's say I want to extend it from 100 GB to
300 GB
My question is how to insert all the 200gb into /home? Where can I start?
df -h displays:
Javascript continue statement in while loop causes an infinite loop
Javascript continue statement in while loop causes an infinite loop
I'm trying to create a while loop with a continue statement. However it
seems to be causing an infinite loop and I can't figure out why.
The code below to me seems like it should start with the var tasksToDo at
3 then decrement down to 0 skipping number 2 on the way.
Any help with what Im doing wrong here greatly appreciated.
var tasksToDo = 3
while (tasksToDo > 0) {
if (tasksToDo == 2) {
continue;
}
console.log('there are ' + tasksToDo + ' tasks');
tasksToDo--;
}
I'm trying to create a while loop with a continue statement. However it
seems to be causing an infinite loop and I can't figure out why.
The code below to me seems like it should start with the var tasksToDo at
3 then decrement down to 0 skipping number 2 on the way.
Any help with what Im doing wrong here greatly appreciated.
var tasksToDo = 3
while (tasksToDo > 0) {
if (tasksToDo == 2) {
continue;
}
console.log('there are ' + tasksToDo + ' tasks');
tasksToDo--;
}
Extract problem and solution from files and create problem collection
Extract problem and solution from files and create problem collection
I have a set of problems and solutions, which I wish to include in several
different documents. I would like to be able to choose if the solutions
should be presented last, or immediate after the problem formulation.
A possibility is to put each problem and solution in a separate file, and
then have some command
\includepart{filename.tex}{problem}
and
\includepart{filename.tex}{solution}
where \includepart{file}{env} includes say everything between
\begin{env}and \end{env}.
Is there a simple way to do this? Are there better solutions to this? This
seems to be a common problem, but I have not found something that does
exactly this.
I have a set of problems and solutions, which I wish to include in several
different documents. I would like to be able to choose if the solutions
should be presented last, or immediate after the problem formulation.
A possibility is to put each problem and solution in a separate file, and
then have some command
\includepart{filename.tex}{problem}
and
\includepart{filename.tex}{solution}
where \includepart{file}{env} includes say everything between
\begin{env}and \end{env}.
Is there a simple way to do this? Are there better solutions to this? This
seems to be a common problem, but I have not found something that does
exactly this.
Thursday, 22 August 2013
Convert PDF's to searchable PDF's (OCR) in SharePoint
Convert PDF's to searchable PDF's (OCR) in SharePoint
When user upload a PDF to library I'm supposed to convert PDF's to
searchable PDF's (OCR) in sharepoint 2010 using Tesseract. I'm looking for
a way...
When user upload a PDF to library I'm supposed to convert PDF's to
searchable PDF's (OCR) in sharepoint 2010 using Tesseract. I'm looking for
a way...
Dynamically Load External Webpage
Dynamically Load External Webpage
I see this site and many others answering similar questions, but often in
ways I fail to understand or just do not make sense. And often in
contradictory ways (maybe the spec keeps changing?). And I see posts about
how to set up cross domain JavaScript communication, but I do not need to
communicate with this external content (and I am still not sure if you
must have access to the code-base of both child and parent or not, for
these hacks to work).
I need to show another person's webpage, on another domain, in a box on my
page. SO basically this is like clicking a link, but instead of specifying
that the browser should open this in a new tab or a new window, I want the
browser to open it in a in-line frame type deal on the current page. So
even I know enough about security to know that there are no
security/communications issues with this feature.
But assuming that the browser developers have removed this completely
reasonable feature, how do I go about doing this? I have heard talk about
some Json data type thing being allowed, but still have not figured out
exactly what that means. Can I contact any random external page and get
some json summery of the page, or how does this work? (I saw an example
with Wikipedia, but I was not sure exactly what was being returned, and if
any random URL would work just as well).
I can use PHP for this, but that is just stupid. I would basically just be
setting up a proxy to access content I am randomly banned from because of
the programming language I am trying to access it from.
I see this site and many others answering similar questions, but often in
ways I fail to understand or just do not make sense. And often in
contradictory ways (maybe the spec keeps changing?). And I see posts about
how to set up cross domain JavaScript communication, but I do not need to
communicate with this external content (and I am still not sure if you
must have access to the code-base of both child and parent or not, for
these hacks to work).
I need to show another person's webpage, on another domain, in a box on my
page. SO basically this is like clicking a link, but instead of specifying
that the browser should open this in a new tab or a new window, I want the
browser to open it in a in-line frame type deal on the current page. So
even I know enough about security to know that there are no
security/communications issues with this feature.
But assuming that the browser developers have removed this completely
reasonable feature, how do I go about doing this? I have heard talk about
some Json data type thing being allowed, but still have not figured out
exactly what that means. Can I contact any random external page and get
some json summery of the page, or how does this work? (I saw an example
with Wikipedia, but I was not sure exactly what was being returned, and if
any random URL would work just as well).
I can use PHP for this, but that is just stupid. I would basically just be
setting up a proxy to access content I am randomly banned from because of
the programming language I am trying to access it from.
XBOX 360 Arcade multiple USB flash drives
XBOX 360 Arcade multiple USB flash drives
Recently I grabbed rather old XBOX 360 Arcade for my son who wanted to
play Minecraft that is not yet available on PS3. This console doesn't have
much internal storage and after resetting and applying latest updates,
only about 24 MB is left. I read that I can either add external HDD or USB
flash drive to it. I have couple of spare USB drives and one of them
actually worked. It is small (4GB) and I am planning to add more. This is
my secondary console so I don't want to spend too much money on it. Few
questions...
I see 3 USB ports so can I put three USB flash drives of 32GB each if I
wanted to?
I am thinking about not getting HDD storage at all as it is more expensive
and very specific to XBOX. USB flash drives are multi-purpose and I could
use those elsewhere after the console dies or I don't want to use it
anymore. Any downside to this?
I would like to buy games from live account instead of on physical disks.
The table in the link seems to indicate that it is supported but I wanted
to confirm as some older articles say otherwise. It seems like this
support was added much later after the console was released.
Can the installed game be moved from one flash drive to another?
Recently I grabbed rather old XBOX 360 Arcade for my son who wanted to
play Minecraft that is not yet available on PS3. This console doesn't have
much internal storage and after resetting and applying latest updates,
only about 24 MB is left. I read that I can either add external HDD or USB
flash drive to it. I have couple of spare USB drives and one of them
actually worked. It is small (4GB) and I am planning to add more. This is
my secondary console so I don't want to spend too much money on it. Few
questions...
I see 3 USB ports so can I put three USB flash drives of 32GB each if I
wanted to?
I am thinking about not getting HDD storage at all as it is more expensive
and very specific to XBOX. USB flash drives are multi-purpose and I could
use those elsewhere after the console dies or I don't want to use it
anymore. Any downside to this?
I would like to buy games from live account instead of on physical disks.
The table in the link seems to indicate that it is supported but I wanted
to confirm as some older articles say otherwise. It seems like this
support was added much later after the console was released.
Can the installed game be moved from one flash drive to another?
Text formatting for strings in Google Documents from Google Apps Script
Text formatting for strings in Google Documents from Google Apps Script
I have some Google Apps scripts that use the DocumentApp .replaceText
method to find a text string in a Google Document and replace it with a
different text string.
var file = DocsList.getFileById('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
var newTextString = 'foo\nbar';
file.replaceText('Old text string',newTextString);
The \n works to make line breaks, but is there a way to format the text
with bold/italics/colors/etc?
I tried to use HTML tags and inline CSS styles with the span tag, but that
didn't work, it just outputs the text including the tags. I remember how
Google Docs used to have an HTML button and you could see the markup that
made up the content of the Google doc, but they took that out.
I have some Google Apps scripts that use the DocumentApp .replaceText
method to find a text string in a Google Document and replace it with a
different text string.
var file = DocsList.getFileById('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
var newTextString = 'foo\nbar';
file.replaceText('Old text string',newTextString);
The \n works to make line breaks, but is there a way to format the text
with bold/italics/colors/etc?
I tried to use HTML tags and inline CSS styles with the span tag, but that
didn't work, it just outputs the text including the tags. I remember how
Google Docs used to have an HTML button and you could see the markup that
made up the content of the Google doc, but they took that out.
where i can see Kuban vs Feyenoord Live Online Streaming
where i can see Kuban vs Feyenoord Live Online Streaming
Watch Live Streaming Link
The UEFA Europa League is an annual association football cup competition
organised by UEFA since 1971 for eligible European football clubs. It is
the second most prestigious European club football contest after the UEFA
Champions League. Clubs qualify for the competition based on their
performance in their national leagues and cup competitions.
Watch Soccer Live
Watch Live Streaming Link
Watch Live Streaming Link
The UEFA Europa League is an annual association football cup competition
organised by UEFA since 1971 for eligible European football clubs. It is
the second most prestigious European club football contest after the UEFA
Champions League. Clubs qualify for the competition based on their
performance in their national leagues and cup competitions.
Watch Soccer Live
Watch Live Streaming Link
How to get unicode character http response in blackberry?
How to get unicode character http response in blackberry?
I have an api that response with json data which contains malayalam
unicharacter and english unicharacter also. it works fine in phonegap. but
when i try to get this response in blackberry native (Java) i got
different character response.
The response i got in phonegap and android native.
The response i got in blackberry 7 native.
how to solve this problem please help me
I have an api that response with json data which contains malayalam
unicharacter and english unicharacter also. it works fine in phonegap. but
when i try to get this response in blackberry native (Java) i got
different character response.
The response i got in phonegap and android native.
The response i got in blackberry 7 native.
how to solve this problem please help me
how to make a caption or description follow cursor when it is hovered over an image
how to make a caption or description follow cursor when it is hovered over
an image
How to make a caption or description follow cursor when it is hovered over
an image, here is what i am talking about:
http://joannagoddard.blogspot.in , in the "MOST POPULAR POST" section, on
right.
an image
How to make a caption or description follow cursor when it is hovered over
an image, here is what i am talking about:
http://joannagoddard.blogspot.in , in the "MOST POPULAR POST" section, on
right.
Wednesday, 21 August 2013
How does one send a chat message in Facebook using jquery within the Chrome browser?
How does one send a chat message in Facebook using jquery within the
Chrome browser?
I'm trying to send a chat message in Facebook using jquery, but keep
getting an error message. Either it being "TypeError: Object # has no
method 'WHATEVERIPUTHERE'"
[Note that I'm pretty new with coding.]
// Basically o = the chat text area.
// the o.WHATEVERIPUTHERE("Hello!") is what I'm trying to do (setting a
value for the text area, and sending it)
I have no idea how to get this to work as my method knowledge is limited.
Basically, I just need help exapnding on this to make this a workable
code. Thanks! [code below]
var o = document.getElementsByClassName("uiTextareaAutogrow _552m");
o.WHATEVERIPUTHERE("Hello!");
Chrome browser?
I'm trying to send a chat message in Facebook using jquery, but keep
getting an error message. Either it being "TypeError: Object # has no
method 'WHATEVERIPUTHERE'"
[Note that I'm pretty new with coding.]
// Basically o = the chat text area.
// the o.WHATEVERIPUTHERE("Hello!") is what I'm trying to do (setting a
value for the text area, and sending it)
I have no idea how to get this to work as my method knowledge is limited.
Basically, I just need help exapnding on this to make this a workable
code. Thanks! [code below]
var o = document.getElementsByClassName("uiTextareaAutogrow _552m");
o.WHATEVERIPUTHERE("Hello!");
Why shall I explicitly cast null for the invocation of a varargs method?
Why shall I explicitly cast null for the invocation of a varargs method?
I've got the following code:
public static void varargsMethod(String ... strings) {
if (strings != null && strings.length != 0) {
for (String s : strings) {
System.out.println(s);
}
} else {
System.out.println("Hello (string free) world!");
}
}
public static void main(String[] args) {
varargsMethod(null);
varargsMethod((String[]) null);
varargsMethod((String) null);
varargsMethod();
}
I wonder why the first invocation with null as the argument generates a
warning with the hint, that an explicit cast is needed. From the answers
on this question it is not clear for me, why this cast is needed. The
first two invocations work and produce the same result, while the third
produces "null". I explicitly want the behaviour of the first two
invocations.
Shouldn't null be always valid (and automatically casted) for reference
types and arrays? I don't see, why the type information is important in
this case.
I've got the following code:
public static void varargsMethod(String ... strings) {
if (strings != null && strings.length != 0) {
for (String s : strings) {
System.out.println(s);
}
} else {
System.out.println("Hello (string free) world!");
}
}
public static void main(String[] args) {
varargsMethod(null);
varargsMethod((String[]) null);
varargsMethod((String) null);
varargsMethod();
}
I wonder why the first invocation with null as the argument generates a
warning with the hint, that an explicit cast is needed. From the answers
on this question it is not clear for me, why this cast is needed. The
first two invocations work and produce the same result, while the third
produces "null". I explicitly want the behaviour of the first two
invocations.
Shouldn't null be always valid (and automatically casted) for reference
types and arrays? I don't see, why the type information is important in
this case.
What does Math.random() do in this JavaScript snippet?
What does Math.random() do in this JavaScript snippet?
I'm watching this Google I/O presentation from 2011
https://www.youtube.com/watch?v=M3uWx-fhjUc
At minute 39:31, Michael shows the output of the closure compiler, which
looks like the code included below.
My question is what exactly is this code doing (how and why)
// Question #1 - floor & random? 2147483648?
Math.floor(Math.random() * 2147483648).toString(36);
var b = /&/g,
c = /</g,d=/>/g,
e = /\"/g,
f = /[&<>\"]/;
// Question #2 - Looks like sanitizing input... yes?
function g(a) {
a = String(a);
f.test(a) && (
a.indexOf("&") != -1 && (a = a.replace(b, "&")),
a.indexOf("<") != -1 && (a = a.replace(c, "<")),
a.indexOf(">") != -1 && (a = a.replace(d, ">")),
a.indexOf('"') != -1 && (a = a.replace(e, """))
);
return a;
};
// Question #3 - void 0 ???
var h = document.getElementById("submit-button"),
i,
j = {
label: void 0,
a: void 0
};
i = '<button title="' + g(j.a) + '"><span>' + g(j.label) +
"</span></button>";
h.innerHTML = i;
I'm watching this Google I/O presentation from 2011
https://www.youtube.com/watch?v=M3uWx-fhjUc
At minute 39:31, Michael shows the output of the closure compiler, which
looks like the code included below.
My question is what exactly is this code doing (how and why)
// Question #1 - floor & random? 2147483648?
Math.floor(Math.random() * 2147483648).toString(36);
var b = /&/g,
c = /</g,d=/>/g,
e = /\"/g,
f = /[&<>\"]/;
// Question #2 - Looks like sanitizing input... yes?
function g(a) {
a = String(a);
f.test(a) && (
a.indexOf("&") != -1 && (a = a.replace(b, "&")),
a.indexOf("<") != -1 && (a = a.replace(c, "<")),
a.indexOf(">") != -1 && (a = a.replace(d, ">")),
a.indexOf('"') != -1 && (a = a.replace(e, """))
);
return a;
};
// Question #3 - void 0 ???
var h = document.getElementById("submit-button"),
i,
j = {
label: void 0,
a: void 0
};
i = '<button title="' + g(j.a) + '"><span>' + g(j.label) +
"</span></button>";
h.innerHTML = i;
How does creating a instance of class inside of the class itself works?
How does creating a instance of class inside of the class itself works?
What makes it possible to create a instance of class inside of the class
itself?
public void class My_Class
{
My_Class new_class= new My_Class();
}
Isn't this like using a function without creating it at the first place ?
How can you explain this be explained to someone from functional
programming?
What makes it possible to create a instance of class inside of the class
itself?
public void class My_Class
{
My_Class new_class= new My_Class();
}
Isn't this like using a function without creating it at the first place ?
How can you explain this be explained to someone from functional
programming?
UnknownJavaServerError when trying to upload data to the Google app engine data store
UnknownJavaServerError when trying to upload data to the Google app engine
data store
I am trying to follow the Google app engine tutorial
This code runs on my local development server. When I execute :
appcfg.py upload_data --config_file bulkloader.yaml
--url=http://localhost:8888/remote_api --filename places.csv --kind=Place
-e nobody@nowhere.com
I get a UnknownJavaServerError. Any ideas why this is happening? [My OS is
Windows, python version is 2.7]
This is the full output I get:
C:\EclipseWorkspace\Android\MobileAssistant2-AppEngine\src>appcfg.py
upload_data --config_file=bulkloader.yaml --filename=places.csv
--kind=Place --url=http://localhost:8888/remote_api -e
nobody@nowhere.com
08:46 PM Uploading data records.
[INFO ] Logging to bulkloader-log-20130821.204602
[INFO ] Throttling transfers:
[INFO ] Bandwidth: 250000 bytes/second
[INFO ] HTTP connections: 8/second
[INFO ] Entities inserted/fetched/modified: 20/second
[INFO ] Batch Size: 10
Password for nobody@nowhere.com:
[INFO ] Opening database: bulkloader-progress-20130821.204602.sql3
[INFO ] Connecting to localhost:8888/remote_api
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line
171, in <module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line
167, in run_file
execfile(script_path, globals_)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
4282, in <module>
main(sys.argv)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
4273, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
2409, in Run
self.action(self)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
4003, in __call__
return method()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
3815, in PerformUpload
run_fn(args)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
3706, in RunBulkloader
sys.exit(bulkloader.Run(arg_dict))
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\bulkloader.py",
line 4395, in Run
return _PerformBulkload(arg_dict)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\bulkloader.py",
line 4260, in _PerformBulkload
loader.finalize()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\bulkload\bulkloader_config.py",
line 382, in finalize
self.reserve_keys(self.keys_to_reserve)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\bulkloader.py",
line 1228, in ReserveKeys
datastore._GetConnection()._reserve_keys(ConvertKeys(keys))
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 1880, in _reserve_keys
self._async_reserve_keys(None, keys).get_result()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 838, in get_result
results = self.__rpcs[0].get_result()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py",
line 612, in get_result
return self.__get_result_hook(self)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 1921, in __reserve_keys_hook
self.check_rpc_success(rpc)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 1234, in check_rpc_success
rpc.check_success()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py",
line 578, in check_success
self.__rpc.CheckSuccess()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\api\apiproxy_rpc.py",
line 156, in _WaitImpl
self.request, self.response)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py",
line 200, in MakeSyncCall
self._MakeRealSyncCall(service, call, request, response)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py",
line 236, in _MakeRealSyncCall
raise UnknownJavaServerError("An unknown error has occured in the "
google.appengine.ext.remote_api.remote_api_stub.UnknownJavaServerError: An
unknown error has occured in the Java remote_api handler for this call.
My source files are given below-
web.xml file:
<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.google.samplesolutions.mobileassistant.CheckInEndpoint,com.google.samplesolutions.mobileassistant.DeviceInfoEndpoint,com.google.samplesolutions.mobileassistant.MessageEndpoint,com.google.samplesolutions.mobileassistant.PlaceEndpoint</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>
</web-app>
bulkloader.yaml file:
#!/usr/bin/python
#
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
python_preamble:
- import: base64
- import: re
- import: google.appengine.ext.bulkload.transform
- import: google.appengine.ext.bulkload.bulkloader_wizard
- import: google.appengine.ext.db
- import: google.appengine.api.datastore
- import: google.appengine.api.users
transformers:
- kind: Offer
connector: csv
connector_options:
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: description
external_name: description
# Type: String Stats: 2 properties of this type in this kind.
- property: title
external_name: title
# Type: String Stats: 2 properties of this type in this kind.
- property: imageUrl
external_name: imageUrl
- kind: Place
connector: csv
connector_options:
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: address
external_name: address
# Type: String Stats: 6 properties of this type in this kind.
- property: location
external_name: location
# Type: GeoPt Stats: 6 properties of this type in this kind.
import_transform: google.appengine.api.datastore_types.GeoPt
- property: name
external_name: name
# Type: String Stats: 6 properties of this type in this kind.
- property: placeId
external_name: placeId
# Type: String Stats: 6 properties of this type in this kind.
- kind: Recommendation
connector: csv
connector_options:
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: description
external_name: description
# Type: String Stats: 4 properties of this type in this kind.
- property: title
external_name: title
# Type: String Stats: 4 properties of this type in this kind.
- property: imageUrl
external_name: imageUrl
- property: expiration
external_name: expiration
import_transform: transform.import_date_time('%m/%d/%Y')
places.csv file:
name,placeId,location,key,address
A store at City1 Shopping Center,store101,"47,-122",1,"Some address of the
store in City 1"
A big store at Some Mall,store102,"47,-122",2,"Some address of the store
in City 2"
Thanks!
data store
I am trying to follow the Google app engine tutorial
This code runs on my local development server. When I execute :
appcfg.py upload_data --config_file bulkloader.yaml
--url=http://localhost:8888/remote_api --filename places.csv --kind=Place
-e nobody@nowhere.com
I get a UnknownJavaServerError. Any ideas why this is happening? [My OS is
Windows, python version is 2.7]
This is the full output I get:
C:\EclipseWorkspace\Android\MobileAssistant2-AppEngine\src>appcfg.py
upload_data --config_file=bulkloader.yaml --filename=places.csv
--kind=Place --url=http://localhost:8888/remote_api -e
nobody@nowhere.com
08:46 PM Uploading data records.
[INFO ] Logging to bulkloader-log-20130821.204602
[INFO ] Throttling transfers:
[INFO ] Bandwidth: 250000 bytes/second
[INFO ] HTTP connections: 8/second
[INFO ] Entities inserted/fetched/modified: 20/second
[INFO ] Batch Size: 10
Password for nobody@nowhere.com:
[INFO ] Opening database: bulkloader-progress-20130821.204602.sql3
[INFO ] Connecting to localhost:8888/remote_api
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line
171, in <module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line
167, in run_file
execfile(script_path, globals_)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
4282, in <module>
main(sys.argv)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
4273, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
2409, in Run
self.action(self)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
4003, in __call__
return method()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
3815, in PerformUpload
run_fn(args)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line
3706, in RunBulkloader
sys.exit(bulkloader.Run(arg_dict))
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\bulkloader.py",
line 4395, in Run
return _PerformBulkload(arg_dict)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\bulkloader.py",
line 4260, in _PerformBulkload
loader.finalize()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\bulkload\bulkloader_config.py",
line 382, in finalize
self.reserve_keys(self.keys_to_reserve)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\tools\bulkloader.py",
line 1228, in ReserveKeys
datastore._GetConnection()._reserve_keys(ConvertKeys(keys))
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 1880, in _reserve_keys
self._async_reserve_keys(None, keys).get_result()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 838, in get_result
results = self.__rpcs[0].get_result()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py",
line 612, in get_result
return self.__get_result_hook(self)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 1921, in __reserve_keys_hook
self.check_rpc_success(rpc)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py",
line 1234, in check_rpc_success
rpc.check_success()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py",
line 578, in check_success
self.__rpc.CheckSuccess()
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\api\apiproxy_rpc.py",
line 156, in _WaitImpl
self.request, self.response)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py",
line 200, in MakeSyncCall
self._MakeRealSyncCall(service, call, request, response)
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py",
line 236, in _MakeRealSyncCall
raise UnknownJavaServerError("An unknown error has occured in the "
google.appengine.ext.remote_api.remote_api_stub.UnknownJavaServerError: An
unknown error has occured in the Java remote_api handler for this call.
My source files are given below-
web.xml file:
<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.google.samplesolutions.mobileassistant.CheckInEndpoint,com.google.samplesolutions.mobileassistant.DeviceInfoEndpoint,com.google.samplesolutions.mobileassistant.MessageEndpoint,com.google.samplesolutions.mobileassistant.PlaceEndpoint</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>
</web-app>
bulkloader.yaml file:
#!/usr/bin/python
#
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
python_preamble:
- import: base64
- import: re
- import: google.appengine.ext.bulkload.transform
- import: google.appengine.ext.bulkload.bulkloader_wizard
- import: google.appengine.ext.db
- import: google.appengine.api.datastore
- import: google.appengine.api.users
transformers:
- kind: Offer
connector: csv
connector_options:
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: description
external_name: description
# Type: String Stats: 2 properties of this type in this kind.
- property: title
external_name: title
# Type: String Stats: 2 properties of this type in this kind.
- property: imageUrl
external_name: imageUrl
- kind: Place
connector: csv
connector_options:
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: address
external_name: address
# Type: String Stats: 6 properties of this type in this kind.
- property: location
external_name: location
# Type: GeoPt Stats: 6 properties of this type in this kind.
import_transform: google.appengine.api.datastore_types.GeoPt
- property: name
external_name: name
# Type: String Stats: 6 properties of this type in this kind.
- property: placeId
external_name: placeId
# Type: String Stats: 6 properties of this type in this kind.
- kind: Recommendation
connector: csv
connector_options:
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: description
external_name: description
# Type: String Stats: 4 properties of this type in this kind.
- property: title
external_name: title
# Type: String Stats: 4 properties of this type in this kind.
- property: imageUrl
external_name: imageUrl
- property: expiration
external_name: expiration
import_transform: transform.import_date_time('%m/%d/%Y')
places.csv file:
name,placeId,location,key,address
A store at City1 Shopping Center,store101,"47,-122",1,"Some address of the
store in City 1"
A big store at Some Mall,store102,"47,-122",2,"Some address of the store
in City 2"
Thanks!
Is there any way of taking a screenshot of a website in PHP, then saving it to a file?
Is there any way of taking a screenshot of a website in PHP, then saving
it to a file?
COM class is not accessible in linux .so which classis used in linux ?
it to a file?
COM class is not accessible in linux .so which classis used in linux ?
Tuesday, 20 August 2013
JQuery scrollTop values fadeIn/Out
JQuery scrollTop values fadeIn/Out
I have this code so that my '.button' would fadeIn if the 'scrollTop > 200'.
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('.button').fadeIn(500);
} else {
$('.button').fadeOut(500);
}
});
});
What I want to happen is I want '.button' to fadeIn if it's on a certain
part of the page, and fadeOut if it's out of the specified part. For
example:
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() 200 - 500) {
$('.button').fadeIn(500);
} else {
$('.button').fadeOut(500);
}
});
});
Basically, I want ".button" to disappear if it's outside of the values given.
I have this code so that my '.button' would fadeIn if the 'scrollTop > 200'.
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('.button').fadeIn(500);
} else {
$('.button').fadeOut(500);
}
});
});
What I want to happen is I want '.button' to fadeIn if it's on a certain
part of the page, and fadeOut if it's out of the specified part. For
example:
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() 200 - 500) {
$('.button').fadeIn(500);
} else {
$('.button').fadeOut(500);
}
});
});
Basically, I want ".button" to disappear if it's outside of the values given.
Right align ToolBarPanel control WPF
Right align ToolBarPanel control WPF
This is my first time using WPF, I have a usercontrol with a ToolBar, and
ToolBarPanels on that ToolBar. My problem is trying to right align the
very last ToolBarPanel which contains some buttons.
http://imgur.com/n5v4YCw
I have scoured the interwebs and tried solutions (wrap it in a grid,
dockpanel, stackpanel) but none have worked.
My XAML is:
<ToolBar.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF475B7E" Offset="1"/>
<GradientStop Color="#FFB9C3D5" Offset="0.427"/>
</LinearGradientBrush>
</ToolBar.Background>
.........
<ToolBarPanel ToolBar.OverflowMode="AsNeeded"
Orientation="Horizontal" HorizontalAlignment="Right" >
<Button
Name="btnPrint"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="1"
IsEnabled="{Binding Path=AllowEdit}"
BorderBrush="#FF586A8B"
DockPanel.Dock="Right"
Visibility="{Binding Path=ControlVisibility.Print,
Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Source="/component/Images/print-image.png"></Image>
<Button.ToolTip>
<ToolTip>
<TextBlock>Print Chart</TextBlock>
</ToolTip>
</Button.ToolTip>
</Button>
<Button
Name="btnCopy"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="1"
IsEnabled="{Binding Path=AllowEdit}"
BorderBrush="#FF586A8B"
Visibility="{Binding Path=ControlVisibility.Copy,
Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Source="/component/Images/copy-image.png"></Image>
<Button.ToolTip>
<ToolTip>
<TextBlock>Copy Chart to Clipboard</TextBlock>
</ToolTip>
</Button.ToolTip>
</Button>
<Button
Name="btnInfo"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="1"
IsEnabled="{Binding Path=AllowEdit}"
BorderBrush="#FF586A8B"
Visibility="{Binding Path=ControlVisibility.Info,
Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Source="/component/Images/help-image.png"></Image>
<Button.ToolTip>
<ToolTip>
<TextBlock>Chart Help</TextBlock>
</ToolTip>
</Button.ToolTip>
</Button>
</ToolBarPanel>
</ToolBar>
This is my first time using WPF, I have a usercontrol with a ToolBar, and
ToolBarPanels on that ToolBar. My problem is trying to right align the
very last ToolBarPanel which contains some buttons.
http://imgur.com/n5v4YCw
I have scoured the interwebs and tried solutions (wrap it in a grid,
dockpanel, stackpanel) but none have worked.
My XAML is:
<ToolBar.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF475B7E" Offset="1"/>
<GradientStop Color="#FFB9C3D5" Offset="0.427"/>
</LinearGradientBrush>
</ToolBar.Background>
.........
<ToolBarPanel ToolBar.OverflowMode="AsNeeded"
Orientation="Horizontal" HorizontalAlignment="Right" >
<Button
Name="btnPrint"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="1"
IsEnabled="{Binding Path=AllowEdit}"
BorderBrush="#FF586A8B"
DockPanel.Dock="Right"
Visibility="{Binding Path=ControlVisibility.Print,
Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Source="/component/Images/print-image.png"></Image>
<Button.ToolTip>
<ToolTip>
<TextBlock>Print Chart</TextBlock>
</ToolTip>
</Button.ToolTip>
</Button>
<Button
Name="btnCopy"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="1"
IsEnabled="{Binding Path=AllowEdit}"
BorderBrush="#FF586A8B"
Visibility="{Binding Path=ControlVisibility.Copy,
Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Source="/component/Images/copy-image.png"></Image>
<Button.ToolTip>
<ToolTip>
<TextBlock>Copy Chart to Clipboard</TextBlock>
</ToolTip>
</Button.ToolTip>
</Button>
<Button
Name="btnInfo"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="1"
IsEnabled="{Binding Path=AllowEdit}"
BorderBrush="#FF586A8B"
Visibility="{Binding Path=ControlVisibility.Info,
Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Source="/component/Images/help-image.png"></Image>
<Button.ToolTip>
<ToolTip>
<TextBlock>Chart Help</TextBlock>
</ToolTip>
</Button.ToolTip>
</Button>
</ToolBarPanel>
</ToolBar>
How to prompt user for input and use input else where in batch file
How to prompt user for input and use input else where in batch file
I am very new to batch scripting. I am trying to prompt a user to "Enter
directory path containing files to be converted:". Once they enter that I
want to prompt them to "Enter directory path to save files to once
converted:". My code currently prompts the first question, but then closes
before the user can input anything.
I am very new to batch scripting. I am trying to prompt a user to "Enter
directory path containing files to be converted:". Once they enter that I
want to prompt them to "Enter directory path to save files to once
converted:". My code currently prompts the first question, but then closes
before the user can input anything.
Importing a hyper-v exported image
Importing a hyper-v exported image
My google-fu is failing me. Badly.
One of my clients sent me a Hyper-V exported VM which constitutes a bunch
of VHDs and an XML file (which I assume is the machine definition file).
Try as I might, I can't figure out how to import this machine or convert
it into a format compatible with any of VMWare Workstation, Virtual Box or
even Windows Virtual PC. Googling and searching the fora for a few hours
has not yielded any satisfying answers.
Can anyone direct me as to how to properly import said Hyper-V exported VM
into any of VMWare Workstation, Virtual Box or Windows Virtual PC please?
Thanks
My google-fu is failing me. Badly.
One of my clients sent me a Hyper-V exported VM which constitutes a bunch
of VHDs and an XML file (which I assume is the machine definition file).
Try as I might, I can't figure out how to import this machine or convert
it into a format compatible with any of VMWare Workstation, Virtual Box or
even Windows Virtual PC. Googling and searching the fora for a few hours
has not yielded any satisfying answers.
Can anyone direct me as to how to properly import said Hyper-V exported VM
into any of VMWare Workstation, Virtual Box or Windows Virtual PC please?
Thanks
Is it possible to get path info in google maps?
Is it possible to get path info in google maps?
When creating a new route in the maps there appears a small info about
this route: how much time there you will need by car or on foot and the
distance? Is it possible to get this info between two LatLng points?
When creating a new route in the maps there appears a small info about
this route: how much time there you will need by car or on foot and the
distance? Is it possible to get this info between two LatLng points?
Cant seem to connect the JDBC sql server driver to java eclipse project
Cant seem to connect the JDBC sql server driver to java eclipse project
I'm trying to setup the connect from my sql server database to my project
but when i try to compile it i get:
java.sql.SQLException: No suitable driver found for jdbc.odbc:login_DSN
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at SelfPractice.main(SelfPractice.java:13)
I'm very much new to this. i went to controlPanel>adminstrive tools>data
sources and there added a data source called login_DSN . i've looked in
older posts and they say to include the driver jar file in class path
which i think i did(i downloaded the jdbc driver from microsoft website
and loaded it to a 'referenced library' in eclipose, but i still get this
error message. How do i solve my driver problem?
I'm trying to setup the connect from my sql server database to my project
but when i try to compile it i get:
java.sql.SQLException: No suitable driver found for jdbc.odbc:login_DSN
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at SelfPractice.main(SelfPractice.java:13)
I'm very much new to this. i went to controlPanel>adminstrive tools>data
sources and there added a data source called login_DSN . i've looked in
older posts and they say to include the driver jar file in class path
which i think i did(i downloaded the jdbc driver from microsoft website
and loaded it to a 'referenced library' in eclipose, but i still get this
error message. How do i solve my driver problem?
How to prevent Apple-tab-span style=white-space:pre>?
How to prevent "Apple-tab-span" style="white-space:pre">?
"Apple-tab-span" style="white-space:pre">shows to my code editor when i
tried to paste a code with tab to my code-editor project?
Is this escaping issue?
"Apple-tab-span" style="white-space:pre">shows to my code editor when i
tried to paste a code with tab to my code-editor project?
Is this escaping issue?
Monday, 19 August 2013
how to select from two tables, update one table with sqldatasource
how to select from two tables, update one table with sqldatasource
The provider is ODP.net. The data-bound control is GridView with an Edit
button. I got ORA-01008 not all variables bound When I click update
button. The boundfield "NAME" is set to Readonly=True. The data is from
two tables but I only want update one table. Thanks for any reply.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT D.ROWID as ROW_ID,D.ID,D.REMARK,M.NAME FROM
PTDIRECT D,PTMASTER M WHERE D.ID=M.ID ORDER BY D.ID"
UpdateCommand="UPDATE PTDIRECT SET ID=:ID,REMARK=:REMARK
WHERE ROWID=:ROW_ID"
OnUpdating="SqlDataSource1_Updating">
The provider is ODP.net. The data-bound control is GridView with an Edit
button. I got ORA-01008 not all variables bound When I click update
button. The boundfield "NAME" is set to Readonly=True. The data is from
two tables but I only want update one table. Thanks for any reply.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT D.ROWID as ROW_ID,D.ID,D.REMARK,M.NAME FROM
PTDIRECT D,PTMASTER M WHERE D.ID=M.ID ORDER BY D.ID"
UpdateCommand="UPDATE PTDIRECT SET ID=:ID,REMARK=:REMARK
WHERE ROWID=:ROW_ID"
OnUpdating="SqlDataSource1_Updating">
Chained select boxes with jquery/php/database not working
Chained select boxes with jquery/php/database not working
It seems that most chained selects are accomplished with JSON, but
unfortunately it's much more convenient for me to use my database to
accomplish this. It's almost there, but for some reason the second select
box is not loading up properly. Instead it's loading the entire HTML for
the page that it's on and I'm not sure why.
Here's what I've got (note that make_list() and model_list() are functions
I previously built that return an array appropriate to their respective
criteria)
The JS:
$(document).ready(function(){
$("select#type").attr("disabled","disabled");
$("select#category").change(function(){
$("select#type").attr("disabled","disabled");
$("select#type").html("<option>loading...</option>");
var id = $("select#category option:selected").attr('value');
$.post("select_type.php", {id:id}, function(data){
$("select#type").removeAttr("disabled");
$("select#type").html(data);
});
});
$("form#select_form").submit(function(){
var cat = $("select#category option:selected").attr('value');
var type = $("select#type option:selected").attr('value');
if(cat>0 && type>0)
{
var result = $("select#type option:selected").html();
$("#result").html('your choice: '+result);
}
else
{
$("#result").html("you must choose two options!");
}
return false;
});
});
The HTML/PHP:
<form>
<div class="clearfix">
<select id="category">
<option value="">Any</option>
<?php foreach ( make_list() as $make ) { ?>
<option value="<?php echo $make ?>"><?php echo $make ?></option>
<?php } ?>
</select>
</div>
<div class="clearfix">
<select id="type">
<option value="">Any</option>
</select>
</div>
</form>
When the first select is changed JQuery should look at a file in the same
folder called 'select_type.php'. Here's what's in that file (strangely
$_POST['id'] doesn't seem to be appending to this file either, despite it
being created in the JS):
foreach ( model_list($_POST['id']) as $model ) {
echo '<option value="'.$model.'">'.$model.'</option>';
}
I've been using this resource for this project:
http://www.yourinspirationweb.com/en/how-to-create-chained-select-with-php-and-jquery/
and it's gotten me most of the way, but unfortunately the data doesn't
seem to be loading into that second select box.
Thanks for looking!
It seems that most chained selects are accomplished with JSON, but
unfortunately it's much more convenient for me to use my database to
accomplish this. It's almost there, but for some reason the second select
box is not loading up properly. Instead it's loading the entire HTML for
the page that it's on and I'm not sure why.
Here's what I've got (note that make_list() and model_list() are functions
I previously built that return an array appropriate to their respective
criteria)
The JS:
$(document).ready(function(){
$("select#type").attr("disabled","disabled");
$("select#category").change(function(){
$("select#type").attr("disabled","disabled");
$("select#type").html("<option>loading...</option>");
var id = $("select#category option:selected").attr('value');
$.post("select_type.php", {id:id}, function(data){
$("select#type").removeAttr("disabled");
$("select#type").html(data);
});
});
$("form#select_form").submit(function(){
var cat = $("select#category option:selected").attr('value');
var type = $("select#type option:selected").attr('value');
if(cat>0 && type>0)
{
var result = $("select#type option:selected").html();
$("#result").html('your choice: '+result);
}
else
{
$("#result").html("you must choose two options!");
}
return false;
});
});
The HTML/PHP:
<form>
<div class="clearfix">
<select id="category">
<option value="">Any</option>
<?php foreach ( make_list() as $make ) { ?>
<option value="<?php echo $make ?>"><?php echo $make ?></option>
<?php } ?>
</select>
</div>
<div class="clearfix">
<select id="type">
<option value="">Any</option>
</select>
</div>
</form>
When the first select is changed JQuery should look at a file in the same
folder called 'select_type.php'. Here's what's in that file (strangely
$_POST['id'] doesn't seem to be appending to this file either, despite it
being created in the JS):
foreach ( model_list($_POST['id']) as $model ) {
echo '<option value="'.$model.'">'.$model.'</option>';
}
I've been using this resource for this project:
http://www.yourinspirationweb.com/en/how-to-create-chained-select-with-php-and-jquery/
and it's gotten me most of the way, but unfortunately the data doesn't
seem to be loading into that second select box.
Thanks for looking!
HOW EVERYTHING OUT [on hold]
HOW EVERYTHING OUT [on hold]
The word in square brackets is the alt text, which gets displayed if the
browser can't show the image. Be sure to include meaningful alt text for
screen-reading software
The word in square brackets is the alt text, which gets displayed if the
browser can't show the image. Be sure to include meaningful alt text for
screen-reading software
display the image from database
display the image from database
I have created a program in JSP to fetch the image and display it on web
page. Program is working correctly image is displayed but other contents
are not displaying. Below is the code
<%
byte[] imgData = null ;
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/buysell","root","root");
Statement stmt = con.createStatement();
ResultSet resultset =stmt.executeQuery("select * from imagemain where
id=1;") ;
while(resultset.next())
{
Blob bl = resultset.getBlob(2);
byte[] pict = bl.getBytes(1,(int)bl.length());
response.setContentType("image/jpg");
OutputStream o = response.getOutputStream();
%>
<img src="<%o.write(pict);%>" width="10" height="10">
<h1>Vishal</h1>
<%
out.print("1");
o.flush();
o.close();
}
%>
the program is not displaying the <h1>Vishal</h1>. Please assist on this
I have created a program in JSP to fetch the image and display it on web
page. Program is working correctly image is displayed but other contents
are not displaying. Below is the code
<%
byte[] imgData = null ;
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/buysell","root","root");
Statement stmt = con.createStatement();
ResultSet resultset =stmt.executeQuery("select * from imagemain where
id=1;") ;
while(resultset.next())
{
Blob bl = resultset.getBlob(2);
byte[] pict = bl.getBytes(1,(int)bl.length());
response.setContentType("image/jpg");
OutputStream o = response.getOutputStream();
%>
<img src="<%o.write(pict);%>" width="10" height="10">
<h1>Vishal</h1>
<%
out.print("1");
o.flush();
o.close();
}
%>
the program is not displaying the <h1>Vishal</h1>. Please assist on this
Sunday, 18 August 2013
Is there an emacs extension that automatically updates the browser?
Is there an emacs extension that automatically updates the browser?
I am working on HTML/CSS/JavaScript from within emacs. My workflow is
currently
Make a change -> Alt-Tab to browser -> F5 (refresh) -> Alt Tab to emacs
Do any extensions exist that would auto-refresh the browser on a change?
Or, possibly a better idea, when I hit a key combination from within
emacs?
I am working on HTML/CSS/JavaScript from within emacs. My workflow is
currently
Make a change -> Alt-Tab to browser -> F5 (refresh) -> Alt Tab to emacs
Do any extensions exist that would auto-refresh the browser on a change?
Or, possibly a better idea, when I hit a key combination from within
emacs?
Validate Login Errors
Validate Login Errors
I am using the following C# code for a Login Page but I get an error that
says:
"Please make sure that the username and the password is Correct"
protected void btnlogin_Click(object sender, EventArgs e)
{
int Results = 0;
if (txtUsername.Text != string.Empty && txtPassword.Text !=
string.Empty)
{
Results = Validate_Logon(txtUsername.Text.Trim(),
txtPassword.Text.Trim());
if (Results == 1)
{
lblMessage.Text = "Login is Good, Send the User to another
page or enable controls";
}
else
{
lblMessage.Text = "Invalid Login";
lblMessage.ForeColor = System.Drawing.Color.Red;
//Dont Give too much information this might tell a hacker
what is wrong in the login
}
}
else
{
lblMessage.Text = "Please make sure that the username and the
password is Correct";
}
}
public int Validate_Logon(String Username, String Password)
{
SqlConnection con = new SqlConnection(@"***************");
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.CommandText = "[dbo].[Log_Members]";
cmdselect.Parameters.Add("@Username", SqlDbType.VarChar,
256).Value = Username;
cmdselect.Parameters.Add("@UPassword", SqlDbType.VarChar,
55).Value = Password;
cmdselect.Parameters.Add("@OutRes", SqlDbType.Int, 4);
cmdselect.Parameters["@OutRes"].Direction =
ParameterDirection.Output;
cmdselect.Connection = con;
int Results = 0;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Results = (int)cmdselect.Parameters["@OutRes"].Value;
}
catch (SqlException ex)
{
lblMessage.Text = ex.Message;
}
finally
{
cmdselect.Dispose();
if (con != null)
{
con.Close();
}
}
return Results;
}
Please I need to know what is wrong with the code above
I am using the following C# code for a Login Page but I get an error that
says:
"Please make sure that the username and the password is Correct"
protected void btnlogin_Click(object sender, EventArgs e)
{
int Results = 0;
if (txtUsername.Text != string.Empty && txtPassword.Text !=
string.Empty)
{
Results = Validate_Logon(txtUsername.Text.Trim(),
txtPassword.Text.Trim());
if (Results == 1)
{
lblMessage.Text = "Login is Good, Send the User to another
page or enable controls";
}
else
{
lblMessage.Text = "Invalid Login";
lblMessage.ForeColor = System.Drawing.Color.Red;
//Dont Give too much information this might tell a hacker
what is wrong in the login
}
}
else
{
lblMessage.Text = "Please make sure that the username and the
password is Correct";
}
}
public int Validate_Logon(String Username, String Password)
{
SqlConnection con = new SqlConnection(@"***************");
SqlCommand cmdselect = new SqlCommand();
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.CommandText = "[dbo].[Log_Members]";
cmdselect.Parameters.Add("@Username", SqlDbType.VarChar,
256).Value = Username;
cmdselect.Parameters.Add("@UPassword", SqlDbType.VarChar,
55).Value = Password;
cmdselect.Parameters.Add("@OutRes", SqlDbType.Int, 4);
cmdselect.Parameters["@OutRes"].Direction =
ParameterDirection.Output;
cmdselect.Connection = con;
int Results = 0;
try
{
con.Open();
cmdselect.ExecuteNonQuery();
Results = (int)cmdselect.Parameters["@OutRes"].Value;
}
catch (SqlException ex)
{
lblMessage.Text = ex.Message;
}
finally
{
cmdselect.Dispose();
if (con != null)
{
con.Close();
}
}
return Results;
}
Please I need to know what is wrong with the code above
Problems with lucene
Problems with lucene
package avajava;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopScoreDocCollector;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.Version;
import java.io.IOException;
public class HelloLucene {
public static void main(String[] args) throws IOException, ParseException {
// 0. Specify the analyzer for tokenizing text.
// The same analyzer should be used for indexing and searching
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_44);
// 1. create the index
Directory index = new RAMDirectory();
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_44,
analyzer);
IndexWriter w = new IndexWriter(index, config);
addDoc(w, "Lucene in Action", "193398817");
addDoc(w, "Lucene for office use", "55320055Z");
addDoc(w, "Managing Gigabytes", "55063554A");
addDoc(w, "The Art of Computer Science", "9900333X");
w.close();
// 2. query
String querystr = "title:of";
// the "title" arg specifies the default field to use
// when no field is explicitly specified in the query.
Query q = new QueryParser(Version.LUCENE_44, "title",
analyzer).parse(querystr);
// 3. search
int hitsPerPage = 10;
IndexReader reader = DirectoryReader.open(index);
IndexSearcher searcher = new IndexSearcher(reader);
TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage,
true);
searcher.search(q, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;
// 4. display results
System.out.println("Found " + hits.length + " hits.");
for(int i=0;i<hits.length;++i) {
int docId = hits[i].doc;
Document d = searcher.doc(docId);
System.out.println((i + 1) + ". " + d.get("isbn") + "\t" + d.get("title"));
}
// reader can only be closed when there
// is no need to access the documents any more.
reader.close();
}
private static void addDoc(IndexWriter w, String title, String isbn)
throws IOException { Document doc = new Document(); doc.add(new
TextField("title", title, Field.Store.YES));
// use a string field for isbn because we don't want it tokenized
doc.add(new StringField("isbn", isbn, Field.Store.YES));
w.addDocument(doc);
} }
I got the above code from some examples.But i am not getting the expected
results on the basis of the query string("title:of").
Output expected :
Found 2 hits. 1. 55320055Z Lucene for office use 2. 9900333X The Art of
Computer Science
Please help.
package avajava;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopScoreDocCollector;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.Version;
import java.io.IOException;
public class HelloLucene {
public static void main(String[] args) throws IOException, ParseException {
// 0. Specify the analyzer for tokenizing text.
// The same analyzer should be used for indexing and searching
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_44);
// 1. create the index
Directory index = new RAMDirectory();
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_44,
analyzer);
IndexWriter w = new IndexWriter(index, config);
addDoc(w, "Lucene in Action", "193398817");
addDoc(w, "Lucene for office use", "55320055Z");
addDoc(w, "Managing Gigabytes", "55063554A");
addDoc(w, "The Art of Computer Science", "9900333X");
w.close();
// 2. query
String querystr = "title:of";
// the "title" arg specifies the default field to use
// when no field is explicitly specified in the query.
Query q = new QueryParser(Version.LUCENE_44, "title",
analyzer).parse(querystr);
// 3. search
int hitsPerPage = 10;
IndexReader reader = DirectoryReader.open(index);
IndexSearcher searcher = new IndexSearcher(reader);
TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage,
true);
searcher.search(q, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;
// 4. display results
System.out.println("Found " + hits.length + " hits.");
for(int i=0;i<hits.length;++i) {
int docId = hits[i].doc;
Document d = searcher.doc(docId);
System.out.println((i + 1) + ". " + d.get("isbn") + "\t" + d.get("title"));
}
// reader can only be closed when there
// is no need to access the documents any more.
reader.close();
}
private static void addDoc(IndexWriter w, String title, String isbn)
throws IOException { Document doc = new Document(); doc.add(new
TextField("title", title, Field.Store.YES));
// use a string field for isbn because we don't want it tokenized
doc.add(new StringField("isbn", isbn, Field.Store.YES));
w.addDocument(doc);
} }
I got the above code from some examples.But i am not getting the expected
results on the basis of the query string("title:of").
Output expected :
Found 2 hits. 1. 55320055Z Lucene for office use 2. 9900333X The Art of
Computer Science
Please help.
set MAX_WRITE_SIZE for php_curl.dll because of slow transfer rates
set MAX_WRITE_SIZE for php_curl.dll because of slow transfer rates
I have really slow transfer rates when posting files with curl in php on
several versions and machines. I've read that this can be solved by
changing the set MAX_WRITE_SIZE setting in curl. But I use the
php_curl.dll, is there any way to set MAX_WRITE_SIZE for php_curl.dll? It
is not a problem with the connection, it is not a problem with the code,
it seems to be a problem of windows.
Thank You!
I have really slow transfer rates when posting files with curl in php on
several versions and machines. I've read that this can be solved by
changing the set MAX_WRITE_SIZE setting in curl. But I use the
php_curl.dll, is there any way to set MAX_WRITE_SIZE for php_curl.dll? It
is not a problem with the connection, it is not a problem with the code,
it seems to be a problem of windows.
Thank You!
Javascript Create Json
Javascript Create Json
I'm trying to create and post a json message in the following format:
var listObjects = [];
$.each(results, function(index, value){
var item = new Object();
item.title = value.Title;
item.code = value.Code;
listObjects.push(item);
});
var jsonResult = JSON.strringify(listObjects);
basically this will create my json like this:
[{"title":"Product 1","code":123456789012},
{"title":"Product 2","code":123456789012},
{"title":"Product 3","code":123456789012},
{"title":"Product 4","code":123456789012},
{"title":"Product 5","code":123456789012},
{"title":"Product 11","code":123456789012},
{"title":"Product 12","code":123456789012},
{"title":"Product 13","code":123456789012}]
how can I do it so that if I want to add some metadata to my json that
will not repeat for each item but just at the top ... something like this:
category: x
type: y
...
items:
title: .....
code: ......
so basically the category and type will define the whole items in the json
but are not repeated for each item ...
I'm trying to create and post a json message in the following format:
var listObjects = [];
$.each(results, function(index, value){
var item = new Object();
item.title = value.Title;
item.code = value.Code;
listObjects.push(item);
});
var jsonResult = JSON.strringify(listObjects);
basically this will create my json like this:
[{"title":"Product 1","code":123456789012},
{"title":"Product 2","code":123456789012},
{"title":"Product 3","code":123456789012},
{"title":"Product 4","code":123456789012},
{"title":"Product 5","code":123456789012},
{"title":"Product 11","code":123456789012},
{"title":"Product 12","code":123456789012},
{"title":"Product 13","code":123456789012}]
how can I do it so that if I want to add some metadata to my json that
will not repeat for each item but just at the top ... something like this:
category: x
type: y
...
items:
title: .....
code: ......
so basically the category and type will define the whole items in the json
but are not repeated for each item ...
getting uv-Coordinates from THREE.js DataTexture
getting uv-Coordinates from THREE.js DataTexture
I am trying to implement a small Volumerenderer with THREE.js. For that I
have a large(at least 65000 elements) array with intensity-values(too
large to pass as a uniform array) to the shader where raycasting and all
that will happen. I wanted to use THREE.DataTexture for that but I don't
seem to have any uv-coordinates in the shader and get the following error:
Error: WebGL: vertexAttribPointer: must have valid GL_ARRAY_BUFFER binding
Error: WebGL: drawArrays: bound vertex attribute buffers do not have
sufficient size for given first and count
This is my setup:
In the init-function:
var data = new Uint8Array(textureArray);
var texture = new THREE.DataTexture(data, 128, 128, THREE.AlphaFormat);
texture.needsUpdate = true;
uniforms = {
texture: {type: "t", value: texture}
}
in the vertex-shader:
varying vec2 vUv;
void main(){
vUv = uv;
}
in the fragment-shader:
uniform sampler2D texture;
varying vec2 vUv;
The shaders are for a THREE.ShaderMaterial on a particleSystem. Everything
works fine as long as i don't have the vUv = uv assignment in the the
vertex-shader and the Texture works when I put it on a Cube like this:
cube = new THREE.CubeGeometry(10,10,10);
material = new THREE.BasicMaterial({map: texture});
mesh = new THREE.Mesh(cube, material);
scene.add(mesh);
Has anybody had a similar problem or an idea where my mistake could be?
I am trying to implement a small Volumerenderer with THREE.js. For that I
have a large(at least 65000 elements) array with intensity-values(too
large to pass as a uniform array) to the shader where raycasting and all
that will happen. I wanted to use THREE.DataTexture for that but I don't
seem to have any uv-coordinates in the shader and get the following error:
Error: WebGL: vertexAttribPointer: must have valid GL_ARRAY_BUFFER binding
Error: WebGL: drawArrays: bound vertex attribute buffers do not have
sufficient size for given first and count
This is my setup:
In the init-function:
var data = new Uint8Array(textureArray);
var texture = new THREE.DataTexture(data, 128, 128, THREE.AlphaFormat);
texture.needsUpdate = true;
uniforms = {
texture: {type: "t", value: texture}
}
in the vertex-shader:
varying vec2 vUv;
void main(){
vUv = uv;
}
in the fragment-shader:
uniform sampler2D texture;
varying vec2 vUv;
The shaders are for a THREE.ShaderMaterial on a particleSystem. Everything
works fine as long as i don't have the vUv = uv assignment in the the
vertex-shader and the Texture works when I put it on a Cube like this:
cube = new THREE.CubeGeometry(10,10,10);
material = new THREE.BasicMaterial({map: texture});
mesh = new THREE.Mesh(cube, material);
scene.add(mesh);
Has anybody had a similar problem or an idea where my mistake could be?
Saturday, 17 August 2013
Flipping image causes massive RAM/CPU uses with AForge.net
Flipping image causes massive RAM/CPU uses with AForge.net
Hey all i am trying to figure out why when i flip the image it uses a LOT
of RAM and CPU (its an quad core i7)
I use this code:
Dim filter As New RotateBilinear(180, True)
image = Filter.Apply(image)
If bIsToRecord Then
If writer Is Nothing Then
Dim [date] As DateTime = DateTime.Now
Dim fileName As [String] =
[String].Format("{0},{1}.avi",[date].Minute, [date].Second)
Try
OpenWriter(fileName, image.Width, image.Height)
Catch ex As Exception
If writer IsNot Nothing Then
writer.Dispose()
writer = Nothing
End If
End Try
End If
Try
If radioButton1.Checked Then
writer.AddFrame(image)
Else
mVideoFileWriter.WriteVideoFrame(image)
End If
Catch ex As Exception
System.Diagnostics.Trace.WriteLine(ex.ToString())
End Try
End If
That is WITHOUT flipping the images
WITH the flipping...
Each screenshot was for 30 seconds.
What could be causing this?
Hey all i am trying to figure out why when i flip the image it uses a LOT
of RAM and CPU (its an quad core i7)
I use this code:
Dim filter As New RotateBilinear(180, True)
image = Filter.Apply(image)
If bIsToRecord Then
If writer Is Nothing Then
Dim [date] As DateTime = DateTime.Now
Dim fileName As [String] =
[String].Format("{0},{1}.avi",[date].Minute, [date].Second)
Try
OpenWriter(fileName, image.Width, image.Height)
Catch ex As Exception
If writer IsNot Nothing Then
writer.Dispose()
writer = Nothing
End If
End Try
End If
Try
If radioButton1.Checked Then
writer.AddFrame(image)
Else
mVideoFileWriter.WriteVideoFrame(image)
End If
Catch ex As Exception
System.Diagnostics.Trace.WriteLine(ex.ToString())
End Try
End If
That is WITHOUT flipping the images
WITH the flipping...
Each screenshot was for 30 seconds.
What could be causing this?
MySQLi New query in a loop
MySQLi New query in a loop
I would like to get my category list with number of row in product table :
Product : id, title, id_cat
Product_cat : id, name
So I do this
if ($stmt = $mysqli->prepare("SELECT id, name FROM product_cat")) {
$stmt->execute();
$stmt->bind_result($cat_id, $cat_name);
while ($stmt->fetch()) {
if ($stmt2 = $mysqli->prepare("SELECT id FROM product WHERE id_cat = ?
")) {
$stmt2->bind_param('i', $cat_id);
$stmt2->execute();
$stmt2->store_result();
$count_product = $stmt->num_rows;
}
echo '<li><a href="list.php?cat='.$cat_id.'"><span class="badge
pull-right">'.$count_product.'</span>'.utf8_encode($cat_name).'</a></li>';
}
}
$stmt->close();
Why this is not correct? Thanks
I would like to get my category list with number of row in product table :
Product : id, title, id_cat
Product_cat : id, name
So I do this
if ($stmt = $mysqli->prepare("SELECT id, name FROM product_cat")) {
$stmt->execute();
$stmt->bind_result($cat_id, $cat_name);
while ($stmt->fetch()) {
if ($stmt2 = $mysqli->prepare("SELECT id FROM product WHERE id_cat = ?
")) {
$stmt2->bind_param('i', $cat_id);
$stmt2->execute();
$stmt2->store_result();
$count_product = $stmt->num_rows;
}
echo '<li><a href="list.php?cat='.$cat_id.'"><span class="badge
pull-right">'.$count_product.'</span>'.utf8_encode($cat_name).'</a></li>';
}
}
$stmt->close();
Why this is not correct? Thanks
how should I change this to use CCParallaxNode?
how should I change this to use CCParallaxNode?
Hello I am a beginner to cocos2d and objective c. I am making a cocos2d
side scroller. I am using CCActions to make my background move. I want my
app to be universal. Right now I am making my app for the iPad, but I want
to make it compatible with all iPhone, iPod Touch, and iPad versions. I am
now learning that CCParallaxNode might make it easier to make the app
universal. Here is my code that I am using right now.
treeBackground = [CCSprite spriteWithFile:@"background.png"
rect:CGRectMake(0, 0, screenWidth * 2, screenHeight * 1.25)];
treeBackground.opacity = treeBackground.opacity - 75;
ccTexParams params = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
[treeBackground.texture setTexParameters:¶ms];
treeBackground.position = ccp(screenWidth, screenHeight/2);
[self addChild:treeBackground z:-5];
CCMoveBy* treeBackgroundMove = [CCMoveBy actionWithDuration:20.0
position:ccp(screenWidth * -1, 0)];
CCPlace* treeBackgroundPlace = [CCPlace
actionWithPosition:ccp(screenWidth, screenHeight/2)];
CCSequence* treeBackgroundSequence = [CCSequence
actions:treeBackgroundMove, treeBackgroundPlace, nil];
CCRepeatForever* treeBackgroundRepeat = [CCRepeatForever
actionWithAction:treeBackgroundSequence];
[treeBackground runAction:treeBackgroundRepeat];
How can I change this to use CCParallaxNode??
Hello I am a beginner to cocos2d and objective c. I am making a cocos2d
side scroller. I am using CCActions to make my background move. I want my
app to be universal. Right now I am making my app for the iPad, but I want
to make it compatible with all iPhone, iPod Touch, and iPad versions. I am
now learning that CCParallaxNode might make it easier to make the app
universal. Here is my code that I am using right now.
treeBackground = [CCSprite spriteWithFile:@"background.png"
rect:CGRectMake(0, 0, screenWidth * 2, screenHeight * 1.25)];
treeBackground.opacity = treeBackground.opacity - 75;
ccTexParams params = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
[treeBackground.texture setTexParameters:¶ms];
treeBackground.position = ccp(screenWidth, screenHeight/2);
[self addChild:treeBackground z:-5];
CCMoveBy* treeBackgroundMove = [CCMoveBy actionWithDuration:20.0
position:ccp(screenWidth * -1, 0)];
CCPlace* treeBackgroundPlace = [CCPlace
actionWithPosition:ccp(screenWidth, screenHeight/2)];
CCSequence* treeBackgroundSequence = [CCSequence
actions:treeBackgroundMove, treeBackgroundPlace, nil];
CCRepeatForever* treeBackgroundRepeat = [CCRepeatForever
actionWithAction:treeBackgroundSequence];
[treeBackground runAction:treeBackgroundRepeat];
How can I change this to use CCParallaxNode??
"illegal else without matching if " in C
"illegal else without matching if " in C
I am new to C++.
I tried compile this simple program, but every time I try to compie it I
get the following error message:
"error C2181: illegal else without matching if"
Here is my code
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int a;
cout << "enter a integer: " << endl;
cin >> a;
if(a >= 56 && 76 <= a){cout<< "you win" << endl;};
else{
cout << "you lose"<< endl;
}
return 0;
}
Could someone tell me where my mistake is?
I am new to C++.
I tried compile this simple program, but every time I try to compie it I
get the following error message:
"error C2181: illegal else without matching if"
Here is my code
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int a;
cout << "enter a integer: " << endl;
cin >> a;
if(a >= 56 && 76 <= a){cout<< "you win" << endl;};
else{
cout << "you lose"<< endl;
}
return 0;
}
Could someone tell me where my mistake is?
Java - Simple way to re-assign values in an array
Java - Simple way to re-assign values in an array
I'm having trouble reassigning values in an array.
public static void main(String[] {
int[] ArrayOfIntegers = new int[4];
ArrayOfIntegers[0] = 11;
ArrayOfIntegers[1] = 12;
ArrayOfIntegers[2] = 13;
ArrayOfIntegers[3] = 14;
ArrayOfIntegers = {11,12,15,17};
}
Why am I unable to reassign values in the manner that I've attempted? If I
can't do it, why can't I do it?
I'm having trouble reassigning values in an array.
public static void main(String[] {
int[] ArrayOfIntegers = new int[4];
ArrayOfIntegers[0] = 11;
ArrayOfIntegers[1] = 12;
ArrayOfIntegers[2] = 13;
ArrayOfIntegers[3] = 14;
ArrayOfIntegers = {11,12,15,17};
}
Why am I unable to reassign values in the manner that I've attempted? If I
can't do it, why can't I do it?
How to insert CSS code into a page if I can't insert it into head tag? Only inline mode?
How to insert CSS code into a page if I can't insert it into head tag?
Only inline mode?
I have to insert some CSS style into a Plain HTML module inside a CMS. The
problem is that I have no access to the template so I can't insert the CSS
into a .css style file.
I had thought that I could use the tag (that would enable me to insert the
CSS styles directly in the HTML) but reading online seems to me that I can
only insert it into the tag and I can't do it because I have not access to
the template code.
So my questions are:
Can I use the tag outside of the tag?
If not the only solution is to use inline CSS or can I try something else?
Tnx
Andrea
Only inline mode?
I have to insert some CSS style into a Plain HTML module inside a CMS. The
problem is that I have no access to the template so I can't insert the CSS
into a .css style file.
I had thought that I could use the tag (that would enable me to insert the
CSS styles directly in the HTML) but reading online seems to me that I can
only insert it into the tag and I can't do it because I have not access to
the template code.
So my questions are:
Can I use the tag outside of the tag?
If not the only solution is to use inline CSS or can I try something else?
Tnx
Andrea
Friday, 16 August 2013
natbib: how to display partial authors in reference [duplicate]
natbib: how to display partial authors in reference [duplicate]
This question already has an answer here:
natbib: how to display partial authors in reference 2 answers
I have asked this question on http://tex.stackexchange.com/, but nobody
answers me...
I am using natbib to manage my references, now I have a problem: my
reference list always displays all author names of an article:
Marcel H. Schulz, Daniel R. Zerbino, Martin Vingron, and Ewan Birney.
Oases: robust
de novo RNA-seq assembly across the dynamic range of expression levels.
Bioinformatics
(Oxford, England), 28(8):1086–1092, April 2012. 7, 9, 10, 40
I set the options to be:
\usepackage[round, sort, numbers]{natbib}
\bibliographystyle{Latex/Classes/PhDbiblio-url2}
\renewcommand{\bibname}{References}
\bibliography{9_backmatter/references}
And use cite{} to cite the references. I tried to used biblatex, but seems
it is not compatible with natbib:
\usepackage[maxnames=3]{biblatex}
I want to display at most 3 authors in full name, otherwise display as et
al. How to set it?
================
Edit: The file PhDbiblio-url2.bst can be found here:
https://bitbucket.org/dekz/thesis/src/3f8d8507cddc/Latex/Classes/PhDbiblio-url2.bst
It seems like the lines here define the display of authors:
INTEGERS { nameptr namesleft numnames }
FUNCTION {format.names}
{ 's :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
nameptr #1 >
{ namesleft #1 >
{ ", " * t * }
{ numnames #2 >
{ "," * }
'skip$
if$
t "others" =
{ " et~al." * }
{ " and " * t * }
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
}
But how to set the numnames from the tex file?
This question already has an answer here:
natbib: how to display partial authors in reference 2 answers
I have asked this question on http://tex.stackexchange.com/, but nobody
answers me...
I am using natbib to manage my references, now I have a problem: my
reference list always displays all author names of an article:
Marcel H. Schulz, Daniel R. Zerbino, Martin Vingron, and Ewan Birney.
Oases: robust
de novo RNA-seq assembly across the dynamic range of expression levels.
Bioinformatics
(Oxford, England), 28(8):1086–1092, April 2012. 7, 9, 10, 40
I set the options to be:
\usepackage[round, sort, numbers]{natbib}
\bibliographystyle{Latex/Classes/PhDbiblio-url2}
\renewcommand{\bibname}{References}
\bibliography{9_backmatter/references}
And use cite{} to cite the references. I tried to used biblatex, but seems
it is not compatible with natbib:
\usepackage[maxnames=3]{biblatex}
I want to display at most 3 authors in full name, otherwise display as et
al. How to set it?
================
Edit: The file PhDbiblio-url2.bst can be found here:
https://bitbucket.org/dekz/thesis/src/3f8d8507cddc/Latex/Classes/PhDbiblio-url2.bst
It seems like the lines here define the display of authors:
INTEGERS { nameptr namesleft numnames }
FUNCTION {format.names}
{ 's :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
nameptr #1 >
{ namesleft #1 >
{ ", " * t * }
{ numnames #2 >
{ "," * }
'skip$
if$
t "others" =
{ " et~al." * }
{ " and " * t * }
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
}
But how to set the numnames from the tex file?
Saturday, 10 August 2013
Making non-singular matrices singular
Making non-singular matrices singular
What is the minimum value of $k$ such that every non-singular $n\times n$
real matrices can be made singular by switching EXACTLY $k$ entries with
ZERO ?
What is the minimum value of $k$ such that every non-singular $n\times n$
real matrices can be made singular by switching EXACTLY $k$ entries with
ZERO ?
Update my ASP.NET MVC4 project templates?
Update my ASP.NET MVC4 project templates?
There are plenty of references around to ajax login form capability in the
asp.net mvc4 Internet Application project template, and also references to
related artifacts such as AjaxLogin.js and method ContextDependentView().
When I created a new project/solution from this template I don't see the
ajax login and I don't find these artifacts.
Is this because I don't have the latest version of the templates? If so
how do I refresh them?
I'm using VS2012 premium update 3.
There are plenty of references around to ajax login form capability in the
asp.net mvc4 Internet Application project template, and also references to
related artifacts such as AjaxLogin.js and method ContextDependentView().
When I created a new project/solution from this template I don't see the
ajax login and I don't find these artifacts.
Is this because I don't have the latest version of the templates? If so
how do I refresh them?
I'm using VS2012 premium update 3.
#EANF#
#EANF#
I would like my mixing console app to be able to move multiple sliders
simultaneously when a user touches them with multiple fingers, just like
in real life.
I have already implemented my logic for a single pan gesture
(UIPanGestureRecognizer). How do I add multiple-touch functionality in
this case?
I would like my mixing console app to be able to move multiple sliders
simultaneously when a user touches them with multiple fingers, just like
in real life.
I have already implemented my logic for a single pan gesture
(UIPanGestureRecognizer). How do I add multiple-touch functionality in
this case?
find depth of water
find depth of water
The bottom of an underground rectangular tank has an area of $12$ square
feet and the depth of the tank is $10$ feet. A liquid is pumped into the
empty tank at the constant rate of $30$ cubic feet per minute. After how
many minutes will the depth of the liquid in the tank be $8$ feet?
so first volume of rectangular tank is $12*10=120$ cubic,now if water is
pumped $30$ cubic feet per minute,then it takes $4$ minute to fill
tank,but what about $8$ depth,in this case volume would be $12*8=96$,does
it would be $96/30=3.2$ minute?
The bottom of an underground rectangular tank has an area of $12$ square
feet and the depth of the tank is $10$ feet. A liquid is pumped into the
empty tank at the constant rate of $30$ cubic feet per minute. After how
many minutes will the depth of the liquid in the tank be $8$ feet?
so first volume of rectangular tank is $12*10=120$ cubic,now if water is
pumped $30$ cubic feet per minute,then it takes $4$ minute to fill
tank,but what about $8$ depth,in this case volume would be $12*8=96$,does
it would be $96/30=3.2$ minute?
Friday, 9 August 2013
If $n$ order stats are iid from Uniform(0,1), why does dividing by the highest order stat give $n−1$ order stats iid from Uniform(0,1)?
If $n$ order stats are iid from Uniform(0,1), why does dividing by the
highest order stat give $n−1$ order stats iid from Uniform(0,1)?
As the title states:
If $P_{(1)}, ... ,P_{(n)}$ are order statistics of $n$ independent uniform
$(0,1)$ random variables, why are $P_{(1)}/P_{(n)} .....
P_{(n-1)}/P_{(n)}$ also order statistics of $n-1$ independent uniform
random variables on $(0,1)$, independent of $P_{(n)}$?
I'd prefer seeing an actual proof of this as I can't seem to locate one
anywhere. Any place I've found that mentions this theorem treats it as
"common knowledge" so-to-speak and doesn't give any theoretical
justification for the claim.
Any help is greatly appreciated!
highest order stat give $n−1$ order stats iid from Uniform(0,1)?
As the title states:
If $P_{(1)}, ... ,P_{(n)}$ are order statistics of $n$ independent uniform
$(0,1)$ random variables, why are $P_{(1)}/P_{(n)} .....
P_{(n-1)}/P_{(n)}$ also order statistics of $n-1$ independent uniform
random variables on $(0,1)$, independent of $P_{(n)}$?
I'd prefer seeing an actual proof of this as I can't seem to locate one
anywhere. Any place I've found that mentions this theorem treats it as
"common knowledge" so-to-speak and doesn't give any theoretical
justification for the claim.
Any help is greatly appreciated!
Subscribe to:
Comments (Atom)