var varName = function funcName() {}
what is the difference between
var a = function() {}
and
var a = function b() {}
The latter, b is undefined?
I'm new to Javascript. Thanks!
Thursday, 3 October 2013
Wednesday, 2 October 2013
Adjusting a RegEx to require 2 digits after an optional decimal?
Adjusting a RegEx to require 2 digits after an optional decimal?
I believe I've found the "perfect" Regular Expression to check against for
currency in jQuery Validate, except it seems to allow the user to put a
single lone decimal at the end or a decimal with a single digit after.
Matches: 700. and 3.0
The Regex:
^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$
I've been playing with it in http://gskinner.com/RegExr/ but can't seem to
modify it in the right places to fix my decimal issue.
Currently it matches everything I need it to:
700,000
700,000.00
700000
I believe I've found the "perfect" Regular Expression to check against for
currency in jQuery Validate, except it seems to allow the user to put a
single lone decimal at the end or a decimal with a single digit after.
Matches: 700. and 3.0
The Regex:
^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$
I've been playing with it in http://gskinner.com/RegExr/ but can't seem to
modify it in the right places to fix my decimal issue.
Currently it matches everything I need it to:
700,000
700,000.00
700000
Batch editing of csv files with Python
Batch editing of csv files with Python
I need to edit several csv files. Actually, most of the files are fine as
they are, it's just the last (41st) column that needs to be changed. For
every occurrence of a particular string in that column, I need it to be
replaced by a different string; specifically, every occurrence of 'S-D'
needs to be replaced by 'S'. I've tried to accomplish this using Python,
but I think I need to write the csv files and I'm not quite sure how to do
this:
import os
import csv
path=os.getcwd()
filenames = os.listdir(path)
for filename in filenames:
if filename.endswith('.csv'):
r=csv.reader(open(filename))
for row in r:
if row[40] == "S-D":
row[40] = "S"
Any help? Also, if anyone has a quick , elegant way of doing this with a
shell script, that would probably be very helpful to me as well.
I need to edit several csv files. Actually, most of the files are fine as
they are, it's just the last (41st) column that needs to be changed. For
every occurrence of a particular string in that column, I need it to be
replaced by a different string; specifically, every occurrence of 'S-D'
needs to be replaced by 'S'. I've tried to accomplish this using Python,
but I think I need to write the csv files and I'm not quite sure how to do
this:
import os
import csv
path=os.getcwd()
filenames = os.listdir(path)
for filename in filenames:
if filename.endswith('.csv'):
r=csv.reader(open(filename))
for row in r:
if row[40] == "S-D":
row[40] = "S"
Any help? Also, if anyone has a quick , elegant way of doing this with a
shell script, that would probably be very helpful to me as well.
Cocoa programming app with multiple view
Cocoa programming app with multiple view
I'm programming a simple application for Mac OSX, using cocoa framework. I
don't know how sending messages between 2 different view in the same
windows. My app have 2 view : first view that contains 1 form and 1 submit
button, second view that contains a WebView that loads a flash.
The steps to do are :
1) At start do a control and based on the result it shows view1 or view2
2) If view1 is visualized, on the submit action, based on inserted data,
view1 disappears and view2 appears.
I would know how build window and views and how manage this logic. Thanks.
I'm programming a simple application for Mac OSX, using cocoa framework. I
don't know how sending messages between 2 different view in the same
windows. My app have 2 view : first view that contains 1 form and 1 submit
button, second view that contains a WebView that loads a flash.
The steps to do are :
1) At start do a control and based on the result it shows view1 or view2
2) If view1 is visualized, on the submit action, based on inserted data,
view1 disappears and view2 appears.
I would know how build window and views and how manage this logic. Thanks.
Tuesday, 1 October 2013
the 7 digit even number
the 7 digit even number
Find a number with the following conditions:
i. It is a $7$ digit number.
ii. There is no repetition of digits.
iii. The digit 5 is in the thousands place.
iv. The greatest digit is in the millions place
v. The digit in the hundred thousands place is twice the digit in the
hundreds place.
vi. The digit in the hundreds pace is twice the digit in the ones place.
vii. The digit in the tens place is two less than the digit in the
millions place
vii. The value of the digit in the ten thousands place is zero.
Find a number with the following conditions:
i. It is a $7$ digit number.
ii. There is no repetition of digits.
iii. The digit 5 is in the thousands place.
iv. The greatest digit is in the millions place
v. The digit in the hundred thousands place is twice the digit in the
hundreds place.
vi. The digit in the hundreds pace is twice the digit in the ones place.
vii. The digit in the tens place is two less than the digit in the
millions place
vii. The value of the digit in the ten thousands place is zero.
How do I configure Chef Solo to install Nginx on a new Vagrant box?
How do I configure Chef Solo to install Nginx on a new Vagrant box?
I'm new to Chef and the documentation (even the home page of their
website) makes my head spin. I'm not even sure if I'm using it for the
correct purpose.
My intent is to setup a Vagrantfile that tells Chef Solo to automatically
install some software automatically when I spin up a new box. That is one
of Chef Solo's intended uses, am I correct?
I'm not really sure if that qualifies as one of "the hardest
infrastructure challenges on the planet", but whatever.
My first goal is to get Chef Solo to install nginx for me. In my project,
I've cloned the cookbook for nginx:
$ git clone https://github.com/opscode-cookbooks/nginx.git cookbooks/nginx
I edited my Vagrantfile to look like this:
Vagrant.configure("2") do |config|
config.vm.box = "opscode-ubuntu-1204"
config.vm.provision :chef_solo do |chef|
chef.add_recipe "nginx"
end
end
When I ran vagrant up, I got some errors that some cookbooks weren't found
(build-essential, apt, etc), so I cloned them from their appropriate
repos. Now, when I vagrant up, I'm getting this output:
[2013-10-01T20:31:03+00:00] INFO: Processing package[nginx] action install
(nginx::package line 38)
================================================================================
Error executing action `install` on resource 'package[nginx]'
================================================================================
Chef::Exceptions::Exec
----------------------
apt-get -q -y install nginx=1.1.19-1ubuntu0.1 returned 100, expected 0
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/package.rb
38: package node['nginx']['package_name'] do
39: notifies :reload, 'ohai[reload_nginx]', :immediately
40: end
41:
Compiled Resource:
------------------
# Declared in
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/package.rb:38:in
`from_file'
package("nginx") do
action :install
retries 0
retry_delay 2
package_name "nginx"
version "1.1.19-1ubuntu0.1"
cookbook_name :nginx
recipe_name "package"
end
[2013-10-01T20:31:08+00:00] INFO: Running queued delayed notifications
before re-raising exception
[2013-10-01T20:31:08+00:00] ERROR: Running exception handlers
[2013-10-01T20:31:08+00:00] ERROR: Exception handlers complete
[2013-10-01T20:31:08+00:00] FATAL: Stacktrace dumped to
/tmp/vagrant-chef-1/chef-stacktrace.out
[2013-10-01T20:31:08+00:00] FATAL: Chef::Exceptions::Exec: package[nginx]
(nginx::package line 38) had an error: Chef::Exceptions::Exec: apt-get -q
-y install nginx=1.1.19-1ubuntu0.1 returned 100, expected 0
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
How can I fix my recipes so that they properly complete?
I'm new to Chef and the documentation (even the home page of their
website) makes my head spin. I'm not even sure if I'm using it for the
correct purpose.
My intent is to setup a Vagrantfile that tells Chef Solo to automatically
install some software automatically when I spin up a new box. That is one
of Chef Solo's intended uses, am I correct?
I'm not really sure if that qualifies as one of "the hardest
infrastructure challenges on the planet", but whatever.
My first goal is to get Chef Solo to install nginx for me. In my project,
I've cloned the cookbook for nginx:
$ git clone https://github.com/opscode-cookbooks/nginx.git cookbooks/nginx
I edited my Vagrantfile to look like this:
Vagrant.configure("2") do |config|
config.vm.box = "opscode-ubuntu-1204"
config.vm.provision :chef_solo do |chef|
chef.add_recipe "nginx"
end
end
When I ran vagrant up, I got some errors that some cookbooks weren't found
(build-essential, apt, etc), so I cloned them from their appropriate
repos. Now, when I vagrant up, I'm getting this output:
[2013-10-01T20:31:03+00:00] INFO: Processing package[nginx] action install
(nginx::package line 38)
================================================================================
Error executing action `install` on resource 'package[nginx]'
================================================================================
Chef::Exceptions::Exec
----------------------
apt-get -q -y install nginx=1.1.19-1ubuntu0.1 returned 100, expected 0
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/package.rb
38: package node['nginx']['package_name'] do
39: notifies :reload, 'ohai[reload_nginx]', :immediately
40: end
41:
Compiled Resource:
------------------
# Declared in
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/package.rb:38:in
`from_file'
package("nginx") do
action :install
retries 0
retry_delay 2
package_name "nginx"
version "1.1.19-1ubuntu0.1"
cookbook_name :nginx
recipe_name "package"
end
[2013-10-01T20:31:08+00:00] INFO: Running queued delayed notifications
before re-raising exception
[2013-10-01T20:31:08+00:00] ERROR: Running exception handlers
[2013-10-01T20:31:08+00:00] ERROR: Exception handlers complete
[2013-10-01T20:31:08+00:00] FATAL: Stacktrace dumped to
/tmp/vagrant-chef-1/chef-stacktrace.out
[2013-10-01T20:31:08+00:00] FATAL: Chef::Exceptions::Exec: package[nginx]
(nginx::package line 38) had an error: Chef::Exceptions::Exec: apt-get -q
-y install nginx=1.1.19-1ubuntu0.1 returned 100, expected 0
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
How can I fix my recipes so that they properly complete?
Array declaration askubuntu.com
Array declaration – askubuntu.com
How can I declare an array in Ubuntu ? I have tried the code below
Unix=('Zero' 'One' 'Two') #echo -n "area2[0] = " echo ${area2[@]} # Aha,
zero-based indexing (first element of array is [0], not …
How can I declare an array in Ubuntu ? I have tried the code below
Unix=('Zero' 'One' 'Two') #echo -n "area2[0] = " echo ${area2[@]} # Aha,
zero-based indexing (first element of array is [0], not …
Is a game view "stack" really a Stack? gamedev.stackexchange.com
Is a game view "stack" really a Stack? – gamedev.stackexchange.com
Given the academic definition of a Stack as "A data structure where items
are added in a FILO manner and accessed in such a way that only the top
item may be examined or removed to be modified." Game …
Given the academic definition of a Stack as "A data structure where items
are added in a FILO manner and accessed in such a way that only the top
item may be examined or removed to be modified." Game …
Monday, 30 September 2013
how to explain prime numbers to children math.stackexchange.com
how to explain prime numbers to children – math.stackexchange.com
My little cousin (12year) asked me about how emails are encrypted and I
want to answers her in such a way she understands it. This is diffuct, but
I am happy with teaching the definition of a prime …
My little cousin (12year) asked me about how emails are encrypted and I
want to answers her in such a way she understands it. This is diffuct, but
I am happy with teaching the definition of a prime …
Safe to leave oven on at 180F while at work to cook ribs=?iso-8859-1?Q?=3F_=96_cooking.stackexchange.com?=
Safe to leave oven on at 180F while at work to cook ribs? –
cooking.stackexchange.com
I'm currently at work and I'm having a little panic attack. I followed a
recipe that require the ribs to be wrapped in foil and cooked at 180F for
9hours. I left about 30 minutes ago and for who ...
cooking.stackexchange.com
I'm currently at work and I'm having a little panic attack. I followed a
recipe that require the ribs to be wrapped in foil and cooked at 180F for
9hours. I left about 30 minutes ago and for who ...
CSS - using ':before' to place an image not appearing in Firefox
CSS - using ':before' to place an image not appearing in Firefox
I'm trying to position a temporary 'beta' ribbon image positioned in the
top left of a wordpress based site.
The following code functions as intended in Chrome and IE. In Firefox,
nothing is appearing:
#page-wrapper:before
{
width: 50px;
content: " ";
background: url(wp-content/uploads/2013/09/betaribbon2.png) no-repeat;
position: absolute;
height: 50px;
pointer-events: none;
}
Can anyone shed light on what I'm doing wrong?
Thanks,
LB
I'm trying to position a temporary 'beta' ribbon image positioned in the
top left of a wordpress based site.
The following code functions as intended in Chrome and IE. In Firefox,
nothing is appearing:
#page-wrapper:before
{
width: 50px;
content: " ";
background: url(wp-content/uploads/2013/09/betaribbon2.png) no-repeat;
position: absolute;
height: 50px;
pointer-events: none;
}
Can anyone shed light on what I'm doing wrong?
Thanks,
LB
Is it possible to load multiple instances of yepnope on a single page?
Is it possible to load multiple instances of yepnope on a single page?
This question was already sort of asked here, but it does not have a
definitive answer. The comments there state that yepnope will not load the
same script twice, so you don't have to worry about that.
But what I'm wondering is whether it is possible to load multiple
instances of yepnope. Because I want to use it to asynchronously load
scripts in both the <head> and before the </body>.
This question was already sort of asked here, but it does not have a
definitive answer. The comments there state that yepnope will not load the
same script twice, so you don't have to worry about that.
But what I'm wondering is whether it is possible to load multiple
instances of yepnope. Because I want to use it to asynchronously load
scripts in both the <head> and before the </body>.
Sunday, 29 September 2013
Segmentation Fault error - Implementing Stack using Linked lists
Segmentation Fault error - Implementing Stack using Linked lists
I am currently in a University program studying Data Structures in C and I
am having a lot of trouble right now. I want to make clear that what I am
asking help for is not for marks, just practice challenge problems.
The goal is to implement a stack using Linked Lists. By looking through
the lecture notes I think I have most of the functions down. I need to
demonstrate Push() and Pop() will an append and a pretend. Using Cygwin, I
compiled with no errors. but when I try to run it, I get a "Segmentation
Fault". What does this mean and how do I fix it? if I remove "stack =
initLListStack();", the error disappears. Here is my code:
#include <stdio.h>
#include <stdlib.h>
typedef struct Link{
int *value;
struct Link *next;
}Link;
typedef struct LList1{
int *size;
Link *head;
}LList1;
typedef struct LListStack{
LList1 *llist;
}LListStack ;
LListStack *initLListStack(void)
{
LListStack *stack = (LListStack *) malloc(sizeof(LListStack)) ;
stack->llist->size = 0;
stack->llist->head = NULL;
return(stack);
}
void removefront(LList1 *llist)
{
if(llist->head != NULL){
llist->head = llist->head->next;
llist->size--;
}
}
Link *FindLastLink(LList1 *llist, Link *link)
{
if(link = NULL){
return(NULL);
}
else if(link->next == NULL){
return(link);
}
else{
return(FindLastLink(llist, link->next));
}
}
Link *FindSecondLastLink(LList1 *llist, Link *link)
{
if(link = NULL){
return(NULL);
}
else if(link->next->next == NULL){
return(link);
}
else{
return(FindSecondLastLink(llist, link->next));
}
}
void removelast(LList1 *llist)
{
Link *secondlastlink = (Link *) malloc(sizeof(Link));
secondlastlink = FindSecondLastLink(llist, llist->head);
secondlastlink->next = NULL;
llist->size--;
}
void prepend(int *newValue, LList1 *templist)
{
Link *node = (Link *) malloc(sizeof(Link));
node->value = newValue;
node->next = templist->head;
templist->head = node;
templist->size++;
}
void append(int *newValue, LList1 *templist)
{
Link *node = (Link *) malloc(sizeof(Link));
Link *lastlink = (Link *) malloc(sizeof(Link));
lastlink = FindLastLink(templist, templist->head);
node->value = newValue;
lastlink->next = node;
node->next = NULL;
templist->size++;
}
void prepush(int *value, LListStack *stack)
{
prepend(value, stack->llist);
}
void apppush(int *value, LListStack *stack)
{
append(value, stack->llist);
}
int prepop(LListStack *stack, int *value)
{
int result ;
if ((!isEmpty(stack)))
{
removefront(stack->llist);
result = 1 ;
}
else {
result = 0 ;
}
return(result) ;
}
int isEmpty(LListStack *stack)
{
int empty;
if (stack->llist->head == NULL)
return( 1 ) ;
else
return( 0 ) ;
}
int apppop(LListStack *stack, int *value)
{
int result ;
if ((!isEmpty(stack)))
{
removelast(stack->llist);
result = 1 ;
}
else
result = 0 ;
return(result) ;
}
//*******MAIN**********//
int main()
{
LListStack *stack = (LListStack *) malloc (sizeof(LListStack));
stack = initLListStack(); //if I take this away, I can run the program
return(0);
}
I don't have that much in Main() yet because I'm just trying to get it to
run first. Initializing the Stack seems to be the problem.
Thanks for your help guys!
I am currently in a University program studying Data Structures in C and I
am having a lot of trouble right now. I want to make clear that what I am
asking help for is not for marks, just practice challenge problems.
The goal is to implement a stack using Linked Lists. By looking through
the lecture notes I think I have most of the functions down. I need to
demonstrate Push() and Pop() will an append and a pretend. Using Cygwin, I
compiled with no errors. but when I try to run it, I get a "Segmentation
Fault". What does this mean and how do I fix it? if I remove "stack =
initLListStack();", the error disappears. Here is my code:
#include <stdio.h>
#include <stdlib.h>
typedef struct Link{
int *value;
struct Link *next;
}Link;
typedef struct LList1{
int *size;
Link *head;
}LList1;
typedef struct LListStack{
LList1 *llist;
}LListStack ;
LListStack *initLListStack(void)
{
LListStack *stack = (LListStack *) malloc(sizeof(LListStack)) ;
stack->llist->size = 0;
stack->llist->head = NULL;
return(stack);
}
void removefront(LList1 *llist)
{
if(llist->head != NULL){
llist->head = llist->head->next;
llist->size--;
}
}
Link *FindLastLink(LList1 *llist, Link *link)
{
if(link = NULL){
return(NULL);
}
else if(link->next == NULL){
return(link);
}
else{
return(FindLastLink(llist, link->next));
}
}
Link *FindSecondLastLink(LList1 *llist, Link *link)
{
if(link = NULL){
return(NULL);
}
else if(link->next->next == NULL){
return(link);
}
else{
return(FindSecondLastLink(llist, link->next));
}
}
void removelast(LList1 *llist)
{
Link *secondlastlink = (Link *) malloc(sizeof(Link));
secondlastlink = FindSecondLastLink(llist, llist->head);
secondlastlink->next = NULL;
llist->size--;
}
void prepend(int *newValue, LList1 *templist)
{
Link *node = (Link *) malloc(sizeof(Link));
node->value = newValue;
node->next = templist->head;
templist->head = node;
templist->size++;
}
void append(int *newValue, LList1 *templist)
{
Link *node = (Link *) malloc(sizeof(Link));
Link *lastlink = (Link *) malloc(sizeof(Link));
lastlink = FindLastLink(templist, templist->head);
node->value = newValue;
lastlink->next = node;
node->next = NULL;
templist->size++;
}
void prepush(int *value, LListStack *stack)
{
prepend(value, stack->llist);
}
void apppush(int *value, LListStack *stack)
{
append(value, stack->llist);
}
int prepop(LListStack *stack, int *value)
{
int result ;
if ((!isEmpty(stack)))
{
removefront(stack->llist);
result = 1 ;
}
else {
result = 0 ;
}
return(result) ;
}
int isEmpty(LListStack *stack)
{
int empty;
if (stack->llist->head == NULL)
return( 1 ) ;
else
return( 0 ) ;
}
int apppop(LListStack *stack, int *value)
{
int result ;
if ((!isEmpty(stack)))
{
removelast(stack->llist);
result = 1 ;
}
else
result = 0 ;
return(result) ;
}
//*******MAIN**********//
int main()
{
LListStack *stack = (LListStack *) malloc (sizeof(LListStack));
stack = initLListStack(); //if I take this away, I can run the program
return(0);
}
I don't have that much in Main() yet because I'm just trying to get it to
run first. Initializing the Stack seems to be the problem.
Thanks for your help guys!
data.table and paste aggregation very slow for big data, bottleneck in large code, large data
data.table and paste aggregation very slow for big data, bottleneck in
large code, large data
I just finished profiling my R code and it turns out that most operations
are done relatively fast, but for my large data this part of the code its
taking most of the time:
collapsed.bam.dt =
split.bam.dt[,list(read.parent.cigar=paste(block.read.parent.cigar,collapse=""),
parent.ref.cigar=paste(block.parent.ref.cigar,collapse=""),
read.ref.cigar=paste(block.read.ref.cigar,collapse=""),
read.ref.start=block.ref.start[1]),
by = read.index];
Note that block.read.parent.cigar, parent.ref.cigar, read.ref.cigar are of
type "character" and I want to concatenate them. In the case of
read.ref.start they are all the same so I just take the first one.
I am not sure if others have found that aggregating data in very large
data tables takes too much time.
Most of my code runs with mclapply with 48 cores so runs pretty fast, but
I cannot think about other ways to improve/parallelize the line above. If
you have some ideas/suggestions please let me know.
Thanks!
large code, large data
I just finished profiling my R code and it turns out that most operations
are done relatively fast, but for my large data this part of the code its
taking most of the time:
collapsed.bam.dt =
split.bam.dt[,list(read.parent.cigar=paste(block.read.parent.cigar,collapse=""),
parent.ref.cigar=paste(block.parent.ref.cigar,collapse=""),
read.ref.cigar=paste(block.read.ref.cigar,collapse=""),
read.ref.start=block.ref.start[1]),
by = read.index];
Note that block.read.parent.cigar, parent.ref.cigar, read.ref.cigar are of
type "character" and I want to concatenate them. In the case of
read.ref.start they are all the same so I just take the first one.
I am not sure if others have found that aggregating data in very large
data tables takes too much time.
Most of my code runs with mclapply with 48 cores so runs pretty fast, but
I cannot think about other ways to improve/parallelize the line above. If
you have some ideas/suggestions please let me know.
Thanks!
decimal of numbers in c
decimal of numbers in c
I just asked a question but couldn't get what I want, and couldn't edited
and reply as it is too long. My question is the same and it is the link to
that question.how to keep decimals in c
#include<stdio.h>
int main()
{
float b,c,;
int a,kk;
printf("Welcome to the unit conversion program\n");
printf("This program can convert the measurements of;\n");
printf("1-Length\n");
printf("2-Mass\n");
printf("Please select the number that corresponds to the measurement you
want to convert in:\n");
scanf("%d",&a);
if (a==1){
printf("Your number will be converted from inches to
centimeters.\n");
printf("Please enter the length.\n");
scanf("%f",&b);
c=b*2.54;
printf("%f inch is %f cm.",b,c);
scanf("%d",kk); \. to avoid to shut the cmd windows .\
}
else if (a==2){
printf("Your number will be converted from pounds (lbs) to
kilograms");
printf("Please enter the mass.\n");
scanf("%d",&b);
c=b*0.45359237;
printf("%d lbs is %d kgs.",b,c);
}
return 0;
}
I just asked a question but couldn't get what I want, and couldn't edited
and reply as it is too long. My question is the same and it is the link to
that question.how to keep decimals in c
#include<stdio.h>
int main()
{
float b,c,;
int a,kk;
printf("Welcome to the unit conversion program\n");
printf("This program can convert the measurements of;\n");
printf("1-Length\n");
printf("2-Mass\n");
printf("Please select the number that corresponds to the measurement you
want to convert in:\n");
scanf("%d",&a);
if (a==1){
printf("Your number will be converted from inches to
centimeters.\n");
printf("Please enter the length.\n");
scanf("%f",&b);
c=b*2.54;
printf("%f inch is %f cm.",b,c);
scanf("%d",kk); \. to avoid to shut the cmd windows .\
}
else if (a==2){
printf("Your number will be converted from pounds (lbs) to
kilograms");
printf("Please enter the mass.\n");
scanf("%d",&b);
c=b*0.45359237;
printf("%d lbs is %d kgs.",b,c);
}
return 0;
}
How to convert java.util.date to iso 8601?
How to convert java.util.date to iso 8601?
I want to convert my current system date and time into ISO 8601 in this
format "2012-04-23T18:25:43.511Z". Please help.
I want to convert my current system date and time into ISO 8601 in this
format "2012-04-23T18:25:43.511Z". Please help.
Saturday, 28 September 2013
SWFObject based Flash movie won't show in Internet Explorer 10
SWFObject based Flash movie won't show in Internet Explorer 10
I am using Roy Tanck's WP-Cumulus Tag Cloud viewer. It's an SWF file that
is used with SWFObject.js to show a spinning sphere of tags. It works fine
in Chrome and FireFox, but in Internet Explorer 10 the canvas is blank. If
I right-click on the canvas I do see the attribution link to Roy Tanck's
web site indicating the movie was loaded, and there are no errors showing
in the Debugger's Console tab, but no sphere of tags, just a blank white
canvas. I am using SWFObject v2.2 and my Flash player version is
11.8.800.175. I traced my main function (shown below) for creating the tag
XML for the SWF and everything checks out fine. Unfortunately, I get
nothing but a blank display for the movie and no errors in the console. I
did look at the values for the flashvars and they are identical to what
they are when I trace the method in Chrome and FireFox. Can anyone give me
some things to try that might help fix this problem?:
// Create the tag cloud using the given associative array where the Key is
the
// value to display in the tag cloud and the Value is the HREF for the link
// to be associated with the display value.
function createTagCloud(aryDisplayStringsWithLinks, style)
{
if (typeof aryDisplayStringsWithLinks == 'undefined')
return;
// Build tags XML partial for use by the Cumulus Tag Cloud.
var tagCloudXML = "<tags>";
var iCount = 0;
for (var Key in aryDisplayStringsWithLinks)
{
tagCloudXML += createOneTagCloudXMLElement(Key,
aryDisplayStringsWithLinks[Key], style);
iCount++;
} // for()
tagCloudXML += "</tags>";
// Must have at least two elements or the tag cloud won't make any sense.
if (iCount < 2)
return;
var params =
{
wmode: "transparent"
};
var flashvars =
{
// TAGS HYPERLINKS ***MUST** HAVE THE STYLE ATTRIBUTE OR YOU WON'T
SEE ANYTHING IN THE VIEWPORT! (and you
// will think it is broken when it is not).
tagcloud: tagCloudXML,
// tagcloud: '<tags><a href="http://google.com/"
style="font-size:9pt;" >One</a><a href="http://microsoft.com/"
style="font-size:9pt;" >Two</a></tags>',
mode: "tags",
distr: "true",
tcolor: "0x3366CC",
hicolor: "0x0000bb"
};
swfobject.embedSWF(
"/Content/flash/tagcloud.swf",
"flashcontent",
"470",
"380",
"9.0.0",
"",
flashvars
);
} // function createTagCloud(aryDisplayStringsWithLins) {
I am using Roy Tanck's WP-Cumulus Tag Cloud viewer. It's an SWF file that
is used with SWFObject.js to show a spinning sphere of tags. It works fine
in Chrome and FireFox, but in Internet Explorer 10 the canvas is blank. If
I right-click on the canvas I do see the attribution link to Roy Tanck's
web site indicating the movie was loaded, and there are no errors showing
in the Debugger's Console tab, but no sphere of tags, just a blank white
canvas. I am using SWFObject v2.2 and my Flash player version is
11.8.800.175. I traced my main function (shown below) for creating the tag
XML for the SWF and everything checks out fine. Unfortunately, I get
nothing but a blank display for the movie and no errors in the console. I
did look at the values for the flashvars and they are identical to what
they are when I trace the method in Chrome and FireFox. Can anyone give me
some things to try that might help fix this problem?:
// Create the tag cloud using the given associative array where the Key is
the
// value to display in the tag cloud and the Value is the HREF for the link
// to be associated with the display value.
function createTagCloud(aryDisplayStringsWithLinks, style)
{
if (typeof aryDisplayStringsWithLinks == 'undefined')
return;
// Build tags XML partial for use by the Cumulus Tag Cloud.
var tagCloudXML = "<tags>";
var iCount = 0;
for (var Key in aryDisplayStringsWithLinks)
{
tagCloudXML += createOneTagCloudXMLElement(Key,
aryDisplayStringsWithLinks[Key], style);
iCount++;
} // for()
tagCloudXML += "</tags>";
// Must have at least two elements or the tag cloud won't make any sense.
if (iCount < 2)
return;
var params =
{
wmode: "transparent"
};
var flashvars =
{
// TAGS HYPERLINKS ***MUST** HAVE THE STYLE ATTRIBUTE OR YOU WON'T
SEE ANYTHING IN THE VIEWPORT! (and you
// will think it is broken when it is not).
tagcloud: tagCloudXML,
// tagcloud: '<tags><a href="http://google.com/"
style="font-size:9pt;" >One</a><a href="http://microsoft.com/"
style="font-size:9pt;" >Two</a></tags>',
mode: "tags",
distr: "true",
tcolor: "0x3366CC",
hicolor: "0x0000bb"
};
swfobject.embedSWF(
"/Content/flash/tagcloud.swf",
"flashcontent",
"470",
"380",
"9.0.0",
"",
flashvars
);
} // function createTagCloud(aryDisplayStringsWithLins) {
Displaying the content of a DIV on submit
Displaying the content of a DIV on submit
I have a HTML form. On submission the form POST values to page.php. The
view then navigates to page.php and displays a success message. I want to
prevent the user from navigating to page.php, and display <div id="first">
In other words, what i want to do is a reset. (Displaying <div id="first">
after user clicks the Done button)
<form action="page.php" method="post">
<div id="first" class="m span3">
THIS DIV CONTAINS FEW TEXT BOXES
</div>
<div id="second" class="m2 span3">
THIS DIV CONTAINS FEW TEXT BOXES AND COMBOBOXES
</div>
<div id="last" class="m3 span3">
THIS DIV CONTAINS FEW TEXT BOXES
</div>
</form>
Once the user clicks the DOne button the following function gets fired
function onComplete() {
$('form').submit();
alert("clicked");
}
I have a HTML form. On submission the form POST values to page.php. The
view then navigates to page.php and displays a success message. I want to
prevent the user from navigating to page.php, and display <div id="first">
In other words, what i want to do is a reset. (Displaying <div id="first">
after user clicks the Done button)
<form action="page.php" method="post">
<div id="first" class="m span3">
THIS DIV CONTAINS FEW TEXT BOXES
</div>
<div id="second" class="m2 span3">
THIS DIV CONTAINS FEW TEXT BOXES AND COMBOBOXES
</div>
<div id="last" class="m3 span3">
THIS DIV CONTAINS FEW TEXT BOXES
</div>
</form>
Once the user clicks the DOne button the following function gets fired
function onComplete() {
$('form').submit();
alert("clicked");
}
Creating Timer Countdown VB.Net?
Creating Timer Countdown VB.Net?
i am creating a minigame where when the use clicks a button, it "attacks"
the monster causing it to lose 5 hp, displayed using a progressbar. then
at the same time the monster also attacks making the player lose hp. but
the problem is these events happen at the exact same time, and i would
like a 2 second interval between the events. ive been trying to get a
timer event to work since this morning, but it just wouldnt work here is
my code
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
If Tick = 0 Then
Timer1.Stop()
Timer1.Enabled = False
Else
Tick -= 1
End If
End Sub
and here is the attack button event
Private Sub btnAttack_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAttack.Click
PlayerAttacks(mhealth, attack)
textShiftUp(numlines)
HPBarsAlter(mhealth, health)
Tick = 2
Timer1.Start()
MonsterAttacks(health, mattack, CritRate)
HPBarsAlter(mhealth, health)
MobDeath(mhealth, MobNumber)
Timer1.Stop()
End Sub
please tell me if you need any more information thank you :)
i am creating a minigame where when the use clicks a button, it "attacks"
the monster causing it to lose 5 hp, displayed using a progressbar. then
at the same time the monster also attacks making the player lose hp. but
the problem is these events happen at the exact same time, and i would
like a 2 second interval between the events. ive been trying to get a
timer event to work since this morning, but it just wouldnt work here is
my code
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
If Tick = 0 Then
Timer1.Stop()
Timer1.Enabled = False
Else
Tick -= 1
End If
End Sub
and here is the attack button event
Private Sub btnAttack_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAttack.Click
PlayerAttacks(mhealth, attack)
textShiftUp(numlines)
HPBarsAlter(mhealth, health)
Tick = 2
Timer1.Start()
MonsterAttacks(health, mattack, CritRate)
HPBarsAlter(mhealth, health)
MobDeath(mhealth, MobNumber)
Timer1.Stop()
End Sub
please tell me if you need any more information thank you :)
Strange issue with jquery sticky menu
Strange issue with jquery sticky menu
I got strange problem. I created sticky menu with jquery. Everything works
fine on first page, but on any other page there is a problem. When i
scroll down to my point, where menu becomes sticky, it automatically goes
back to top (with some margin from top). So basically i scroll down and
then it scrolls up . This code is cleaned up, i have also added fade
effects on hover, but that is not what causes the problem.
var navoffset = $('nav').offset().top;
navoffset = navoffset+80;//offset=10 + half of menu height
$(window).scroll(function(){
if( $(window).scrollTop() > navoffset ){
$('nav').css({position: 'fixed' , top: '-90px'}); // stick half of menu
}else
{
$('nav').css({position: 'relative' , top: '0px'}); //set back
}
});
EDIT: Oh, and when i open inspect element, everything works fine on all
pages.
I got strange problem. I created sticky menu with jquery. Everything works
fine on first page, but on any other page there is a problem. When i
scroll down to my point, where menu becomes sticky, it automatically goes
back to top (with some margin from top). So basically i scroll down and
then it scrolls up . This code is cleaned up, i have also added fade
effects on hover, but that is not what causes the problem.
var navoffset = $('nav').offset().top;
navoffset = navoffset+80;//offset=10 + half of menu height
$(window).scroll(function(){
if( $(window).scrollTop() > navoffset ){
$('nav').css({position: 'fixed' , top: '-90px'}); // stick half of menu
}else
{
$('nav').css({position: 'relative' , top: '0px'}); //set back
}
});
EDIT: Oh, and when i open inspect element, everything works fine on all
pages.
Friday, 27 September 2013
.htaccess to rewrite one specific file to another specific file
.htaccess to rewrite one specific file to another specific file
All I need to do is rewrite a .js file to a .php file, so when someone
visits "lib/rary.js" they actually get "lib/rary.php".
This is what I'm trying:
RewriteCond ^lib/rary.php lib/rary.js [L]
But it's giving me a server config error.
Any ideas?
Thanks!
All I need to do is rewrite a .js file to a .php file, so when someone
visits "lib/rary.js" they actually get "lib/rary.php".
This is what I'm trying:
RewriteCond ^lib/rary.php lib/rary.js [L]
But it's giving me a server config error.
Any ideas?
Thanks!
Does Spring contain something similar to BeanUtils populate method?
Does Spring contain something similar to BeanUtils populate method?
I'm trying to populate a pojo with data from a map. I can use Apache
Commons but I'm curious if Spring also has an implementation built in.
I know Spring must contain a method that does this mapping; spring
integration inbound http gateways will map HTTP payloads to a POJO
(request-payload-type).
Is BeanUtils the de facto standard for doing exactly what I want?
I'm trying to populate a pojo with data from a map. I can use Apache
Commons but I'm curious if Spring also has an implementation built in.
I know Spring must contain a method that does this mapping; spring
integration inbound http gateways will map HTTP payloads to a POJO
(request-payload-type).
Is BeanUtils the de facto standard for doing exactly what I want?
Add to html on to class with jquery
Add to html on to class with jquery
So I'd like to add html on to every element with a certain class but the
way I call it:
$(".foldUpSection").find(".header").html($(".foldUpSection").find(".header").html()
+ '<div class="miniArrow" style="font-weight:bold;float:
right;display:block;width:21px; height:21px; margin-right:15px"><img
style="height:13px" src="images/rightArrow.png" /></div>');
inserts the code from the first .header.
I tried this but after thinking about it I realize it is obviously
undefined. Is there a way to reference the current instance of the change
in a class wide modification?
So I'd like to add html on to every element with a certain class but the
way I call it:
$(".foldUpSection").find(".header").html($(".foldUpSection").find(".header").html()
+ '<div class="miniArrow" style="font-weight:bold;float:
right;display:block;width:21px; height:21px; margin-right:15px"><img
style="height:13px" src="images/rightArrow.png" /></div>');
inserts the code from the first .header.
I tried this but after thinking about it I realize it is obviously
undefined. Is there a way to reference the current instance of the change
in a class wide modification?
Cookie not geting saved on page reload
Cookie not geting saved on page reload
I have this code
$(document).ready(function () {
var d = new Date();
var newMinutes = d.getTimezoneOffset();
var storedMinutes = getCookieValue("tzom");
if (newMinutes != storedMinutes) {
setCookie("tzom", newMinutes);
alert("new" + newMinutes);
alert("stored" + storedMinutes);
document.location.reload(true);
}
});
What I'm trying to do here is check a timezone value in a cookie to see if
it is different to the current timezone set by the user. This will happen
if I user comes to the site and changes their timezone and then goes to
another page. If there is a difference then I set the cookie with the new
value and reload the page. The problem is that when I reload the page it
still shows that there is a difference in the timezones and so the page
reloads in an infinite loop. If I am somehow able to click on a different
page during this infinite loop then the looping stops.
What is wrong here?
EDIT
Rest of the code is here
function getCookieValue(c_name) {
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1) {
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1) {
c_value = null;
}
else {
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1) {
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start, c_end));
}
return c_value;
}
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" +
exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
I have this code
$(document).ready(function () {
var d = new Date();
var newMinutes = d.getTimezoneOffset();
var storedMinutes = getCookieValue("tzom");
if (newMinutes != storedMinutes) {
setCookie("tzom", newMinutes);
alert("new" + newMinutes);
alert("stored" + storedMinutes);
document.location.reload(true);
}
});
What I'm trying to do here is check a timezone value in a cookie to see if
it is different to the current timezone set by the user. This will happen
if I user comes to the site and changes their timezone and then goes to
another page. If there is a difference then I set the cookie with the new
value and reload the page. The problem is that when I reload the page it
still shows that there is a difference in the timezones and so the page
reloads in an infinite loop. If I am somehow able to click on a different
page during this infinite loop then the looping stops.
What is wrong here?
EDIT
Rest of the code is here
function getCookieValue(c_name) {
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1) {
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1) {
c_value = null;
}
else {
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1) {
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start, c_end));
}
return c_value;
}
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" +
exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
Writing an application to help administer SQL databases
Writing an application to help administer SQL databases
I currently have a collection of SQL scripts that are used routinely and I
would like to write an application where I can "plug-in" the values and
let the application handle running the code. I'd like to eliminate having
to open a SQL file, find the script, change the code accordingly, select
and run it.
My question is what language would best facilitate this? What are best
practices when doing something like this? I'm working in a Windows
environment, working on SQL 2008 R2 Servers. I have resources to learn on
the fly so the language isnt too big of a deal. Also, purchasing a tool is
out of the question.
Thanks in advance!
I currently have a collection of SQL scripts that are used routinely and I
would like to write an application where I can "plug-in" the values and
let the application handle running the code. I'd like to eliminate having
to open a SQL file, find the script, change the code accordingly, select
and run it.
My question is what language would best facilitate this? What are best
practices when doing something like this? I'm working in a Windows
environment, working on SQL 2008 R2 Servers. I have resources to learn on
the fly so the language isnt too big of a deal. Also, purchasing a tool is
out of the question.
Thanks in advance!
Paging issue when trying to use AJAX
Paging issue when trying to use AJAX
After a few hours of looking for an answer and reading numerous tutorials
on AJAX I feel it might be time to get an opinion or answer on my problem.
In the server side code I am calling a method which gets data back from a
database. The data is then stored within a session variable for later use
when filtering and searching for specific data.
When the page first loads the Index ActionResult goes through as intended
and paging works correctly. When I apply a search parameter the AJAX call
also gets hit and this returns the data. However, when I click the next
page button after the search has completed the AJAX check within the
controller isn't hit and instead bounces to the else statement.
Below is the code being used in the controller and JQuery within the view.
Please note, the JQuery is in the main view and not a separate JScript
file or Partial.
public ActionResult Index(Enums.OrderFilter? orderFilter, string
searchTerm, int? page)
{
if (Request.IsAjaxRequest())
{
List<PortalOrderHeader> customerOrders = null;
if (!string.IsNullOrEmpty(searchTerm))
{
customerOrders = GetDatabaseData.GetDataFromSession(searchTerm);
}
else
{
// work in progress
}
ViewBag.CurrentFilter = searchTerm;
var pagedList = customerOrders.ToPagedList(page ?? 1, 13);
return PartialView("_OrderResults", pagedList);
}
}
else
{
// Gets data from database on page load or if a switch statement returns
as true
customerOrders = GetDatabaseData.GetDataFromDatabaseDirectly();
}
function search() {
var searchterm = $("#search-textbox").val();
if (searchterm.length >= 2) {
$("#results").fadeOut('slow', function () {
$.ajax({
url: '@Url.Action("Index", "Orders")',
// Also tried using "url: '@Url.Action("Index", "Orders", new { page
= Model.PageNumber, searchTerm = ViewBag.CurrentFilter })'",
data: { searchTerm: searchterm },
type: 'POST',
success: function (data) {
$("#results").html(data);
},
error: function (jqXhr, textStatus, errorThrown) {
},
complete: function () {
$("#search-button").removeClass('disabled');
$("#results").fadeIn('slow');
}
});
I believe I've narrowed down the issue to the paging buttons but I've had
no luck resolving the problem. When I inspect the element after the first
ajax call the ViewBag.CurrentFilter and Model.PageNumber are within the
button, however when you press the button the else statement it seems to
forget everything it had in prior to the button being pressed.
@Html.ActionLink("Next", "Index", new{page = Model.PageNumber + 1,
searchTerm = ViewBag.CurrentFilter, filterSetting = ViewBag.FilterSetting},
new { @class = "paging", data_direction = "next" })
After a few hours of looking for an answer and reading numerous tutorials
on AJAX I feel it might be time to get an opinion or answer on my problem.
In the server side code I am calling a method which gets data back from a
database. The data is then stored within a session variable for later use
when filtering and searching for specific data.
When the page first loads the Index ActionResult goes through as intended
and paging works correctly. When I apply a search parameter the AJAX call
also gets hit and this returns the data. However, when I click the next
page button after the search has completed the AJAX check within the
controller isn't hit and instead bounces to the else statement.
Below is the code being used in the controller and JQuery within the view.
Please note, the JQuery is in the main view and not a separate JScript
file or Partial.
public ActionResult Index(Enums.OrderFilter? orderFilter, string
searchTerm, int? page)
{
if (Request.IsAjaxRequest())
{
List<PortalOrderHeader> customerOrders = null;
if (!string.IsNullOrEmpty(searchTerm))
{
customerOrders = GetDatabaseData.GetDataFromSession(searchTerm);
}
else
{
// work in progress
}
ViewBag.CurrentFilter = searchTerm;
var pagedList = customerOrders.ToPagedList(page ?? 1, 13);
return PartialView("_OrderResults", pagedList);
}
}
else
{
// Gets data from database on page load or if a switch statement returns
as true
customerOrders = GetDatabaseData.GetDataFromDatabaseDirectly();
}
function search() {
var searchterm = $("#search-textbox").val();
if (searchterm.length >= 2) {
$("#results").fadeOut('slow', function () {
$.ajax({
url: '@Url.Action("Index", "Orders")',
// Also tried using "url: '@Url.Action("Index", "Orders", new { page
= Model.PageNumber, searchTerm = ViewBag.CurrentFilter })'",
data: { searchTerm: searchterm },
type: 'POST',
success: function (data) {
$("#results").html(data);
},
error: function (jqXhr, textStatus, errorThrown) {
},
complete: function () {
$("#search-button").removeClass('disabled');
$("#results").fadeIn('slow');
}
});
I believe I've narrowed down the issue to the paging buttons but I've had
no luck resolving the problem. When I inspect the element after the first
ajax call the ViewBag.CurrentFilter and Model.PageNumber are within the
button, however when you press the button the else statement it seems to
forget everything it had in prior to the button being pressed.
@Html.ActionLink("Next", "Index", new{page = Model.PageNumber + 1,
searchTerm = ViewBag.CurrentFilter, filterSetting = ViewBag.FilterSetting},
new { @class = "paging", data_direction = "next" })
Thursday, 26 September 2013
How to run a SQL query automatically on Date basis?
How to run a SQL query automatically on Date basis?
I want to run a timely based query that will run every day at a given
time. How can I do it? Can it be possible with trigger?
I want to run a timely based query that will run every day at a given
time. How can I do it? Can it be possible with trigger?
Thursday, 19 September 2013
UIScrollView Horizontal Scroll Thumb in the Vertical Track
UIScrollView Horizontal Scroll Thumb in the Vertical Track
If an insane client had asked for this functionality, I would have told
him it was impossible.
Yet here I have your everyday UITableView inside a UIScrollView, setup in
Interface Builder. The scroll view has vertical scrolling enabled, but not
horizontal. So what the heck is THIS:
Note the bottom right -- that capsule is the visible scroll thumb in a
horizontal orientation. If you scroll the table view up and down, that
thumb moves left and right... INSIDE THE VERTICAL SCROLL TRACK. The width
of the track is the complete representation of the height of the scroll
view's contents; I scroll to the top of the table view, and the thumb
moves to the left, so I can just see the right side of that capsule shape.
This has to be some kind of weird bug, right? Any ideas how to shake this
loose?
If an insane client had asked for this functionality, I would have told
him it was impossible.
Yet here I have your everyday UITableView inside a UIScrollView, setup in
Interface Builder. The scroll view has vertical scrolling enabled, but not
horizontal. So what the heck is THIS:
Note the bottom right -- that capsule is the visible scroll thumb in a
horizontal orientation. If you scroll the table view up and down, that
thumb moves left and right... INSIDE THE VERTICAL SCROLL TRACK. The width
of the track is the complete representation of the height of the scroll
view's contents; I scroll to the top of the table view, and the thumb
moves to the left, so I can just see the right side of that capsule shape.
This has to be some kind of weird bug, right? Any ideas how to shake this
loose?
does not show up
does not show up
I am trying to get some rich snipped code on my wordpress site, but I
can´t get it to work. I have got several articles that are reviews, so my
aim is to add some micro data for itemtype="http://schema.org/Review". You
can check this article for testing and see how the code shows up on the
internet browser. Notice that the bit missing on the browser is .
This is the code I have on my theme sigle_post.php file:
<!-- review box -->
<div class="reviewbox">
<div itemscope="itemscope"
itemtype="http://schema.org/Review">
<!-- Este es el nuevo título para las reviews -->
<div class="review_header">
<h3> Review:
<span itemprop="itemreviewed">
<?php $review_product =
get_post_custom_values('reviewproductthemeloy_text');
echo $review_product[0];
?></span></h3><h4> por <span
itemprop="reviewer"> <?php
$review_author =
get_post_custom_values('reviewauthorthemeloy_text');
echo $review_author[0];
?>
</span>
el <span itemprop="dtreviewed"><?php echo
get_the_date('Y-m-d'); ?></span></h4></div>
<ul class="progress-bar">
<?php
for($i=0; $i<10; $i++)
{
$rate_value =
'criteria'.$i.'themeloy_slider';
$text_value =
'criteria'.$i.'themeloy_text';
$rate =
get_post_custom_values($rate_value);
$rating_text =
get_post_custom_values($text_value);
if(!empty($rate[0]) &&
!empty($rating_text[0]) &&
$rate[0] >0)
{
?>
<li class="meter">
<div class="meter-content"
style="width:<?php echo $rate[0];
?>%"></div>
<span class="meter-title"><?php echo
$rating_text[0]; ?> <span
itemprop="rating"><span itemprop="average">
<?php echo $rate[0]; ?><meta itemprop="best"
content="100"/><meta itemprop="worst"
content="0"/>%</span></span>
</li>
<?php
}
}
?>
if(!empty($rate2[0]) && !empty($rating_text2[0]) &&
$rate2[0] >0) { ?>
<li class="meter">
<div class="meter-content"
style="width:<?php echo
themeloy_get_total_review($post_id);
?>%"></div>
<span class="meter-title"><?php _e('Total
Score', 'tl_back'); ?> <?php
echo $total_review; ?>%</span>
</li>
<?php } ?>
</ul>
<?php if($review_summer =
get_post_custom_values('review_themeloy_wysiwyg')){?>
<div class="review-summery">
<h4><?php $review_title =
get_post_custom_values('reviewtitlethemeloy_text');
echo $review_title[0]; ?></h4>
<span itemprop="summary"> <?php echo
$review_summer[0]; ?></span>
</div>
<?php }?>
<?php $userreview =
get_post_custom_values('userreviewthemeloy_checkbox');
?>
<?php if( of_get_option('user_disable_review')
== 0) { ?>
<?php if($userreview[0] == 1) { ?>
<div class="clearfix"></div>
<div class="votebox">
<div id="votecount"><img src="<?php echo
get_template_directory_uri();
?>/img/ajax-loading.gif" /> <span
class="user-rate-summery"> <?php
_e('Valoración de los lectores: ',
'tl_back'); ?> </span> <span
class="vote-per"><?php echo
themeloy_get_user_review($post_id);
?></span>% ( <span
class="vote-count"><?php echo $user_vote
=
absint(get_post_meta($post_id,'votes_count',
true )); ?></span> </div>
<span class="vote-label"><?php _e(' votos
)', 'tl_back'); ?></span>
<div id="star" data-readonly="<?php echo
themeloy_vote_response($post_id); ?>"
data-score="<?php echo
(themeloy_get_user_review($post_id) /
20); ?>" data-postid="<?php the_ID(); ?>"
data-path="<?php echo
get_template_directory_uri(); ?>/img">
</div>
</div>
<?php } } ?>
</div>
</div>
<!-- close review box -->
This is what I get on my firefox browser:
<!-- review box -->
<div class="reviewbox">
<!-- Este es el nuevo título para las reviews -->
<div class="review_header">
<h3> Review:
<span itemprop="itemreviewed">
GT Avalanche 1.0</span></h3><h4> por
<span itemprop="reviewer"> BiciReview
</span>
el <span
itemprop="dtreviewed">2013-09-16</span></h4></div>
<ul class="progress-bar">
<li class="meter">
<div class="meter-content"
style="width:90%"></div>
<span class="meter-title"> <span
itemprop="rating"><span itemprop="average">
90<meta itemprop="best" content="100"/><meta
itemprop="worst"
content="0"/>%</span></span>
</li>
</ul>
<div
class="review-summery">
<h4> Veredicto</h4>
<span itemprop="summary"> <p>Una bicicleta
que puede darnos un buen rendimiento, siempre
que no vayamos a realizar trazados muy
exigentes. Pero ten en cuenta que estamos
hablando de una bici de rango medio.</p>
<div class="clearfix"></div>
<div class="votebox">
<div id="votecount"><img
src="http://bicireview.com/wp-content/themes/themerush/img/ajax-loading.gif"
/> <span class="user-rate-summery">
Valoración de los lectores: </span>
<span class="vote-per">0.00</span>% (
<span class="vote-count">0</span> </div>
<span class="vote-label"> votos )</span>
<div id="star" data-readonly="0"
data-score="0" data-postid="1220"
data-path="http://bicireview.com/wp-content/themes/themerush/img">
</div>
</div>
</div>
<!-- close review box -->
I want to thank in advance all you for your time, and excuse me if have
not explain myself enough.
Regards
Borja
I am trying to get some rich snipped code on my wordpress site, but I
can´t get it to work. I have got several articles that are reviews, so my
aim is to add some micro data for itemtype="http://schema.org/Review". You
can check this article for testing and see how the code shows up on the
internet browser. Notice that the bit missing on the browser is .
This is the code I have on my theme sigle_post.php file:
<!-- review box -->
<div class="reviewbox">
<div itemscope="itemscope"
itemtype="http://schema.org/Review">
<!-- Este es el nuevo título para las reviews -->
<div class="review_header">
<h3> Review:
<span itemprop="itemreviewed">
<?php $review_product =
get_post_custom_values('reviewproductthemeloy_text');
echo $review_product[0];
?></span></h3><h4> por <span
itemprop="reviewer"> <?php
$review_author =
get_post_custom_values('reviewauthorthemeloy_text');
echo $review_author[0];
?>
</span>
el <span itemprop="dtreviewed"><?php echo
get_the_date('Y-m-d'); ?></span></h4></div>
<ul class="progress-bar">
<?php
for($i=0; $i<10; $i++)
{
$rate_value =
'criteria'.$i.'themeloy_slider';
$text_value =
'criteria'.$i.'themeloy_text';
$rate =
get_post_custom_values($rate_value);
$rating_text =
get_post_custom_values($text_value);
if(!empty($rate[0]) &&
!empty($rating_text[0]) &&
$rate[0] >0)
{
?>
<li class="meter">
<div class="meter-content"
style="width:<?php echo $rate[0];
?>%"></div>
<span class="meter-title"><?php echo
$rating_text[0]; ?> <span
itemprop="rating"><span itemprop="average">
<?php echo $rate[0]; ?><meta itemprop="best"
content="100"/><meta itemprop="worst"
content="0"/>%</span></span>
</li>
<?php
}
}
?>
if(!empty($rate2[0]) && !empty($rating_text2[0]) &&
$rate2[0] >0) { ?>
<li class="meter">
<div class="meter-content"
style="width:<?php echo
themeloy_get_total_review($post_id);
?>%"></div>
<span class="meter-title"><?php _e('Total
Score', 'tl_back'); ?> <?php
echo $total_review; ?>%</span>
</li>
<?php } ?>
</ul>
<?php if($review_summer =
get_post_custom_values('review_themeloy_wysiwyg')){?>
<div class="review-summery">
<h4><?php $review_title =
get_post_custom_values('reviewtitlethemeloy_text');
echo $review_title[0]; ?></h4>
<span itemprop="summary"> <?php echo
$review_summer[0]; ?></span>
</div>
<?php }?>
<?php $userreview =
get_post_custom_values('userreviewthemeloy_checkbox');
?>
<?php if( of_get_option('user_disable_review')
== 0) { ?>
<?php if($userreview[0] == 1) { ?>
<div class="clearfix"></div>
<div class="votebox">
<div id="votecount"><img src="<?php echo
get_template_directory_uri();
?>/img/ajax-loading.gif" /> <span
class="user-rate-summery"> <?php
_e('Valoración de los lectores: ',
'tl_back'); ?> </span> <span
class="vote-per"><?php echo
themeloy_get_user_review($post_id);
?></span>% ( <span
class="vote-count"><?php echo $user_vote
=
absint(get_post_meta($post_id,'votes_count',
true )); ?></span> </div>
<span class="vote-label"><?php _e(' votos
)', 'tl_back'); ?></span>
<div id="star" data-readonly="<?php echo
themeloy_vote_response($post_id); ?>"
data-score="<?php echo
(themeloy_get_user_review($post_id) /
20); ?>" data-postid="<?php the_ID(); ?>"
data-path="<?php echo
get_template_directory_uri(); ?>/img">
</div>
</div>
<?php } } ?>
</div>
</div>
<!-- close review box -->
This is what I get on my firefox browser:
<!-- review box -->
<div class="reviewbox">
<!-- Este es el nuevo título para las reviews -->
<div class="review_header">
<h3> Review:
<span itemprop="itemreviewed">
GT Avalanche 1.0</span></h3><h4> por
<span itemprop="reviewer"> BiciReview
</span>
el <span
itemprop="dtreviewed">2013-09-16</span></h4></div>
<ul class="progress-bar">
<li class="meter">
<div class="meter-content"
style="width:90%"></div>
<span class="meter-title"> <span
itemprop="rating"><span itemprop="average">
90<meta itemprop="best" content="100"/><meta
itemprop="worst"
content="0"/>%</span></span>
</li>
</ul>
<div
class="review-summery">
<h4> Veredicto</h4>
<span itemprop="summary"> <p>Una bicicleta
que puede darnos un buen rendimiento, siempre
que no vayamos a realizar trazados muy
exigentes. Pero ten en cuenta que estamos
hablando de una bici de rango medio.</p>
<div class="clearfix"></div>
<div class="votebox">
<div id="votecount"><img
src="http://bicireview.com/wp-content/themes/themerush/img/ajax-loading.gif"
/> <span class="user-rate-summery">
Valoración de los lectores: </span>
<span class="vote-per">0.00</span>% (
<span class="vote-count">0</span> </div>
<span class="vote-label"> votos )</span>
<div id="star" data-readonly="0"
data-score="0" data-postid="1220"
data-path="http://bicireview.com/wp-content/themes/themerush/img">
</div>
</div>
</div>
<!-- close review box -->
I want to thank in advance all you for your time, and excuse me if have
not explain myself enough.
Regards
Borja
Get list from enum [on hold]
Get list from enum [on hold]
public enum MyEnum
{
A,
Ab,
Abc,
Abcd,
Abcde
}
Using LINQ, I want to extract a list from MyEnum that contains all the
items of MyEnum exept the items Ab and Abc.
public enum MyEnum
{
A,
Ab,
Abc,
Abcd,
Abcde
}
Using LINQ, I want to extract a list from MyEnum that contains all the
items of MyEnum exept the items Ab and Abc.
Playing a MP3 Stream in a C# Application
Playing a MP3 Stream in a C# Application
Is there a library where I can stream & play the following link (Pause,
Play, Forward, Back) full control on song etc and of course playing it..
http://stream.vkdownload.net/cs536519v4/u173702374/cb6a320ef08a.mp3
Thanks! i'm using WinForms C#
Is there a library where I can stream & play the following link (Pause,
Play, Forward, Back) full control on song etc and of course playing it..
http://stream.vkdownload.net/cs536519v4/u173702374/cb6a320ef08a.mp3
Thanks! i'm using WinForms C#
Desing of form in spring
Desing of form in spring
I am using spring framework. This question mainly concerns about design
and implementation.
In my project, I have to use many forms and most of them are different.
What is the recommended way of implementing forms in spring. Using Model?
I want to use ajax for forms submissions. The forms in the project are
really huge having 8-15 fields. Is it a good way to use ajax for such huge
forms? If yes, how can I do it? Can I use model attribute?
I am using spring framework. This question mainly concerns about design
and implementation.
In my project, I have to use many forms and most of them are different.
What is the recommended way of implementing forms in spring. Using Model?
I want to use ajax for forms submissions. The forms in the project are
really huge having 8-15 fields. Is it a good way to use ajax for such huge
forms? If yes, how can I do it? Can I use model attribute?
OMA CP on BlackBerry OS10
OMA CP on BlackBerry OS10
I am trying to provision BB10 devices OTA with an OMACP XML. I need to
know if BB10 supports OMACP or not.
Best Regards.
I am trying to provision BB10 devices OTA with an OMACP XML. I need to
know if BB10 supports OMACP or not.
Best Regards.
Are the results of x++, x++; and x = x++; undefined?
Are the results of x++, x++; and x = x++; undefined?
The following code can be compiled with VC++ 2013 RC.
int x = 0;
x++, x++;
x = x++;
However, someone said the results of these statements are not defined by
the C or C++ standard. Is it true or false?
The following code can be compiled with VC++ 2013 RC.
int x = 0;
x++, x++;
x = x++;
However, someone said the results of these statements are not defined by
the C or C++ standard. Is it true or false?
Inconsolata font not displaying fine in VS 2013
Inconsolata font not displaying fine in VS 2013
I was using the Inconsolata in VS2012 as it is a very nice font for
programming.
But now VS2013 is not displaying it very nicely. See the image. It's
displaying a bit smaller, a bit more roughly. Any ideas?
UPDATE
I took another close look at the image at pixel level and I found that the
characters are rendered exactly the same. The only big difference is that
in VS2012 there is 1 pixel between each character, while in VS2013 there
is no pixel in between.
I was using the Inconsolata in VS2012 as it is a very nice font for
programming.
But now VS2013 is not displaying it very nicely. See the image. It's
displaying a bit smaller, a bit more roughly. Any ideas?
UPDATE
I took another close look at the image at pixel level and I found that the
characters are rendered exactly the same. The only big difference is that
in VS2012 there is 1 pixel between each character, while in VS2013 there
is no pixel in between.
Wednesday, 18 September 2013
How can i transfer files from Windows machine to linux machine using Windows Outlook 2010
How can i transfer files from Windows machine to linux machine using
Windows Outlook 2010
I'm looking for a VBA script which can transfer files from my windows
outlook mail box to a linux machine that is residing in a another server.
I'm wondering if this is possible?
I've got a VBA to transfer files from my outlook to a windows share but
failed at linux implementation. The reason why i'm looking to work on
outlook is I've a scheduled reports which comes to my mail box and they
have to be transferred to linux machine.
I've got an access to the linux server using putty and FTP.Please if
someone can assist me on this would be really appreciated.
-Shiva
Windows Outlook 2010
I'm looking for a VBA script which can transfer files from my windows
outlook mail box to a linux machine that is residing in a another server.
I'm wondering if this is possible?
I've got a VBA to transfer files from my outlook to a windows share but
failed at linux implementation. The reason why i'm looking to work on
outlook is I've a scheduled reports which comes to my mail box and they
have to be transferred to linux machine.
I've got an access to the linux server using putty and FTP.Please if
someone can assist me on this would be really appreciated.
-Shiva
Foundation 4 - Sections- Centering Tabs
Foundation 4 - Sections- Centering Tabs
Problem: Attempting to Create 6 centered tabs in a row, however because I
can't keep all 6 tabs on the same row. It does center the tabs, however
pushes 2 of the tabs one line below and leaves an extra empty cell on the
first line.
I tried using small-centered and made no difference.
Version: Foundation 4
Browser: Chrome - Latest
Code
<div class="row">
<div class="large-6 large-centered columns">
<div class="section-container horizontal-nav"
data-section="horizontal-nav" >
<section class="section">
<p class="title"><a href="#">Tab 1</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 2</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 3</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 4</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 5</a></p >
</section>
<section class="section">
<p class="title"><a href="#">Tab 6</a></p>
</section>
</div>
</div>
</div>
Problem: Attempting to Create 6 centered tabs in a row, however because I
can't keep all 6 tabs on the same row. It does center the tabs, however
pushes 2 of the tabs one line below and leaves an extra empty cell on the
first line.
I tried using small-centered and made no difference.
Version: Foundation 4
Browser: Chrome - Latest
Code
<div class="row">
<div class="large-6 large-centered columns">
<div class="section-container horizontal-nav"
data-section="horizontal-nav" >
<section class="section">
<p class="title"><a href="#">Tab 1</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 2</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 3</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 4</a></p>
</section>
<section class="section">
<p class="title"><a href="#">Tab 5</a></p >
</section>
<section class="section">
<p class="title"><a href="#">Tab 6</a></p>
</section>
</div>
</div>
</div>
JS selected item not showing properly in css menu
JS selected item not showing properly in css menu
Here is my css
#myMenu ul li { display: inline; }
#myMenu ul li a {
background-color:#333333;
text-transform: uppercase;
font-weight: bold;
font-family: "Open Sans",Arial,sans-serif;
font-size:12px;
text-decoration: none;
padding: 1em 2em;
color: #000000;
border-left:1px solid #333333;
border-right:1px solid #333333;
border-top:1px solid #333333;
}
#myMenu ul li a:hover
{
color: #fff;
background-color: #999999;
}
.selection{
background-color: #000000;
border-bottom:10px solid #000000;
border-top:9px solid #000000;
}
here is my code.
<div align="right" id="myMenu">
<ul>
<li><a href="#"
data-id="appstructurediv">Structure</a></li>
<li id="style"><a href="#"
data-id="appstylediv">Style</a></li>
<li><a href="#" data-id="appdetailsdiv">Details</a></li>
</ul>
javascript
$(function () {
$("li:first-child").addClass("selection");
$('li').click(function () {
$('#myMenu li').removeClass('selection');
$(this).addClass('selection');
});
});
i want to add black colour to selected items background. but above code is
not working. if i remove,background-color:#333333 from #myMenu ul li a it
works. any help...
Here is my css
#myMenu ul li { display: inline; }
#myMenu ul li a {
background-color:#333333;
text-transform: uppercase;
font-weight: bold;
font-family: "Open Sans",Arial,sans-serif;
font-size:12px;
text-decoration: none;
padding: 1em 2em;
color: #000000;
border-left:1px solid #333333;
border-right:1px solid #333333;
border-top:1px solid #333333;
}
#myMenu ul li a:hover
{
color: #fff;
background-color: #999999;
}
.selection{
background-color: #000000;
border-bottom:10px solid #000000;
border-top:9px solid #000000;
}
here is my code.
<div align="right" id="myMenu">
<ul>
<li><a href="#"
data-id="appstructurediv">Structure</a></li>
<li id="style"><a href="#"
data-id="appstylediv">Style</a></li>
<li><a href="#" data-id="appdetailsdiv">Details</a></li>
</ul>
javascript
$(function () {
$("li:first-child").addClass("selection");
$('li').click(function () {
$('#myMenu li').removeClass('selection');
$(this).addClass('selection');
});
});
i want to add black colour to selected items background. but above code is
not working. if i remove,background-color:#333333 from #myMenu ul li a it
works. any help...
Get list of Virtual directories from IIS using comand prompt
Get list of Virtual directories from IIS using comand prompt
Is there a way to get a list of Virtual directories under a specific
website in IIS using the command prompt. I was able to perform the task
using C# but I have a specific requirement where-in I need to list all the
virtual directories under a website using the command prompt.
Is there a way to get a list of Virtual directories under a specific
website in IIS using the command prompt. I was able to perform the task
using C# but I have a specific requirement where-in I need to list all the
virtual directories under a website using the command prompt.
OutOfMemory Android Error
OutOfMemory Android Error
I have a camera application that I'm trying to make and I've just started,
but I keep running into an error when I try to take the second picture. Am
I not recycling the bitmap properly?
private PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
capture.setVisibility(View.INVISIBLE); //hide on screen icons
photo = BitmapFactory.decodeByteArray(data, 0, data.length);
Toast.makeText(getApplicationContext(), "Picture Size: " +
photo.getWidth() + " x " + photo.getHeight(),
Toast.LENGTH_SHORT).show();
//show ScrollView with options
dialog.setContentView(R.layout.dialog_preview);
dialog.setCancelable(true);
dialog.show();
//final ImageView preview =
(ImageView)dialog.findViewById(R.id.preview);
//preview.setImageBitmap(photo);
dialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
Toast.makeText(context, "Dialog was canceled",
Toast.LENGTH_SHORT).show();
//photo = null;
photo.recycle();
capture.setVisibility(View.VISIBLE); //show on screen
icons
mCamera.startPreview(); //resume preview
dialog.cancel();
}
});
}
}; //end PictureCallback
I have a camera application that I'm trying to make and I've just started,
but I keep running into an error when I try to take the second picture. Am
I not recycling the bitmap properly?
private PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
capture.setVisibility(View.INVISIBLE); //hide on screen icons
photo = BitmapFactory.decodeByteArray(data, 0, data.length);
Toast.makeText(getApplicationContext(), "Picture Size: " +
photo.getWidth() + " x " + photo.getHeight(),
Toast.LENGTH_SHORT).show();
//show ScrollView with options
dialog.setContentView(R.layout.dialog_preview);
dialog.setCancelable(true);
dialog.show();
//final ImageView preview =
(ImageView)dialog.findViewById(R.id.preview);
//preview.setImageBitmap(photo);
dialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
Toast.makeText(context, "Dialog was canceled",
Toast.LENGTH_SHORT).show();
//photo = null;
photo.recycle();
capture.setVisibility(View.VISIBLE); //show on screen
icons
mCamera.startPreview(); //resume preview
dialog.cancel();
}
});
}
}; //end PictureCallback
error when converting from PDF to XML
error when converting from PDF to XML
Our company has an in house tool that converts from PDF to XML but the
process comes to a hault when this guy pops up :
"System.Runtime.InteropServices.COMException (0x000003E9): TypeError:
theDoc.xfa is undefined"
Anyone know what the issue is here?
Thanks
Our company has an in house tool that converts from PDF to XML but the
process comes to a hault when this guy pops up :
"System.Runtime.InteropServices.COMException (0x000003E9): TypeError:
theDoc.xfa is undefined"
Anyone know what the issue is here?
Thanks
How to convert QPixmap (".GIF") in QByteArray?
How to convert QPixmap (".GIF") in QByteArray?
I'm having trouble converting a QPixmap in QByteArray, when the format of
QPixmap is "GIF"
For formats such as PNG and JPG I can convert QByteArray quietly.
I'm having trouble converting a QPixmap in QByteArray, when the format of
QPixmap is "GIF"
For formats such as PNG and JPG I can convert QByteArray quietly.
Get variable current memory space in PHP
Get variable current memory space in PHP
SO,
The problem
I have need in determining variable space used in script in certain
moment. The variable is normal PHP variable - so it can be anything
(array, object, resource e t.c.). As a result i want some function - let
it be called getMemorySpace - and should return integer value as a number
of bytes, which are used for variable in current moment.
My approach
I know that the easiest way to do this is to use memory_get_usage() with
combination of unset() and copying variable (and, probably,
gc_collect_cycles()). But this method has a serious problem: imagine that
we have X Mbytes memory limitation for our script and checked variable, of
cause, fit this requirement. If we'll try to act as described above with
memory_get_usage() - we'll face a problem for all variables that are
larger than X/2, cause first we need to copy our variable (before
destroying it). So, such way will result it memory overflow.
Specifics
As I've searched from google (which actually is a front-end for SO in such
cases) - get memory space is a problem in PHP with native methods. For
example, if we have an array, then one of solutions is to walk recursively
and gather information about element's size (that would be strlen() for
strings and standard sizes for other data types).
But the problem is more complicated since I want to know that size even if
it's object, callback or even resource. In fact, approximately (but
precise till corresponding unit - for example, if we're measuring in
Mbytes, than it should be +/- 1Mbyte in result) solution will also be good
- but I have no clue - how to do this in other way that those described
above. This is the only reason I've not provided any PHP code.
I'm using PHP 5.5 and so answer could rely on that (if it matters).
SO,
The problem
I have need in determining variable space used in script in certain
moment. The variable is normal PHP variable - so it can be anything
(array, object, resource e t.c.). As a result i want some function - let
it be called getMemorySpace - and should return integer value as a number
of bytes, which are used for variable in current moment.
My approach
I know that the easiest way to do this is to use memory_get_usage() with
combination of unset() and copying variable (and, probably,
gc_collect_cycles()). But this method has a serious problem: imagine that
we have X Mbytes memory limitation for our script and checked variable, of
cause, fit this requirement. If we'll try to act as described above with
memory_get_usage() - we'll face a problem for all variables that are
larger than X/2, cause first we need to copy our variable (before
destroying it). So, such way will result it memory overflow.
Specifics
As I've searched from google (which actually is a front-end for SO in such
cases) - get memory space is a problem in PHP with native methods. For
example, if we have an array, then one of solutions is to walk recursively
and gather information about element's size (that would be strlen() for
strings and standard sizes for other data types).
But the problem is more complicated since I want to know that size even if
it's object, callback or even resource. In fact, approximately (but
precise till corresponding unit - for example, if we're measuring in
Mbytes, than it should be +/- 1Mbyte in result) solution will also be good
- but I have no clue - how to do this in other way that those described
above. This is the only reason I've not provided any PHP code.
I'm using PHP 5.5 and so answer could rely on that (if it matters).
Tuesday, 17 September 2013
The address of the Web Page is wrong after login
The address of the Web Page is wrong after login
I am using asp.net and i am trying to login from the fancy box. I have
code sample like this :
function (LoginResponse) {
$.each(LoginResponse, function () {
if (this["IsLogin"] == "true") {
window.location.reload(true);
window.location.href =
"Account/MyProfile.aspx";
}
else {
jAlert('Warning!', 'Invalid login
Credintials', 'Please enter valid Username
and Password..', 'yellow');
}
clear_form_elements('#UserLoginSection');
//Clears the element of the form
});
}
);
Some time it goes well with this address "Account/MyProfile.aspx" But some
time The Address wrong and in the address bar something like this come
again and again "Account/Account/MyProfile.aspx" There should not be
Double Account meaning "Account/MyProfile.aspx" should be there. and I
have tried to remove Account in the javascript function above But some
time it works well but some time it does not. What i have to do please
help me.
I am using asp.net and i am trying to login from the fancy box. I have
code sample like this :
function (LoginResponse) {
$.each(LoginResponse, function () {
if (this["IsLogin"] == "true") {
window.location.reload(true);
window.location.href =
"Account/MyProfile.aspx";
}
else {
jAlert('Warning!', 'Invalid login
Credintials', 'Please enter valid Username
and Password..', 'yellow');
}
clear_form_elements('#UserLoginSection');
//Clears the element of the form
});
}
);
Some time it goes well with this address "Account/MyProfile.aspx" But some
time The Address wrong and in the address bar something like this come
again and again "Account/Account/MyProfile.aspx" There should not be
Double Account meaning "Account/MyProfile.aspx" should be there. and I
have tried to remove Account in the javascript function above But some
time it works well but some time it does not. What i have to do please
help me.
Check many keys in dictionary: optimization
Check many keys in dictionary: optimization
Is there a better way to write the following:
if "msg" in response_dic or "save_act_errors" in response_dic or
"add_act_errors" in response_dic or "modif_act_errors" in response_dic
or "update_act_errors" in response_dic:
#do stuff
response_dic is a dictionary, I am checking for keys.
Is there a better way to write the following:
if "msg" in response_dic or "save_act_errors" in response_dic or
"add_act_errors" in response_dic or "modif_act_errors" in response_dic
or "update_act_errors" in response_dic:
#do stuff
response_dic is a dictionary, I am checking for keys.
How to recreate primary after dropping primary key column?
How to recreate primary after dropping primary key column?
I would like to recreate a primary key column in pg 8.4. But the query i
am trying does not work ( it does not execute actually):
update beta
set id=rown
from
(select row_number() as rown
from beta as b over (order by b.id) -- b.id is null on all rows
) q;
I would like to recreate a primary key column in pg 8.4. But the query i
am trying does not work ( it does not execute actually):
update beta
set id=rown
from
(select row_number() as rown
from beta as b over (order by b.id) -- b.id is null on all rows
) q;
Can all of this be done in one function?
Can all of this be done in one function?
I have not found a way to do this. I have a large SQL statement that does
the following:
checks for two temp tables, if found deletes them
Declares local variables
Sets local variables
runs SQL statement1 which inserts into #tmp1 (temp table)
runs SQL statement2 which inserts into #tmp2 (temp table)
runs SQL statement3 which selects from #tmp1 and #temp2 (temp table) and
returns pivot results
Running this in a query window works fine but I'd like to make one
function (or something) to do the same.
EDIT1: I seem to be able to call a table function from excel and return
those results but I can't call a stored proc from excel, I get an error.
The problem with the table function is that I can't delete (drop) tables.
I have not found a way to do this. I have a large SQL statement that does
the following:
checks for two temp tables, if found deletes them
Declares local variables
Sets local variables
runs SQL statement1 which inserts into #tmp1 (temp table)
runs SQL statement2 which inserts into #tmp2 (temp table)
runs SQL statement3 which selects from #tmp1 and #temp2 (temp table) and
returns pivot results
Running this in a query window works fine but I'd like to make one
function (or something) to do the same.
EDIT1: I seem to be able to call a table function from excel and return
those results but I can't call a stored proc from excel, I get an error.
The problem with the table function is that I can't delete (drop) tables.
Read properties and call methods from another object Javascript Prototype Pattern
Read properties and call methods from another object Javascript Prototype
Pattern
Im trying to get how can I access properties from another constructor. I
want to separate objects like App, Effects, Utils for example and call
properties and methods from one to another. Is that possible, or is this
way completely wrong way?
var App = function() {
this.someProperty = 'Lorem';
this.init();
};
App.prototype = {
init:function(){
this.bindEvents();
},
bindEvents:function(){
var self = this;
$(window).on('resize', function(e) {
e.preventDefault();
this.windowWidth = $(window).width();
// Is that Correct?
Utils.prototype.resizeElement(this.windowWidth);
});
}
};
var Utils = function(){};
Utils.prototype = {
resizeElement: function(windowW){
console.log(windowW);
},
someMethod:function(){
// How can i access property written in App constructor?
console.log(this.someProperty);
}
};
var Effects = function(){
this.init();
};
Effects.prototype = {
hideElement:function(ele){
$(ele).hide();
}
};
var app = new App();
Pattern
Im trying to get how can I access properties from another constructor. I
want to separate objects like App, Effects, Utils for example and call
properties and methods from one to another. Is that possible, or is this
way completely wrong way?
var App = function() {
this.someProperty = 'Lorem';
this.init();
};
App.prototype = {
init:function(){
this.bindEvents();
},
bindEvents:function(){
var self = this;
$(window).on('resize', function(e) {
e.preventDefault();
this.windowWidth = $(window).width();
// Is that Correct?
Utils.prototype.resizeElement(this.windowWidth);
});
}
};
var Utils = function(){};
Utils.prototype = {
resizeElement: function(windowW){
console.log(windowW);
},
someMethod:function(){
// How can i access property written in App constructor?
console.log(this.someProperty);
}
};
var Effects = function(){
this.init();
};
Effects.prototype = {
hideElement:function(ele){
$(ele).hide();
}
};
var app = new App();
select2-jquery: How to set maximumselectionsize dynamically
select2-jquery: How to set maximumselectionsize dynamically
I've a requirement where I'll decide Max selections to be allowed in
select2 ui.How can I do that. I tried by
$('#ChnageLnk').on('click',function(){
$('#SelectD').select2({maximumselectionsize :1});
});
I've a requirement where I'll decide Max selections to be allowed in
select2 ui.How can I do that. I tried by
$('#ChnageLnk').on('click',function(){
$('#SelectD').select2({maximumselectionsize :1});
});
Sunday, 15 September 2013
Cell Array containing cell array
Cell Array containing cell array
I have a cell array containing 1x4 cells
A=
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
What i'm looking for is to make a cell array containing something like the
following
B={'str1','str2','str3','str4';cell2mat(A{1,1})}
A cell array comes from another operations where the size in rows and
columns can vary, so i would like to know weather or not this could be
automatized using a for loop or something like that.
I have a cell array containing 1x4 cells
A=
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
<1x4 cell> <1x4 cell> <1x4 cell>
What i'm looking for is to make a cell array containing something like the
following
B={'str1','str2','str3','str4';cell2mat(A{1,1})}
A cell array comes from another operations where the size in rows and
columns can vary, so i would like to know weather or not this could be
automatized using a for loop or something like that.
Is header redirection injectable
Is header redirection injectable
Its all begin with the a redirect function I have used to enable language
switching. I use header('Location: ' . $_SERVER['HTTP_REFERER']); to
redirect user back to his previous page which is redirected through
javascript window.location.href .
I've tried
$_SERVER['HTTP_REFERER']=');';
header('Location: ' . $_SERVER['HTTP_REFERER']);
and it redirected to an error page http://localhost/);
However I know that there might be some trick to make it a leakage,
therefore I'm asking is there any injection method to this? I won't mind
to let user modify their http_referer and send to an error page if the
code is not vulnerable.
Its all begin with the a redirect function I have used to enable language
switching. I use header('Location: ' . $_SERVER['HTTP_REFERER']); to
redirect user back to his previous page which is redirected through
javascript window.location.href .
I've tried
$_SERVER['HTTP_REFERER']=');';
header('Location: ' . $_SERVER['HTTP_REFERER']);
and it redirected to an error page http://localhost/);
However I know that there might be some trick to make it a leakage,
therefore I'm asking is there any injection method to this? I won't mind
to let user modify their http_referer and send to an error page if the
code is not vulnerable.
VBA Excel - Want to embed varying images into CDO email
VBA Excel - Want to embed varying images into CDO email
Ok, I have been working on this for a while now with no progress, so I'll
toss it to you guys. I am writing a program in VBA for Excel that sends
emails to customers. I would like to vary the images that the email sends
out. The only working way I've found to embed images is to reference a
site like imgur.com and embed it into an HTML email.
The code I am trying to make work is:
emailBody = emailBody & "<img src='Worksheet("Coupon Page").Cells(D,
i).Value'/>" & "<br/>"
It should add an image from the link in cell (D,i); where D is the column
title and 'i' is the variable that determines the image. It is throwing
errors when it hits the double quotes (") on Coupon Page saying it is
expecting the end of the expression. I'm not sure how to proceed here. I
don't know how else to make the image vary based on the variable 'i'. Any
thoughts or ideas would be very much appreciated!
Thanks!
Ok, I have been working on this for a while now with no progress, so I'll
toss it to you guys. I am writing a program in VBA for Excel that sends
emails to customers. I would like to vary the images that the email sends
out. The only working way I've found to embed images is to reference a
site like imgur.com and embed it into an HTML email.
The code I am trying to make work is:
emailBody = emailBody & "<img src='Worksheet("Coupon Page").Cells(D,
i).Value'/>" & "<br/>"
It should add an image from the link in cell (D,i); where D is the column
title and 'i' is the variable that determines the image. It is throwing
errors when it hits the double quotes (") on Coupon Page saying it is
expecting the end of the expression. I'm not sure how to proceed here. I
don't know how else to make the image vary based on the variable 'i'. Any
thoughts or ideas would be very much appreciated!
Thanks!
Data attribute value from MySQL
Data attribute value from MySQL
I'm new to PHP and MySQL so i'm not quite sure what i am doing wrong here.
I am using the jQuery plugin quicksand to create a filterable portfolio.
The plugin uses custom data attribute data-tag inside the li item to
populate the filter nav.
What I am trying to do is use a foreach loop to populate the contents of
the ul. The problem is that the filter nav won't auto populate when I use
php to get the value of the data attribute from the gallery_tag column in
my mySQL table.
<?php
$pagetitle = "Red Penguin - Our Work";
$navcurrent = "work";
$headTitle = "RECENT WORK";
$headsubTitle = "SOME OF OUR RECENT WORK";
include_once('includes/headersub.php');
include_once('includes/connection.php');
include_once('includes/project.php');
$project = new Project;
$projects = $project->fetch_all();
?>
<div class="row">
<nav id="filter"></nav>
<section id="container">
<ul id="stage" class="three-up">
<?php foreach($projects as $project) { ?>
<li class="gallerylist" data-tag="<?php echo
$project['gallery_tag']; ?>">
<a href="project.php?id=<?php echo $project['gallery_id'];
?>">
<img src="<?php echo $project['gallery_thumb']; ?> "
alt="<?php echo $project['gallery_proj']; ?>" />
<?php echo $project['gallery_title']; ?>
</a>
</li>
<?php } ?>
</ul>
</section>
The error that comes up in the log is in the jquery line:
tags = elem.data('tags').split(',');
I'm not quite sure why this is a conflict that causes the jquery to be
unable to read the value of the data-attribute as taken from the
gallery_tag column of my table. Any help would be appreciated.
I'm new to PHP and MySQL so i'm not quite sure what i am doing wrong here.
I am using the jQuery plugin quicksand to create a filterable portfolio.
The plugin uses custom data attribute data-tag inside the li item to
populate the filter nav.
What I am trying to do is use a foreach loop to populate the contents of
the ul. The problem is that the filter nav won't auto populate when I use
php to get the value of the data attribute from the gallery_tag column in
my mySQL table.
<?php
$pagetitle = "Red Penguin - Our Work";
$navcurrent = "work";
$headTitle = "RECENT WORK";
$headsubTitle = "SOME OF OUR RECENT WORK";
include_once('includes/headersub.php');
include_once('includes/connection.php');
include_once('includes/project.php');
$project = new Project;
$projects = $project->fetch_all();
?>
<div class="row">
<nav id="filter"></nav>
<section id="container">
<ul id="stage" class="three-up">
<?php foreach($projects as $project) { ?>
<li class="gallerylist" data-tag="<?php echo
$project['gallery_tag']; ?>">
<a href="project.php?id=<?php echo $project['gallery_id'];
?>">
<img src="<?php echo $project['gallery_thumb']; ?> "
alt="<?php echo $project['gallery_proj']; ?>" />
<?php echo $project['gallery_title']; ?>
</a>
</li>
<?php } ?>
</ul>
</section>
The error that comes up in the log is in the jquery line:
tags = elem.data('tags').split(',');
I'm not quite sure why this is a conflict that causes the jquery to be
unable to read the value of the data-attribute as taken from the
gallery_tag column of my table. Any help would be appreciated.
Draw tangent line on parametric curve with MatLab
Draw tangent line on parametric curve with MatLab
The question is very similar to this one but here I have parametric
equations such as:
x = sin(t)
y = cos(t)
How can I do this?
The question is very similar to this one but here I have parametric
equations such as:
x = sin(t)
y = cos(t)
How can I do this?
what does a question mark mean before a php form action
what does a question mark mean before a php form action
<form action="?login" method="POST">
<button>Login with Google</button>
</form>
I have seen many different actions for a form action that must usually
point to a php file ro ... but what does the ?login mean
more information : This is from the openid library and after the button is
clicked it goes to a google allow page! and after our login is complete
the button will not be shown! what does this mean ?
<form action="?login" method="POST">
<button>Login with Google</button>
</form>
I have seen many different actions for a form action that must usually
point to a php file ro ... but what does the ?login mean
more information : This is from the openid library and after the button is
clicked it goes to a google allow page! and after our login is complete
the button will not be shown! what does this mean ?
How to debug apk on my phone via USB?
How to debug apk on my phone via USB?
IDE: IDEA v12.
Phone: JIAYU G2.
USB Debugging is automatically turned on, however IDEA says: "USB device
not found".
I haven't drivers. Please help and do not vote down if you don't
understand what I'm talking about.
IDE: IDEA v12.
Phone: JIAYU G2.
USB Debugging is automatically turned on, however IDEA says: "USB device
not found".
I haven't drivers. Please help and do not vote down if you don't
understand what I'm talking about.
Floated div not same height as parent
Floated div not same height as parent
I want to make two divs next to each other inside a parent div
Like this:
70% 30%
<----><-->
|-----|--|
| | |
| | |
|-----|--|
It only works when the parent got a fixed height, but I want the parent to
be auto in order the content to fit perfectly inside the parent.
When the parent doesn't got a fixed height:
|-----|--|
|conte|nt|
|conte|--|
|conte|
|-----|
CSS:
.biginside {
background-color: pink;
height:100%;
width: 70%;
float: left;
}
.parent {
background-color: blue;
height: auto;
}
.smallinside {
background-color: red;
height: 100%;
width: 30%;
float: left;
}
HTML:
<div class="parent"><div
class="biginside"><p>content</p><p>content</p></div><div
class="smallinside">content</div></div>
Checkout the fiddle http://jsfiddle.net/LQQTm/1/
I want to make two divs next to each other inside a parent div
Like this:
70% 30%
<----><-->
|-----|--|
| | |
| | |
|-----|--|
It only works when the parent got a fixed height, but I want the parent to
be auto in order the content to fit perfectly inside the parent.
When the parent doesn't got a fixed height:
|-----|--|
|conte|nt|
|conte|--|
|conte|
|-----|
CSS:
.biginside {
background-color: pink;
height:100%;
width: 70%;
float: left;
}
.parent {
background-color: blue;
height: auto;
}
.smallinside {
background-color: red;
height: 100%;
width: 30%;
float: left;
}
HTML:
<div class="parent"><div
class="biginside"><p>content</p><p>content</p></div><div
class="smallinside">content</div></div>
Checkout the fiddle http://jsfiddle.net/LQQTm/1/
Saturday, 14 September 2013
how to pase json data to php
how to pase json data to php
I am new with php and angularjs
I want to get json data
the chrome show the data whitch I post
{"sessionName":"1","computer":"2","quality":{"name":"LAN(very fast)"}}
I know it ,if I want to get sesstionName is
$value = json_decode(file_get_contents('php://input'));
echo $value->sessionName;
how can I get quality value in php ?
please help , thanks a lot!
I am new with php and angularjs
I want to get json data
the chrome show the data whitch I post
{"sessionName":"1","computer":"2","quality":{"name":"LAN(very fast)"}}
I know it ,if I want to get sesstionName is
$value = json_decode(file_get_contents('php://input'));
echo $value->sessionName;
how can I get quality value in php ?
please help , thanks a lot!
populate mongoose subdocuments with REST api
populate mongoose subdocuments with REST api
I've been looking over threads and the mongoose docs but am still missing
something about including subdocuments. I have REST api running with
express and i want to give the "location" details from the "location" id
when you lookup "people". Below are my two schema's.
You'll see i'm trying to populate people.location with the title of the
location.. but eventually i'd like to include all details from the schema.
people.location contains the id of a location that exists.
peopleSchema.js
module.exports = function(db) {
return db.model('People', PeopleSchema());
}
function PeopleSchema () {
var Schema = require('mongoose').Schema;
LocationsSchema = new Schema({
title: String
});
console.log(LocationsSchema);
return new Schema({
first_name: String,
last_name: String,
address: {
unit: Number,
address: String,
zipcode: String,
city: String,
region: String,
country: String
},
image: String,
job_title: String,
created_at: { type: Date, default: Date.now },
active_until: { type: Date, default: null },
hourly_wage: Number,
location: [{type: Schema.ObjectId , ref: 'Locations'}], // Inheirit
store info
employee_number: Number
}, { collection: 'people' });
}
locationSchema.js
module.exports = function(db) {
return db.model('Locations', LocationsSchema());
}
function LocationsSchema () {
var Schema = require('mongoose').Schema;
return new Schema({
title: String,
address: {
unit: Number,
address: String,
zipcode: String,
city: String,
region: String,
country: String
},
current_manager: String, // Inherit person details
alternate_contact: String, // Inherit person details
hours: {
sunday: String,
monday: String,
tuesday: String,
wednesday: String,
thursday: String,
friday: String,
saturday: String,
holidays: String
},
employees: "", // mixin employees that work at this location
created_at: { type: Date, default: Date.now },
active_until: { type: Date, default: null }
}, { collection: 'locations' });
}
and i'm returning from /people with this
app.get('/people', function (req, res) {
return PeopleModel.find().populate('location').exec(function (err, obj) {
if (!err) {
return res.send(obj);
} else {
return res.send(err);
}
});
});
and the location field is coming up null, even though it has the id in
there. If anybody could give me any pointers or related links that would
be great! Let me know if you need me to post anything else.
I've been looking over threads and the mongoose docs but am still missing
something about including subdocuments. I have REST api running with
express and i want to give the "location" details from the "location" id
when you lookup "people". Below are my two schema's.
You'll see i'm trying to populate people.location with the title of the
location.. but eventually i'd like to include all details from the schema.
people.location contains the id of a location that exists.
peopleSchema.js
module.exports = function(db) {
return db.model('People', PeopleSchema());
}
function PeopleSchema () {
var Schema = require('mongoose').Schema;
LocationsSchema = new Schema({
title: String
});
console.log(LocationsSchema);
return new Schema({
first_name: String,
last_name: String,
address: {
unit: Number,
address: String,
zipcode: String,
city: String,
region: String,
country: String
},
image: String,
job_title: String,
created_at: { type: Date, default: Date.now },
active_until: { type: Date, default: null },
hourly_wage: Number,
location: [{type: Schema.ObjectId , ref: 'Locations'}], // Inheirit
store info
employee_number: Number
}, { collection: 'people' });
}
locationSchema.js
module.exports = function(db) {
return db.model('Locations', LocationsSchema());
}
function LocationsSchema () {
var Schema = require('mongoose').Schema;
return new Schema({
title: String,
address: {
unit: Number,
address: String,
zipcode: String,
city: String,
region: String,
country: String
},
current_manager: String, // Inherit person details
alternate_contact: String, // Inherit person details
hours: {
sunday: String,
monday: String,
tuesday: String,
wednesday: String,
thursday: String,
friday: String,
saturday: String,
holidays: String
},
employees: "", // mixin employees that work at this location
created_at: { type: Date, default: Date.now },
active_until: { type: Date, default: null }
}, { collection: 'locations' });
}
and i'm returning from /people with this
app.get('/people', function (req, res) {
return PeopleModel.find().populate('location').exec(function (err, obj) {
if (!err) {
return res.send(obj);
} else {
return res.send(err);
}
});
});
and the location field is coming up null, even though it has the id in
there. If anybody could give me any pointers or related links that would
be great! Let me know if you need me to post anything else.
Special character encoding french cakephp
Special character encoding french cakephp
I have this code to put my string french
<?php echo $this->Form->create('Envoie');?>
<fieldset>
<legend>
<?php echo __('Imaa Envoie'); ?>
</legend>
<textarea name="data[code]" cols="30" rows="12" ></textarea>
</fieldset>
<?php echo $this->Form->end(__('Submit'));?>
In my controller i have this code
$strng=explode("ss", $this->request->data["code"]);
$sss="";
for($i=0;$i<count($strng)-1;$i++)
{
$s=$strng[$i];
$info=explode('&&&id', $s);
$id=trim($info[0]);
$sss=$sss."<br>sum code<br>";
$script=str_replace ( "aa", '"'.$login.'"', $script);
$sss=$sss.$script;
}
$this->set("sss",$sss);
In my view i have this
<?=$sss ?>
String in is : 157m² de superficie, 2ème étage, 2 Salons, 2 ch., 2 SDB,
Séjour, Cuisine, Buanderie, …
String out is : 157m² de superficie, 2ème étage, 2 Salons, 2 ch., 2
SDB, Séjour, Cuisine, Buanderie,�
I have this code to put my string french
<?php echo $this->Form->create('Envoie');?>
<fieldset>
<legend>
<?php echo __('Imaa Envoie'); ?>
</legend>
<textarea name="data[code]" cols="30" rows="12" ></textarea>
</fieldset>
<?php echo $this->Form->end(__('Submit'));?>
In my controller i have this code
$strng=explode("ss", $this->request->data["code"]);
$sss="";
for($i=0;$i<count($strng)-1;$i++)
{
$s=$strng[$i];
$info=explode('&&&id', $s);
$id=trim($info[0]);
$sss=$sss."<br>sum code<br>";
$script=str_replace ( "aa", '"'.$login.'"', $script);
$sss=$sss.$script;
}
$this->set("sss",$sss);
In my view i have this
<?=$sss ?>
String in is : 157m² de superficie, 2ème étage, 2 Salons, 2 ch., 2 SDB,
Séjour, Cuisine, Buanderie, …
String out is : 157m² de superficie, 2ème étage, 2 Salons, 2 ch., 2
SDB, Séjour, Cuisine, Buanderie,�
How to search in a custom built arraylist?
How to search in a custom built arraylist?
I have an arraylist built like this:
In class: Strings.java
ArrayList<MyQueue> strings = new ArrayList<MyQueue>();
strings.add (new MyQueue("paper", "clips", "eraser"));
strings.add (new MyQueue("paperplane", "numbers", "pineapple"));
In class: MyQueue.java
--Constructor with 3 string parameters--
--Getters/setters for three strings--
Now in the Strings.java class, I want to search my ArrayList "strings" to
see if it has the string "paper"?
How could I do this efficiently?
I have an arraylist built like this:
In class: Strings.java
ArrayList<MyQueue> strings = new ArrayList<MyQueue>();
strings.add (new MyQueue("paper", "clips", "eraser"));
strings.add (new MyQueue("paperplane", "numbers", "pineapple"));
In class: MyQueue.java
--Constructor with 3 string parameters--
--Getters/setters for three strings--
Now in the Strings.java class, I want to search my ArrayList "strings" to
see if it has the string "paper"?
How could I do this efficiently?
Unmount flash drive from program running on the drive
Unmount flash drive from program running on the drive
I have a Java program that is designed to work from a flash drive on both
Mac and Windows. For Windows, I have been able to add an 'Eject' option
using RemoveDrive.exe. I planned to use the following command line to
achieve the same thing on Mac, however when I tried, it wouldn't let me
unmount the drive until I closed the Java application. Is there any
solution to this:
diskutil unmount /Volumes/USB
I have a Java program that is designed to work from a flash drive on both
Mac and Windows. For Windows, I have been able to add an 'Eject' option
using RemoveDrive.exe. I planned to use the following command line to
achieve the same thing on Mac, however when I tried, it wouldn't let me
unmount the drive until I closed the Java application. Is there any
solution to this:
diskutil unmount /Volumes/USB
Munin always rendering straight line
Munin always rendering straight line
I've created a simple Munin plugin that returns one integer value in range
from 0 to 20000, and I've got this green line with value 500 present on
every graph, even if there is no data for graph present.
Plugin config section:
graph_title R: folder age in seconds
graph_category prkno
graph_info This graph shows age of folders
graph_args --upper-limit 20000 -l 0
graph_vlabel seconds
drive_r.label R:
Munin output if zoomed to period without data:
Munin output with data present:
I've created a simple Munin plugin that returns one integer value in range
from 0 to 20000, and I've got this green line with value 500 present on
every graph, even if there is no data for graph present.
Plugin config section:
graph_title R: folder age in seconds
graph_category prkno
graph_info This graph shows age of folders
graph_args --upper-limit 20000 -l 0
graph_vlabel seconds
drive_r.label R:
Munin output if zoomed to period without data:
Munin output with data present:
Need to change featured slider image size in wordpress
Need to change featured slider image size in wordpress
i need to change the size of featured images on my aviation classifieds
website. I am a pilot and i dont know coding stuff. I saw other threads on
stackoverflow and I tried to go to media settings in wordpress backend but
that did not change the size of images on the featured slider.
Can somebody tell me exactly how can i do it programmatically. Which file
and what type of code should i use.
i need to change the size of featured images on my aviation classifieds
website. I am a pilot and i dont know coding stuff. I saw other threads on
stackoverflow and I tried to go to media settings in wordpress backend but
that did not change the size of images on the featured slider.
Can somebody tell me exactly how can i do it programmatically. Which file
and what type of code should i use.
Friday, 13 September 2013
draging the button it will navigate the next page how can write the code?
draging the button it will navigate the next page how can write the code?
<a draggable="true" class="user" id="leonardo"
ondragstart="dragUser(this, event)" aria-selected="undefined">
IPD</a>
draging the button it will navigate the next page how can write the code?
<a draggable="true" class="user" id="leonardo"
ondragstart="dragUser(this, event)" aria-selected="undefined">
IPD</a>
draging the button it will navigate the next page how can write the code?
asp.net web api dynamic json
asp.net web api dynamic json
I have a web api endpoint that receives JSON and serializes it into
objects. Very basic and common stuff. However, I have a requirement to
accept custom user defined fields. For example, a developer may want to
add a custom field for "account #" and pass that along via the API. I'm
stuck how I could define a field on my class if I don't know the name. I
need to support unlimited fields so I cannot simply create a field for
custom1, custom2, custom2, etc.
I would think that my JSON could look something like this... where
custom_label_xxx is identifies the field label:
...
"custom_fields": {
"custom_label_90": 49,
"custom_label_83": [ 28, 29, 30 ],
"custom_label_89": "2012/05/21"
},
...
How in the world can I setup a dynamic class to accept this dynamic JSON?
I have Googled forever and cannot find any examples using custom fields.
I have a web api endpoint that receives JSON and serializes it into
objects. Very basic and common stuff. However, I have a requirement to
accept custom user defined fields. For example, a developer may want to
add a custom field for "account #" and pass that along via the API. I'm
stuck how I could define a field on my class if I don't know the name. I
need to support unlimited fields so I cannot simply create a field for
custom1, custom2, custom2, etc.
I would think that my JSON could look something like this... where
custom_label_xxx is identifies the field label:
...
"custom_fields": {
"custom_label_90": 49,
"custom_label_83": [ 28, 29, 30 ],
"custom_label_89": "2012/05/21"
},
...
How in the world can I setup a dynamic class to accept this dynamic JSON?
I have Googled forever and cannot find any examples using custom fields.
Use of -q Flag in Python
Use of -q Flag in Python
What does the -q flag in Python mean/do ? Also how do I access a list of
the flags through the terminal (Cygwin) ? I tried help() and then -q but
that said that -q could not be found.
What does the -q flag in Python mean/do ? Also how do I access a list of
the flags through the terminal (Cygwin) ? I tried help() and then -q but
that said that -q could not be found.
Using Javascript/jquery how can I get values from each cells in a selected row
Using Javascript/jquery how can I get values from each cells in a selected
row
I am trying to figure out how to get and assign each cell value in a row
to a variable.In particular the check box values
Here is an example of the table
<table id="mytable" class="table">
<thead>
<b><tr><th>Header1</th><th>Header2</th><th>Header2</th><th>Header3</th></tr></b>
</thead>
<tr>
<td>value1</td>
<td>value1</td>
<td>
<label><input id="divpriority" ng-model="priority"
type="checkbox" /> Option1</label>
<label><input id="divsource" type="checkbox" />
Option2</label>
<label> <input type="checkbox"
checked/>Otion3</label>
</td>
<td><br/><br/><button id="buttonvalues" type="button"
class="btn-primary">GetValues</button></td>
</tr>
</table>
So when the "GetValues" button is clicked in the current row the values
from each cell are assigned to a variable.
I was thinking of something along the lines of this:(I know this is likely
incorrect)
$("#mytable table tbody ").on("click", "#buttonvalues", function() { var
header1; var header2; var Options = new Array()
var header1 = $(this).closest('tr').header1.val ; var header2 =
$(this).closest('tr').header2.val
Options = //Not sure what to do here
Using Javascript/jquery how can I get values from each cells in a selected
row and assign the values to a variable with the click of a button
included in the row.
Please emphasize on assigning values from the check box into an array
variable. I would like to get the name of the checkbox thats checked into
the array
row
I am trying to figure out how to get and assign each cell value in a row
to a variable.In particular the check box values
Here is an example of the table
<table id="mytable" class="table">
<thead>
<b><tr><th>Header1</th><th>Header2</th><th>Header2</th><th>Header3</th></tr></b>
</thead>
<tr>
<td>value1</td>
<td>value1</td>
<td>
<label><input id="divpriority" ng-model="priority"
type="checkbox" /> Option1</label>
<label><input id="divsource" type="checkbox" />
Option2</label>
<label> <input type="checkbox"
checked/>Otion3</label>
</td>
<td><br/><br/><button id="buttonvalues" type="button"
class="btn-primary">GetValues</button></td>
</tr>
</table>
So when the "GetValues" button is clicked in the current row the values
from each cell are assigned to a variable.
I was thinking of something along the lines of this:(I know this is likely
incorrect)
$("#mytable table tbody ").on("click", "#buttonvalues", function() { var
header1; var header2; var Options = new Array()
var header1 = $(this).closest('tr').header1.val ; var header2 =
$(this).closest('tr').header2.val
Options = //Not sure what to do here
Using Javascript/jquery how can I get values from each cells in a selected
row and assign the values to a variable with the click of a button
included in the row.
Please emphasize on assigning values from the check box into an array
variable. I would like to get the name of the checkbox thats checked into
the array
How to select all textarea boxes within a given div in JQuery? (To disable/require all)
How to select all textarea boxes within a given div in JQuery? (To
disable/require all)
I have a project that shows a DIV within a form when a checkbox is
selected, and within that DIV is a a script that could infinitely add text
areas.
What I want is if a a bajillion of these text areas are created, I want to
disable all of them from being submitted with the form, as well as make
them not required if the over arching checkbox is deselected.
Edit: The reason I am specific about the textareas within a given DIV is
because I have text areas elsewhere on the form!
So, how would I select all of the text boxes within a given DIV? Or, by
name? (all of them on a given class (since they're all a part of the
needb1_3[]array)). I've found some code/threads/answers to select input
boxes, radios, checkboxes, but never text areas.
Thanks for any help in advance.
jsfiddle: http://jsfiddle.net/fmdx/rNqwc/1/
HTML:
<div>
<input id="needb1-3customcheck" type="checkbox"
class="schedb1checkboxes[]" data- select="#needb1-3custom">Need
Custom?
</div>
<div id="needb1-3custom" style="display:none; padding-left:40px;">
<div id="customb1_3" style="padding-left:40px;">
<textarea id="needb1_3_1" placeholder="Six Foot Utility..."
name="needb1_3[]" required>
</textarea>
</div><!-- Ending Custom Div -->
<div style="padding-left:40px;"><a id="add_b1_3" href="#"><span>Add
Exception</span></a></div>
</div>
JQuery:
var b1_3customcounter = 1;
$(function () {
$('a#add_b1_3').click(function () {
b1_3customcounter += 1;
$('#customb1_3').append(
'<div><textarea id="need_b1_3_' + b1_3customcounter + '"
placeholder="Six Foot Utility..." name="needb1_3[]' + '"
required></textarea><a class="remove" href="#">Remove</a></div>');
event.preventDefault();
});
});
$(document).on('click', '.remove', function(){
var $this = $(this);
$(this).closest('div').remove();
event.preventDefault();
});
$('#needb1-3customcheck').click(function(){
var collapse_content_selector = $(this).attr('data-select');
$(collapse_content_selector).toggle(function(){
if($(this).css('display')=='none'){
//Do this while the section is hidden
$('#needb1_3_1').prop('required', false);
}else{
//Do this while the section is visible
$('#needb1_3_1').prop('required', true);
}
});
});
disable/require all)
I have a project that shows a DIV within a form when a checkbox is
selected, and within that DIV is a a script that could infinitely add text
areas.
What I want is if a a bajillion of these text areas are created, I want to
disable all of them from being submitted with the form, as well as make
them not required if the over arching checkbox is deselected.
Edit: The reason I am specific about the textareas within a given DIV is
because I have text areas elsewhere on the form!
So, how would I select all of the text boxes within a given DIV? Or, by
name? (all of them on a given class (since they're all a part of the
needb1_3[]array)). I've found some code/threads/answers to select input
boxes, radios, checkboxes, but never text areas.
Thanks for any help in advance.
jsfiddle: http://jsfiddle.net/fmdx/rNqwc/1/
HTML:
<div>
<input id="needb1-3customcheck" type="checkbox"
class="schedb1checkboxes[]" data- select="#needb1-3custom">Need
Custom?
</div>
<div id="needb1-3custom" style="display:none; padding-left:40px;">
<div id="customb1_3" style="padding-left:40px;">
<textarea id="needb1_3_1" placeholder="Six Foot Utility..."
name="needb1_3[]" required>
</textarea>
</div><!-- Ending Custom Div -->
<div style="padding-left:40px;"><a id="add_b1_3" href="#"><span>Add
Exception</span></a></div>
</div>
JQuery:
var b1_3customcounter = 1;
$(function () {
$('a#add_b1_3').click(function () {
b1_3customcounter += 1;
$('#customb1_3').append(
'<div><textarea id="need_b1_3_' + b1_3customcounter + '"
placeholder="Six Foot Utility..." name="needb1_3[]' + '"
required></textarea><a class="remove" href="#">Remove</a></div>');
event.preventDefault();
});
});
$(document).on('click', '.remove', function(){
var $this = $(this);
$(this).closest('div').remove();
event.preventDefault();
});
$('#needb1-3customcheck').click(function(){
var collapse_content_selector = $(this).attr('data-select');
$(collapse_content_selector).toggle(function(){
if($(this).css('display')=='none'){
//Do this while the section is hidden
$('#needb1_3_1').prop('required', false);
}else{
//Do this while the section is visible
$('#needb1_3_1').prop('required', true);
}
});
});
Thursday, 12 September 2013
Jenkins configuration - svn URL to monitor specific directory in branches
Jenkins configuration - svn URL to monitor specific directory in branches
I have reviewed the resulting "Questions that may already have your
answer" as well as many variations of a google search. 2 scenarios were
found that used a different solution, which does not meet our needs.
-Build from trunk or branches' - SVN URL variables The end result I am
trying to achieve is a single job that monitors a specific project under
all branches. For instance, a checkin to
svn://svn.host/branches/*/project/code/place would trigger a build. I have
tried to wildcard the svn URL as such with regular expressions and
continue to receive notification the the URL is invalid. Has anyone been
able to configure a single Jenkins job that monitors a specific directory
under multiple branches? Thanks in advance for any assistance.
I have reviewed the resulting "Questions that may already have your
answer" as well as many variations of a google search. 2 scenarios were
found that used a different solution, which does not meet our needs.
-Build from trunk or branches' - SVN URL variables The end result I am
trying to achieve is a single job that monitors a specific project under
all branches. For instance, a checkin to
svn://svn.host/branches/*/project/code/place would trigger a build. I have
tried to wildcard the svn URL as such with regular expressions and
continue to receive notification the the URL is invalid. Has anyone been
able to configure a single Jenkins job that monitors a specific directory
under multiple branches? Thanks in advance for any assistance.
bootswatch makes my webpage load slow even on my computer in previews?
bootswatch makes my webpage load slow even on my computer in previews?
So Bootswatch.com has some awesome themes for twitter bootstrap.
Unfortunately as soon as I swapped out the CSS scripts for Bootswatch.com
the webpage loads super super slow. On my computer when i click preview or
double click the .html file.
What is causing this to happen? its not even uploaded to the internet,
this is all local. I cant understand why changing the CSS would make a
difference. Not to mention the new CSS has fewer lines of code.
So Bootswatch.com has some awesome themes for twitter bootstrap.
Unfortunately as soon as I swapped out the CSS scripts for Bootswatch.com
the webpage loads super super slow. On my computer when i click preview or
double click the .html file.
What is causing this to happen? its not even uploaded to the internet,
this is all local. I cant understand why changing the CSS would make a
difference. Not to mention the new CSS has fewer lines of code.
Launch app Iphone portrait, and Ipad landscape
Launch app Iphone portrait, and Ipad landscape
I have this code, i need detect is ipad launch app landscape or iphone in
portrait mode only
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"])
{
NSLog(@"This is iPhone");
}
else{
NSLog(@"This is iPad");
}
I have this code, i need detect is ipad launch app landscape or iphone in
portrait mode only
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"])
{
NSLog(@"This is iPhone");
}
else{
NSLog(@"This is iPad");
}
combined EMF / GMF Editor throws conflicting handler message
combined EMF / GMF Editor throws conflicting handler message
I used this article
(http://www.eclipse.org/articles/article.php?file=Article-Integrating-EMF-GMF-Editors/index.html)
to combine my EMF and GMF Editor. This works fine so far with eclipse Juno
4.2.0. But after updating to 4.2.2 or Kepler, I get this messages when
switching between my EMF and GMF tabs:
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.289
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.undo:
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction@ab287)}
vs {ActionHandler(org.eclipse.emf.edit.ui.action.UndoAction@4eeb3f)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.293
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.paste:
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalPasteAction@b4519b)}
vs {ActionHandler(org.eclipse.emf.edit.ui.action.PasteAction@59abfd)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.296
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.redo:
{ActionHandler(org.eclipse.emf.edit.ui.action.RedoAction@1f44cbf)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalRedoAction@1dac3e4)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.299
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.delete:
{ActionHandler(org.eclipse.emf.edit.ui.action.DeleteAction@1227e51)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalDeleteAction@1932bb6)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.302
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.cut:
{ActionHandler(org.eclipse.emf.edit.ui.action.CutAction@c4eb64)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalCutAction@3a26f2)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.305
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.copy:
{ActionHandler(org.eclipse.emf.edit.ui.action.CopyAction@81c5c9)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalCopyAction@1e043b2)
This is really anoying since I searched already a few hours to find a
solution. What I don't understand is that this messages don't occur with
eclipse Juno 4.2.0. Is there a way to tell eclipse which ActionHandler
should be used?
Cheers, Phil
I used this article
(http://www.eclipse.org/articles/article.php?file=Article-Integrating-EMF-GMF-Editors/index.html)
to combine my EMF and GMF Editor. This works fine so far with eclipse Juno
4.2.0. But after updating to 4.2.2 or Kepler, I get this messages when
switching between my EMF and GMF tabs:
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.289
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.undo:
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalUndoAction@ab287)}
vs {ActionHandler(org.eclipse.emf.edit.ui.action.UndoAction@4eeb3f)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.293
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.paste:
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalPasteAction@b4519b)}
vs {ActionHandler(org.eclipse.emf.edit.ui.action.PasteAction@59abfd)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.296
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.redo:
{ActionHandler(org.eclipse.emf.edit.ui.action.RedoAction@1f44cbf)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.actions.global.GlobalRedoAction@1dac3e4)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.299
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.delete:
{ActionHandler(org.eclipse.emf.edit.ui.action.DeleteAction@1227e51)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalDeleteAction@1932bb6)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.302
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.cut:
{ActionHandler(org.eclipse.emf.edit.ui.action.CutAction@c4eb64)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalCutAction@3a26f2)}
!ENTRY org.eclipse.ui 4 4 2013-09-11 13:11:40.305
!MESSAGE Conflicting handlers for org.eclipse.ui.edit.copy:
{ActionHandler(org.eclipse.emf.edit.ui.action.CopyAction@81c5c9)} vs
{ActionHandler(org.eclipse.gmf.runtime.common.ui.action.internal.actions.global.GlobalCopyAction@1e043b2)
This is really anoying since I searched already a few hours to find a
solution. What I don't understand is that this messages don't occur with
eclipse Juno 4.2.0. Is there a way to tell eclipse which ActionHandler
should be used?
Cheers, Phil
Different format for timestamp when using c# datareader
Different format for timestamp when using c# datareader
I'm reading a timestamp from a mysql table using an OdbcDataReader. When I
look at the data in the table it is in the format 2013-09-12 11:11:09. But
the reader seems to read it in the format 12/09/2013 11:11:09.
I then try to insert this into another mysql table but receive the error:
Incorrect datetime value: '12/09/2013 11:11:09' for column 'timestamp' at
row 1
How can I sort out this difference in formatting? Should I be referencing
some Unix timestamp value somehow?
I'm reading a timestamp from a mysql table using an OdbcDataReader. When I
look at the data in the table it is in the format 2013-09-12 11:11:09. But
the reader seems to read it in the format 12/09/2013 11:11:09.
I then try to insert this into another mysql table but receive the error:
Incorrect datetime value: '12/09/2013 11:11:09' for column 'timestamp' at
row 1
How can I sort out this difference in formatting? Should I be referencing
some Unix timestamp value somehow?
jQuery: .next() doesn't working within .each() loop
jQuery: .next() doesn't working within .each() loop
I'm using bootstrap-tooltip plugin to display tooltips. And my HTML is
like this:
<a href="#" data-role="tooltip" title="">actions</a>
<div class="user-actions">
<a class="icon" href="/edit">
<i class="icon-pencil"></i>
</a>
<a class="icon" href="/delete">
<i class="icon-trash"></i>
</a>
</div>
My JS:
$(function() {
$('[data-role=tooltip]').tooltip({
html: true,
placement: 'bottom',
trigger: 'click'
});
$('a[data-role=tooltip]').each(function(){
var content = this.next().html()
this.attr('title', content);
});
});
What I want my script to do is to loop through every <a
data-role='tooltip' title=''> selector, then find immediately following
selector, get its html and put it as a value of title attribute.
BUT
it just doesn't work. The console error says:
Uncaught TypeError: Object [object HTMLAnchorElement] has no method 'next'
What I did wrong? And how I can make it work?
Help me please
I'm using bootstrap-tooltip plugin to display tooltips. And my HTML is
like this:
<a href="#" data-role="tooltip" title="">actions</a>
<div class="user-actions">
<a class="icon" href="/edit">
<i class="icon-pencil"></i>
</a>
<a class="icon" href="/delete">
<i class="icon-trash"></i>
</a>
</div>
My JS:
$(function() {
$('[data-role=tooltip]').tooltip({
html: true,
placement: 'bottom',
trigger: 'click'
});
$('a[data-role=tooltip]').each(function(){
var content = this.next().html()
this.attr('title', content);
});
});
What I want my script to do is to loop through every <a
data-role='tooltip' title=''> selector, then find immediately following
selector, get its html and put it as a value of title attribute.
BUT
it just doesn't work. The console error says:
Uncaught TypeError: Object [object HTMLAnchorElement] has no method 'next'
What I did wrong? And how I can make it work?
Help me please
How to search multiple term in columns if that term not be empty and get only one page of rows?
How to search multiple term in columns if that term not be empty and get
only one page of rows?
I have to search field :name and email ;I want to let user to search with
these fields and if each of fields be empty,not search for that field.I
tried this LINQ to entity:
var result=new List<T>();
String tmp;
if(!String.IsNullOrEmpty(name.Text))
{
tmp=name.Text;
result=result.Concat(context.Where(u=>u.Name==tmp);
}
if(!String.IsNullOrEmpty(email.Text))
{
tmp=email.Text;
result=result.Concat(context.Where(u=>u.EMail==tmp);
}
var thisPageResult=result.Skip((page - 1) * perPage).Take(perPage);
but in this method;all of result will be stored in memory and then I get
thisPageResult from it.
How can I create above search to load only this page's result into
memory,not all result?
only one page of rows?
I have to search field :name and email ;I want to let user to search with
these fields and if each of fields be empty,not search for that field.I
tried this LINQ to entity:
var result=new List<T>();
String tmp;
if(!String.IsNullOrEmpty(name.Text))
{
tmp=name.Text;
result=result.Concat(context.Where(u=>u.Name==tmp);
}
if(!String.IsNullOrEmpty(email.Text))
{
tmp=email.Text;
result=result.Concat(context.Where(u=>u.EMail==tmp);
}
var thisPageResult=result.Skip((page - 1) * perPage).Take(perPage);
but in this method;all of result will be stored in memory and then I get
thisPageResult from it.
How can I create above search to load only this page's result into
memory,not all result?
Wednesday, 11 September 2013
What does double colons and underscore mean in Joomla?
What does double colons and underscore mean in Joomla?
I am learning basic PHP, trying to read and get some basic understanding
of JOOMLA core files, whereas I come across a lot of operators like "::_",
which I don't understand.
I did some google research and there are a lot of explanations regarding
double colons (::), but almost nothing on "::_", one of the files that
contain this operator is joomla-site-root/mod_login/tmpl/default.php, and
the line is
<form action="<?php echo JRoute::_('index.php', true,
$params->get('usesecure')); ?>" method="post" id="login-form">
So what does this mean? Is "JRoute::_('index.php', true,
$params->get('usesecure'))" a function call of class JRoute? if yes, what
function is it? I checked out the joomla
API(http://api.joomla.org/Joomla-Platform/Application/JRouter.html) but
still remain clueless. Please, any help would be greatly appreciated.
I am learning basic PHP, trying to read and get some basic understanding
of JOOMLA core files, whereas I come across a lot of operators like "::_",
which I don't understand.
I did some google research and there are a lot of explanations regarding
double colons (::), but almost nothing on "::_", one of the files that
contain this operator is joomla-site-root/mod_login/tmpl/default.php, and
the line is
<form action="<?php echo JRoute::_('index.php', true,
$params->get('usesecure')); ?>" method="post" id="login-form">
So what does this mean? Is "JRoute::_('index.php', true,
$params->get('usesecure'))" a function call of class JRoute? if yes, what
function is it? I checked out the joomla
API(http://api.joomla.org/Joomla-Platform/Application/JRouter.html) but
still remain clueless. Please, any help would be greatly appreciated.
Making a variable length list translatable
Making a variable length list translatable
I want to display a list of values from an array, and have it be
translatable. My translation method of choice is gettext. An example of
what I am trying to do is to turn a variable-length array like:
$array = ('apple', 'plum', 'watermelon', [...]);
into a string like apple, plum and watermelon.
Doing it only in English would not be a problem, but making it
translatable is, because other languages may not necessarily use a comma
to separate values and/or may not have the word "and" without a comma
between the second last and last values. If I knew that the array always
had 3 values, I could easily just do:
sprintf(gettext("%s, %s and %s"), $array[0], $array[1], $array[2]);
The problem is that the array can vary in length. How can I make a
translatable list from a variable-length array?
I want to display a list of values from an array, and have it be
translatable. My translation method of choice is gettext. An example of
what I am trying to do is to turn a variable-length array like:
$array = ('apple', 'plum', 'watermelon', [...]);
into a string like apple, plum and watermelon.
Doing it only in English would not be a problem, but making it
translatable is, because other languages may not necessarily use a comma
to separate values and/or may not have the word "and" without a comma
between the second last and last values. If I knew that the array always
had 3 values, I could easily just do:
sprintf(gettext("%s, %s and %s"), $array[0], $array[1], $array[2]);
The problem is that the array can vary in length. How can I make a
translatable list from a variable-length array?
How to create only once my static list when create my object again and again
How to create only once my static list when create my object again and again
I have an class and one of the class members is static list that keep all
my object and i only want to create this list (List<myObject> list = new
...) once. what is the best way to do it ?
public class MyObject
{
private string _name;
private static List<Capture> _list;
public MyObject(string name)
{
_name = name;
}
public void start()
{
_list.Add(this);
}
}
I have an class and one of the class members is static list that keep all
my object and i only want to create this list (List<myObject> list = new
...) once. what is the best way to do it ?
public class MyObject
{
private string _name;
private static List<Capture> _list;
public MyObject(string name)
{
_name = name;
}
public void start()
{
_list.Add(this);
}
}
Format in TSQL of simple 'Merge into' query using 'Case'
Format in TSQL of simple 'Merge into' query using 'Case'
I have a TSQL UPDATE query as follows:
UPDATE Table
SET Value = CASE
WHEN (Condition1 = 'A') AND (Condition2 = '1') THEN 'BLAH-1'
WHEN (Condition1 = 'B') AND (Condition2 = '1') THEN 'BLAH-2'
END
WHERE (Condition1 IN ('A','B')) AND (Condition2 IN ('1'))
Can someone show me the format for the above as a 'MERGE INTO' query, if
it is possible?
MERGE INTO Table
USING ...
WHEN MATCHED THEN UPDATE SET ...
WHEN NOT MATCHED THEN INSERT ... VALUES ...
In other words, if (Condition1) AND (Condition2) don't exist, then add the
records to the table.
If it helps, the various 'cases' will either all need to be UPDATED or all
INSERTED.
I am using SQL server 2012.
Thanks in advance.
I have a TSQL UPDATE query as follows:
UPDATE Table
SET Value = CASE
WHEN (Condition1 = 'A') AND (Condition2 = '1') THEN 'BLAH-1'
WHEN (Condition1 = 'B') AND (Condition2 = '1') THEN 'BLAH-2'
END
WHERE (Condition1 IN ('A','B')) AND (Condition2 IN ('1'))
Can someone show me the format for the above as a 'MERGE INTO' query, if
it is possible?
MERGE INTO Table
USING ...
WHEN MATCHED THEN UPDATE SET ...
WHEN NOT MATCHED THEN INSERT ... VALUES ...
In other words, if (Condition1) AND (Condition2) don't exist, then add the
records to the table.
If it helps, the various 'cases' will either all need to be UPDATED or all
INSERTED.
I am using SQL server 2012.
Thanks in advance.
what does getting the documentElement of 0 return
what does getting the documentElement of 0 return
most javascript libraries contain lines similar to:
var b = (a ? a.ownerDocument || a: 0).documentElement;
if a is null, what is (0).documentElement supposed to return?
most javascript libraries contain lines similar to:
var b = (a ? a.ownerDocument || a: 0).documentElement;
if a is null, what is (0).documentElement supposed to return?
How to insert varibale from emailadress in mail()?
How to insert varibale from emailadress in mail()?
How do I insert a variable form email address in the PHP mail() function?
$form_data =array();
$form_data['firstName'] = 'Joe';
$form_data['surname'] = 'Do';
$form_data['email'] = 'info@Domain';
print "From: ".$form_data['firstName']." ".$form_data['surname']."
<".$form_data['email'].">\n";
When I wrap <> around then the email address is not displayed I have tried
print "<{$form_data['email']}>";
print '<'.$form_data['email'].'>';
But I don't know how to solve this
How do I insert a variable form email address in the PHP mail() function?
$form_data =array();
$form_data['firstName'] = 'Joe';
$form_data['surname'] = 'Do';
$form_data['email'] = 'info@Domain';
print "From: ".$form_data['firstName']." ".$form_data['surname']."
<".$form_data['email'].">\n";
When I wrap <> around then the email address is not displayed I have tried
print "<{$form_data['email']}>";
print '<'.$form_data['email'].'>';
But I don't know how to solve this
SQL string connection issue
SQL string connection issue
I have to establish a connection using connection string to DB. I am using
SQL Server 2008 R2, for which i need connection string. It is not
SQLEXPRESS.
Current String::
< add name="ApplicationServices" connectionString="server=USER-PC\SQL
Server;database=TLE;Connection Timeout=40"
providerName="System.Data.SqlClient"/>
But it is not working. I am getting error ""A network-related or
instance-specific error occurred while establishing a connection to SQL
Server. The server was not found or was not accessible. Verify that the
instance name is correct and that SQL Server is configured to allow remote
connections. (provider: SQL Network Interfaces, error: 26 - Error Locating
Server/Instance Specified)""
I have to establish a connection using connection string to DB. I am using
SQL Server 2008 R2, for which i need connection string. It is not
SQLEXPRESS.
Current String::
< add name="ApplicationServices" connectionString="server=USER-PC\SQL
Server;database=TLE;Connection Timeout=40"
providerName="System.Data.SqlClient"/>
But it is not working. I am getting error ""A network-related or
instance-specific error occurred while establishing a connection to SQL
Server. The server was not found or was not accessible. Verify that the
instance name is correct and that SQL Server is configured to allow remote
connections. (provider: SQL Network Interfaces, error: 26 - Error Locating
Server/Instance Specified)""
Tuesday, 10 September 2013
How to Scroll for Windows From Host , WPF
How to Scroll for Windows From Host , WPF
I am Capturing Video in WPF using DirectX and DritectShow.
I am using WIndows From host for WindowsFromControl, Which is required by
DirectX to Display Preview of Video.
<WindowsFormsHost Name="windowsFormHostControl">
<wf:PictureBox x:Name="VideoPanel" />
</WindowsFormsHost>
Now the problem is If the Video Resolution is High, then I am only able to
view partial Video. I have tried putting if WindosHostForm inside Scroll
Viewer but the scroll dose not work.
Any help or suggestion for getting Scroll for Windows From Host is
appreciated.
I am Capturing Video in WPF using DirectX and DritectShow.
I am using WIndows From host for WindowsFromControl, Which is required by
DirectX to Display Preview of Video.
<WindowsFormsHost Name="windowsFormHostControl">
<wf:PictureBox x:Name="VideoPanel" />
</WindowsFormsHost>
Now the problem is If the Video Resolution is High, then I am only able to
view partial Video. I have tried putting if WindosHostForm inside Scroll
Viewer but the scroll dose not work.
Any help or suggestion for getting Scroll for Windows From Host is
appreciated.
BlueJ error: incompatible types
BlueJ error: incompatible types
Complete noob at Java here. School just started and I'm taking APCS. Our
teacher showed us this cool class called Scanner, but he hasn't taught us
it yet. I thought it was pretty cool, so I decided to research it more.
After I did a little research, I found out that it basically allows you to
use information imputed into the System into your code. I tried to make my
own little program using this code. The idea is very simple.
Ask the user to input his first name.
After receiving the users first name, ask him to verify that it is his
name (no spelling errors, wrong name, etc.).
Use if/else statement, if yes: print a thank you. if no: print a random
string making fun of him.
At this point I intended to use and if/else statement. This is something
that we as a class have yet to cover. After typing out my if else
statement, I got a compile-time error. Here's what BlueJ gave me:
incompatible type
This is the code:
public class useInfo
{
public static void main(String[] args)
{
String firstName;
String verifyFirstName;
Scanner keyboardInput = new Scanner(System.in);
Scanner verification = new Scanner(System.in);
System.out.print("Please Enter your first name here --->");
firstName = keyboardInput.nextLine();
System.out.println("Thank you! Your first name is " + firstName + " ,
correct?");
keyboardInput.close();
verifyFirstName = verification.nextLine();
if (verifyFirstName = "Yes") //this is the section I get the error on.
RIGHT HERE.
{
System.out.println("Great! Thanks for you time.");
}
else
{
System.out.println("You need to get your stuff together. How can
you not even type your own name correctly?");
}
}
}
Thanks in advance for your help!
Sincerely, Abdi
Complete noob at Java here. School just started and I'm taking APCS. Our
teacher showed us this cool class called Scanner, but he hasn't taught us
it yet. I thought it was pretty cool, so I decided to research it more.
After I did a little research, I found out that it basically allows you to
use information imputed into the System into your code. I tried to make my
own little program using this code. The idea is very simple.
Ask the user to input his first name.
After receiving the users first name, ask him to verify that it is his
name (no spelling errors, wrong name, etc.).
Use if/else statement, if yes: print a thank you. if no: print a random
string making fun of him.
At this point I intended to use and if/else statement. This is something
that we as a class have yet to cover. After typing out my if else
statement, I got a compile-time error. Here's what BlueJ gave me:
incompatible type
This is the code:
public class useInfo
{
public static void main(String[] args)
{
String firstName;
String verifyFirstName;
Scanner keyboardInput = new Scanner(System.in);
Scanner verification = new Scanner(System.in);
System.out.print("Please Enter your first name here --->");
firstName = keyboardInput.nextLine();
System.out.println("Thank you! Your first name is " + firstName + " ,
correct?");
keyboardInput.close();
verifyFirstName = verification.nextLine();
if (verifyFirstName = "Yes") //this is the section I get the error on.
RIGHT HERE.
{
System.out.println("Great! Thanks for you time.");
}
else
{
System.out.println("You need to get your stuff together. How can
you not even type your own name correctly?");
}
}
}
Thanks in advance for your help!
Sincerely, Abdi
jQuery Animations Choppy? Slowing Down Site
jQuery Animations Choppy? Slowing Down Site
I am in the middle of putting together a website for someone, and they are
dead-set on having various effects in the background of the site to make
it look like an old television.
I've done several things. A vignette around the edge, images of static
that randomize their opacity in the background, and a large scanline-bar
thing that moves from the top to the bottom of the page.
However I realized that, even though it looked all good on one computer,
later on, I noticed (by watching the static flicker and the movement along
the Y-axis of the bar) that it was almost slowing down. Animation would
get choppy and stutter. Sometimes it's barely noticeable, but sometimes
it's glaring and ugly.
I read around, and saw something about setting images to 100% width and
height causes jquery-animate slowdowns....but I can't really change that,
as the effect relies upon these stacked effects covering the whole view
port.
You may suggest smaller images. I tried that already - making my 1080
backgrounds 1/4 their size....but then I also got the slowdown again, and
then read that up-scaling images while animating them ALSO causes
slowdown.
I've fiddled around for hours and tried alternate jquery snippets but
nothing seems to work - I just always get moments of stuttering, choppy
animation of these effects.
Because I'm not unsure of a single piece of code, I don't want to flood
all of the jquery into this post.
If anyone could navigate to http://www.dillonprobinson.com/chris , I would
greatly appreciate some pointers as to what's making things slow down.
I've tried Chrome's diagnostic tools but nothing stood out to me, so maybe
it will to someone else.
I'm not on a strict deadline at all, but I'd like to get this important
part of the site working smoothly before I move on to content.
If anyone here is nice enough to take a look.....I know my styling and
formatting is messy. Cleanup comes later :)
I am in the middle of putting together a website for someone, and they are
dead-set on having various effects in the background of the site to make
it look like an old television.
I've done several things. A vignette around the edge, images of static
that randomize their opacity in the background, and a large scanline-bar
thing that moves from the top to the bottom of the page.
However I realized that, even though it looked all good on one computer,
later on, I noticed (by watching the static flicker and the movement along
the Y-axis of the bar) that it was almost slowing down. Animation would
get choppy and stutter. Sometimes it's barely noticeable, but sometimes
it's glaring and ugly.
I read around, and saw something about setting images to 100% width and
height causes jquery-animate slowdowns....but I can't really change that,
as the effect relies upon these stacked effects covering the whole view
port.
You may suggest smaller images. I tried that already - making my 1080
backgrounds 1/4 their size....but then I also got the slowdown again, and
then read that up-scaling images while animating them ALSO causes
slowdown.
I've fiddled around for hours and tried alternate jquery snippets but
nothing seems to work - I just always get moments of stuttering, choppy
animation of these effects.
Because I'm not unsure of a single piece of code, I don't want to flood
all of the jquery into this post.
If anyone could navigate to http://www.dillonprobinson.com/chris , I would
greatly appreciate some pointers as to what's making things slow down.
I've tried Chrome's diagnostic tools but nothing stood out to me, so maybe
it will to someone else.
I'm not on a strict deadline at all, but I'd like to get this important
part of the site working smoothly before I move on to content.
If anyone here is nice enough to take a look.....I know my styling and
formatting is messy. Cleanup comes later :)
python: rstrip one exact string, respecting order
python: rstrip one exact string, respecting order
Is it possible to use the python command rstrip so that it does only
remove one exact string and does not take all letters separately?
I was confused when this happened:
>>>"Boat.txt".rstrip(".txt")
>>>'Boa'
What I expected was:
>>>"Boat.txt".rstrip(".txt")
>>>'Boat'
Can I somehow use rstrip and respect the order, so that I get the second
outcome?
Is it possible to use the python command rstrip so that it does only
remove one exact string and does not take all letters separately?
I was confused when this happened:
>>>"Boat.txt".rstrip(".txt")
>>>'Boa'
What I expected was:
>>>"Boat.txt".rstrip(".txt")
>>>'Boat'
Can I somehow use rstrip and respect the order, so that I get the second
outcome?
Default working directory in swi-prolog
Default working directory in swi-prolog
I'm having a problem with changing a directory in which I store *.pl
files. The default one is located in my home folder. I can change working
directory either by using working_directory predicate or cd command in
swi-pl interpreter. The thing is I have to do it every single time I run
swi so I'm looking for a permanent solution. I tried to include those two
solutions in .plrc file which I created in my home directory but it didn't
help.
I am Mac OS X user, if that would be of any help.
Also, can you recommend any text editors for prolog with multi-tabs support?
Thanks in advance
I'm having a problem with changing a directory in which I store *.pl
files. The default one is located in my home folder. I can change working
directory either by using working_directory predicate or cd command in
swi-pl interpreter. The thing is I have to do it every single time I run
swi so I'm looking for a permanent solution. I tried to include those two
solutions in .plrc file which I created in my home directory but it didn't
help.
I am Mac OS X user, if that would be of any help.
Also, can you recommend any text editors for prolog with multi-tabs support?
Thanks in advance
Reverse engineer exe or DLL for C# winforms
Reverse engineer exe or DLL for C# winforms
I want to ask if there is any program to use so that I can reverse
engineer from an exe or dll to C# code because by mistake I erase the
source code and I want to make modification.
I want to ask if there is any program to use so that I can reverse
engineer from an exe or dll to C# code because by mistake I erase the
source code and I want to make modification.
sample make file for creating more than one exe files with different directory
sample make file for creating more than one exe files with different
directory
I am having a directory called test where make file should be. i am having
subdirectory called sub1, sub2, sub3.
test/Makefile
test/sub1
test/sub2
test/sub3
I want to create exe1 by compiling sub1, exe2 by compiling sub2 and exe3
from sub3.
Can i add more than one directory in vpath?? or any other solution
directory
I am having a directory called test where make file should be. i am having
subdirectory called sub1, sub2, sub3.
test/Makefile
test/sub1
test/sub2
test/sub3
I want to create exe1 by compiling sub1, exe2 by compiling sub2 and exe3
from sub3.
Can i add more than one directory in vpath?? or any other solution
Monday, 9 September 2013
white circle in microsoft SQL server management studio 2012
white circle in microsoft SQL server management studio 2012
I'm new in SQL server management studio 2012
now i'm use data from server and it has a white circle on my database
4 people in my team use this server and everyone see that...
we use same ID to login to this server...
what does it's mean
please help me...
I'm new in SQL server management studio 2012
now i'm use data from server and it has a white circle on my database
4 people in my team use this server and everyone see that...
we use same ID to login to this server...
what does it's mean
please help me...
working with cookies in dispatch-classic
working with cookies in dispatch-classic
I need to programmatically log into a backend server, which returns an
auth token as a cookie, then use that cookie to make requests going
forward. I'm working in Lift 2.4, and everything I read seems to recommend
using http-dispatch, but that has been cumbersome to learn! :-/ I'm
working in dispatch-classic because of my SBT version (0.1-SNAPSHOT) and
scala version 2.9.1. So I'm currently loading the dispatch 0.8.6
libraries.
I found the following at
https://groups.google.com/forum/#!msg/dispatch-scala/m7oWv2YAtjQ/imnkYoCDVUcJ
For retrieving cookies:
To read a cookie from a response, you have to call the Response#getCookies
method. For example, you could do something like this:
val res =
Http(url("http://www.google.com/ig/api").addQueryParameter("weather",
"Bonn, Germany"))
val response = for { r <- res } yield (r.getCookies, r.getResponseBody)
for adding cookies to subsequent requests:
url("http://www.google.com/ig/api").addCookie(cookie)
But I can't get this to work. My preference is code that works with
dispatch 0.8.6, but if you can make it work in another version and don't
see what that version won't work with my SBT and scala/Lift versions, I'll
try using your recommended library version.
I need to programmatically log into a backend server, which returns an
auth token as a cookie, then use that cookie to make requests going
forward. I'm working in Lift 2.4, and everything I read seems to recommend
using http-dispatch, but that has been cumbersome to learn! :-/ I'm
working in dispatch-classic because of my SBT version (0.1-SNAPSHOT) and
scala version 2.9.1. So I'm currently loading the dispatch 0.8.6
libraries.
I found the following at
https://groups.google.com/forum/#!msg/dispatch-scala/m7oWv2YAtjQ/imnkYoCDVUcJ
For retrieving cookies:
To read a cookie from a response, you have to call the Response#getCookies
method. For example, you could do something like this:
val res =
Http(url("http://www.google.com/ig/api").addQueryParameter("weather",
"Bonn, Germany"))
val response = for { r <- res } yield (r.getCookies, r.getResponseBody)
for adding cookies to subsequent requests:
url("http://www.google.com/ig/api").addCookie(cookie)
But I can't get this to work. My preference is code that works with
dispatch 0.8.6, but if you can make it work in another version and don't
see what that version won't work with my SBT and scala/Lift versions, I'll
try using your recommended library version.
Subscribe to:
Comments (Atom)