Distance/Similarity between two matrices
I'm in the process of writing an application which identifies the closest
matrix from a set of square matrices $M$ to a given square matrix $A$. The
closest can be defined as the most similar.
I think finding the distance between two given matrices is a fair approach
since the smallest Euclidean distance is used to identify the closeness of
vectors.
I found that the distance between two matrices ($A,B$) could be calculated
using the Frobenius distance $F$:
$$F_{A,B} = \sqrt{trace((A-B)*(A-B)')} $$
where $B'$ represents the conjugate transpose of B.
I have the following points I need to clarify
Is the distance between matrices a fair measure of similarity?
If distance is used, is Frobenius distance a fair measure for this
problem? any other suggestions?
Monday, 30 September 2013
Newton's Method - Slow Convergence math.stackexchange.com
Newton's Method - Slow Convergence – math.stackexchange.com
I'm using Newton's method to find the root of the equation
$\frac{1}{2}x^2+x+1-e^x=0$ with $x_0=1$. Clearly the root is $x=0$, but it
takes many iterations to reach this root. What is the reason for …
I'm using Newton's method to find the root of the equation
$\frac{1}{2}x^2+x+1-e^x=0$ with $x_0=1$. Clearly the root is $x=0$, but it
takes many iterations to reach this root. What is the reason for …
IOS - Facebook score and timeline
IOS - Facebook score and timeline
I'am trying to make facebook leader board for my app.. but i don't under
stand that
WHY NOT PUBLISH NEWSFEED or Any other info to my facebook test user pages?
my source code have any problem? =(
[Sandbox mode/3test user tried/there is no error] Write permission is OK.
Fetching current score is OK.
Score post returns no error and "FACEBOOK_NON_JSON_RESULT" = true;
[self FBRequestWritePermissions];
NSMutableDictionary* params = [NSMutableDictionary
dictionaryWithObjectsAndKeys:
[FBSession
activeSession].accessTokenData.accessToken,@"access_token",
[NSString stringWithFormat:@"%d",
nScore], @"score",
nil];
NSLog(@"Access Token : %@",[FBSession
activeSession].accessTokenData.accessToken);
NSLog(@"Fetching current score");
// Get the score, and only send the updated score if it's highter
[FBRequestConnection startWithGraphPath:[NSString
stringWithFormat:@"/%llu/scores", _myData.idName] parameters:params
HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id
result, NSError *error) {
if (result && !error) {
int nCurrentScore = 0;
if ([[result objectForKey:@"data"]count] > 0) {
nCurrentScore = [[[[result objectForKey:@"data"]
objectAtIndex:0] objectForKey:@"score"] intValue];
}
NSLog(@"Current score is %d", nCurrentScore);
if (nScore > nCurrentScore) {
NSLog(@"Posting new score of %d", nScore);
[FBRequestConnection startWithGraphPath:[NSString
stringWithFormat:@"/%llu/scores", _myData.idName]
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection
*connection, id result, NSError *error)
{
NSLog(@"Score posted:%@ \n\n %@
\n\n%@",result,error,_isPublishable==YES?@"YES":@"NO");
}];
}
else {
NSLog(@"Existing score is higher - not posting new score");
}
}
}];
Facebook tutorial saids..
"The process is simple. Each time a player achieves a score in the game,
the game issues an HTTP POST request /USER_ID/scores with a user
access_token. Assuming the user has granted the publish_actions
permission, their score will post to the graph
From there, Facebook can automatically generate several interesting
stories, including high score stories when the player reaches a new high
score, and passing stories when the player overtakes a friend in the
game."
But i don't understand why not post to the graph...?
I'am trying to make facebook leader board for my app.. but i don't under
stand that
WHY NOT PUBLISH NEWSFEED or Any other info to my facebook test user pages?
my source code have any problem? =(
[Sandbox mode/3test user tried/there is no error] Write permission is OK.
Fetching current score is OK.
Score post returns no error and "FACEBOOK_NON_JSON_RESULT" = true;
[self FBRequestWritePermissions];
NSMutableDictionary* params = [NSMutableDictionary
dictionaryWithObjectsAndKeys:
[FBSession
activeSession].accessTokenData.accessToken,@"access_token",
[NSString stringWithFormat:@"%d",
nScore], @"score",
nil];
NSLog(@"Access Token : %@",[FBSession
activeSession].accessTokenData.accessToken);
NSLog(@"Fetching current score");
// Get the score, and only send the updated score if it's highter
[FBRequestConnection startWithGraphPath:[NSString
stringWithFormat:@"/%llu/scores", _myData.idName] parameters:params
HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id
result, NSError *error) {
if (result && !error) {
int nCurrentScore = 0;
if ([[result objectForKey:@"data"]count] > 0) {
nCurrentScore = [[[[result objectForKey:@"data"]
objectAtIndex:0] objectForKey:@"score"] intValue];
}
NSLog(@"Current score is %d", nCurrentScore);
if (nScore > nCurrentScore) {
NSLog(@"Posting new score of %d", nScore);
[FBRequestConnection startWithGraphPath:[NSString
stringWithFormat:@"/%llu/scores", _myData.idName]
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection
*connection, id result, NSError *error)
{
NSLog(@"Score posted:%@ \n\n %@
\n\n%@",result,error,_isPublishable==YES?@"YES":@"NO");
}];
}
else {
NSLog(@"Existing score is higher - not posting new score");
}
}
}];
Facebook tutorial saids..
"The process is simple. Each time a player achieves a score in the game,
the game issues an HTTP POST request /USER_ID/scores with a user
access_token. Assuming the user has granted the publish_actions
permission, their score will post to the graph
From there, Facebook can automatically generate several interesting
stories, including high score stories when the player reaches a new high
score, and passing stories when the player overtakes a friend in the
game."
But i don't understand why not post to the graph...?
installing debian/ubuntu packags to an arbitrary place
installing debian/ubuntu packags to an arbitrary place
I am involved in a project to bring up an internal repository of
ubuntu/debian packages.
In some way I am getting a package, changing it's options and rebuild,
putting that into the internal repository. For this project I need to be
able to install "my" package to a place that is different form standard
system place, so that my package and a system one could co-exist.
I also need this to be done in a way, that would not dig too deep into
modifying debian/rules file because i am doing my builds in mostly
automated way.
So, what are my options?
I am involved in a project to bring up an internal repository of
ubuntu/debian packages.
In some way I am getting a package, changing it's options and rebuild,
putting that into the internal repository. For this project I need to be
able to install "my" package to a place that is different form standard
system place, so that my package and a system one could co-exist.
I also need this to be done in a way, that would not dig too deep into
modifying debian/rules file because i am doing my builds in mostly
automated way.
So, what are my options?
Sunday, 29 September 2013
Submitting form data to a new screen using javafx
Submitting form data to a new screen using javafx
I'm currently working on a desktop app using javafx. IN the introductory
screen, I have a form where the user would fill in various information,
and then submit the form contents to a new screen, discarding the old
screen as the user would not be heading back there in the application
logic flow. However I'm at a loss as to how this would be done. I was
thinking it would be like Android where I could call a get new screen
function, calling the class for the new screen's constructor and it'd pass
over to there, but when trying that, it just created a new window, which
obviously isn't what I'm after. Was wondering if anyone knew of a better
way that I could move the application to a new screen, and still easily
pass the form information over to that screen for further processing.
I'm currently working on a desktop app using javafx. IN the introductory
screen, I have a form where the user would fill in various information,
and then submit the form contents to a new screen, discarding the old
screen as the user would not be heading back there in the application
logic flow. However I'm at a loss as to how this would be done. I was
thinking it would be like Android where I could call a get new screen
function, calling the class for the new screen's constructor and it'd pass
over to there, but when trying that, it just created a new window, which
obviously isn't what I'm after. Was wondering if anyone knew of a better
way that I could move the application to a new screen, and still easily
pass the form information over to that screen for further processing.
AGGREGATE FUNCTION SQL 2012 query unable to construct select statement
AGGREGATE FUNCTION SQL 2012 query unable to construct select statement
Im failry New to this and Im a SQL beginner. i have been assigned 10
scenerios to tackle but i have struggled with the Last 3 qsns. they are
the following:
Write a SELECT statement that returns one row for each category that has
products with these columns: The CategoryName column from the Categories
table The count of the products in the Products table The list price of
the most expensive product in the Products table Sort the result set so
the category with the most products appears first.
9.(5 points) Write a SELECT statement that returns one row for each
customer that has orders with these columns: The EmailAddress column from
the Customers table A count of the number of orders The total amount for
each order (Hint: First, subtract the discount amount from the price.
Then, multiply by the quantity.) Return only those rows where the customer
has more than than 1 order. Sort the result set in descending sequence by
the sum of the line item amounts.
Please, If anyone can assist me in how to tackle these problem i would
truly appreciate it
Im failry New to this and Im a SQL beginner. i have been assigned 10
scenerios to tackle but i have struggled with the Last 3 qsns. they are
the following:
Write a SELECT statement that returns one row for each category that has
products with these columns: The CategoryName column from the Categories
table The count of the products in the Products table The list price of
the most expensive product in the Products table Sort the result set so
the category with the most products appears first.
9.(5 points) Write a SELECT statement that returns one row for each
customer that has orders with these columns: The EmailAddress column from
the Customers table A count of the number of orders The total amount for
each order (Hint: First, subtract the discount amount from the price.
Then, multiply by the quantity.) Return only those rows where the customer
has more than than 1 order. Sort the result set in descending sequence by
the sum of the line item amounts.
Please, If anyone can assist me in how to tackle these problem i would
truly appreciate it
How to add letter count after a word in javascript
How to add letter count after a word in javascript
So, I have this textarea in html and I am trying to implement something
like twitter.
Everytime a user types in '#' I want to highlight the word and at the end
of word I want to display a letter count. So for example, " Hi my name is
#user123(7) , whats your name?" I already have the highlighting taken care
of, but I am currently lost on the letter count part. Here is my HTML
<div id="inputback" class="format"></div>
<textarea id="input" class="format"></textarea>
Javascript
var textarea = document.getElementById("input");
var hashflag = 0 ;
var textlength;
textarea.onkeydown = function(e){
textarea.style.height = "";
textarea.style.height = textarea.scrollHeight + "px";
textlength = textarea.value.length;
var str = textarea.value;
str = str.replace(/(\s)([#]\w*)/g, "$1<b>$2</b>");
$('#inputback').html(str);
}
Here is my CSS
.format
{
font: 9pt Consolas;
}
#input { border: 1px solid black; background: transparent; z-index: 10; }
#inputback {
color: transparent;
position: absolute;
top: 0px
}
#inputback b
{
color: black;
background-color: #808080;
font-weight: normal;
}
Here is my jsfiddle of what i have accomplished.
http://jsfiddle.net/gjqWy/114/
Thank you in advance!
P.S I dont want to use any plugins or Jquery. Just plain Javascript/html/css
So, I have this textarea in html and I am trying to implement something
like twitter.
Everytime a user types in '#' I want to highlight the word and at the end
of word I want to display a letter count. So for example, " Hi my name is
#user123(7) , whats your name?" I already have the highlighting taken care
of, but I am currently lost on the letter count part. Here is my HTML
<div id="inputback" class="format"></div>
<textarea id="input" class="format"></textarea>
Javascript
var textarea = document.getElementById("input");
var hashflag = 0 ;
var textlength;
textarea.onkeydown = function(e){
textarea.style.height = "";
textarea.style.height = textarea.scrollHeight + "px";
textlength = textarea.value.length;
var str = textarea.value;
str = str.replace(/(\s)([#]\w*)/g, "$1<b>$2</b>");
$('#inputback').html(str);
}
Here is my CSS
.format
{
font: 9pt Consolas;
}
#input { border: 1px solid black; background: transparent; z-index: 10; }
#inputback {
color: transparent;
position: absolute;
top: 0px
}
#inputback b
{
color: black;
background-color: #808080;
font-weight: normal;
}
Here is my jsfiddle of what i have accomplished.
http://jsfiddle.net/gjqWy/114/
Thank you in advance!
P.S I dont want to use any plugins or Jquery. Just plain Javascript/html/css
margin:auto; with inline-block
margin:auto; with inline-block
i have a "container" div to which i gave margin:auto; which worked fine as
long as i gave it a specific width, but now i changed it to inline-block
and margin:auto; isnt working
previous css
#container {
border: 1px solid black;
height: 500px;
width: 650px;
}
.MtopBig {
margin-top: 75px;
}
.center {
margin-left: auto;
margin-right: auto;
text-align: center;
}
new css
#container {
border: 1px solid black;
display: inline-block;
padding: 50px;
}
.MtopBig {
margin: 75px auto;
position: relative;
}
.center {
text-align: center;
}
DEMO fiddle.
i have a "container" div to which i gave margin:auto; which worked fine as
long as i gave it a specific width, but now i changed it to inline-block
and margin:auto; isnt working
previous css
#container {
border: 1px solid black;
height: 500px;
width: 650px;
}
.MtopBig {
margin-top: 75px;
}
.center {
margin-left: auto;
margin-right: auto;
text-align: center;
}
new css
#container {
border: 1px solid black;
display: inline-block;
padding: 50px;
}
.MtopBig {
margin: 75px auto;
position: relative;
}
.center {
text-align: center;
}
DEMO fiddle.
Saturday, 28 September 2013
is a "where in" clause with 1000 parts too much
is a "where in" clause with 1000 parts too much
If i want to create a page of status/message updates for a particular
entity, is there a better way to do it than this:
get all entities you follow/subscribe to
perform WHERE IN on status table.
My concern is: what if you follow 1000, 2000 entities? is that a problem?
whats the optimal way of doing this kind of data retrieval?
If i want to create a page of status/message updates for a particular
entity, is there a better way to do it than this:
get all entities you follow/subscribe to
perform WHERE IN on status table.
My concern is: what if you follow 1000, 2000 entities? is that a problem?
whats the optimal way of doing this kind of data retrieval?
Vector instantiation in java
Vector instantiation in java
I have a class Fruit in whose constructor I am instantiating a
vector(vector of different fruits). And In that class I am writing a
searchVector method. I want to invoke that method from another class
searchFruit but if I create an object of the Fruit class, a new vector
gets initialized. When I call the searchVector method, the vector is
empty(as new vector gets created) and hence the search fails. Is there a
way that I could call the searchVector method from searchFruit class.
class Fruit{
Vector v;
Fruit(){
v= new vector();
}
public Fruit searchVector(String fruit){
//Searches Fruit
}
}
class searchFruit{
Fruit apple = new Fruit();
apple.searchVector("Apple");
}
Or if I want to write the search function in the searchFruit class how do
I pass the created vector to that class.
I have a class Fruit in whose constructor I am instantiating a
vector(vector of different fruits). And In that class I am writing a
searchVector method. I want to invoke that method from another class
searchFruit but if I create an object of the Fruit class, a new vector
gets initialized. When I call the searchVector method, the vector is
empty(as new vector gets created) and hence the search fails. Is there a
way that I could call the searchVector method from searchFruit class.
class Fruit{
Vector v;
Fruit(){
v= new vector();
}
public Fruit searchVector(String fruit){
//Searches Fruit
}
}
class searchFruit{
Fruit apple = new Fruit();
apple.searchVector("Apple");
}
Or if I want to write the search function in the searchFruit class how do
I pass the created vector to that class.
Access php object value
Access php object value
I have this object i am able to access the name by $object->name but not
able to get the starline and endline. I try $object->starline it return
null.
PHPParser_Node_Expr_Variable Object ( [subNodes:protected] => Array (
[name] => var ) [attributes:protected] => Array ( [startLine] => 2
[endLine] => 2 ) )
I have this object i am able to access the name by $object->name but not
able to get the starline and endline. I try $object->starline it return
null.
PHPParser_Node_Expr_Variable Object ( [subNodes:protected] => Array (
[name] => var ) [attributes:protected] => Array ( [startLine] => 2
[endLine] => 2 ) )
Friday, 27 September 2013
Visual Studio 2012 Add Reference Browse Default Path
Visual Studio 2012 Add Reference Browse Default Path
Most of my solutions will have an External References folder inside the
same folder as my Visual Studio solution. Usually solutions will have a
few of the same DLLs, but it is important for each solution to have its
own copy for the build machine and in case of different version numbers.
Previously in Visual Studio 2010 and earlier, when I add a reference to a
DLL External References folder the file browser dialog will open in the
last folder that I added a reference to for this specific Visual Studio
solution (or maybe project). In Visual Studio 2012 (Update 3) it seems to
open the file browser in the last folder that I referenced, regardless of
if it was within the current Visual Studio Solution or not. This means
that I sometimes reference a DLL in a another solution's External
References folder by mistake.
How can I change this back to the Visual Studio 2010 behaviour?
Most of my solutions will have an External References folder inside the
same folder as my Visual Studio solution. Usually solutions will have a
few of the same DLLs, but it is important for each solution to have its
own copy for the build machine and in case of different version numbers.
Previously in Visual Studio 2010 and earlier, when I add a reference to a
DLL External References folder the file browser dialog will open in the
last folder that I added a reference to for this specific Visual Studio
solution (or maybe project). In Visual Studio 2012 (Update 3) it seems to
open the file browser in the last folder that I referenced, regardless of
if it was within the current Visual Studio Solution or not. This means
that I sometimes reference a DLL in a another solution's External
References folder by mistake.
How can I change this back to the Visual Studio 2010 behaviour?
How can I plot the counts of my observed variable against the counts of a different level of the observed variable in a scatterplot?
How can I plot the counts of my observed variable against the counts of a
different level of the observed variable in a scatterplot?
I'd like to create scatter plots of the different conflict types against
each other. Each numbered sample would be a point. Samples should be
removed when there isn't aren't conflicts of the two types being plotted
against each other. I want to look at each relationship between conflict
types.
I made an example plot below of what I've been working on below but it
required lines and lines of explicit hard coding.
df <- structure(list(Name = c("487", "487", "232", "276", "405", "19",
"477", "487", "232", "159", "19", "232", "405", "487", "276",
"159", "159", "19", "286", "232", "232", "174", "19", "405",
"286", "599", "232", "30", "477", "232", "477", "477", "477",
"477", "477", "286", "159", "721", "487", "487", "276", "30",
"660", "345", "345", "345", "345", "174", "477", "355", "477",
"174", "159", "30", "477", "345", "276", "405", "608", "286",
"30", "232", "19", "721", "721", "102", "599", "345", "430",
"296", "174", "174", "174", "430", "430", "477", "487", "487",
"430", "430", "487", "345", "702", "30", "19", "30", "702", "702",
"174", "477", "174", "355", "159", "232", "430", "296", "702",
"286", "430", "702", "702", "712", "345", "184", "721", "184",
"102", "296", "599", "702", "702", "702", "38", "38", "38", "430",
"430", "430", "477", "477", "430", "477", "660", "702", "702",
"660", "660", "660", "702", "296", "702", "174", "296", "296",
"345", "702", "660", "599", "417", "417", "417", "702", "652",
"345", "184", "591", "184", "184", "599", "417", "90", "599",
"430", "678", "678", "38", "38", "477", "678", "678", "477",
"678", "678", "417", "430", "430", "572", "572", "572", "702",
"572", "702", "702", "702", "442", "442", "678", "442", "296",
"30", "311", "311", "311", "311", "311", "311", "591", "591",
"102", "442", "608", "430", "194", "194", "194", "678", "678",
"678", "38", "38", "678", "38", "38", "49", "49", "49", "690",
"690", "690", "572", "690", "296", "296", "552", "690", "702",
"580", "580", "580", "580", "454", "454", "454", "702", "702",
"345", "311", "311", "311", "184", "608", "194", "102", "224",
"224", "194", "194", "194", "660", "660", "38", "660", "660",
"90", "90", "212", "212", "212", "212", "690", "668", "690",
"690", "442", "562", "562", "562", "562", "562", "562", "562",
"562", "417", "417", "652", "652", "320", "320", "320", "184",
"599", "430", "678", "678", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "690", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "591", "194",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "102", "102", "224",
"329", "329", "224", "224", "224", "224", "224", "660", "212",
"212", "212", "212", "203", "203", "203", "203", "212", "212",
"668", "62", "76", "76", "76", "76", "76", "76", "76", "76",
"76", "76", "76", "76", "76", "652", "652", "62", "62", "430",
"678"), Conflict = structure(c(2L, 2L, 2L, 1L, 1L, 1L, 2L, 3L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 2L, 1L, 4L, 1L, 1L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 3L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 3L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 3L, 2L, 2L, 2L, 2L,
2L, 4L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L,
1L, 1L, 3L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L,
2L, 4L, 3L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 3L, 3L,
4L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 1L, 2L, 2L, 4L, 1L, 2L, 3L,
1L, 2L, 4L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 4L,
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 4L, 1L, 1L, 2L, 2L, 1L, 2L,
1L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 3L, 3L, 1L, 3L, 2L, 2L,
3L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 4L, 2L, 2L, 1L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 2L,
1L, 1L, 3L, 3L, 1L, 1L, 2L, 4L, 2L, 4L, 2L, 3L, 1L, 1L, 1L, 2L,
3L, 1L, 2L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 3L, 3L, 1L,
2L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 3L, 2L,
4L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L,
2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 2L,
2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L,
2L, 3L, 3L, 2L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 3L, 1L, 2L, 2L,
1L, 3L, 4L, 2L, 4L, 2L, 1L, 2L, 1L, 4L, 1L, 1L, 1L, 2L, 2L, 4L,
2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 3L, 1L, 2L, 3L, 2L,
2L), .Label = c("DB Zero", "File Zero", "Het - Homo", "Homo - Het"
), class = "factor")), .Names = c("Name", "Conflict"), row.names = c(NA,
-393L), class = "data.frame")
different level of the observed variable in a scatterplot?
I'd like to create scatter plots of the different conflict types against
each other. Each numbered sample would be a point. Samples should be
removed when there isn't aren't conflicts of the two types being plotted
against each other. I want to look at each relationship between conflict
types.
I made an example plot below of what I've been working on below but it
required lines and lines of explicit hard coding.
df <- structure(list(Name = c("487", "487", "232", "276", "405", "19",
"477", "487", "232", "159", "19", "232", "405", "487", "276",
"159", "159", "19", "286", "232", "232", "174", "19", "405",
"286", "599", "232", "30", "477", "232", "477", "477", "477",
"477", "477", "286", "159", "721", "487", "487", "276", "30",
"660", "345", "345", "345", "345", "174", "477", "355", "477",
"174", "159", "30", "477", "345", "276", "405", "608", "286",
"30", "232", "19", "721", "721", "102", "599", "345", "430",
"296", "174", "174", "174", "430", "430", "477", "487", "487",
"430", "430", "487", "345", "702", "30", "19", "30", "702", "702",
"174", "477", "174", "355", "159", "232", "430", "296", "702",
"286", "430", "702", "702", "712", "345", "184", "721", "184",
"102", "296", "599", "702", "702", "702", "38", "38", "38", "430",
"430", "430", "477", "477", "430", "477", "660", "702", "702",
"660", "660", "660", "702", "296", "702", "174", "296", "296",
"345", "702", "660", "599", "417", "417", "417", "702", "652",
"345", "184", "591", "184", "184", "599", "417", "90", "599",
"430", "678", "678", "38", "38", "477", "678", "678", "477",
"678", "678", "417", "430", "430", "572", "572", "572", "702",
"572", "702", "702", "702", "442", "442", "678", "442", "296",
"30", "311", "311", "311", "311", "311", "311", "591", "591",
"102", "442", "608", "430", "194", "194", "194", "678", "678",
"678", "38", "38", "678", "38", "38", "49", "49", "49", "690",
"690", "690", "572", "690", "296", "296", "552", "690", "702",
"580", "580", "580", "580", "454", "454", "454", "702", "702",
"345", "311", "311", "311", "184", "608", "194", "102", "224",
"224", "194", "194", "194", "660", "660", "38", "660", "660",
"90", "90", "212", "212", "212", "212", "690", "668", "690",
"690", "442", "562", "562", "562", "562", "562", "562", "562",
"562", "417", "417", "652", "652", "320", "320", "320", "184",
"599", "430", "678", "678", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "690", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "591", "194",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "62", "62", "62", "62",
"62", "62", "62", "62", "62", "62", "62", "102", "102", "224",
"329", "329", "224", "224", "224", "224", "224", "660", "212",
"212", "212", "212", "203", "203", "203", "203", "212", "212",
"668", "62", "76", "76", "76", "76", "76", "76", "76", "76",
"76", "76", "76", "76", "76", "652", "652", "62", "62", "430",
"678"), Conflict = structure(c(2L, 2L, 2L, 1L, 1L, 1L, 2L, 3L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 2L, 1L, 4L, 1L, 1L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 3L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 3L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 3L, 2L, 2L, 2L, 2L,
2L, 4L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L,
1L, 1L, 3L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L,
2L, 4L, 3L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 3L, 3L,
4L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 1L, 2L, 2L, 4L, 1L, 2L, 3L,
1L, 2L, 4L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 4L,
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 4L, 1L, 1L, 2L, 2L, 1L, 2L,
1L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 3L, 3L, 1L, 3L, 2L, 2L,
3L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 4L, 2L, 2L, 1L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 2L,
1L, 1L, 3L, 3L, 1L, 1L, 2L, 4L, 2L, 4L, 2L, 3L, 1L, 1L, 1L, 2L,
3L, 1L, 2L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 3L, 3L, 1L,
2L, 1L, 3L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 3L, 2L,
4L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L,
2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 2L,
2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L,
2L, 3L, 3L, 2L, 2L, 3L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 3L, 1L, 2L, 2L,
1L, 3L, 4L, 2L, 4L, 2L, 1L, 2L, 1L, 4L, 1L, 1L, 1L, 2L, 2L, 4L,
2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 3L, 1L, 2L, 3L, 2L,
2L), .Label = c("DB Zero", "File Zero", "Het - Homo", "Homo - Het"
), class = "factor")), .Names = c("Name", "Conflict"), row.names = c(NA,
-393L), class = "data.frame")
Is there a template engine like c# razorengine for nodejs
Is there a template engine like c# razorengine for nodejs
Is there a template engine for nodejs like razorengine which is
specialized in outputting html but not limited to html. So I would be able
to create javascript files on the fly with it too like i can with
RazorEngine?
An example i would love to be able to do:
var fs = require('fs');
var engine = require('templatingEngine');
var template = "<p>Hello, <% name %></p>";
var data = [
{id:"1", name: "bob"},
{id:"2", name: "pete"},
{id:"3", name: "jake"}
];
var result = engine.parse(template, data);
fs.writeFile("/tmp/hellos.html", result, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
hellos.html ==>
<p>Hello, bob</p>
<p>Hello, pete</p>
<p>Hello, jake</p>
Is there a template engine for nodejs like razorengine which is
specialized in outputting html but not limited to html. So I would be able
to create javascript files on the fly with it too like i can with
RazorEngine?
An example i would love to be able to do:
var fs = require('fs');
var engine = require('templatingEngine');
var template = "<p>Hello, <% name %></p>";
var data = [
{id:"1", name: "bob"},
{id:"2", name: "pete"},
{id:"3", name: "jake"}
];
var result = engine.parse(template, data);
fs.writeFile("/tmp/hellos.html", result, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
hellos.html ==>
<p>Hello, bob</p>
<p>Hello, pete</p>
<p>Hello, jake</p>
HTML5 Validation - Unclosed Elements that seem to be closed
HTML5 Validation - Unclosed Elements that seem to be closed
I'm getting errors when trying to validate this page in HTML5:
Unclosed element fieldset.
Stray end tag fieldset.
Unclosed element form.
For this block of html:
<form class="pure-form pure-form-aligned" id="submit_form_contact"
novalidate>
<fieldset>
<div class="pure-control-group">
<label for="name">Your Name:</label>
<input id="name" type="text" placeholder="Name"
name="name" required>
</div>
<div class="pure-control-group">
<label for="email">Your Email:</label>
<input id="email" type="email" placeholder="Email Address"
name="email" required>
</div>
<div class="pure-control-group">
<label for="email_text">Inquiry Type: </label>
<select id="inquiry_dropdown" class="pure-input-1-2"
name="inquiry">
<option>General</option>
<option>Sales & Marketing</option>
<option>Press & Editorial</option>
</select>
</div>
<div class="pure-control-group">
<label for="message" style="vertical-align:
top;">Message:</label>
<textarea id="message" type="text" placeholder="Enter
message here..." name="message"></textarea>
</div>
<div id="errors" style="text-align: center; color: red;"></div>
<button id="contact_submit" class="pure-button
pure-button-primary" style="background-color: #003A70;
float:right; margin-right:
35px;margin-top:15px;">Submit</button>
</div>
</fieldset>
</form>
... I can't figure out why. Everything seems to be closed properly. Can
anyone spot anything I'm doing wrong?
I'm getting errors when trying to validate this page in HTML5:
Unclosed element fieldset.
Stray end tag fieldset.
Unclosed element form.
For this block of html:
<form class="pure-form pure-form-aligned" id="submit_form_contact"
novalidate>
<fieldset>
<div class="pure-control-group">
<label for="name">Your Name:</label>
<input id="name" type="text" placeholder="Name"
name="name" required>
</div>
<div class="pure-control-group">
<label for="email">Your Email:</label>
<input id="email" type="email" placeholder="Email Address"
name="email" required>
</div>
<div class="pure-control-group">
<label for="email_text">Inquiry Type: </label>
<select id="inquiry_dropdown" class="pure-input-1-2"
name="inquiry">
<option>General</option>
<option>Sales & Marketing</option>
<option>Press & Editorial</option>
</select>
</div>
<div class="pure-control-group">
<label for="message" style="vertical-align:
top;">Message:</label>
<textarea id="message" type="text" placeholder="Enter
message here..." name="message"></textarea>
</div>
<div id="errors" style="text-align: center; color: red;"></div>
<button id="contact_submit" class="pure-button
pure-button-primary" style="background-color: #003A70;
float:right; margin-right:
35px;margin-top:15px;">Submit</button>
</div>
</fieldset>
</form>
... I can't figure out why. Everything seems to be closed properly. Can
anyone spot anything I'm doing wrong?
VBA Access - Create Excel Active X Object Error
VBA Access - Create Excel Active X Object Error
I am facing a strange situation with my MS Access VBA Code. I have a form
with several buttons for importing data into tables coming from different
Excel files.
In the form, 2 buttons have to open the same Excel workbook but different
sheets. In order to do this, I called the following subroutine in one of
the buttons:
Sub solar_solar(showNotification As Boolean)
Dim xlApp As Excel.Application
Dim eexWB As Workbook
Dim updatedDates As String
Dim insertedDates As String
On Error GoTo errorHandling
' open excel application and source file
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlApp.DisplayAlerts = False
Set eexWB = xlApp.Workbooks.Open(c_sourceFile_solar, False, True)
' update records
updatedDates = updateWindOrSolarRecords(eexWB, cWindSheet,
cStartRowWind, cStartColWind, c_sql_WindTable)
' more code ...
End Sub
The other subroutine (wind_wind) has exactly the same code for opening the
excel file. The solar_solar subroutine runs just fine but when then I try
to run the second one, the code does not start executing and I get the
alert: "Object library feature not supported" (Fehler beim Kompilieren:
Funktionsmerkmal der Objektbibliothek nicht unerstützt) and points to the
line:
Set xlApp = CreateObject("Excel.Application")
This occurs in Windows 7 MS Access 2002. I do not understand how it is
possible for this code to run well in one subroutine and not in another,
when it is practically the same. Has anyone experienced something similar?
Any advice?
Thanks.
I am facing a strange situation with my MS Access VBA Code. I have a form
with several buttons for importing data into tables coming from different
Excel files.
In the form, 2 buttons have to open the same Excel workbook but different
sheets. In order to do this, I called the following subroutine in one of
the buttons:
Sub solar_solar(showNotification As Boolean)
Dim xlApp As Excel.Application
Dim eexWB As Workbook
Dim updatedDates As String
Dim insertedDates As String
On Error GoTo errorHandling
' open excel application and source file
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlApp.DisplayAlerts = False
Set eexWB = xlApp.Workbooks.Open(c_sourceFile_solar, False, True)
' update records
updatedDates = updateWindOrSolarRecords(eexWB, cWindSheet,
cStartRowWind, cStartColWind, c_sql_WindTable)
' more code ...
End Sub
The other subroutine (wind_wind) has exactly the same code for opening the
excel file. The solar_solar subroutine runs just fine but when then I try
to run the second one, the code does not start executing and I get the
alert: "Object library feature not supported" (Fehler beim Kompilieren:
Funktionsmerkmal der Objektbibliothek nicht unerstützt) and points to the
line:
Set xlApp = CreateObject("Excel.Application")
This occurs in Windows 7 MS Access 2002. I do not understand how it is
possible for this code to run well in one subroutine and not in another,
when it is practically the same. Has anyone experienced something similar?
Any advice?
Thanks.
how to read values of JSON response from the server?
how to read values of JSON response from the server?
iam front end developer, and now i should to read JSON responce from
server which looks like that:
<RESULT>
<OVERALL_RESULT></OVERALL_RESULT>
<POINTS>0</POINTS>
<QUESTIONS>
<QUESTION>
<ID>1</ID>
<CORRECT></CORRECT>
</QUESTION>
<QUESTION>
<ID>2</ID>
<CORRECT>X</CORRECT>
</QUESTION>
<QUESTION>
<ID>3</ID>
<CORRECT>X</CORRECT>
</QUESTION>
<QUESTION>
<ID>4</ID>
<CORRECT>X</CORRECT>
</QUESTION>
<QUESTION>
<ID>5</ID>
<CORRECT>X</CORRECT>
</QUESTION>
</QUESTIONS>
</RESULT>
how can i read it and save in variables values from this response? like this:
var q1 = "1";
var q1IsCorrect = false;
var q2 = "2";
var q2IsCorrect = true;
and so on...
iam front end developer, and now i should to read JSON responce from
server which looks like that:
<RESULT>
<OVERALL_RESULT></OVERALL_RESULT>
<POINTS>0</POINTS>
<QUESTIONS>
<QUESTION>
<ID>1</ID>
<CORRECT></CORRECT>
</QUESTION>
<QUESTION>
<ID>2</ID>
<CORRECT>X</CORRECT>
</QUESTION>
<QUESTION>
<ID>3</ID>
<CORRECT>X</CORRECT>
</QUESTION>
<QUESTION>
<ID>4</ID>
<CORRECT>X</CORRECT>
</QUESTION>
<QUESTION>
<ID>5</ID>
<CORRECT>X</CORRECT>
</QUESTION>
</QUESTIONS>
</RESULT>
how can i read it and save in variables values from this response? like this:
var q1 = "1";
var q1IsCorrect = false;
var q2 = "2";
var q2IsCorrect = true;
and so on...
Python how to know if a record inserted successfully or not
Python how to know if a record inserted successfully or not
I'm using Python MySQL Connector, I inserted a record into database, and
it was successful. But in Python code, how can I know if it is inserted or
not? My Table does not have a primary key.
def insert(params) :
db_connection = Model.get_db_connection()
cursor = db_connection.cursor()
try :
cursor.execute("""INSERT INTO `User`(`UID`, `IP`)
VALUES(%s,%s);""", (params))
db_connection.commit()
except :
db_connection.rollback()
Model.close_db(db_connection)
return result
I'm using Python MySQL Connector, I inserted a record into database, and
it was successful. But in Python code, how can I know if it is inserted or
not? My Table does not have a primary key.
def insert(params) :
db_connection = Model.get_db_connection()
cursor = db_connection.cursor()
try :
cursor.execute("""INSERT INTO `User`(`UID`, `IP`)
VALUES(%s,%s);""", (params))
db_connection.commit()
except :
db_connection.rollback()
Model.close_db(db_connection)
return result
Thursday, 26 September 2013
URL parsing and sessions in Reservation system
URL parsing and sessions in Reservation system
I am creating a flight/hotel reservation system like farecompare.com
Farecompare parse values to other sites and create sessions other sites
too. Anyone tell me how they create sesssions in it. I can parse url but i
am not able to create sessions.
public function flight($depart, $return, $from, $to, $type, $class,
$adults, $seniors, $children) {
$dep = explode("/", $depart);
$ret = explode("/", $return);
if ($type == 'RoundTrip') {
$expurl = 'http://www.expedia.co.in/Flights-Search?trip=' .
strtolower($type) . '&leg1=from%3A' . $from . '%29%2Cto%3A' . $to
. '%29%2Cdeparture%3A' . $dep[1] . '/' . $dep[0] . '/' . $dep[2] .
'TANYT&leg2=from%3A' . $to . '%29%2Cto%3A' . $from .
'%29%2Cdeparture%3A' . $ret[1] . '/' . $ret[0] . '/' . $ret[2] .
'TANYT&passengers=children%3A' . $children . '%2Cadults%3A' .
$adults . '%2Cseniors%3A' . $seniors .
'%2Cinfantinlap%3AY&options=cabinclass%3Aeconomy%2Cnopenalty%3AN%2Csortby%3Aprice&mode=search';
echo '<a href = "' . $expurl . '" target = "_blank">Expedia</a>';
} else {
$type = 'oneway';
$expurl = 'http://www.expedia.co.in/Flights-Search?trip=' .
strtolower($type) . '&leg1=from%3A' . $from . '%29%2Cto%3A' . $to
. '%29%2Cdeparture%3A' . $dep[1] . '/' . $dep[0] . '/' . $dep[2] .
'TANYT&passengers=children%3A' . $children . '%2Cadults%3A' .
$adults . '%2Cseniors%3A' . $seniors .
'%2Cinfantinlap%3AY&options=cabinclass%3Aeconomy%2Cnopenalty%3AN%2Csortby%3Aprice&mode=search';
echo '<a href = "' . $expurl . '" target = "_blank">Expedia</a>';
}
}
I worked on Expedia by parsing url to get data but there are other sites
like cheapoait, travelocity etc which uses sessions. How to create
sessions
I am creating a flight/hotel reservation system like farecompare.com
Farecompare parse values to other sites and create sessions other sites
too. Anyone tell me how they create sesssions in it. I can parse url but i
am not able to create sessions.
public function flight($depart, $return, $from, $to, $type, $class,
$adults, $seniors, $children) {
$dep = explode("/", $depart);
$ret = explode("/", $return);
if ($type == 'RoundTrip') {
$expurl = 'http://www.expedia.co.in/Flights-Search?trip=' .
strtolower($type) . '&leg1=from%3A' . $from . '%29%2Cto%3A' . $to
. '%29%2Cdeparture%3A' . $dep[1] . '/' . $dep[0] . '/' . $dep[2] .
'TANYT&leg2=from%3A' . $to . '%29%2Cto%3A' . $from .
'%29%2Cdeparture%3A' . $ret[1] . '/' . $ret[0] . '/' . $ret[2] .
'TANYT&passengers=children%3A' . $children . '%2Cadults%3A' .
$adults . '%2Cseniors%3A' . $seniors .
'%2Cinfantinlap%3AY&options=cabinclass%3Aeconomy%2Cnopenalty%3AN%2Csortby%3Aprice&mode=search';
echo '<a href = "' . $expurl . '" target = "_blank">Expedia</a>';
} else {
$type = 'oneway';
$expurl = 'http://www.expedia.co.in/Flights-Search?trip=' .
strtolower($type) . '&leg1=from%3A' . $from . '%29%2Cto%3A' . $to
. '%29%2Cdeparture%3A' . $dep[1] . '/' . $dep[0] . '/' . $dep[2] .
'TANYT&passengers=children%3A' . $children . '%2Cadults%3A' .
$adults . '%2Cseniors%3A' . $seniors .
'%2Cinfantinlap%3AY&options=cabinclass%3Aeconomy%2Cnopenalty%3AN%2Csortby%3Aprice&mode=search';
echo '<a href = "' . $expurl . '" target = "_blank">Expedia</a>';
}
}
I worked on Expedia by parsing url to get data but there are other sites
like cheapoait, travelocity etc which uses sessions. How to create
sessions
Wednesday, 25 September 2013
Testing LDAP Authentication in a laptop with out a Domain
Testing LDAP Authentication in a laptop with out a Domain
I have to develop as ASP.net application and need to authenticate users
using LDAP. I don't have a windows server installed . I wonder how I can
test my code from my local laptop
Any suggestions ??
I have to develop as ASP.net application and need to authenticate users
using LDAP. I don't have a windows server installed . I wonder how I can
test my code from my local laptop
Any suggestions ??
Thursday, 19 September 2013
Would process with more threads on JVM have more cpu time than process with one thread?
Would process with more threads on JVM have more cpu time than process
with one thread?
Based on the question on Linux, this is effective way to hogging the CPU
until 2.6.38. How about JVM? Assume we have implemented the lock free
algorithm, all these threads are totally independent from each other. Will
more threads help us to gain more CPU time from the system?
with one thread?
Based on the question on Linux, this is effective way to hogging the CPU
until 2.6.38. How about JVM? Assume we have implemented the lock free
algorithm, all these threads are totally independent from each other. Will
more threads help us to gain more CPU time from the system?
ExtJS: RENDERER NOT GETTING CALLED
ExtJS: RENDERER NOT GETTING CALLED
I can't figure out why my customer renderer for my grouped-column grid
isn't being called...
Ext.define('PT.view.deal.YearCol', {
extend: 'Ext.grid.column.Column',
alias: 'widget.yearcolumn',
columns: [
{
text: 1,
renderer: function(v, m, r) {
console.log('renderer called'); // THIS IS NEVER
CALLED!!!!!!!!
return custom(r);
}
},
...
]
});
Ext.define('PT.view.deal.QuarterlyGrid', {
extend: 'Ext.grid.Panel',
columns: [
{
text: 'Item Number',
dataIndex: 'Item_Number'
},
{
xtype: 'yearcolumn',
text: 2013
},
...
]
});
the grid columns/headers are displayed correctly ... but the grid data
isn't rendered. Why is that function not being called.
I can't figure out why my customer renderer for my grouped-column grid
isn't being called...
Ext.define('PT.view.deal.YearCol', {
extend: 'Ext.grid.column.Column',
alias: 'widget.yearcolumn',
columns: [
{
text: 1,
renderer: function(v, m, r) {
console.log('renderer called'); // THIS IS NEVER
CALLED!!!!!!!!
return custom(r);
}
},
...
]
});
Ext.define('PT.view.deal.QuarterlyGrid', {
extend: 'Ext.grid.Panel',
columns: [
{
text: 'Item Number',
dataIndex: 'Item_Number'
},
{
xtype: 'yearcolumn',
text: 2013
},
...
]
});
the grid columns/headers are displayed correctly ... but the grid data
isn't rendered. Why is that function not being called.
MPMoviePlayerController crashes when calling stop in iOS7
MPMoviePlayerController crashes when calling stop in iOS7
Recently i've been with a very strange issue. It only happens in iOS 7. I
use MPMoviePlayerController to play a stream from the Web. It was working
perfect....until I switch to iOS7. Now it gives me EXC_BAD_ACCESS whenever
I call stop. When the playbackFinishes I also call stop and it does not
give me any errors, only when I press the stop button.
Did someone had the same issue? Thanks in advance.
Recently i've been with a very strange issue. It only happens in iOS 7. I
use MPMoviePlayerController to play a stream from the Web. It was working
perfect....until I switch to iOS7. Now it gives me EXC_BAD_ACCESS whenever
I call stop. When the playbackFinishes I also call stop and it does not
give me any errors, only when I press the stop button.
Did someone had the same issue? Thanks in advance.
php-chippest way for instant messages, Notifications
php-chippest way for instant messages, Notifications
I'm building a site that need to have instant messages and notifications.
I have heard about socket and comet, but it seems a bit complicated. Also
heard about ajax solution. the client make a request and then the server
only replies when he got new data to send. (he can check for new data like
every x milliseconds with sleep method. The new request will be send only
when the last one got respond, or after it timed out.
looking for new messages every x seconds just doesn't feel smart, but it
very easy Implementation so I'm temped to use it.
The problem is, does this system will slow the client browser/ my server?
and if so, whats the cippest way to implement an instant
messages|notification system?
I'm building a site that need to have instant messages and notifications.
I have heard about socket and comet, but it seems a bit complicated. Also
heard about ajax solution. the client make a request and then the server
only replies when he got new data to send. (he can check for new data like
every x milliseconds with sleep method. The new request will be send only
when the last one got respond, or after it timed out.
looking for new messages every x seconds just doesn't feel smart, but it
very easy Implementation so I'm temped to use it.
The problem is, does this system will slow the client browser/ my server?
and if so, whats the cippest way to implement an instant
messages|notification system?
Wait panel on smartgwt
Wait panel on smartgwt
Do you know any components in smartgwt in order to do some like this?
I´ve done it using several componets, Labels, Camva, Img, Layouts....
Thanks
Do you know any components in smartgwt in order to do some like this?
I´ve done it using several componets, Labels, Camva, Img, Layouts....
Thanks
Series markers disable on lines and enable on legend in Highchart
Series markers disable on lines and enable on legend in Highchart
I have a line chart in Highchart with more than 10 series. When the chart
is plotted for more that 2 months data with series marker enabled, the
chart looks congested and makes no sense so I disabled series markers.
When series marker is disabled, the markers in the legends also
disappeared. What I want is to disable the markers only in the series and
enable markers in legends. How can I achieve this? Can anybody please help
me this?
Thanks, Rocky.
I have a line chart in Highchart with more than 10 series. When the chart
is plotted for more that 2 months data with series marker enabled, the
chart looks congested and makes no sense so I disabled series markers.
When series marker is disabled, the markers in the legends also
disappeared. What I want is to disable the markers only in the series and
enable markers in legends. How can I achieve this? Can anybody please help
me this?
Thanks, Rocky.
Wednesday, 18 September 2013
Accessing KSEG2 addresses in GDB
Accessing KSEG2 addresses in GDB
We have a core file from an executable (N32 ABI, MIPS64 Rel2 Arch). From
an embedded device where we have wired TLB's to use some of the KSEG2
space as well. When the core file is loaded in GDB it throws the following
error even thought GDB seems to have loaded the sections correctly (from
"maintanence info section" output).
(gdb) maint info sec ... 0xe0000000->0xe8000000 at 0x4100ff80: load5 ALLOC
LOAD HAS_CONTENTS ...
(gdb) x 0xe0000000 0xe0000000: Cannot access memory at address 0xe0000000
Any thoughts from anyone as to what I could be facing. Some assumption in
GDB about the 2G KUSEG?.
We have a core file from an executable (N32 ABI, MIPS64 Rel2 Arch). From
an embedded device where we have wired TLB's to use some of the KSEG2
space as well. When the core file is loaded in GDB it throws the following
error even thought GDB seems to have loaded the sections correctly (from
"maintanence info section" output).
(gdb) maint info sec ... 0xe0000000->0xe8000000 at 0x4100ff80: load5 ALLOC
LOAD HAS_CONTENTS ...
(gdb) x 0xe0000000 0xe0000000: Cannot access memory at address 0xe0000000
Any thoughts from anyone as to what I could be facing. Some assumption in
GDB about the 2G KUSEG?.
Can't launch Android Studio on Mac OS X (10.5.8)
Can't launch Android Studio on Mac OS X (10.5.8)
I have downloaded Android Studio and when I try to launch the application,
my tool bar looks like the program is going to start, but then quickly
stops. I don't know how to check/set any system variables. Any help would
be appreciated!
I have downloaded Android Studio and when I try to launch the application,
my tool bar looks like the program is going to start, but then quickly
stops. I don't know how to check/set any system variables. Any help would
be appreciated!
Spring resource bundle delimer
Spring resource bundle delimer
We are using Spring LocaleChangeInterceptor and
ReloadableResourceBundleMessageSource for all our localization needs. All
is well until a strange requirement comes.
What the new requirement needs is that we have to allow each language
property file to "float", which means that these resource bundles are no
longer required to have all keys to be in sync.
Missing keys, in this use case, will have to default to use en_US
properties. We have proposed to write tools to fill the missing keys with
English messages, but that got push back hard from above. They say that it
was doable in Struts and Spring should also do the same.
I have been searching up and down the web but I cannot find such example.
Can this even be done in Spring 3?
We are using Spring LocaleChangeInterceptor and
ReloadableResourceBundleMessageSource for all our localization needs. All
is well until a strange requirement comes.
What the new requirement needs is that we have to allow each language
property file to "float", which means that these resource bundles are no
longer required to have all keys to be in sync.
Missing keys, in this use case, will have to default to use en_US
properties. We have proposed to write tools to fill the missing keys with
English messages, but that got push back hard from above. They say that it
was doable in Struts and Spring should also do the same.
I have been searching up and down the web but I cannot find such example.
Can this even be done in Spring 3?
View mysql log files : ib_logfile0
View mysql log files : ib_logfile0
I am trying to debug a remote server to which I dont have direct access.
Its mysqld daemon is getting restarted repeatedly.
I got access to these log files.
ib_logfile0
ib_logfile1
localhost.err
Is is possible to view them in any human readable format?or Is there any
other log files which I should be looking at?
strings ib_logfile0 //didnt help much. Is there any other way?
Similar question :
http://forums.mysql.com/read.php?22,198636,198636#msg-198636
Thanks!
I am trying to debug a remote server to which I dont have direct access.
Its mysqld daemon is getting restarted repeatedly.
I got access to these log files.
ib_logfile0
ib_logfile1
localhost.err
Is is possible to view them in any human readable format?or Is there any
other log files which I should be looking at?
strings ib_logfile0 //didnt help much. Is there any other way?
Similar question :
http://forums.mysql.com/read.php?22,198636,198636#msg-198636
Thanks!
Add a video watermark (text) in Javascript / HTML?
Add a video watermark (text) in Javascript / HTML?
I'm using HTML5 video on my website.
Is there a way in Javascript and / or HTML to permanently add a text
watermark to a video saying for example "Right click video to visit
www.exampleURL.com"?
I already tried nesting a span tag inside the video tag and playing with
the Zindex value but it doesn't work.
I know Flash and other video players allow that but I'm not interested in
those technologies.
Thanks
I'm using HTML5 video on my website.
Is there a way in Javascript and / or HTML to permanently add a text
watermark to a video saying for example "Right click video to visit
www.exampleURL.com"?
I already tried nesting a span tag inside the video tag and playing with
the Zindex value but it doesn't work.
I know Flash and other video players allow that but I'm not interested in
those technologies.
Thanks
Javascript How can I get the href from no id anchor tag?
Javascript How can I get the href from no id anchor tag?
<a href="href">inner</a>
Under function don't work because no id
document.getElementById("???").href
<a href="href">inner</a>
Under function don't work because no id
document.getElementById("???").href
Check if another script is loaded without using JQUERY
Check if another script is loaded without using JQUERY
I have two different that are somewhat depending on eachother (i.e one of
the script has a function that calls the other script)
Now i wont go into any details other than saying i am not able to load one
before the other.
Because of this i need to make a check in the scripts to check if the
other script is loaded (So that the scripts "waits" for eachother).
My Boss does NOT want me to use Jquery so i was wondering is there a way
in Plain javascript to check if another script is loaded? And if so how?
I have two different that are somewhat depending on eachother (i.e one of
the script has a function that calls the other script)
Now i wont go into any details other than saying i am not able to load one
before the other.
Because of this i need to make a check in the scripts to check if the
other script is loaded (So that the scripts "waits" for eachother).
My Boss does NOT want me to use Jquery so i was wondering is there a way
in Plain javascript to check if another script is loaded? And if so how?
Javascript Http Get Request error : NS_ERROR_FAILURE
Javascript Http Get Request error : NS_ERROR_FAILURE
I'm writting a website (it's my very first without java..) and what is
done is simple. I call a javascript function "changeVideo()" that make a
request to a php page "GetAVideo.php" which returns the url to a randomly
choosen video (choosen between videos files on my server).
Last night, i could watch videos without problem but today, when i load my
page, the video is not loaded because the GET request fails :
"NS_ERROR_FAILURE: Failure xhr_object.send();"
I can't understand why, here are my sources : javascript:
function changeVideo()
{
console.log("changeVideo path:", path);
var xhr_object = null;
if (window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if (window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
var request = "http://ogdabou.com/php/GetAVideo.php";
/*if (path.length > 0)
{
request = request + "?folders=";
for (var i = 0; i < path.length ; i++)
{
request = request + path[i] + ";";
}
}*/
console.log("request: ", request);
xhr_object.open("GET", request, false);
xhr_object.send();
console.log("response: ", xhr_object.responseText);
videoPlayer.src(xhr_object.responseText);
videoPlayer.currentTime(0);
videoPlayer.play();
document.getElementById("videoTitle").innerHTML =
xhr_object.responseText;
return false;
};
php :
<?php
$dirname = '../videos';
$videoList = array();
$dir = opendir($dirname);
if (count($_GET) > 0)
{
$folders=explode(";", $_GET['folders']);
foreach ($folders as $videoFolder) {
$fullPath = $dirname."/".$videoFolder;
echo "Visiting $fullpath";
$videoList = fillVideoList($fullPath, $videoList);
}
}
else
{
$videoList = fillVideoList($dirname, $videoList);
}
//use join to get the paths.
closedir($dir);
$choosenOne = $videoList[rand(0, count($videoList) - 1)];
$choosenOne = str_replace("../videos/","", $choosenOne);
echo "http://ogdabou.com/videos/".$choosenOne;
?>
<?php
// Fill the videoList with the given folder. Also visit subdirectories.
function fillVideoList($folder, $videoList)
{
$path = $folder;
$folder = opendir($folder);
while($file = readdir($folder)) {
if($file != '.' && $file != '..')
{
$fullPath = "$path/$file";
if (is_dir($fullPath))
{
$videoList = fillVideoList($fullPath,
$videoList);
}
else if(pathinfo($fullPath, PATHINFO_EXTENSION) ==
"webm")
{
$videoList[] = $fullPath;
}
}
}
return $videoList;
}
?>
Thank you !
I'm writting a website (it's my very first without java..) and what is
done is simple. I call a javascript function "changeVideo()" that make a
request to a php page "GetAVideo.php" which returns the url to a randomly
choosen video (choosen between videos files on my server).
Last night, i could watch videos without problem but today, when i load my
page, the video is not loaded because the GET request fails :
"NS_ERROR_FAILURE: Failure xhr_object.send();"
I can't understand why, here are my sources : javascript:
function changeVideo()
{
console.log("changeVideo path:", path);
var xhr_object = null;
if (window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if (window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
var request = "http://ogdabou.com/php/GetAVideo.php";
/*if (path.length > 0)
{
request = request + "?folders=";
for (var i = 0; i < path.length ; i++)
{
request = request + path[i] + ";";
}
}*/
console.log("request: ", request);
xhr_object.open("GET", request, false);
xhr_object.send();
console.log("response: ", xhr_object.responseText);
videoPlayer.src(xhr_object.responseText);
videoPlayer.currentTime(0);
videoPlayer.play();
document.getElementById("videoTitle").innerHTML =
xhr_object.responseText;
return false;
};
php :
<?php
$dirname = '../videos';
$videoList = array();
$dir = opendir($dirname);
if (count($_GET) > 0)
{
$folders=explode(";", $_GET['folders']);
foreach ($folders as $videoFolder) {
$fullPath = $dirname."/".$videoFolder;
echo "Visiting $fullpath";
$videoList = fillVideoList($fullPath, $videoList);
}
}
else
{
$videoList = fillVideoList($dirname, $videoList);
}
//use join to get the paths.
closedir($dir);
$choosenOne = $videoList[rand(0, count($videoList) - 1)];
$choosenOne = str_replace("../videos/","", $choosenOne);
echo "http://ogdabou.com/videos/".$choosenOne;
?>
<?php
// Fill the videoList with the given folder. Also visit subdirectories.
function fillVideoList($folder, $videoList)
{
$path = $folder;
$folder = opendir($folder);
while($file = readdir($folder)) {
if($file != '.' && $file != '..')
{
$fullPath = "$path/$file";
if (is_dir($fullPath))
{
$videoList = fillVideoList($fullPath,
$videoList);
}
else if(pathinfo($fullPath, PATHINFO_EXTENSION) ==
"webm")
{
$videoList[] = $fullPath;
}
}
}
return $videoList;
}
?>
Thank you !
Tuesday, 17 September 2013
Python: Executing multiple functions simultaneously
Python: Executing multiple functions simultaneously
I m trying to run two functions simultaneously in Python. I have tried the
below code which uses multiprocessing but when i execute the second
functions starts after the first is done.
from multiprocessing import Process
def func1:
#does something
def func2:
#does something
if __name__=='__main__':
p1 = Process(target = func1)
p1.start()
p2 = Process(target = func2)
p2.start()
I m trying to run two functions simultaneously in Python. I have tried the
below code which uses multiprocessing but when i execute the second
functions starts after the first is done.
from multiprocessing import Process
def func1:
#does something
def func2:
#does something
if __name__=='__main__':
p1 = Process(target = func1)
p1.start()
p2 = Process(target = func2)
p2.start()
How do I put the last day of the month on its corresponding month of the year in MS excel?
How do I put the last day of the month on its corresponding month of the
year in MS excel?
How do I put the last day of the month on its corresponding month of the
year in Excel? Because I need to do this from 2005 to 2025 in creating a
Time Dimension Table. I tried to find a solution in Visual Studio but I
didn't find any option to customize it.
COLUMN C COLUMN D
Friday, July 01, 2005 2005-07-31 Saturday, July 02, 2005 2005-07-31
Sunday, July 03, 2005 2005-07-31 Monday, July 04, 2005 2005-07-31 Tuesday,
July 05, 2005 2005-07-31 ....... .... ... Wednesday, July 27, 2005
2005-07-31 Thursday, July 28, 2005 2005-07-31 Friday, July 29, 2005
2005-07-31 Saturday, July 30, 2005 2005-07-31 Sunday, July 31, 2005
2005-07-31 ..... ... .. Monday, August 01, 2005 2005-08-31 Tuesday, August
02, 2005 2005-08-31 Wednesday, August 03, 2005 2005-08-31 Thursday, August
04, 2005 2005-08-31 Friday, August 05, 2005 2005-08-31
and so forth all the way to year 2025
Thank you in advance!
Beau
year in MS excel?
How do I put the last day of the month on its corresponding month of the
year in Excel? Because I need to do this from 2005 to 2025 in creating a
Time Dimension Table. I tried to find a solution in Visual Studio but I
didn't find any option to customize it.
COLUMN C COLUMN D
Friday, July 01, 2005 2005-07-31 Saturday, July 02, 2005 2005-07-31
Sunday, July 03, 2005 2005-07-31 Monday, July 04, 2005 2005-07-31 Tuesday,
July 05, 2005 2005-07-31 ....... .... ... Wednesday, July 27, 2005
2005-07-31 Thursday, July 28, 2005 2005-07-31 Friday, July 29, 2005
2005-07-31 Saturday, July 30, 2005 2005-07-31 Sunday, July 31, 2005
2005-07-31 ..... ... .. Monday, August 01, 2005 2005-08-31 Tuesday, August
02, 2005 2005-08-31 Wednesday, August 03, 2005 2005-08-31 Thursday, August
04, 2005 2005-08-31 Friday, August 05, 2005 2005-08-31
and so forth all the way to year 2025
Thank you in advance!
Beau
How do I share variables between methods in a controller in Rails 4?
How do I share variables between methods in a controller in Rails 4?
I'm trying to learn Ruby on Rails, so one of the projects I am doing is
developing an app where you enter a URL, click submit, the server starts
downloading the file from that URL, and then you see a page showing you
the details of the download (periodically updated from the server). I
haven't gotten my head around some of the idiosyncrasies of instance
variables vs. class variables in Ruby, and I have done something horrible:
class ProgressWebsController < ApplicationController
layout "application"
include ActionController::Live
before_action :set_progress_web, only: [:edit, :update, :destroy]
@@thread
@@test=0
@@clonePW
# GET /progress_webs
# GET /progress_webs.json
def index
@progress_web=ProgressWeb.new
end
def updateProgress
puts "Not gonna happen"
end
# GET /progress_webs/1
# GET /progress_webs/1.json
def show
puts "Downloading %s" % @@clonePW['url'].to_s
@@thread = download(@@clonePW['url'].to_s)
@progress_web=@@clonePW
@@start = Time.now
end
# GET /progress_webs/new
def new
if( @@test.eql?("100.00"))
puts "DOWNLOAD COMPLETE"
@@thread.exit
render :partial => "complete", :locals => { :progress_int => @@test,
:done_int =>@@done, :elapsed_int =>@@elapsed_int }
return
end
@@test= "%.2f" % @@thread[:progress].to_f
@@done= "%d" % @@thread[:done]
now = Time.now
elapsed =now - @@start
@@elapsed_int="%d" % elapsed
render :partial => "progress", :locals => { :progress_int => @@test,
:done_int =>@@done, :elapsed_int =>@@elapsed_int }
end
def download(url)
Thread.new do
thread = Thread.current
body = thread[:body] = []
url = URI.parse url
Net::HTTP.new(url.host, url.port).request_get(url.path) do |response|
length = thread[:length] = response['Content-Length'].to_i
response.read_body do |fragment|
body << fragment
thread[:done] = (thread[:done] || 0) + fragment.length
thread[:progress] = thread[:done].quo(length) * 100
end
end
end
end
First of all, I wasn't able to get it to call the updateProgress method,
it kept going to "show", and passing "updateProgress" as the parameter
"id". Instead of fiddling too much with this, I just hijacked the "new"
method and had my jQuery call that every time it wants an update on the
download status. Forgive me for this, I probably bit off more than I can
chew before learning the basics.
Secondly, only one person can use this webapp at a time, because I had to
use class variables instead of instance variables. If I used instance
variables then they would be nil by the time one method looked at a value
another method was supposed to have set. Reading up on why that is, I
think I get the idea, but what is the solution? Is there an easy way to
share values between methods in a controller in rails? I've found a
similar question on here where the answers recommended doing the
calculations in the model, but would that work for my purposes as well?
I'm trying to learn Ruby on Rails, so one of the projects I am doing is
developing an app where you enter a URL, click submit, the server starts
downloading the file from that URL, and then you see a page showing you
the details of the download (periodically updated from the server). I
haven't gotten my head around some of the idiosyncrasies of instance
variables vs. class variables in Ruby, and I have done something horrible:
class ProgressWebsController < ApplicationController
layout "application"
include ActionController::Live
before_action :set_progress_web, only: [:edit, :update, :destroy]
@@thread
@@test=0
@@clonePW
# GET /progress_webs
# GET /progress_webs.json
def index
@progress_web=ProgressWeb.new
end
def updateProgress
puts "Not gonna happen"
end
# GET /progress_webs/1
# GET /progress_webs/1.json
def show
puts "Downloading %s" % @@clonePW['url'].to_s
@@thread = download(@@clonePW['url'].to_s)
@progress_web=@@clonePW
@@start = Time.now
end
# GET /progress_webs/new
def new
if( @@test.eql?("100.00"))
puts "DOWNLOAD COMPLETE"
@@thread.exit
render :partial => "complete", :locals => { :progress_int => @@test,
:done_int =>@@done, :elapsed_int =>@@elapsed_int }
return
end
@@test= "%.2f" % @@thread[:progress].to_f
@@done= "%d" % @@thread[:done]
now = Time.now
elapsed =now - @@start
@@elapsed_int="%d" % elapsed
render :partial => "progress", :locals => { :progress_int => @@test,
:done_int =>@@done, :elapsed_int =>@@elapsed_int }
end
def download(url)
Thread.new do
thread = Thread.current
body = thread[:body] = []
url = URI.parse url
Net::HTTP.new(url.host, url.port).request_get(url.path) do |response|
length = thread[:length] = response['Content-Length'].to_i
response.read_body do |fragment|
body << fragment
thread[:done] = (thread[:done] || 0) + fragment.length
thread[:progress] = thread[:done].quo(length) * 100
end
end
end
end
First of all, I wasn't able to get it to call the updateProgress method,
it kept going to "show", and passing "updateProgress" as the parameter
"id". Instead of fiddling too much with this, I just hijacked the "new"
method and had my jQuery call that every time it wants an update on the
download status. Forgive me for this, I probably bit off more than I can
chew before learning the basics.
Secondly, only one person can use this webapp at a time, because I had to
use class variables instead of instance variables. If I used instance
variables then they would be nil by the time one method looked at a value
another method was supposed to have set. Reading up on why that is, I
think I get the idea, but what is the solution? Is there an easy way to
share values between methods in a controller in rails? I've found a
similar question on here where the answers recommended doing the
calculations in the model, but would that work for my purposes as well?
JSDoc 3 parse error getter/setter with the same name in strict mode
JSDoc 3 parse error getter/setter with the same name in strict mode
I am getting error when compiling the following code to generate a
document with JSDoc 3. If I remove the first line, "user strict";, then it
works. Is this a bug in JSDoc, or I am missing something?
Code:
"use strict";
var BaseClass = require("./BaseClass").BaseClass;
/**
* @class
* @extends BaseClass
*/
var MyClass = BaseClass.extend(
/** @lends MyClass.prototype */
{
/**
* Initializer.
* @public
*/
initialize:function () {
this._id = -1;
},
/**
* Property id
* @public
* @property {number} id
*/
get id() {
return this._id;
},
set id(id) {
this._id = id;
}
});
exports.MyClass = MyClass;
Here's the error I am seeing:
./jsdoc3/jsdoc -c ./conf.json
js: "/xxx/src/main.js", line 31: Property "id" already defined in this
object literal.
js: }
js: ....^
org.mozilla.javascript.EvaluatorException: Compilation produced 1 syntax
errors. (/xxx/src/main.js#1)
at
org.mozilla.javascript.tools.ToolErrorReporter.runtimeError(ToolErrorReporter.java:144)
at org.mozilla.javascript.Parser.parse(Parser.java:596)
at org.mozilla.javascript.Parser.parse(Parser.java:505)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18._c_anonymous_24(Unknown
Source)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18.call(Unknown
Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18._c_anonymous_2(Unknown
Source)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18.call(Unknown
Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1._c_main_3(Unknown
Source)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown
Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1._c_script_0(Unknown
Source)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown
Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown
Source)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.exec(Unknown
Source)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:654)
at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:552)
at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:507)
at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:499)
at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:215)
at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:134)
at org.mozilla.javascript.Context.call(Context.java:521)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:535)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:198)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:174)
make: *** [docs] Error 1
I am getting error when compiling the following code to generate a
document with JSDoc 3. If I remove the first line, "user strict";, then it
works. Is this a bug in JSDoc, or I am missing something?
Code:
"use strict";
var BaseClass = require("./BaseClass").BaseClass;
/**
* @class
* @extends BaseClass
*/
var MyClass = BaseClass.extend(
/** @lends MyClass.prototype */
{
/**
* Initializer.
* @public
*/
initialize:function () {
this._id = -1;
},
/**
* Property id
* @public
* @property {number} id
*/
get id() {
return this._id;
},
set id(id) {
this._id = id;
}
});
exports.MyClass = MyClass;
Here's the error I am seeing:
./jsdoc3/jsdoc -c ./conf.json
js: "/xxx/src/main.js", line 31: Property "id" already defined in this
object literal.
js: }
js: ....^
org.mozilla.javascript.EvaluatorException: Compilation produced 1 syntax
errors. (/xxx/src/main.js#1)
at
org.mozilla.javascript.tools.ToolErrorReporter.runtimeError(ToolErrorReporter.java:144)
at org.mozilla.javascript.Parser.parse(Parser.java:596)
at org.mozilla.javascript.Parser.parse(Parser.java:505)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18._c_anonymous_24(Unknown
Source)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18.call(Unknown
Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18._c_anonymous_2(Unknown
Source)
at
org.mozilla.javascript.gen.file__Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_node_modules_jsdoc_src_parser_js_18.call(Unknown
Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1._c_main_3(Unknown
Source)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown
Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1._c_script_0(Unknown
Source)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown
Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.call(Unknown
Source)
at
org.mozilla.javascript.gen._Users_ytakeda_Projects_Supernova_snova_docs_submodules_jsdoc3_jsdoc_js_1.exec(Unknown
Source)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:654)
at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:552)
at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:507)
at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:499)
at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:215)
at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:134)
at org.mozilla.javascript.Context.call(Context.java:521)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:535)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:198)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:174)
make: *** [docs] Error 1
Sum of Sumif Over Multiple Sheets
Sum of Sumif Over Multiple Sheets
I know Im not doing this properly but I am a VBA beginner and am trying to
perform a sumif of a value on multiple sheets in a workbook and then
return a sum of those sumifs.
This is how I tried but I get a #NAME? error and don't know where to go
from here.
Public Function Lookup(x As Long) As Long
Dim sh As Worksheet, wb As Workbook, arr() As Variant
Set wb = Workbooks.Open("Purchased.xlsm")
For Each sh In wb
arr() = Application.SumIf(Range("A1:A10000"), x, Range("B1:B10000"))
Next
Lookup = Application.WorksheetFunction.Sum(arr())
End Function
I know Im not doing this properly but I am a VBA beginner and am trying to
perform a sumif of a value on multiple sheets in a workbook and then
return a sum of those sumifs.
This is how I tried but I get a #NAME? error and don't know where to go
from here.
Public Function Lookup(x As Long) As Long
Dim sh As Worksheet, wb As Workbook, arr() As Variant
Set wb = Workbooks.Open("Purchased.xlsm")
For Each sh In wb
arr() = Application.SumIf(Range("A1:A10000"), x, Range("B1:B10000"))
Next
Lookup = Application.WorksheetFunction.Sum(arr())
End Function
Sunday, 15 September 2013
[__NSCFString NSInteger]: unrecognized selector sent to instance
[__NSCFString NSInteger]: unrecognized selector sent to instance
Why I have this error when I'm trying to recover/compare my NSInteger
[__NSCFString subTag]: unrecognized selector sent to instance
This is how I have declared subTag, which is part from an object called
OptionSubView:
@property (nonatomic, assign) NSInteger subTag;
Then, I'm trying to compare this property, and my code crash:
for(OptionSubView *subV in self.optionsSubViews){
if( subV.subTag == segControl.tag){
subViewSelected = subV.tipo;
}
}
Why I have this error when I'm trying to recover/compare my NSInteger
[__NSCFString subTag]: unrecognized selector sent to instance
This is how I have declared subTag, which is part from an object called
OptionSubView:
@property (nonatomic, assign) NSInteger subTag;
Then, I'm trying to compare this property, and my code crash:
for(OptionSubView *subV in self.optionsSubViews){
if( subV.subTag == segControl.tag){
subViewSelected = subV.tipo;
}
}
How to use COSMctrl on QT/C++ application?
How to use COSMctrl on QT/C++ application?
I am fairly new at C++ in regards to GUI programming, for a project I need
to use a Map viewer to draw routes from city to city. My class decided to
use QT for everything related to GUI and Netbeans for code.
I read that the best framework using OpenStreetMaps is COSMctrl. However I
have no idea how to use it. I have used JMapViewer to generate maps in
Java and all it involved was importing the JAR files and adding the map to
a JLabel.
How do I do that in a C++/QT application? I have no idea on how to make my
program recognize COSMctrl and placing the map on a QTLabel for it to be
displayed on my application.
Help would be greatly appreciated.
I am fairly new at C++ in regards to GUI programming, for a project I need
to use a Map viewer to draw routes from city to city. My class decided to
use QT for everything related to GUI and Netbeans for code.
I read that the best framework using OpenStreetMaps is COSMctrl. However I
have no idea how to use it. I have used JMapViewer to generate maps in
Java and all it involved was importing the JAR files and adding the map to
a JLabel.
How do I do that in a C++/QT application? I have no idea on how to make my
program recognize COSMctrl and placing the map on a QTLabel for it to be
displayed on my application.
Help would be greatly appreciated.
Database supporting fast approximate nearest neighbor queries
Database supporting fast approximate nearest neighbor queries
Is there a database that supports fast approximate nearest neighbor
queries in high-dimensional vector spaces?
I'm looking for a database that would fit the following use case:
Works for millions of points
Works for hundreds-thousands of dimensions
Potentially uses cover trees or locality sensitive hashing for indexing
Does a robust implementation of this exist?
Is there a database that supports fast approximate nearest neighbor
queries in high-dimensional vector spaces?
I'm looking for a database that would fit the following use case:
Works for millions of points
Works for hundreds-thousands of dimensions
Potentially uses cover trees or locality sensitive hashing for indexing
Does a robust implementation of this exist?
GLFW with Cygwin - undefined references to GL
GLFW with Cygwin - undefined references to GL
I'm attempting to compile this tutorial
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-1-opening-a-window/
with Cygwin. I'm getting the following errors:
$ g++ main.cpp -o main -lm -lgl -lglut -lglew -lglfw
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(window.o):window.c:(.text+0
x927): undefined reference to `_imp__glClear@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x26d): undefined reference to `_imp__wglMakeCurrent@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x27e): undefined reference to `_imp__wglDeleteContext@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x11a0): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x11c8): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x11f0): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1394): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x150f): undefined reference to `_imp__wglMakeCurrent@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1520): undefined reference to `_imp__wglGetProcAddress@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1661): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1696): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x16d1): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1712): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x17a5): undefined reference to `_imp__wglCreateContext@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1800): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1984): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x19b1): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1a71): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1cb1): undefined reference to `_imp__glGetIntegerv@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1ccc): undefined reference to `_imp__glGetFloatv@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1cd2): undefined reference to `_imp__glClearColor@16'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1d06): undefined reference to `_imp__glClear@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld:
/usr/lib/gc
c/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o): bad reloc
address 0x0
in section `.rdata'
collect2: error: ld returned 1 exit status
What may be causing these errors?
I'm attempting to compile this tutorial
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-1-opening-a-window/
with Cygwin. I'm getting the following errors:
$ g++ main.cpp -o main -lm -lgl -lglut -lglew -lglfw
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(window.o):window.c:(.text+0
x927): undefined reference to `_imp__glClear@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x26d): undefined reference to `_imp__wglMakeCurrent@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x27e): undefined reference to `_imp__wglDeleteContext@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x11a0): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x11c8): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x11f0): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1394): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x150f): undefined reference to `_imp__wglMakeCurrent@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1520): undefined reference to `_imp__wglGetProcAddress@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1661): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1696): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x16d1): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1712): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x17a5): undefined reference to `_imp__wglCreateContext@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1800): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1984): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x19b1): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1a71): undefined reference to `_imp___iob'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1cb1): undefined reference to `_imp__glGetIntegerv@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1ccc): undefined reference to `_imp__glGetFloatv@8'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1cd2): undefined reference to `_imp__glClearColor@16'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o):win32_windo
w.c:(.text+0x1d06): undefined reference to `_imp__glClear@4'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld:
/usr/lib/gc
c/i686-pc-cygwin/4.7.3/../../../libglfw.a(win32_window.o): bad reloc
address 0x0
in section `.rdata'
collect2: error: ld returned 1 exit status
What may be causing these errors?
Get start location of capturing group within regex pattern
Get start location of capturing group within regex pattern
Basically, I want to find the index for the first occurrence of any of the
substrings: "ABC", "DEF", or "GHI", so long as they occur in an interval
of three. The regex that I wrote to match this pattern is:
regex = compile ("(?:[a-zA-Z]{3})*?(ABC|DEF|GHI)")
The *? ensures that I get the first match, since it's non-greedy. I'm
using a capturing group since I assume that that is the only way to
actually get the index (of the substring) that I'm actually looking for. I
don't care where the match itself starts, just where the capturing group
starts. The ...{3}... mandates that the pattern occur in an interval of 3,
ie:
example_1 = "BNDABCDJML"
example_2 = "JKMJABCKME"
example_1 would match since "ABC" occurs at position 3 but example_2 would
not match since "ABC" occurs at position 4.
Ideally, given the string:
text = "STCABCFFC"
this matches, but if I simply get the start of the match, it will give me
0, since that's the beginning index of the match, where what I want is 3
I'd like to do this:
print match(regex, text).group(1).start()
but, of course, this doesn't work, since start() is not a method for
strings, plus the string is now independent of text. I can't simply search
for the starting index of the substring in the capturing group, because
that won't guarantee me that it follows the regex pattern (only occur in
intervals of 3). Perhaps I'm overlooking something, I don't write too much
in python, so forgive me if this is a trivial question.
Basically, I want to find the index for the first occurrence of any of the
substrings: "ABC", "DEF", or "GHI", so long as they occur in an interval
of three. The regex that I wrote to match this pattern is:
regex = compile ("(?:[a-zA-Z]{3})*?(ABC|DEF|GHI)")
The *? ensures that I get the first match, since it's non-greedy. I'm
using a capturing group since I assume that that is the only way to
actually get the index (of the substring) that I'm actually looking for. I
don't care where the match itself starts, just where the capturing group
starts. The ...{3}... mandates that the pattern occur in an interval of 3,
ie:
example_1 = "BNDABCDJML"
example_2 = "JKMJABCKME"
example_1 would match since "ABC" occurs at position 3 but example_2 would
not match since "ABC" occurs at position 4.
Ideally, given the string:
text = "STCABCFFC"
this matches, but if I simply get the start of the match, it will give me
0, since that's the beginning index of the match, where what I want is 3
I'd like to do this:
print match(regex, text).group(1).start()
but, of course, this doesn't work, since start() is not a method for
strings, plus the string is now independent of text. I can't simply search
for the starting index of the substring in the capturing group, because
that won't guarantee me that it follows the regex pattern (only occur in
intervals of 3). Perhaps I'm overlooking something, I don't write too much
in python, so forgive me if this is a trivial question.
GAE self.request.get IMG SRC to passing as a argument to python function
GAE self.request.get IMG SRC to passing as a argument to python function
Is there any way to get a img src so it can be pass aa an argument in GAE?
the images are not in database its in the html, say for eg: in index.html
I have some images & a user clicks on a image the page redirects to
images.html via a onClick js function with that selected image rendering
on images.html, Now to work with that image I need to pass it to my python
function/script?
If it would had been a text field it would be easy, we can get it via the
NAME value,right BUT how to get a image src value In short is there any
thing like self.request.get(IMG_SRC) #not from database but from the html
after post (post from index.html to image.html} ?
Or are there any module or python buildin function that is can be used for
getting the img src & passing it python function as an argument?
Is there any way to get a img src so it can be pass aa an argument in GAE?
the images are not in database its in the html, say for eg: in index.html
I have some images & a user clicks on a image the page redirects to
images.html via a onClick js function with that selected image rendering
on images.html, Now to work with that image I need to pass it to my python
function/script?
If it would had been a text field it would be easy, we can get it via the
NAME value,right BUT how to get a image src value In short is there any
thing like self.request.get(IMG_SRC) #not from database but from the html
after post (post from index.html to image.html} ?
Or are there any module or python buildin function that is can be used for
getting the img src & passing it python function as an argument?
Close filedilaog with truclient
Close filedilaog with truclient
A am using LR 11.52 TruClient for Firefox to record a opening a filedialog
(native) and chosing a file and adding it. Recording With Firefox do not
close the filedialog, but doing the same With IE Works (at least so it
sems). But when I run this script in loadmode/on the Controller With
several users I suspect it to create a memoryleak, because after some time
it starts to fail.
Is there a way to manually say to 'LR 11.52 TruClient for Firefox' that it
must close the browser after adding a file. Maybe java script on the
Object?
My script gets recorded With this action:
Set [path] on [object] filebox with an Object role of filebox.
A am using LR 11.52 TruClient for Firefox to record a opening a filedialog
(native) and chosing a file and adding it. Recording With Firefox do not
close the filedialog, but doing the same With IE Works (at least so it
sems). But when I run this script in loadmode/on the Controller With
several users I suspect it to create a memoryleak, because after some time
it starts to fail.
Is there a way to manually say to 'LR 11.52 TruClient for Firefox' that it
must close the browser after adding a file. Maybe java script on the
Object?
My script gets recorded With this action:
Set [path] on [object] filebox with an Object role of filebox.
Saturday, 14 September 2013
Javascript code for recording the clicks
Javascript code for recording the clicks
I have a set of websites.
In each website there is my Javascript code:
$(document).ready(function(){
$('div').click(function()
{
// Do something
}
});
Then, I want to enable each user (via iFrame) to see the website and
clicks on the banners. I have two problems:
1- How to get the clicks of each user to the database of my own site?
Because javascript is within the pages of other website and I need to
capture each click and send it to my own server for further processing and
DB actions.
2- I ONLY want to capture the clicks of users who see the websites through
my own iframe and not anywhere else.
thanks in advance
I have a set of websites.
In each website there is my Javascript code:
$(document).ready(function(){
$('div').click(function()
{
// Do something
}
});
Then, I want to enable each user (via iFrame) to see the website and
clicks on the banners. I have two problems:
1- How to get the clicks of each user to the database of my own site?
Because javascript is within the pages of other website and I need to
capture each click and send it to my own server for further processing and
DB actions.
2- I ONLY want to capture the clicks of users who see the websites through
my own iframe and not anywhere else.
thanks in advance
Peak Finding algorithm's real time applicatio
Peak Finding algorithm's real time applicatio
can I know the real time application of peak finding algorithm? I had
online class regarding this algorithm even though I could understand the
alogrithm I want to today's application of this algorithm.`
can I know the real time application of peak finding algorithm? I had
online class regarding this algorithm even though I could understand the
alogrithm I want to today's application of this algorithm.`
Trying to make a toggle type button in pygame. Having an issue
Trying to make a toggle type button in pygame. Having an issue
Alright, so the issue here is that upon reviving the click, the first
condition is satisfied, and the variable is set to true. Immediately
after, the event is like... still going on or whatever, and the variable
being false satisfies the second condition, which immediately resets the
variable to true. Any ideas on how to resolve this sort of thing?
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN :
x, y = event.pos
if TutorialOn == True:
if x >= 25 and x <= 175 and y >= 350 and y<= 450:
TutorialOn = False
if TutorialOn == False:
if x >= 25 and x <= 175 and y >= 350 and y<= 450:
TutorialOn = True
Alright, so the issue here is that upon reviving the click, the first
condition is satisfied, and the variable is set to true. Immediately
after, the event is like... still going on or whatever, and the variable
being false satisfies the second condition, which immediately resets the
variable to true. Any ideas on how to resolve this sort of thing?
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN :
x, y = event.pos
if TutorialOn == True:
if x >= 25 and x <= 175 and y >= 350 and y<= 450:
TutorialOn = False
if TutorialOn == False:
if x >= 25 and x <= 175 and y >= 350 and y<= 450:
TutorialOn = True
HTML: Button Bar Semantics - Which Elements Should I Use?
HTML: Button Bar Semantics - Which Elements Should I Use?
I'm building a button bar for rich text editing features on a
contenteditable.
I want to group list items into boxes.
for instance, bold, italic, and underline would share a box,
alignment options would have another, etc..
What's the ideal HTML markup for this scenario?
The <ul> Example:
<ul class="bar">
<div class="group-font">
<li><a class="button-bold">Bold</a></li>
<li><a class="button-italic">Italic</a></li>
<li><a class="button-underline">Underline</a></li>
</div>
<div class="group-align">
<li><a class="button-alignLeft">Left</a></li>
<li><a class="button-alignCenter">Center</a></li>
</div>
</ul>
Can <li>'s validly be indirect descendants (within a div or otherwise) of
their list container, like in the example above?
The <menu> Example:
<menu class="bar">
<div class="group-type">
<a class="button-bold">Bold</a>
<a class="button-italic">Italic</a>
<a class="button-underline">Underline</a>
</div>
<div class="group-align">
<a class="button-alignLeft">Left</a>
<a class="button-alignCenter">Center</a>
</div>
</menu>
What would be considered the most elegant solution?
I'm building a button bar for rich text editing features on a
contenteditable.
I want to group list items into boxes.
for instance, bold, italic, and underline would share a box,
alignment options would have another, etc..
What's the ideal HTML markup for this scenario?
The <ul> Example:
<ul class="bar">
<div class="group-font">
<li><a class="button-bold">Bold</a></li>
<li><a class="button-italic">Italic</a></li>
<li><a class="button-underline">Underline</a></li>
</div>
<div class="group-align">
<li><a class="button-alignLeft">Left</a></li>
<li><a class="button-alignCenter">Center</a></li>
</div>
</ul>
Can <li>'s validly be indirect descendants (within a div or otherwise) of
their list container, like in the example above?
The <menu> Example:
<menu class="bar">
<div class="group-type">
<a class="button-bold">Bold</a>
<a class="button-italic">Italic</a>
<a class="button-underline">Underline</a>
</div>
<div class="group-align">
<a class="button-alignLeft">Left</a>
<a class="button-alignCenter">Center</a>
</div>
</menu>
What would be considered the most elegant solution?
Transcluding Attributes in an Angular Directive
Transcluding Attributes in an Angular Directive
I was creating a select replacement directive to make it easy to style up
selects according to the design without having to always right a bunch of
markup (i.e. the directive does it for you!).
I didn't realize that attributes don't transclude to where you put
ng-transclude and just go to the root element.
I have an example here: http://plnkr.co/edit/OLLntqMzbGCJS7g7h1j4?p=preview
You can see that it looks great... but there's one major flaw. The id and
name attributes aren't being transferred. Which, ya know, without name, it
doesn't post to the server (this form ties into an existing system, so
AJAXing the model isn't an option).
For example, this is what I start with:
<select class="my-select irrelevant-class" name="reason" id="reason"
data-anything="banana">
<option value="">Reason for Contact...</option>
<option>Banana</option>
<option>Pizza</option>
<option>The good stuff</option>
<option>This is an example of a really, really, really, really,
really, really long option item</option>
</select>
...this is what I want it to look like:
<div class="faux-select" ng-class="{ placeholder: default == viewVal,
focus: obj.focus }">
<span class="faux-value">{{viewVal}}</span>
<span class="icon-arrow-down"></span>
<select ng-model="val" ng-focus="obj.focus = true" ng-blur="obj.focus
= false" ng-transclude class="my-select irrelevant-class"
name="reason" id="reason" data-anything="banana">
<option value="">Reason for Contact...</option>
<option>Banana</option>
<option>Pizza</option>
<option>The good stuff</option>
<option>This is an example of a really, really, really, really,
really, really long option item</option>
</select>
</div>
...but this is what actually happens:
<div class="faux-select my-select" ng-class="{ placeholder: default ==
viewVal, focus: obj.focus }" name="reason" id="reason"
data-anything="banana">
<span class="faux-value">{{viewVal}}</span>
<span class="icon-arrow-down"></span>
<select ng-model="val" ng-focus="obj.focus = true" ng-blur="obj.focus
= false" ng-transclude>
<option value="">Reason for Contact...</option>
<option>Banana</option>
<option>Pizza</option>
<option>The good stuff</option>
<option>This is an example of a really, really, really, really,
really, really long option item</option>
</select>
</div>
Specifically, the issue is that there's no name attribute on the select,
so it doesn't actually send the data to the server.
Obviously, I can use a pre-compile phase to transfer the name and id
attributes (that's what I am doing for now), but it would be nice if it
would just automatically transfer all of the attributes so they can add
any classes, arbitrary data, (ng-)required, (ng-)disabled attributes, etc,
etc.
I tried getting transclude: 'element' to work, but then I couldn't the
other attributes from the template onto it.
Note, I saw the post here: How can I transclude into an attribute?, but it
looks like they just manually transfer the data, and I am aiming to get it
to auto-transfer all the attributes.
I was creating a select replacement directive to make it easy to style up
selects according to the design without having to always right a bunch of
markup (i.e. the directive does it for you!).
I didn't realize that attributes don't transclude to where you put
ng-transclude and just go to the root element.
I have an example here: http://plnkr.co/edit/OLLntqMzbGCJS7g7h1j4?p=preview
You can see that it looks great... but there's one major flaw. The id and
name attributes aren't being transferred. Which, ya know, without name, it
doesn't post to the server (this form ties into an existing system, so
AJAXing the model isn't an option).
For example, this is what I start with:
<select class="my-select irrelevant-class" name="reason" id="reason"
data-anything="banana">
<option value="">Reason for Contact...</option>
<option>Banana</option>
<option>Pizza</option>
<option>The good stuff</option>
<option>This is an example of a really, really, really, really,
really, really long option item</option>
</select>
...this is what I want it to look like:
<div class="faux-select" ng-class="{ placeholder: default == viewVal,
focus: obj.focus }">
<span class="faux-value">{{viewVal}}</span>
<span class="icon-arrow-down"></span>
<select ng-model="val" ng-focus="obj.focus = true" ng-blur="obj.focus
= false" ng-transclude class="my-select irrelevant-class"
name="reason" id="reason" data-anything="banana">
<option value="">Reason for Contact...</option>
<option>Banana</option>
<option>Pizza</option>
<option>The good stuff</option>
<option>This is an example of a really, really, really, really,
really, really long option item</option>
</select>
</div>
...but this is what actually happens:
<div class="faux-select my-select" ng-class="{ placeholder: default ==
viewVal, focus: obj.focus }" name="reason" id="reason"
data-anything="banana">
<span class="faux-value">{{viewVal}}</span>
<span class="icon-arrow-down"></span>
<select ng-model="val" ng-focus="obj.focus = true" ng-blur="obj.focus
= false" ng-transclude>
<option value="">Reason for Contact...</option>
<option>Banana</option>
<option>Pizza</option>
<option>The good stuff</option>
<option>This is an example of a really, really, really, really,
really, really long option item</option>
</select>
</div>
Specifically, the issue is that there's no name attribute on the select,
so it doesn't actually send the data to the server.
Obviously, I can use a pre-compile phase to transfer the name and id
attributes (that's what I am doing for now), but it would be nice if it
would just automatically transfer all of the attributes so they can add
any classes, arbitrary data, (ng-)required, (ng-)disabled attributes, etc,
etc.
I tried getting transclude: 'element' to work, but then I couldn't the
other attributes from the template onto it.
Note, I saw the post here: How can I transclude into an attribute?, but it
looks like they just manually transfer the data, and I am aiming to get it
to auto-transfer all the attributes.
In there a inherit value for the contenteditable attribute?
In there a inherit value for the contenteditable attribute?
As per
HTML-5
The values are "empty string", "true" and "false". There is no "inherit"
value. If the attribute is not set, than it inherits from the parent
element. "inherit" is a state since it is a Enumerated Attribute.
html5-contenteditable-valid-values
What happens when you travel upwards in the DOM and find no
Parent/Ancestor Element with the attribute set till the root html element?
As per
HTML-5
The values are "empty string", "true" and "false". There is no "inherit"
value. If the attribute is not set, than it inherits from the parent
element. "inherit" is a state since it is a Enumerated Attribute.
html5-contenteditable-valid-values
What happens when you travel upwards in the DOM and find no
Parent/Ancestor Element with the attribute set till the root html element?
getting the folder path of the last location i right clicked
getting the folder path of the last location i right clicked
i created a right click shortcut (in windows right click menu) for my
application, and i want to get the folder path of the right clicked
location how do i do it?
my code to create a shortcut :
RegistryKey rKey =
Registry.ClassesRoot.OpenSubKey("Directory\Background\shell", true);
String[] names = rKey.GetSubKeyNames(); foreach (String s in names) {
System.Windows.Forms.MessageBox.Show(s); } RegistryKey newKey =
rKey.CreateSubKey("Create HTML Folder"); RegistryKey newSubKey =
newKey.CreateSubKey("command"); newSubKey.SetValue("",
"C:\Users\Aviv\Desktop\basicFileCreator.exe " + "\"" + "%1" + "\"");
newSubKey.Close(); newKey.Close(); rKey.Close();
i created a right click shortcut (in windows right click menu) for my
application, and i want to get the folder path of the right clicked
location how do i do it?
my code to create a shortcut :
RegistryKey rKey =
Registry.ClassesRoot.OpenSubKey("Directory\Background\shell", true);
String[] names = rKey.GetSubKeyNames(); foreach (String s in names) {
System.Windows.Forms.MessageBox.Show(s); } RegistryKey newKey =
rKey.CreateSubKey("Create HTML Folder"); RegistryKey newSubKey =
newKey.CreateSubKey("command"); newSubKey.SetValue("",
"C:\Users\Aviv\Desktop\basicFileCreator.exe " + "\"" + "%1" + "\"");
newSubKey.Close(); newKey.Close(); rKey.Close();
How to implement linphone in blackberry?
How to implement linphone in blackberry?
I am using blackberry plugin for eclipse and bold 9900 simulator, i am
trying to implement VOIP, and i came across linphone but unable to
download source code for linphone? Need help how to implement linphone in
blackberry and where to download source code for the same?
I am using blackberry plugin for eclipse and bold 9900 simulator, i am
trying to implement VOIP, and i came across linphone but unable to
download source code for linphone? Need help how to implement linphone in
blackberry and where to download source code for the same?
Friday, 13 September 2013
Django Form Primary Key on save() method - getting NoneType traceback
Django Form Primary Key on save() method - getting NoneType traceback
I was using the q&a at Get Primary Key after Saving a ModelForm in Django.
It's exactly on point with what I need to do.
I have the following view:
def meeting_event(request):
if request.method == 'POST':
form = meetingEventForm(request.POST)
if form.is_valid():
new_agenda=form.save()
return HttpResponseRedirect(reverse('agenda_detail',
args=(new_agenda.pk,)))
else:
form = meetingEventForm()
return render_to_response('agendas/event.html',{'form':form,},
context_instance=RequestContext(request))
I've confirmed that this makes it into the database cleanly. However, I
get the following error:
Traceback:
File
"/usr/lib/python2.6/site-packages/Django-1.5.2-py2.6.egg/django/core/handlers/base.py"
in get_response
115. response = callback(request,
*callback_args, **callback_kwargs)
File
"/usr/lib/python2.6/site-packages/Django-1.5.2-py2.6.egg/django/contrib/auth/decorators.py"
in _wrapped_view
25. return view_func(request, *args, **kwargs)
File "/var/www/html/tamtools/agendas/views.py" in meeting_event
44. return HttpResponseRedirect(reverse('agenda_detail',
args=(new_agenda.pk,)))
Exception Type: AttributeError at /agendas/add/
Exception Value: 'NoneType' object has no attribute 'pk'
Has something changed in Django 1.5 that I don't know about? new_agenda
should be a meetingEventForm type, shouldn't it?
I was using the q&a at Get Primary Key after Saving a ModelForm in Django.
It's exactly on point with what I need to do.
I have the following view:
def meeting_event(request):
if request.method == 'POST':
form = meetingEventForm(request.POST)
if form.is_valid():
new_agenda=form.save()
return HttpResponseRedirect(reverse('agenda_detail',
args=(new_agenda.pk,)))
else:
form = meetingEventForm()
return render_to_response('agendas/event.html',{'form':form,},
context_instance=RequestContext(request))
I've confirmed that this makes it into the database cleanly. However, I
get the following error:
Traceback:
File
"/usr/lib/python2.6/site-packages/Django-1.5.2-py2.6.egg/django/core/handlers/base.py"
in get_response
115. response = callback(request,
*callback_args, **callback_kwargs)
File
"/usr/lib/python2.6/site-packages/Django-1.5.2-py2.6.egg/django/contrib/auth/decorators.py"
in _wrapped_view
25. return view_func(request, *args, **kwargs)
File "/var/www/html/tamtools/agendas/views.py" in meeting_event
44. return HttpResponseRedirect(reverse('agenda_detail',
args=(new_agenda.pk,)))
Exception Type: AttributeError at /agendas/add/
Exception Value: 'NoneType' object has no attribute 'pk'
Has something changed in Django 1.5 that I don't know about? new_agenda
should be a meetingEventForm type, shouldn't it?
site show empty space on website (ipad/mobile)
site show empty space on website (ipad/mobile)
i have a site (beta.risingsunjeans.com) which is currently using
Foundation, on screen size looks perfect but in a another resolution
(ipad/iphone/mobile) the content looks perfect except that i get a huge
empty space on the right sice, i'm already using the right tags on the
header
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
i have a site (beta.risingsunjeans.com) which is currently using
Foundation, on screen size looks perfect but in a another resolution
(ipad/iphone/mobile) the content looks perfect except that i get a huge
empty space on the right sice, i'm already using the right tags on the
header
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
cferror without exception variables
cferror without exception variables
I have an issue where cferror is triggered, but there are no exception
variables (the error struct that cferror should return does not exists).
I've dumped the variables scope, and it's empty. The error handler isn't
the problem because the exception variable is populated when other errors
occur. Something on the website is triggering cferror but it does not
populate the exception variables. How can I track this down?
I am aware that one should instead use the onError method. However, this
particular site still uses Application.cfm, and the decision to convert to
Application.cfc is out of my hands.
I have an issue where cferror is triggered, but there are no exception
variables (the error struct that cferror should return does not exists).
I've dumped the variables scope, and it's empty. The error handler isn't
the problem because the exception variable is populated when other errors
occur. Something on the website is triggering cferror but it does not
populate the exception variables. How can I track this down?
I am aware that one should instead use the onError method. However, this
particular site still uses Application.cfm, and the decision to convert to
Application.cfc is out of my hands.
set up a alert reminder on a specific time
set up a alert reminder on a specific time
from: me <me@foo.com> via zohocrm.com
to: you@bar.com
date: Wed, Sep 4, 2013 at 1:38 PM
subject: AAA
mailed-by: zohocrm.com
:Important mainly because of the people in the conversation.
how to send an email with a via similar to zohocrm? i'm trying to create
an email function for my users but i don't know how to allow them to send
an email from my website then send it with a via note on the detail status
from: me <me@foo.com> via zohocrm.com
to: you@bar.com
date: Wed, Sep 4, 2013 at 1:38 PM
subject: AAA
mailed-by: zohocrm.com
:Important mainly because of the people in the conversation.
how to send an email with a via similar to zohocrm? i'm trying to create
an email function for my users but i don't know how to allow them to send
an email from my website then send it with a via note on the detail status
Workflow not working when Item is added by TimerJob in SharePoint 2010 List
Workflow not working when Item is added by TimerJob in SharePoint 2010 List
Hi,
I've created a Timer Job which will add an item to a list every 10
minutes. I've also configured a workflow to send one email as soon item is
added. This workflow is working fine if I'm adding entry manually. If
entry is added by TimerJob then workflow isn't working. Can anyone guide
me?
Regards, Vikrant
Hi,
I've created a Timer Job which will add an item to a list every 10
minutes. I've also configured a workflow to send one email as soon item is
added. This workflow is working fine if I'm adding entry manually. If
entry is added by TimerJob then workflow isn't working. Can anyone guide
me?
Regards, Vikrant
Thursday, 12 September 2013
How to upload large file using TFTP (Trivial File Transfer Protocol) in android
How to upload large file using TFTP (Trivial File Transfer Protocol) in
android
I know TFTP (Trivial File Transfer Protocol) can be used to upload small
file,
But now, I want to upload the large file to server,
Please tell me how,
Thanks,
android
I know TFTP (Trivial File Transfer Protocol) can be used to upload small
file,
But now, I want to upload the large file to server,
Please tell me how,
Thanks,
BizTalk Server Development - Doing it the Biztalk way
BizTalk Server Development - Doing it the Biztalk way
I recently had an integration project with a very short timeline. It's a
requirement that we use Biztalk where all the integration related
processes are centralized.
My project requires that I use a job queue pattern where an order coming
from the procurement system may result into multiple tasks which must be
executed in order. This becomes more complex as more tasks are created for
that order on certain events later in time.
Writing a framework for this which can be reusable, easy to maintain, and
pluggable for later use with new customers, target system, and
transactions can't be handled in BizTalk. I instead opted for pure C# +
EF4.1 approach, where the job creation and execution is initiated from
Biztalk.
Basically, we have reduced BizTalk to take the role of Windows Service.
Is this bad design? Is this a poor approach? My heart says it is, but with
the constraints I'm faced with this is the best approach available.
However, ultimately, we are building software solutions to address
problems. Even if it means not following the norm.
What are your thoughts?
I recently had an integration project with a very short timeline. It's a
requirement that we use Biztalk where all the integration related
processes are centralized.
My project requires that I use a job queue pattern where an order coming
from the procurement system may result into multiple tasks which must be
executed in order. This becomes more complex as more tasks are created for
that order on certain events later in time.
Writing a framework for this which can be reusable, easy to maintain, and
pluggable for later use with new customers, target system, and
transactions can't be handled in BizTalk. I instead opted for pure C# +
EF4.1 approach, where the job creation and execution is initiated from
Biztalk.
Basically, we have reduced BizTalk to take the role of Windows Service.
Is this bad design? Is this a poor approach? My heart says it is, but with
the constraints I'm faced with this is the best approach available.
However, ultimately, we are building software solutions to address
problems. Even if it means not following the norm.
What are your thoughts?
Why is the running time of two instances on two cores larger than one instance only?
Why is the running time of two instances on two cores larger than one
instance only?
I am facing a "maybe" strange problem. Let's say I have an executable.
When I run it on a computer with two cores, the process runs over a time
t1. Then, if I run two instances of the process (the same executable but
on different directories, launched either manually or by using gnu
parallel), the running time for each process is not close to t1 but
actually larger, sometimes close to 1.9t1. I must note that the two cores
are physical (macbook pro mid 2009, Mountain Lion). I have also tested
this behaviour on a linux machine with 8 cores. If I run 1, 2, 3, and 4
instances, the running time per instance is about t1. But, after 5, 6, 7,
and 8 instances, the running time per instance is increasingly larger than
t1.
I have detected this behaviour when running a simulation. I was able to
reduce the test case to the simple test presented below. I wanted to check
std::vector, std::array, static and dynamic arrays, at several compilation
levels. The test code is the following:
#include <iostream>
#include <vector>
#include <array>
#include <cstdlib>
struct Particle {
private:
int nc;
public:
void reset(void) { nc = 0; };
void set(const int & val) { nc = val; };
};
#define N 10000 // number of particles
#define M 200000 // number of steps
#define STDVECTOR 0
#define STDARRAY 0
#define ARRAY 1
#define DYNARRAY 0
int main (void)
{
#if STDVECTOR
std::vector<Particle> particles(N);
#elif STDARRAY
std::array<Particle, N> particles;
#elif ARRAY
Particle particles[N];
#elif DYNARRAY
Particle *particles; particles = new Particle [N];
instance only?
I am facing a "maybe" strange problem. Let's say I have an executable.
When I run it on a computer with two cores, the process runs over a time
t1. Then, if I run two instances of the process (the same executable but
on different directories, launched either manually or by using gnu
parallel), the running time for each process is not close to t1 but
actually larger, sometimes close to 1.9t1. I must note that the two cores
are physical (macbook pro mid 2009, Mountain Lion). I have also tested
this behaviour on a linux machine with 8 cores. If I run 1, 2, 3, and 4
instances, the running time per instance is about t1. But, after 5, 6, 7,
and 8 instances, the running time per instance is increasingly larger than
t1.
I have detected this behaviour when running a simulation. I was able to
reduce the test case to the simple test presented below. I wanted to check
std::vector, std::array, static and dynamic arrays, at several compilation
levels. The test code is the following:
#include <iostream>
#include <vector>
#include <array>
#include <cstdlib>
struct Particle {
private:
int nc;
public:
void reset(void) { nc = 0; };
void set(const int & val) { nc = val; };
};
#define N 10000 // number of particles
#define M 200000 // number of steps
#define STDVECTOR 0
#define STDARRAY 0
#define ARRAY 1
#define DYNARRAY 0
int main (void)
{
#if STDVECTOR
std::vector<Particle> particles(N);
#elif STDARRAY
std::array<Particle, N> particles;
#elif ARRAY
Particle particles[N];
#elif DYNARRAY
Particle *particles; particles = new Particle [N];
Problems With or Alternative To Unidirectional has_and_belongs_to_many association
Problems With or Alternative To Unidirectional has_and_belongs_to_many
association
I have two components to my application, for the most part, data
entry/tracking and data reporting.
I have a basic data tracking object, let's call it Meter:
class Meter < ActiveRecord::Base
has_many :activity_records
end
I have a collection of different reporting objects, like tabular reports,
charts, widgets, etc. All of these objects, per user configuration, refer
to a collection of Meters as data sources.
I model this relationship as has_and_belongs_to_many, through a join
table: a Widget has many Meters; Meters can be referenced by many Widgets.
class Widget < ActiveRecord::Base
has_and_belongs_to_many :meters
end
Now, I don't think Meters actually need to know which reporting objects
reference them. A Meter should be able to exist blithely, collecting data
and (through a Service object) responding to data requests. I should
never, ever, refer to @meter.widgets.
So, do I need, in the Meter model, to declare half a dozen different habtm
relationships for all the different reporting objects?
Concrete Questions:
1. Are there unintended consequences from omitting the habtm declaration
on Meters?
2. Is there a better way to design this relationship?
With regard to the second question, I have played with the concept of a
MeterSet but found it a bit over-engineered:
class Widget < ActiveRecord::Base
has_one :meter_set, as: :requester
has_many :meters, through: :meter_set
end
class MeterSet < ActiveRecord::Base
belongs_to :requester, polymorphic: true
has_and_belongs_to_many :meters
end
I've moved the location of the join from one model to another... and I
suppose I've reduced the number of tables in my application, overall?
association
I have two components to my application, for the most part, data
entry/tracking and data reporting.
I have a basic data tracking object, let's call it Meter:
class Meter < ActiveRecord::Base
has_many :activity_records
end
I have a collection of different reporting objects, like tabular reports,
charts, widgets, etc. All of these objects, per user configuration, refer
to a collection of Meters as data sources.
I model this relationship as has_and_belongs_to_many, through a join
table: a Widget has many Meters; Meters can be referenced by many Widgets.
class Widget < ActiveRecord::Base
has_and_belongs_to_many :meters
end
Now, I don't think Meters actually need to know which reporting objects
reference them. A Meter should be able to exist blithely, collecting data
and (through a Service object) responding to data requests. I should
never, ever, refer to @meter.widgets.
So, do I need, in the Meter model, to declare half a dozen different habtm
relationships for all the different reporting objects?
Concrete Questions:
1. Are there unintended consequences from omitting the habtm declaration
on Meters?
2. Is there a better way to design this relationship?
With regard to the second question, I have played with the concept of a
MeterSet but found it a bit over-engineered:
class Widget < ActiveRecord::Base
has_one :meter_set, as: :requester
has_many :meters, through: :meter_set
end
class MeterSet < ActiveRecord::Base
belongs_to :requester, polymorphic: true
has_and_belongs_to_many :meters
end
I've moved the location of the join from one model to another... and I
suppose I've reduced the number of tables in my application, overall?
Post-commit hook failed (exit code 3) with output
Post-commit hook failed (exit code 3) with output
I'm trying to call a Jenkins job remotely using a post-commit script. I'm
currently committing code through Eclipse Kepler/Subversive/SVNKit
Connector.
post-commit script:
if svnlook dirs-changed -r "$REV" "$REPOS" | grep -qEe '^trunk/'; then
wget
--post-data="job=APS-RemoteServerAction&token=SECRET&ACTION=deploy&ASSET_NAME=POST-COMMIT-TEST&DEPLOY_ENV=DEV&REVISION=$REV"
"http://my.domain.com:8080/buildByToken/buildWithParameters"
fi
Screenshot of error through Eclipse:
Important notes:
Code does get committed properly, repository browser indicates a new version
The job runs on Jenkins, the history shows that
Everytime I commit, I get this error message
I tried adding the flag --quiet, but I got the same exit code.
I'm thinking it's due to wget and posting the values?
Edit #1
I would like to point out that I'm using the Jenkins Build Authorization
Token Root Plugin. I switched to a POST instead of a GET (which works) due
to eventually moving onto https and keeping the token out of the URL.
I'm trying to call a Jenkins job remotely using a post-commit script. I'm
currently committing code through Eclipse Kepler/Subversive/SVNKit
Connector.
post-commit script:
if svnlook dirs-changed -r "$REV" "$REPOS" | grep -qEe '^trunk/'; then
wget
--post-data="job=APS-RemoteServerAction&token=SECRET&ACTION=deploy&ASSET_NAME=POST-COMMIT-TEST&DEPLOY_ENV=DEV&REVISION=$REV"
"http://my.domain.com:8080/buildByToken/buildWithParameters"
fi
Screenshot of error through Eclipse:
Important notes:
Code does get committed properly, repository browser indicates a new version
The job runs on Jenkins, the history shows that
Everytime I commit, I get this error message
I tried adding the flag --quiet, but I got the same exit code.
I'm thinking it's due to wget and posting the values?
Edit #1
I would like to point out that I'm using the Jenkins Build Authorization
Token Root Plugin. I switched to a POST instead of a GET (which works) due
to eventually moving onto https and keeping the token out of the URL.
why my class can not be found?
why my class can not be found?
Doing some php and the root directory looks like this:
web/
-index.php
src/
-Controllers/
-IndexController.php
-Services/
-IpService.php
class IpService has namespace Service i added this namespace to autoload:
"autoload": {
"psr-0": {
"Service\\": "src/"
}
}
and in the IndexController.php im doing this:
use Services\IpService;
$app['ip_service'] = function () {
return new IpService();
};
but when i call $app['ip_service']->get() i'm getting the error:
Fatal error: Class 'Services\IpService' not found in
E:\xampp\htdocs\src\Controllers\IndexController.php on line 18
Doing some php and the root directory looks like this:
web/
-index.php
src/
-Controllers/
-IndexController.php
-Services/
-IpService.php
class IpService has namespace Service i added this namespace to autoload:
"autoload": {
"psr-0": {
"Service\\": "src/"
}
}
and in the IndexController.php im doing this:
use Services\IpService;
$app['ip_service'] = function () {
return new IpService();
};
but when i call $app['ip_service']->get() i'm getting the error:
Fatal error: Class 'Services\IpService' not found in
E:\xampp\htdocs\src\Controllers\IndexController.php on line 18
protecting attributes using state_machine
protecting attributes using state_machine
I'm trying to protect updates to certain attributes using state_machine
but I can't seem to get it to work correctly.
I want to LOCK updates on certain attributes when the state is completed
But instead of firing on STATE completed it fires during the transition to
completed as well... meaning before the state has finished, preventing the
state entirely!
eg
## BLOCK CHANGES MADE IN COMPLETED OR FAILED STATE
validate :lock_down_attributes_when_published, :if => Proc.new { |log|
log.state?(:completed) }
or
validate :lock_down_attributes_when_published, :if => Proc.new { |log|
log.completed? }
with
private
def lock_down_attributes_when_published
return unless completed?
message = "must not change when #{state}"
errors.add(:head_count, message) if head_count_changed?
errors.add(:quiz_master_id, message) if quiz_master_id_changed?
errors.add(:qm_fee, message) if qm_fee_pennies_changed?
errors.add(:total_fee, message) if total_fee_pennies_changed?
end
It's
I'm trying to protect updates to certain attributes using state_machine
but I can't seem to get it to work correctly.
I want to LOCK updates on certain attributes when the state is completed
But instead of firing on STATE completed it fires during the transition to
completed as well... meaning before the state has finished, preventing the
state entirely!
eg
## BLOCK CHANGES MADE IN COMPLETED OR FAILED STATE
validate :lock_down_attributes_when_published, :if => Proc.new { |log|
log.state?(:completed) }
or
validate :lock_down_attributes_when_published, :if => Proc.new { |log|
log.completed? }
with
private
def lock_down_attributes_when_published
return unless completed?
message = "must not change when #{state}"
errors.add(:head_count, message) if head_count_changed?
errors.add(:quiz_master_id, message) if quiz_master_id_changed?
errors.add(:qm_fee, message) if qm_fee_pennies_changed?
errors.add(:total_fee, message) if total_fee_pennies_changed?
end
It's
XSLT: How to exclude only a few empty tags from the output?
XSLT: How to exclude only a few empty tags from the output?
I need to ensure that the empty tags (except the mandatory fields)be
excluded from the output. The mandatory fields should be in the output
even if they are empty
Using the following xslt, I am able to exclude the empty tags. But even
the mandatory fields, if they are empty are removed from the output.
Please advise.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match= "*[not(@*|*|comment()|processing-instruction()) and
normalizespace()='']"/>
</xsl:stylesheet>
I need to ensure that the empty tags (except the mandatory fields)be
excluded from the output. The mandatory fields should be in the output
even if they are empty
Using the following xslt, I am able to exclude the empty tags. But even
the mandatory fields, if they are empty are removed from the output.
Please advise.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match= "*[not(@*|*|comment()|processing-instruction()) and
normalizespace()='']"/>
</xsl:stylesheet>
Get value element same level?
Get value element same level?
I have a code:
<table>
<tr>
<td>
<input type="text" value="1" />
<input id="button" type="button" value="Click me!" />
</td>
</tr>
</table>
I want to get value of input[type="text"] by below code but It doesn't
work, please help me
<script type="text/javascript">
$(document).ready(function() {
$("#button").bind("click", function() {
alert($(this).siblings().find('input[type="hidden"]').val(););
});
});
</script>
I have a code:
<table>
<tr>
<td>
<input type="text" value="1" />
<input id="button" type="button" value="Click me!" />
</td>
</tr>
</table>
I want to get value of input[type="text"] by below code but It doesn't
work, please help me
<script type="text/javascript">
$(document).ready(function() {
$("#button").bind("click", function() {
alert($(this).siblings().find('input[type="hidden"]').val(););
});
});
</script>
Wednesday, 11 September 2013
How to create apk file in command line?
How to create apk file in command line?
I was using eclipse ide to build apk file . Now i want to create apk file
in command line in linux. But when i say ant debug it gives following
error :
failed to create task or checkenv
Cause : The name is undefined ....
I have ant version 1.9.2 . and android version 17. I have build.xml file .
I was using eclipse ide to build apk file . Now i want to create apk file
in command line in linux. But when i say ant debug it gives following
error :
failed to create task or checkenv
Cause : The name is undefined ....
I have ant version 1.9.2 . and android version 17. I have build.xml file .
Download .jar File From URL Using Java
Download .jar File From URL Using Java
I have integrated an update system into my Java program, and the one thing
that is missing is a way to download a jar file from a URL using Java. How
can one go about doing this? I would like the file to replace the existing
one. I have no idea how to do this.
I have integrated an update system into my Java program, and the one thing
that is missing is a way to download a jar file from a URL using Java. How
can one go about doing this? I would like the file to replace the existing
one. I have no idea how to do this.
Sort an ArrayList of semicolon separated values by a field
Sort an ArrayList of semicolon separated values by a field
I have an ArrayList of semicolon separated values that needs to be sorted
by the second field of each of the ArrayList elements.
Each of the elements of the array list have the form:
field1;field2;field3;field4
and need to be sorted by field.2 Is there a way to do this without having
to create a temporary array, switch field1 and field2, sort that array,
and then switch field1 and field2 again?
Thank you for any help you might be able to offer
I have an ArrayList of semicolon separated values that needs to be sorted
by the second field of each of the ArrayList elements.
Each of the elements of the array list have the form:
field1;field2;field3;field4
and need to be sorted by field.2 Is there a way to do this without having
to create a temporary array, switch field1 and field2, sort that array,
and then switch field1 and field2 again?
Thank you for any help you might be able to offer
Shell Script with environment variable
Shell Script with environment variable
I have a C program that has the following code at the end:
memcpy(buff,"TEST=",4)
putenv(buff)
system("/bin/bash")
I put a new environment variable in a new shell. I want to then echo test
into a text file which i can easily do. I then want to exit the shell and
run it again so running this would look as follows
./cprog "some arg"
echo $TEST > test.txt
exit
./cprog "some arg"
echo $TEST > test.txt
exit
I have to keep exiting so I can change the TEST variable. How could I make
this work in a shell script so i could just keep looping and running the c
program so I could change the argument but never exiting the shell script
itself.
I have a C program that has the following code at the end:
memcpy(buff,"TEST=",4)
putenv(buff)
system("/bin/bash")
I put a new environment variable in a new shell. I want to then echo test
into a text file which i can easily do. I then want to exit the shell and
run it again so running this would look as follows
./cprog "some arg"
echo $TEST > test.txt
exit
./cprog "some arg"
echo $TEST > test.txt
exit
I have to keep exiting so I can change the TEST variable. How could I make
this work in a shell script so i could just keep looping and running the c
program so I could change the argument but never exiting the shell script
itself.
How to query many-to-many relationship with 'AND' condition using LINQ and Entity Framework
How to query many-to-many relationship with 'AND' condition using LINQ and
Entity Framework
My current database solution includes three tables called Establishment,
Feature, and a linking many-to-many table called EstablishmentFeature
(since an establishment can have many features, and a feature can exists
across multiple establishments).
I need to generate a query that returns establishments that meet only
certain criteria, namely, which establishments have X features based on a
collection of featureId's being passed in. The establishment must have ALL
features that are being search, i.e.. AND not OR condition.
I got the SQL to achieve the desired result, but I am pulling my hair out
trying to work out the LINQ (lambra prefereably) equivalent. The T-SQL is:
SELECT e.[EstablishmentId], e.[Name], e.[Description]
FROM Establishment e
INNER JOIN EstablishmentFeature ef
ON e.[EstablishmentId] = ef.[EstablishmentId]
WHERE ef.[FeatureId] in ('20', '15', '72')
GROUP BY e.[EstablishmentId], e.[Name], e.[Description]
HAVING COUNT(*) = 3
I tried to use Linqer to convert the SQL but Linqer crashes when it
attempts the conversion. I tried reinstalling Linqer, but it crashes
without fail when trying to compile the LINQ syntax. (Simpler conversions
work though). Also tried to work out the LINQ equivalent using LinqPad,
but I just ended up chasing my tail...
Is this something I will have to use PredicateBuilder for? Somewhat
exhausted, I don't want to go through the PredicateBuilder learning curve
if there is a simple solution that is escaping me.
Entity Framework
My current database solution includes three tables called Establishment,
Feature, and a linking many-to-many table called EstablishmentFeature
(since an establishment can have many features, and a feature can exists
across multiple establishments).
I need to generate a query that returns establishments that meet only
certain criteria, namely, which establishments have X features based on a
collection of featureId's being passed in. The establishment must have ALL
features that are being search, i.e.. AND not OR condition.
I got the SQL to achieve the desired result, but I am pulling my hair out
trying to work out the LINQ (lambra prefereably) equivalent. The T-SQL is:
SELECT e.[EstablishmentId], e.[Name], e.[Description]
FROM Establishment e
INNER JOIN EstablishmentFeature ef
ON e.[EstablishmentId] = ef.[EstablishmentId]
WHERE ef.[FeatureId] in ('20', '15', '72')
GROUP BY e.[EstablishmentId], e.[Name], e.[Description]
HAVING COUNT(*) = 3
I tried to use Linqer to convert the SQL but Linqer crashes when it
attempts the conversion. I tried reinstalling Linqer, but it crashes
without fail when trying to compile the LINQ syntax. (Simpler conversions
work though). Also tried to work out the LINQ equivalent using LinqPad,
but I just ended up chasing my tail...
Is this something I will have to use PredicateBuilder for? Somewhat
exhausted, I don't want to go through the PredicateBuilder learning curve
if there is a simple solution that is escaping me.
Hidden For a View Model attribute - getting changed property EF
Hidden For a View Model attribute - getting changed property EF
I need to know if 2 attributes have been changed, in order to do some
stuff. I think there should be 2 approaches, but I can't figure it out.
I created a ViewModel with an attribute for the old value. In my view:
@{DateTime date =
Convert.ToDateTime(Model.event.fromDate.ToShortDateString());}
@Html.HiddenFor(m => m.previousDate, new { @Value = date })
@Html.TextBoxFor(model =>
model.event.fromDate,"{0:dd/MM/yyyy}",new{@class="date"})
In the view Model:
....
public Event event {get; set;}
public DateTime previousDate {get; set;}
And my Event class:
....
DateTime fromDate { get; set; }
When I post the view, the "previousDate" attribute of the ViewModel comes
with default time '01/01/1901', and not the one that I set.
I think other approach could be to get changed properties from entity
framework, but I haven't been able to do it either.
I need to know if 2 attributes have been changed, in order to do some
stuff. I think there should be 2 approaches, but I can't figure it out.
I created a ViewModel with an attribute for the old value. In my view:
@{DateTime date =
Convert.ToDateTime(Model.event.fromDate.ToShortDateString());}
@Html.HiddenFor(m => m.previousDate, new { @Value = date })
@Html.TextBoxFor(model =>
model.event.fromDate,"{0:dd/MM/yyyy}",new{@class="date"})
In the view Model:
....
public Event event {get; set;}
public DateTime previousDate {get; set;}
And my Event class:
....
DateTime fromDate { get; set; }
When I post the view, the "previousDate" attribute of the ViewModel comes
with default time '01/01/1901', and not the one that I set.
I think other approach could be to get changed properties from entity
framework, but I haven't been able to do it either.
sql different name but same value
sql different name but same value
I am having value like this
ID | Value
—- ——–
1000 1
1000 2
1000 3
1001 2
1001 3
1001 4
1001 5
I want the output like this
1000 | 1
1000 | 1
1000 | 1
1001 | 2
1001 | 2
1001 | 2
1001 | 2
Please Help..
I am having value like this
ID | Value
—- ——–
1000 1
1000 2
1000 3
1001 2
1001 3
1001 4
1001 5
I want the output like this
1000 | 1
1000 | 1
1000 | 1
1001 | 2
1001 | 2
1001 | 2
1001 | 2
Please Help..
Retrieve the grouped rows of an excel sheet programmatically using Excel-VBA & C#
Retrieve the grouped rows of an excel sheet programmatically using
Excel-VBA & C#
I want to retrieve the filtered rows (filtered using EmailAddress) of an
excel sheet programmatically, using C# with the reference of EPPlus
Library. Then I can able to write those grouped records into separate
excel files.
Note: Mine is C# console application. Library using for Excel operations:
EPPlus.dll
Anybody has ideas, please pop it out. Thanks.
Excel-VBA & C#
I want to retrieve the filtered rows (filtered using EmailAddress) of an
excel sheet programmatically, using C# with the reference of EPPlus
Library. Then I can able to write those grouped records into separate
excel files.
Note: Mine is C# console application. Library using for Excel operations:
EPPlus.dll
Anybody has ideas, please pop it out. Thanks.
Tuesday, 10 September 2013
First time run configuration (ASP MVC 4)
First time run configuration (ASP MVC 4)
I'm creating a simple MVC CMS for which I need a first time run
configuration (to set up the database and admin user account, etc.).
The setup screen will ask them for the database connection string, so at
first run, there is no knowledge of a database store.
How would I detect that this is the first time the application is being
run, and take them to that setup screen?
Should I put a setting in the web.config with an initial value of false:
<add key="SetupComplete" value="false" />
And once the setup is complete, I can change it via:
ConfigurationManager.AppSettings.Set("SetupComplete", "True");
The downfall of this method is that, if the application is restarted, the
config value will default to "false". What is a good solution to this
problem?
I'm creating a simple MVC CMS for which I need a first time run
configuration (to set up the database and admin user account, etc.).
The setup screen will ask them for the database connection string, so at
first run, there is no knowledge of a database store.
How would I detect that this is the first time the application is being
run, and take them to that setup screen?
Should I put a setting in the web.config with an initial value of false:
<add key="SetupComplete" value="false" />
And once the setup is complete, I can change it via:
ConfigurationManager.AppSettings.Set("SetupComplete", "True");
The downfall of this method is that, if the application is restarted, the
config value will default to "false". What is a good solution to this
problem?
Loop through javascript for image previews
Loop through javascript for image previews
I'm currently getting to grips with html5 API image uploading and I'm a
bit stuck with some javascript (way out my comfort zone) involved.
This is a snippet of my upload table (it also involves data collection for
each image not shown here for things like renaming the image etc):
<tr>
<td>Image '.$i.':</td><td><output id="display'.$i.'"></output></td>
</tr>
<tr>
<td>Choose Image:</td>
<td><input name="file'.$i.'" type="file" id="file'.$i.'" accept="image/*"
/></td>
</tr>
$i is a php counter, the user selects how many photos they will upload and
it creates that many image boxes.
This is the javascript used to show an image preview:
document.getElementById('file1').addEventListener('change',
handleFileSelect, false);
function handleFileSelect(evt) {
var files = evt.target.files;
var f = files[0];
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
document.getElementById('display1').innerHTML = ['<img
src="', e.target.result,'" title="', theFile.name, '"
width="100" />'].join('');
};
})(f);
reader.readAsDataURL(f);
}
My question is, being a javascript novice, is there a simple way to loop
the script for each image. Currently it will only show the preview for
'file1', is there a way to change the '1' to something like $i, $i++ used
for php loops? lets say the number of image boxes is stored as the php
varible $totelboxes
I'm currently getting to grips with html5 API image uploading and I'm a
bit stuck with some javascript (way out my comfort zone) involved.
This is a snippet of my upload table (it also involves data collection for
each image not shown here for things like renaming the image etc):
<tr>
<td>Image '.$i.':</td><td><output id="display'.$i.'"></output></td>
</tr>
<tr>
<td>Choose Image:</td>
<td><input name="file'.$i.'" type="file" id="file'.$i.'" accept="image/*"
/></td>
</tr>
$i is a php counter, the user selects how many photos they will upload and
it creates that many image boxes.
This is the javascript used to show an image preview:
document.getElementById('file1').addEventListener('change',
handleFileSelect, false);
function handleFileSelect(evt) {
var files = evt.target.files;
var f = files[0];
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
document.getElementById('display1').innerHTML = ['<img
src="', e.target.result,'" title="', theFile.name, '"
width="100" />'].join('');
};
})(f);
reader.readAsDataURL(f);
}
My question is, being a javascript novice, is there a simple way to loop
the script for each image. Currently it will only show the preview for
'file1', is there a way to change the '1' to something like $i, $i++ used
for php loops? lets say the number of image boxes is stored as the php
varible $totelboxes
angularjs basic todo example refuses to work
angularjs basic todo example refuses to work
I have the following page I am working on (it is taken from the official
angularjs todo example page)
doctype 5
html(ng-app)
head
title myapp
script
var photos = !{JSON.stringify(photos)};
body
div#header-wrapper(ng-controller='PhotosCtrl')
div.col-wrap#header
div.col-2.offset-1: div.fixed-height#logo
div.col-wrap.padded#divisor Welcome
div.col-wrap.center
div.col-19#main
div.item(ng-repeat='photo in photos')
p.desc(ng-model='photo.desc')
script(type='text/javascript',
src='http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js')
script(type='text/javascript', src='/js/app.js')
//app.js
function PhotosCtrl($scope){
$scope.photos = photos;
};
the photos object looks like this:
[
{ url:"http://example.comimage.jpg", desc:"this is a picture" },
{ url:"http://example.comimage.jpg", desc:"this is a picture" },
];
but nothing is showing in my #main div. Any idea why?
I have the following page I am working on (it is taken from the official
angularjs todo example page)
doctype 5
html(ng-app)
head
title myapp
script
var photos = !{JSON.stringify(photos)};
body
div#header-wrapper(ng-controller='PhotosCtrl')
div.col-wrap#header
div.col-2.offset-1: div.fixed-height#logo
div.col-wrap.padded#divisor Welcome
div.col-wrap.center
div.col-19#main
div.item(ng-repeat='photo in photos')
p.desc(ng-model='photo.desc')
script(type='text/javascript',
src='http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js')
script(type='text/javascript', src='/js/app.js')
//app.js
function PhotosCtrl($scope){
$scope.photos = photos;
};
the photos object looks like this:
[
{ url:"http://example.comimage.jpg", desc:"this is a picture" },
{ url:"http://example.comimage.jpg", desc:"this is a picture" },
];
but nothing is showing in my #main div. Any idea why?
How to extract a filename from a URL & append a word to it?
How to extract a filename from a URL & append a word to it?
I have the following url:
url = http://photographs.500px.com/kyle/09-09-201315-47-571378756077.jpg
I would like to extract the file name in this url:
09-09-201315-47-571378756077.jpg
Once I get this file name, I'm going to save it with this name to the
Desktop.
filename = **extracted file name from the url**
download_photo = urllib.urlretrieve(url, "/home/ubuntu/Desktop/%s.jpg" %
(filename))
After this, I'm going to resize the photo, once that is done, I've going
to save the resized version and append the word "_small" to the end of the
filename.
downloadedphoto = Image.open("/home/ubuntu/Desktop/%s.jpg" % (filename))
resize_downloadedphoto = downloadedphoto.resize.((300, 300), Image.ANTIALIAS)
resize_downloadedphoto.save("/home/ubuntu/Desktop/%s.jpg" % (filename +
_small))
From this, what I am trying to achieve is to get two files, the original
photo with the original name, then the resized photo with the modified
name. Like so:
09-09-201315-47-571378756077.jpg
09-09-201315-47-571378756077_small.jpg
How can I go about doing this?
I have the following url:
url = http://photographs.500px.com/kyle/09-09-201315-47-571378756077.jpg
I would like to extract the file name in this url:
09-09-201315-47-571378756077.jpg
Once I get this file name, I'm going to save it with this name to the
Desktop.
filename = **extracted file name from the url**
download_photo = urllib.urlretrieve(url, "/home/ubuntu/Desktop/%s.jpg" %
(filename))
After this, I'm going to resize the photo, once that is done, I've going
to save the resized version and append the word "_small" to the end of the
filename.
downloadedphoto = Image.open("/home/ubuntu/Desktop/%s.jpg" % (filename))
resize_downloadedphoto = downloadedphoto.resize.((300, 300), Image.ANTIALIAS)
resize_downloadedphoto.save("/home/ubuntu/Desktop/%s.jpg" % (filename +
_small))
From this, what I am trying to achieve is to get two files, the original
photo with the original name, then the resized photo with the modified
name. Like so:
09-09-201315-47-571378756077.jpg
09-09-201315-47-571378756077_small.jpg
How can I go about doing this?
How to send and recieve data between two Bluetooth devices
How to send and recieve data between two Bluetooth devices
I'm new to Bluetooth programming. So, I need to make a application to send
and read data between two Bluetooth devices(Windows PC and android phone).
I plan to use spp. I have already read 32.NET documentation in Bluetooth
inthehand library. If somebody can support me to teach the basic steps
should be used in my code in order to connect PC to Android and transfer
data between them.
Is it enough two device have been already paired by Windows? Do I also
need to pair two devices through Windows?
Please help me........!
I'm new to Bluetooth programming. So, I need to make a application to send
and read data between two Bluetooth devices(Windows PC and android phone).
I plan to use spp. I have already read 32.NET documentation in Bluetooth
inthehand library. If somebody can support me to teach the basic steps
should be used in my code in order to connect PC to Android and transfer
data between them.
Is it enough two device have been already paired by Windows? Do I also
need to pair two devices through Windows?
Please help me........!
How to get records that exist in one MySql table and not another
How to get records that exist in one MySql table and not another
I need to write a query that returns the records that exist in one MySql
table and do not exist in the other table. In this example, I want all of
the wafers that exist in the wafer_log table that do not exist in the
bt_log table.
Here is the current query I'm using:
SELECT wafer_log.wafer, bt_log.id AS blid, wafer_log.id AS wlid
FROM bt_log RIGHT OUTER JOIN wafer_log
ON bt_log.waferid = wafer_log.wafer
WHERE wafer_log.wafer IS NOT NULL AND bt_log.id NULL;
My thought here was to get the wafer name from the table I care about as
well as the ids for both of the tables and do an outer join on the wafer
name. From there, I wanted to see all of the results where wafer name was
not null in wafer_log table and id in the bt_log is null.
I don't feel like the results look right though.
Any help would be appreciated.
I need to write a query that returns the records that exist in one MySql
table and do not exist in the other table. In this example, I want all of
the wafers that exist in the wafer_log table that do not exist in the
bt_log table.
Here is the current query I'm using:
SELECT wafer_log.wafer, bt_log.id AS blid, wafer_log.id AS wlid
FROM bt_log RIGHT OUTER JOIN wafer_log
ON bt_log.waferid = wafer_log.wafer
WHERE wafer_log.wafer IS NOT NULL AND bt_log.id NULL;
My thought here was to get the wafer name from the table I care about as
well as the ids for both of the tables and do an outer join on the wafer
name. From there, I wanted to see all of the results where wafer name was
not null in wafer_log table and id in the bt_log is null.
I don't feel like the results look right though.
Any help would be appreciated.
How to redirect sub.domain.com to proper url
How to redirect sub.domain.com to proper url
I have a website and some sub-domains which are working like so:
http://sub.domain.com/ goes to: http://www.domain.com/sub/.
But what I want it do do is:
http://sub.domain.com/ goes to: http://sub.domain.com/sub/ but still keep
the URI in the address bar the same, so it should read:
http://sub.domain.com/.
So when a user enters http://sub.domain.com/ in the address bar, it will
display content from http://sub.domain.com/sub/ but still display
http://sub.domain.com/ in the address bar.
If the user visits another page in sub.domain.com website the address bar
should still display correct address which might be something like
http://sub.domain.com/page2.html instead of
http://domain.com/sub/page2.html.
How can we achieve this? I've done it years ago but to be honest I don't
remember the approach I used and I have tried a few articles online but
they weren't correct.
Any help is greatly appreciated
Thank you
My current code is:
@{
// Redirect from subdomain if necessary.
string variables = (Request.ServerVariables["SERVER_NAME"]);
switch(variables.Trim().ToLower())
{
case "sub.domain.com":
Response.Redirect("http://domain.com/sub/", true);
break;
default:
Layout = "~/Shared/_View.cshtml";
break;
}
}
I have a website and some sub-domains which are working like so:
http://sub.domain.com/ goes to: http://www.domain.com/sub/.
But what I want it do do is:
http://sub.domain.com/ goes to: http://sub.domain.com/sub/ but still keep
the URI in the address bar the same, so it should read:
http://sub.domain.com/.
So when a user enters http://sub.domain.com/ in the address bar, it will
display content from http://sub.domain.com/sub/ but still display
http://sub.domain.com/ in the address bar.
If the user visits another page in sub.domain.com website the address bar
should still display correct address which might be something like
http://sub.domain.com/page2.html instead of
http://domain.com/sub/page2.html.
How can we achieve this? I've done it years ago but to be honest I don't
remember the approach I used and I have tried a few articles online but
they weren't correct.
Any help is greatly appreciated
Thank you
My current code is:
@{
// Redirect from subdomain if necessary.
string variables = (Request.ServerVariables["SERVER_NAME"]);
switch(variables.Trim().ToLower())
{
case "sub.domain.com":
Response.Redirect("http://domain.com/sub/", true);
break;
default:
Layout = "~/Shared/_View.cshtml";
break;
}
}
Subscribe to:
Comments (Atom)