function, JSON, and variable
I've a problem with creation a function. For example I have a parsed json
date, I want to get value of 'test' and return it.
function returnVal(name) {
parsedJSON = JSON.parse('{"test": "hello"}');
return parsedJSON.name;
}
Thanks for any advices, and excuse me for my bad English :)
Saturday, 31 August 2013
JS in Rails App only loads the first time
JS in Rails App only loads the first time
I am using a fade effect on some links on my applications home page. This
is being accomplished by some JQuery:
javascripts/pages.js
$(document).ready(function() {
$('.home_tile_text').hide().removeClass('text').addClass('text-js');
$('.home_tile_overlay').hide().removeClass('overlay').addClass('overlay-js');
$('.home_tile').mouseenter(function(){
$(this).find('.text-js').finish().hide().fadeIn();
$(this).find('.overlay-js').finish().hide().fadeIn();
});
$('.home_tile').mouseleave(function(){
$(this).find('.text-js').finish().show().fadeOut();
$(this).find('.overlay-js').finish().show().fadeOut();
});
});
This all works great when I fire up the app for the first time. However,
if I navigate away from the home page, when I come back, the fade effect
no longer works until I "refresh" the page. Any ideas?
I am using a fade effect on some links on my applications home page. This
is being accomplished by some JQuery:
javascripts/pages.js
$(document).ready(function() {
$('.home_tile_text').hide().removeClass('text').addClass('text-js');
$('.home_tile_overlay').hide().removeClass('overlay').addClass('overlay-js');
$('.home_tile').mouseenter(function(){
$(this).find('.text-js').finish().hide().fadeIn();
$(this).find('.overlay-js').finish().hide().fadeIn();
});
$('.home_tile').mouseleave(function(){
$(this).find('.text-js').finish().show().fadeOut();
$(this).find('.overlay-js').finish().show().fadeOut();
});
});
This all works great when I fire up the app for the first time. However,
if I navigate away from the home page, when I come back, the fade effect
no longer works until I "refresh" the page. Any ideas?
Why is List.reduce necessary in this newbie example?
Why is List.reduce necessary in this newbie example?
pPlaying around with F#, I am confused with the following behavior. When
codeList.reduce (gt;gt;)/code is commented out, there is the error/p
precodedefaultLabel |gt; showRainbow ----------------^^^^^^^^^^^ This
expression was expected to have type CoolLabel -gt; 'a but here has type
(CoolLabel -gt; CoolLabel) list /code/pre pin this example boiled down
from a
href=http://fsharpforfunandprofit.com/posts/conciseness-functions-as-building-blocks/
rel=nofollowhttp://fsharpforfunandprofit.com/posts/conciseness-functions-as-building-blocks//a
:/p precode// create an underlying type type CoolLabel = { label : string;
} let defaultLabel = {label=;} let setLabel msg label = {label with
CoolLabel.label = msg} let rainbow =
[red;orange;yellow;green;blue;indigo;violet] let showRainbow = rainbow
|gt; List.map setLabel |gt; List.reduce (gt;gt;) // test the showRainbow
function defaultLabel |gt; showRainbow /code/pre pWhen codeList.reduce
(gt;gt;)/code is removed, I would think that showRainbow should return a
list of CoolLabel, and the compiler would be cool with everything. I get
that List.reduce () would return the last CoolLabel from the list.
Thanks./p
pPlaying around with F#, I am confused with the following behavior. When
codeList.reduce (gt;gt;)/code is commented out, there is the error/p
precodedefaultLabel |gt; showRainbow ----------------^^^^^^^^^^^ This
expression was expected to have type CoolLabel -gt; 'a but here has type
(CoolLabel -gt; CoolLabel) list /code/pre pin this example boiled down
from a
href=http://fsharpforfunandprofit.com/posts/conciseness-functions-as-building-blocks/
rel=nofollowhttp://fsharpforfunandprofit.com/posts/conciseness-functions-as-building-blocks//a
:/p precode// create an underlying type type CoolLabel = { label : string;
} let defaultLabel = {label=;} let setLabel msg label = {label with
CoolLabel.label = msg} let rainbow =
[red;orange;yellow;green;blue;indigo;violet] let showRainbow = rainbow
|gt; List.map setLabel |gt; List.reduce (gt;gt;) // test the showRainbow
function defaultLabel |gt; showRainbow /code/pre pWhen codeList.reduce
(gt;gt;)/code is removed, I would think that showRainbow should return a
list of CoolLabel, and the compiler would be cool with everything. I get
that List.reduce () would return the last CoolLabel from the list.
Thanks./p
Creating random alingment for a matrix in matlab
Creating random alingment for a matrix in matlab
How can I create an array with number from 1 to 10 for example without
repeating. Because I will use it to re-aling a matrix's rows. For example
of 1 to 10, I want my output as: 4 1 3 8 2 5 6 7 9 10 But I don't want to
have repated numbers. How can I do that?
How can I create an array with number from 1 to 10 for example without
repeating. Because I will use it to re-aling a matrix's rows. For example
of 1 to 10, I want my output as: 4 1 3 8 2 5 6 7 9 10 But I don't want to
have repated numbers. How can I do that?
input onfocus not changing div style
input onfocus not changing div style
I have two input forms. I want the second input form to appear when the
user focuses on the first input form. I used a simple javascript "onfocus"
within the input tags. This worked fine when it was changing the style of
another input form. This however left an unwanted gap. I tried making it
so the entire div group appeard onfocus but it had no effect.
I want to make the entire "form-group" div to appear when the user focuses
on the first input form but for some reason, this is not working at all.
HTML
<div class="form-group<?php if(form_error('con_password') != ''){ echo "
has-error"; } ?>">
<div class="col-md-10">
<input type="password" name="con_password" class="form-control
input-lg" placeholder="Password Confirmation"
onfocus="occupation.style.display='block'">
<span class="help-block"><?php echo form_error('con_password');
?></span>
</div>
</div>
<div class="form-group<?php if(form_error('occupation') != ''){ echo "
has-error"; } ?>" id="occupation">
<div class="col-md-10">
<input type="text" name="occupation" class="form-control input-lg"
value="<?php echo set_value('occupation'); ?>"
placeholder="Occupation" onfocus="hearus.style.display='block'">
<span class="help-block"><?php echo form_error('occupation');
?></span>
</div>
</div>
CSS
#occupation{
display: none;
}
I have two input forms. I want the second input form to appear when the
user focuses on the first input form. I used a simple javascript "onfocus"
within the input tags. This worked fine when it was changing the style of
another input form. This however left an unwanted gap. I tried making it
so the entire div group appeard onfocus but it had no effect.
I want to make the entire "form-group" div to appear when the user focuses
on the first input form but for some reason, this is not working at all.
HTML
<div class="form-group<?php if(form_error('con_password') != ''){ echo "
has-error"; } ?>">
<div class="col-md-10">
<input type="password" name="con_password" class="form-control
input-lg" placeholder="Password Confirmation"
onfocus="occupation.style.display='block'">
<span class="help-block"><?php echo form_error('con_password');
?></span>
</div>
</div>
<div class="form-group<?php if(form_error('occupation') != ''){ echo "
has-error"; } ?>" id="occupation">
<div class="col-md-10">
<input type="text" name="occupation" class="form-control input-lg"
value="<?php echo set_value('occupation'); ?>"
placeholder="Occupation" onfocus="hearus.style.display='block'">
<span class="help-block"><?php echo form_error('occupation');
?></span>
</div>
</div>
CSS
#occupation{
display: none;
}
Recursive vs iterative factorials in java?
Recursive vs iterative factorials in java?
In java, which method is typically faster for computing the factorials of
numbers? Recursive or iterative?
Also, which works better for larger numbers and which is better for
smaller numbers?
In java, which method is typically faster for computing the factorials of
numbers? Recursive or iterative?
Also, which works better for larger numbers and which is better for
smaller numbers?
RecusriveDirectoryIterator - Getting files within folder with specific params
RecusriveDirectoryIterator - Getting files within folder with specific params
My end-goal is to grab only jpg|png files from within a directory (that
has directories in it). I first started with this article and settled on
the OOP approach (since this seems to be the best way forward). Of course,
with this comes some complexities that I haven't found a good example for
thusfar. The following example (taken from the PHP docs page) seems to get
me part of the way there, but I haven't found a good way to match all of
the requirements (below the example):
$ritit = new RecursiveIteratorIterator(new
RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST );
$r = array();
foreach ($ritit as $splFileInfo) {
$path = $splFileInfo->isDir()
? array($splFileInfo->getFilename() => array())
: array($splFileInfo->getFilename());
for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) {
$path =
array($ritit->getSubIterator($depth)->current()->getFilename() =>
$path);
}
$r = array_merge_recursive($r, $path);
}
print_r($r);
What I'd like to do is:
Specify a $directory (let's say /media/galleries)
Have it only look at directories first (so if any files are in that
top-level directory it ignores them)
Check if each directory is readable (it may do this by default already)
List out each jpg|png file within these files (again, making sure each is
readable which I believe it may do by default)
Ignore any/all dot files in the FilesystemIterator seems to do, but I'm
still getting the dreaded .DS_Store files in the top-level)
Store these as a multi-dimensional array
The aforementioned example seems to be almost there, but any help to steer
me in the right direction would be greatly appreciated. Thanks!
My end-goal is to grab only jpg|png files from within a directory (that
has directories in it). I first started with this article and settled on
the OOP approach (since this seems to be the best way forward). Of course,
with this comes some complexities that I haven't found a good example for
thusfar. The following example (taken from the PHP docs page) seems to get
me part of the way there, but I haven't found a good way to match all of
the requirements (below the example):
$ritit = new RecursiveIteratorIterator(new
RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST );
$r = array();
foreach ($ritit as $splFileInfo) {
$path = $splFileInfo->isDir()
? array($splFileInfo->getFilename() => array())
: array($splFileInfo->getFilename());
for ($depth = $ritit->getDepth() - 1; $depth >= 0; $depth--) {
$path =
array($ritit->getSubIterator($depth)->current()->getFilename() =>
$path);
}
$r = array_merge_recursive($r, $path);
}
print_r($r);
What I'd like to do is:
Specify a $directory (let's say /media/galleries)
Have it only look at directories first (so if any files are in that
top-level directory it ignores them)
Check if each directory is readable (it may do this by default already)
List out each jpg|png file within these files (again, making sure each is
readable which I believe it may do by default)
Ignore any/all dot files in the FilesystemIterator seems to do, but I'm
still getting the dreaded .DS_Store files in the top-level)
Store these as a multi-dimensional array
The aforementioned example seems to be almost there, but any help to steer
me in the right direction would be greatly appreciated. Thanks!
CSS3 image rotating spinner in JS for non CSS3 browsers?
CSS3 image rotating spinner in JS for non CSS3 browsers?
I have a rotating image spinner that looks fantastic...in browsers that
support it. it can be seen at kingpetroleum.co.uk/background.php - it's in
the top corner.
I need to somehow create the same effect for users that are using browsers
that can't display it.
I'm not great with javascript so would be hoping on finding a good
tutorial / guide etc but after a bit of googling I've not come up with
anything.
Any help is appreciated.
I have a rotating image spinner that looks fantastic...in browsers that
support it. it can be seen at kingpetroleum.co.uk/background.php - it's in
the top corner.
I need to somehow create the same effect for users that are using browsers
that can't display it.
I'm not great with javascript so would be hoping on finding a good
tutorial / guide etc but after a bit of googling I've not come up with
anything.
Any help is appreciated.
Friday, 30 August 2013
How to solve these two Queries help please
How to solve these two Queries help please
I am new to SQL and I have a homework assignment. I did all questions
right but still unable to figure out this two queries so please help if
you can. I appreciate you in advance.
I have FOUR tables:
EMPLOYEE which conatin the attributes (Fname, Minit, Lname, Ssn, Bdate,
Address, Sex, Salary, Super_ssn, Dno)
Table DEPARTMENT have the columns ( Dname, Dnumber, Mgr_ssn, Mgr_start_date)
Table PROJECT have the columns ( Pname, Pnumber, Plocation, Dnum)
Table DEPENDENT (Essn, Dependent_name, Sex, Bdate, Relationship)
Q1. For the department that controls the most number of projects, list its
name? I came up with this query but still it just gives me each Department
how many Projects it control but can not get it to work as giving me just
the one that has the most :(
SELECT Dname, COUNT(distinct Pnumber) as NumberOfProjects
FROM Department, Project
WHERE Dnum = Dnumber
GROUP BY Dname;
Q2. Retrieve the names and Ssn of employee who have more dependents than
any other employees?
I came up with this but idk why it does not work. I keep on getting an error
SELECT Fname, Lname, Ssn
FROM Employee
WHERE max((SELECT COUNT(*)
FROM Dependent
WHERE Ssn = Essn));
BTW I am using MySql WorkBench 5.2 and The language is just SQL allowed to
be used
I am new to SQL and I have a homework assignment. I did all questions
right but still unable to figure out this two queries so please help if
you can. I appreciate you in advance.
I have FOUR tables:
EMPLOYEE which conatin the attributes (Fname, Minit, Lname, Ssn, Bdate,
Address, Sex, Salary, Super_ssn, Dno)
Table DEPARTMENT have the columns ( Dname, Dnumber, Mgr_ssn, Mgr_start_date)
Table PROJECT have the columns ( Pname, Pnumber, Plocation, Dnum)
Table DEPENDENT (Essn, Dependent_name, Sex, Bdate, Relationship)
Q1. For the department that controls the most number of projects, list its
name? I came up with this query but still it just gives me each Department
how many Projects it control but can not get it to work as giving me just
the one that has the most :(
SELECT Dname, COUNT(distinct Pnumber) as NumberOfProjects
FROM Department, Project
WHERE Dnum = Dnumber
GROUP BY Dname;
Q2. Retrieve the names and Ssn of employee who have more dependents than
any other employees?
I came up with this but idk why it does not work. I keep on getting an error
SELECT Fname, Lname, Ssn
FROM Employee
WHERE max((SELECT COUNT(*)
FROM Dependent
WHERE Ssn = Essn));
BTW I am using MySql WorkBench 5.2 and The language is just SQL allowed to
be used
Thursday, 29 August 2013
javascript doesn't work all the time in IE
javascript doesn't work all the time in IE
Using spring form tags in jsp.
Following is my script,which i am using for pagination :
function getNextPage(){
var next = document.getElementById('nextPageID');
next.checked=true;
var buttonName = document.getElementById('refreshbuttonID');
buttonName.click();
}
when user clicks Next in view (using jsp), onclick event I am calling the
getNextPage();
<button type="submit" onclick="getNextPage();">Next</button>
and I set hidden check-box to true
<td>
<form:checkbox id="nextPageID" path="nextPage"/>
<input type="hidden" value="1" name="_nextPage"/>
</td>
and then calling the method in controller to get next results and show on
page.
everything works fines in chrome and firefox, when it comes IE, some times
it does and sometimes doesn't. and page keeps refreshing with old data..It
works all the time in debug mode (even in IE)
It is not hitting the javascript in IE on some occassions. is there
something I am missing in function or something different to do in IE? Any
suggestions!
Using spring form tags in jsp.
Following is my script,which i am using for pagination :
function getNextPage(){
var next = document.getElementById('nextPageID');
next.checked=true;
var buttonName = document.getElementById('refreshbuttonID');
buttonName.click();
}
when user clicks Next in view (using jsp), onclick event I am calling the
getNextPage();
<button type="submit" onclick="getNextPage();">Next</button>
and I set hidden check-box to true
<td>
<form:checkbox id="nextPageID" path="nextPage"/>
<input type="hidden" value="1" name="_nextPage"/>
</td>
and then calling the method in controller to get next results and show on
page.
everything works fines in chrome and firefox, when it comes IE, some times
it does and sometimes doesn't. and page keeps refreshing with old data..It
works all the time in debug mode (even in IE)
It is not hitting the javascript in IE on some occassions. is there
something I am missing in function or something different to do in IE? Any
suggestions!
Wednesday, 28 August 2013
Rails 4 form_for error: undefined method `model_name' for ActionController::Parameters:Class
Rails 4 form_for error: undefined method `model_name' for
ActionController::Parameters:Class
I'm trying to make a basic form for creating a user record:
<%= debug(@user) %>
<%= form_for @user, url: {action: "create_user"}, html: {class:
"user-create-form"} do |f| %>
<div class="form-group"><%= f.text_field :first_name,
class:'form-control' %></div>
<div class="form-group"><%= f.text_field :last_name,
class:'form-control' %></div>
<div class="form-group"><%= f.text_field :email, class:'form-control'
%></div>
<div class="form-group"><%= f.text_field :password,
class:'form-control' %></div>
<%= f.submit "Update" %>
<% end %>
In the controller:
def create_user
@user = params[:user]
@user = User.new if !@user
end
This loads fine and without error, but when I submit the form, I get the
following error:
NoMethodError in Admin#create_user
Showing
/Applications/MAMP/htdocs/clippo2/app/views/admin/create_user.html.erb
where line #6 raised:
undefined method `model_name' for ActionController::Parameters:Class
Extracted source (around line #6):
<%= form_for @user, url: {action: "create_user"}, html: {class:
"user-create-form"} do |f| %>
ActionController::Parameters:Class
I'm trying to make a basic form for creating a user record:
<%= debug(@user) %>
<%= form_for @user, url: {action: "create_user"}, html: {class:
"user-create-form"} do |f| %>
<div class="form-group"><%= f.text_field :first_name,
class:'form-control' %></div>
<div class="form-group"><%= f.text_field :last_name,
class:'form-control' %></div>
<div class="form-group"><%= f.text_field :email, class:'form-control'
%></div>
<div class="form-group"><%= f.text_field :password,
class:'form-control' %></div>
<%= f.submit "Update" %>
<% end %>
In the controller:
def create_user
@user = params[:user]
@user = User.new if !@user
end
This loads fine and without error, but when I submit the form, I get the
following error:
NoMethodError in Admin#create_user
Showing
/Applications/MAMP/htdocs/clippo2/app/views/admin/create_user.html.erb
where line #6 raised:
undefined method `model_name' for ActionController::Parameters:Class
Extracted source (around line #6):
<%= form_for @user, url: {action: "create_user"}, html: {class:
"user-create-form"} do |f| %>
AngularJS ng-repeat over data with # keys
AngularJS ng-repeat over data with # keys
The data i'm trying to iterate over looks like this:
{
"request": "Stream/GetDigest",
"response": {
"success": true,
"content": {
"0": {
"artifact_id": "36",
"timestamp": "2013-08-20 11:59:00",
"modified": "2013-08-20 11:59:00",
"text": "Why did the last one BLAHHHHH duplicate?
I don't think I clicked it twice...",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"1": {
"artifact_id": "35",
"timestamp": "2013-08-20 11:57:51",
"modified": "2013-08-20 11:57:51",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"2": {
"artifact_id": "34",
"timestamp": "2013-08-20 11:57:50",
"modified": "2013-08-20 11:57:50",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"3": {
"artifact_id": "30",
"timestamp": "2013-08-19 13:15:32",
"modified": "2013-08-20 11:01:12",
"text": "This is some awesome text that we want to
display!",
"author_desc": "",
"object_type": "artifact",
"comments": {
"5": {
"artifact_id": "30",
"comment_id": "5",
"user_id": "5",
"author_desc": "Michael C.",
"timestamp": "2013-08-19 16:18:12",
"private": "1",
"reported": 0,
"moderated": 0,
"banned": 0,
"text": "This is a createComment artifact"
},
"6": {
"artifact_id": "30",
"comment_id": "6",
"user_id": "5",
"author_desc": "Michael C.",
"timestamp": "2013-08-20 11:01:12",
"private": "1",
"reported": 0,
"moderated": 0,
"banned": 0,
"text": "This is another comment"
}
}
},
"4": {
"artifact_id": "33",
"timestamp": "2013-08-19 15:25:11",
"modified": "2013-08-19 15:25:11",
"text": "Kitten Ipsum dolor sit amet urna,
bibendum life litora quis wish vel happy litora
kitties laoreet buddy Praesent her. Lure, local
ipsum amet urna molestie Nam. Snuggliest sed first
chuf his cat kitten, ac climb the curtains cat
eget sagittis et front",
"author_desc": "",
"object_type": "artifact",
"comments": []
}
}
}
}
The goal is to iterate over the response.content.# sections. Currently i'm
passing in the content through the controller (baby steps - i'm new)
through a GetDigest variable. So my NGrepeater looks like this:
<li ng-repeat="thing in GetDigestList.response.content">
How can I make it iterate over the sub sections of this json?
Thanks!
The data i'm trying to iterate over looks like this:
{
"request": "Stream/GetDigest",
"response": {
"success": true,
"content": {
"0": {
"artifact_id": "36",
"timestamp": "2013-08-20 11:59:00",
"modified": "2013-08-20 11:59:00",
"text": "Why did the last one BLAHHHHH duplicate?
I don't think I clicked it twice...",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"1": {
"artifact_id": "35",
"timestamp": "2013-08-20 11:57:51",
"modified": "2013-08-20 11:57:51",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"2": {
"artifact_id": "34",
"timestamp": "2013-08-20 11:57:50",
"modified": "2013-08-20 11:57:50",
"text": "This is a new artifact for a new day.",
"author_desc": "",
"object_type": "artifact",
"comments": []
},
"3": {
"artifact_id": "30",
"timestamp": "2013-08-19 13:15:32",
"modified": "2013-08-20 11:01:12",
"text": "This is some awesome text that we want to
display!",
"author_desc": "",
"object_type": "artifact",
"comments": {
"5": {
"artifact_id": "30",
"comment_id": "5",
"user_id": "5",
"author_desc": "Michael C.",
"timestamp": "2013-08-19 16:18:12",
"private": "1",
"reported": 0,
"moderated": 0,
"banned": 0,
"text": "This is a createComment artifact"
},
"6": {
"artifact_id": "30",
"comment_id": "6",
"user_id": "5",
"author_desc": "Michael C.",
"timestamp": "2013-08-20 11:01:12",
"private": "1",
"reported": 0,
"moderated": 0,
"banned": 0,
"text": "This is another comment"
}
}
},
"4": {
"artifact_id": "33",
"timestamp": "2013-08-19 15:25:11",
"modified": "2013-08-19 15:25:11",
"text": "Kitten Ipsum dolor sit amet urna,
bibendum life litora quis wish vel happy litora
kitties laoreet buddy Praesent her. Lure, local
ipsum amet urna molestie Nam. Snuggliest sed first
chuf his cat kitten, ac climb the curtains cat
eget sagittis et front",
"author_desc": "",
"object_type": "artifact",
"comments": []
}
}
}
}
The goal is to iterate over the response.content.# sections. Currently i'm
passing in the content through the controller (baby steps - i'm new)
through a GetDigest variable. So my NGrepeater looks like this:
<li ng-repeat="thing in GetDigestList.response.content">
How can I make it iterate over the sub sections of this json?
Thanks!
How to send request on a URL in Perl
How to send request on a URL in Perl
I want to send a request of XML on a Particular URL and get the resposne
from there .How could i do this is Perl by creating A Module.I am new in
Perl Please help me .
I want to send a request of XML on a Particular URL and get the resposne
from there .How could i do this is Perl by creating A Module.I am new in
Perl Please help me .
Stuck with DNS questions during migration to AWS EC2 + Route 53
Stuck with DNS questions during migration to AWS EC2 + Route 53
We're running a little hosting service with two nameservers registered for
us at a local registrar:
ns1.ourcompany.com
ns2.ourcompany.com
Now i want to move over to cloudflare with all the DNS services. From
them, i got two new nameservers:
lady.ns.cloudflare.com
pete.ns.cloudflare.com
It is a killer requirement for us that we do not loose the existing two
nameservers because they are already configured in customers top-level
domains where we don't have access directly.
Now, i'm wondering what my options are:
Find out what ip's the two cloudflare servers really have and change the
entries for our existing nameservers to these ip's -> pro, solved; con,
the ip's can change and silently break my dns setup. More lookups are
necessary to finally lookup a customers top level domain.
Making an CNAME alias for my existing nameserver to point to cloudflare
servers directly, but this is against the RFC of DNS, no one will do that
for me..
Pay a business account for at least 200$ per month at cloudflare to get
custom named nameservers
Are there other DNS providers which has an API for automation and offers
custom/vanity nameserver for a payable price per month?
We're running a little hosting service with two nameservers registered for
us at a local registrar:
ns1.ourcompany.com
ns2.ourcompany.com
Now i want to move over to cloudflare with all the DNS services. From
them, i got two new nameservers:
lady.ns.cloudflare.com
pete.ns.cloudflare.com
It is a killer requirement for us that we do not loose the existing two
nameservers because they are already configured in customers top-level
domains where we don't have access directly.
Now, i'm wondering what my options are:
Find out what ip's the two cloudflare servers really have and change the
entries for our existing nameservers to these ip's -> pro, solved; con,
the ip's can change and silently break my dns setup. More lookups are
necessary to finally lookup a customers top level domain.
Making an CNAME alias for my existing nameserver to point to cloudflare
servers directly, but this is against the RFC of DNS, no one will do that
for me..
Pay a business account for at least 200$ per month at cloudflare to get
custom named nameservers
Are there other DNS providers which has an API for automation and offers
custom/vanity nameserver for a payable price per month?
Tuesday, 27 August 2013
getting the name of a key of an object in js
getting the name of a key of an object in js
I hopefully have a very simple question but if I have the code
console.log("my args", args);
and the result that comes back is
Object { pageList1=null}
how do i get the name pageList1
it doesnt matter that this is null i just need the name pageList1..
this is what i have tried
parse: function (result, args) {
var myKey = Object.keys(args);
return result.data.myKey;
}
ok so using on of the answers i updated the code to be
parse: function (result, args) {
for (variable in args) {
return result.data.variable;
}
}
but that doesnt like just the name variable as thats not in the JSON
structure..
OK so the answer was
parse: function (result, args) {
var pageListVariable = Object.keys(args)[0];
return result.data[pageListVariable];
}
when needing to change the call of the json the . needs to be replaced
with []
I hopefully have a very simple question but if I have the code
console.log("my args", args);
and the result that comes back is
Object { pageList1=null}
how do i get the name pageList1
it doesnt matter that this is null i just need the name pageList1..
this is what i have tried
parse: function (result, args) {
var myKey = Object.keys(args);
return result.data.myKey;
}
ok so using on of the answers i updated the code to be
parse: function (result, args) {
for (variable in args) {
return result.data.variable;
}
}
but that doesnt like just the name variable as thats not in the JSON
structure..
OK so the answer was
parse: function (result, args) {
var pageListVariable = Object.keys(args)[0];
return result.data[pageListVariable];
}
when needing to change the call of the json the . needs to be replaced
with []
Sending image file over Bluetooth 4.0 LE
Sending image file over Bluetooth 4.0 LE
I am trying to send an .png image file from one iOS Device to another over
Bluetooth 4.0 LE.
I am able to simple pieces of data like strings, but unable to
successfully send and utilize image files.
In the Peripheral device, I start out with this
pictureBeforeData = [UIImage imageNamed:@"myImage.png"];
NSData *myData = UIImagePNGRepresentation(pictureBeforeData);
Then I make myData a characteristic's value.
_myCharacteristic =
[[CBMutableCharacteristic alloc] initWithType:_myCharacteristicUUID
properties:CBCharacteristicPropertyRead
value:myData
permissions:CBAttributePermissionsReadable];
In the Central Device, I have this when the characteristic's value is updated
- (void)peripheral:(CBPeripheral *)peripheral
didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic
error:(NSError *)error {
if ([characteristic.UUID isEqual:[CBUUID
UUIDWithString:_myCharacteristicUUID]])
{
NSLog(@"PICTURE CHARACTERISTIC FOUND"); // This successfully gets logged
NSData *dataFromCharacteristic = [[NSData alloc]
initWithData:characteristic.value];
UIImage *imageFromData = [[UIImage
alloc]initWithData:dataFromCharacteristic];
// This correctly logs the size of my image
NSLog(@"SIZE: %f, %f", imageFromData.size.height,
imageFromData.size.width);
// This causes the imageView to turn completely black
_sentPictureImageView.image = imageFromData;
if (!([_myImagesArray containsObject:imageFromData]))
{
NSLog(@"DOES NOT CONTAIN"); // This is successfully logged
[_myImagesArray addObject:imageFromData]; // This runs but is
apparently not adding the image to the array
}
NSLog(@"COUNT: %u", _contactsImagesArray.count); // This always logs 0
- The array is empty }
When I run this, I get this error:
<Error>: ImageIO: PNG invalid PNG file: iDOT doesn't point to valid IDAT
chunk
I looked through this thread and tried the solutions, but nothing seemed
to work. Invalid PNG Image file: iDOT doesn't point to valid IDAT chunk
Right after receiving this error, the size correctly logs out:
SIZE: 160.000000, 160.000000
Does the fact that I can read the size mean that I am successfully sending
the image file over?
When I attempt to add the image to an array, the array always returns a
count of 0.
My imageView is the black square, which should be displaying the image I
have sent over.
I am trying to send an .png image file from one iOS Device to another over
Bluetooth 4.0 LE.
I am able to simple pieces of data like strings, but unable to
successfully send and utilize image files.
In the Peripheral device, I start out with this
pictureBeforeData = [UIImage imageNamed:@"myImage.png"];
NSData *myData = UIImagePNGRepresentation(pictureBeforeData);
Then I make myData a characteristic's value.
_myCharacteristic =
[[CBMutableCharacteristic alloc] initWithType:_myCharacteristicUUID
properties:CBCharacteristicPropertyRead
value:myData
permissions:CBAttributePermissionsReadable];
In the Central Device, I have this when the characteristic's value is updated
- (void)peripheral:(CBPeripheral *)peripheral
didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic
error:(NSError *)error {
if ([characteristic.UUID isEqual:[CBUUID
UUIDWithString:_myCharacteristicUUID]])
{
NSLog(@"PICTURE CHARACTERISTIC FOUND"); // This successfully gets logged
NSData *dataFromCharacteristic = [[NSData alloc]
initWithData:characteristic.value];
UIImage *imageFromData = [[UIImage
alloc]initWithData:dataFromCharacteristic];
// This correctly logs the size of my image
NSLog(@"SIZE: %f, %f", imageFromData.size.height,
imageFromData.size.width);
// This causes the imageView to turn completely black
_sentPictureImageView.image = imageFromData;
if (!([_myImagesArray containsObject:imageFromData]))
{
NSLog(@"DOES NOT CONTAIN"); // This is successfully logged
[_myImagesArray addObject:imageFromData]; // This runs but is
apparently not adding the image to the array
}
NSLog(@"COUNT: %u", _contactsImagesArray.count); // This always logs 0
- The array is empty }
When I run this, I get this error:
<Error>: ImageIO: PNG invalid PNG file: iDOT doesn't point to valid IDAT
chunk
I looked through this thread and tried the solutions, but nothing seemed
to work. Invalid PNG Image file: iDOT doesn't point to valid IDAT chunk
Right after receiving this error, the size correctly logs out:
SIZE: 160.000000, 160.000000
Does the fact that I can read the size mean that I am successfully sending
the image file over?
When I attempt to add the image to an array, the array always returns a
count of 0.
My imageView is the black square, which should be displaying the image I
have sent over.
Using jQuery to calculate offset in an absolutely positioned container
Using jQuery to calculate offset in an absolutely positioned container
All of my content is within an absolute container, #content, which is 100%
width and height. So when scrolling, we are scrolling through the
container, not the body.
I am trying to caclulate the offset of a series of sections within the
page like so:
$('.advance').on("click", function(){
var nextSection = $(this).parent('.section').next('.section');
var nextDistanceTop = nextSection.offset().top - 25;
$("#content").animate({ scrollTop: nextDistanceTop });
});
Because the container is absolutely positioned, the offset().top is giving
me the offset from the top of the viewport. I need to calculate the offset
relative to the top of the screen/header, or the scroll position. Any
other workarounds to accomplish this?
All of my content is within an absolute container, #content, which is 100%
width and height. So when scrolling, we are scrolling through the
container, not the body.
I am trying to caclulate the offset of a series of sections within the
page like so:
$('.advance').on("click", function(){
var nextSection = $(this).parent('.section').next('.section');
var nextDistanceTop = nextSection.offset().top - 25;
$("#content").animate({ scrollTop: nextDistanceTop });
});
Because the container is absolutely positioned, the offset().top is giving
me the offset from the top of the viewport. I need to calculate the offset
relative to the top of the screen/header, or the scroll position. Any
other workarounds to accomplish this?
c++ build errors on win32 school application
c++ build errors on win32 school application
I haven't been programming in c++ very long, but need to make an Win32
application for my school. The teacher helped me a lot with information
but after a few days of trying I am still stuck.
Errors:
error C2440: '=' : cannot convert from 'const char [11]' to 'LPCWSTR'
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const
char [11]' to 'LPCWSTR'
error C2664: 'TextOutW' : cannot convert parameter 4 from 'char *' to
'LPCWSTR'
IntelliSense: argument of type "char *" is incompatible with parameter of
type "LPCWSTR"
Don't know if all the other suff is right, but i only get those 4 error now
cpp file:
/* Hoofdstuk 10, User Interface */
#include "Callback_NYCM.h"
// UI
int WINAPI WinMain(HINSTANCE thisInstance,HINSTANCE prevInstance,LPSTR
lpCmdLine,int nShowCmd)
{
PAINTSTRUCT ps;
HDC hdc;
MSG msg;
HWND hwnd;
WNDCLASSEX wndclassex; //struct_WNDCLASSEX via windows.h
// toekenning
wndclassex.cbSize = sizeof(WNDCLASSEX);
wndclassex.style = CS_HREDRAW | CS_VREDRAW;
wndclassex.lpfnWndProc = WndProc;
wndclassex.cbClsExtra = 0;
wndclassex.cbWndExtra = 0;
wndclassex.hInstance = thisInstance;
wndclassex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclassex.hCursor = LoadCursor(thisInstance,IDC_ARROW);
wndclassex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndclassex.lpszMenuName = NULL;
wndclassex.lpszClassName = "WNDCLASSEX";
wndclassex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
// functie aanroep
RegisterClassEx(&wndclassex);
// IfThen -> CreateWindows
if(!(hwnd = CreateWindowEx(NULL,"WNDCLASSEX","Hoofdstuk
10",WS_OVERLAPPEDWINDOW
| WS_VISIBLE,50,50,650,300,NULL,NULL,thisInstance,NULL)))
{
return 0;
}
// logische structuur
while(GetMessage(&msg, NULL, 0, 0))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
};
header file:
/*Hoofdstuk 10, Deelnemer.h*/
//Declaratie
class Deelnemer
{
private:
char* nm;
public:
//Constructor
Deelnemer(){
}
//Methoden = prototype
void Deelnemer::Invoeren();
char* Deelnemer::WeergevenNaam();
};
//Implemenmtatie.Invoeren
void Deelnemer::Invoeren()
{
nm = "Roy";
}
//.Weergeven
char* Deelnemer::WeergevenNaam()
{
return nm;
}
callback_NYCM.h:
/*Hoofdstuk 10, Callback_NYCM*/
#include "Windows.h"
#include "Deelnemer.h"
// prototype
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam);
//Implementatie
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
//Constructie
PAINTSTRUCT ps;
HDC hdc;
MSG msg;
WNDCLASSEX wndclassex;
// HWND hwnd;
Deelnemer deelnemer1;
//UI
switch(message)
{
case WM_PAINT:
{
//Functieaanroep.Initialisatie
deelnemer1.Invoeren();
//.TextOut
TextOut(hdc,50,50,deelnemer1.WeergevenNaam(),
strlen(deelnemer1.WeergevenNaam()));
EndPaint(hwnd,&ps);
return 0;
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
break;
default:
{
return DefWindowProc(hwnd,message,wparam,lparam);
}
break;
}
return 0;
}
I think my constructor or something like that is wrong and my return value
for char* Deelnemer::WeergevenNaam()
Could somebody explain me what is wrong in my code so I know how to get it
working?
UPDATE:
Updating your application requires to use UNICODE string literals
throughout, i.e. L"MyString" instead of "MyString". You also need to use
WCHAR/wchar_t in place of char
But how do i do this with my code, could somebody help?
UPDATE 2: That solved al lot of errors!
But i have some more errors left in this part
Deelnemer deelnemer1;
switch(message)
{
case WM_PAINT:
{
//Functieaanroep.Initialisatie
deelnemer1.Invoeren();
//.TextOut
TextOut(hdc,50,50,deelnemer1.WeergevenNaam(),
strlen(deelnemer1.WeergevenNaam()));
EndPaint(hwnd,&ps);
return 0;
}
-- deelnemer1.WeergevenNaam() is not working: -TextOutW' : cannot convert
parameter 4 from 'char *' to 'LPCWSTR' -IntelliSense: argument of type
"char *" is incompatible with parameter of type "LPCWSTR"
I haven't been programming in c++ very long, but need to make an Win32
application for my school. The teacher helped me a lot with information
but after a few days of trying I am still stuck.
Errors:
error C2440: '=' : cannot convert from 'const char [11]' to 'LPCWSTR'
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const
char [11]' to 'LPCWSTR'
error C2664: 'TextOutW' : cannot convert parameter 4 from 'char *' to
'LPCWSTR'
IntelliSense: argument of type "char *" is incompatible with parameter of
type "LPCWSTR"
Don't know if all the other suff is right, but i only get those 4 error now
cpp file:
/* Hoofdstuk 10, User Interface */
#include "Callback_NYCM.h"
// UI
int WINAPI WinMain(HINSTANCE thisInstance,HINSTANCE prevInstance,LPSTR
lpCmdLine,int nShowCmd)
{
PAINTSTRUCT ps;
HDC hdc;
MSG msg;
HWND hwnd;
WNDCLASSEX wndclassex; //struct_WNDCLASSEX via windows.h
// toekenning
wndclassex.cbSize = sizeof(WNDCLASSEX);
wndclassex.style = CS_HREDRAW | CS_VREDRAW;
wndclassex.lpfnWndProc = WndProc;
wndclassex.cbClsExtra = 0;
wndclassex.cbWndExtra = 0;
wndclassex.hInstance = thisInstance;
wndclassex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclassex.hCursor = LoadCursor(thisInstance,IDC_ARROW);
wndclassex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndclassex.lpszMenuName = NULL;
wndclassex.lpszClassName = "WNDCLASSEX";
wndclassex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
// functie aanroep
RegisterClassEx(&wndclassex);
// IfThen -> CreateWindows
if(!(hwnd = CreateWindowEx(NULL,"WNDCLASSEX","Hoofdstuk
10",WS_OVERLAPPEDWINDOW
| WS_VISIBLE,50,50,650,300,NULL,NULL,thisInstance,NULL)))
{
return 0;
}
// logische structuur
while(GetMessage(&msg, NULL, 0, 0))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
};
header file:
/*Hoofdstuk 10, Deelnemer.h*/
//Declaratie
class Deelnemer
{
private:
char* nm;
public:
//Constructor
Deelnemer(){
}
//Methoden = prototype
void Deelnemer::Invoeren();
char* Deelnemer::WeergevenNaam();
};
//Implemenmtatie.Invoeren
void Deelnemer::Invoeren()
{
nm = "Roy";
}
//.Weergeven
char* Deelnemer::WeergevenNaam()
{
return nm;
}
callback_NYCM.h:
/*Hoofdstuk 10, Callback_NYCM*/
#include "Windows.h"
#include "Deelnemer.h"
// prototype
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam);
//Implementatie
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
//Constructie
PAINTSTRUCT ps;
HDC hdc;
MSG msg;
WNDCLASSEX wndclassex;
// HWND hwnd;
Deelnemer deelnemer1;
//UI
switch(message)
{
case WM_PAINT:
{
//Functieaanroep.Initialisatie
deelnemer1.Invoeren();
//.TextOut
TextOut(hdc,50,50,deelnemer1.WeergevenNaam(),
strlen(deelnemer1.WeergevenNaam()));
EndPaint(hwnd,&ps);
return 0;
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
break;
default:
{
return DefWindowProc(hwnd,message,wparam,lparam);
}
break;
}
return 0;
}
I think my constructor or something like that is wrong and my return value
for char* Deelnemer::WeergevenNaam()
Could somebody explain me what is wrong in my code so I know how to get it
working?
UPDATE:
Updating your application requires to use UNICODE string literals
throughout, i.e. L"MyString" instead of "MyString". You also need to use
WCHAR/wchar_t in place of char
But how do i do this with my code, could somebody help?
UPDATE 2: That solved al lot of errors!
But i have some more errors left in this part
Deelnemer deelnemer1;
switch(message)
{
case WM_PAINT:
{
//Functieaanroep.Initialisatie
deelnemer1.Invoeren();
//.TextOut
TextOut(hdc,50,50,deelnemer1.WeergevenNaam(),
strlen(deelnemer1.WeergevenNaam()));
EndPaint(hwnd,&ps);
return 0;
}
-- deelnemer1.WeergevenNaam() is not working: -TextOutW' : cannot convert
parameter 4 from 'char *' to 'LPCWSTR' -IntelliSense: argument of type
"char *" is incompatible with parameter of type "LPCWSTR"
Find Public Facebook Videos
Find Public Facebook Videos
http://www.downvids.net/video/
I am trying to build an iOS app and having trouble trying to find the
public links of facebook videos.
So in general i wanted to do what this website above is doing, show
popular or new videos that are shared on facebook.
Can anybody guide me in right direction please?
http://www.downvids.net/video/
I am trying to build an iOS app and having trouble trying to find the
public links of facebook videos.
So in general i wanted to do what this website above is doing, show
popular or new videos that are shared on facebook.
Can anybody guide me in right direction please?
How to add timestamp on MySQL outputfile?
How to add timestamp on MySQL outputfile?
Hi I'm making an event that runs every minute and extracts certain columns
on a table and creates an output-file in excel format
Since I cannot overwrite the file, i wanted to append a time-stamp on the
filename so it will create unique excel filenames.
Here is the sample of my event
CREATE EVENT IF NOT EXISTS 'Extract_Users'
ON SCHEDULE EVERY 1 Minute
COMMENT 'Data Extraction' DO SELECT userID, email, id FROM
table_one.user_name
INTO OUTFILE 'C:\path\path\Desktop\test\user.xls'
Thank you!
Hi I'm making an event that runs every minute and extracts certain columns
on a table and creates an output-file in excel format
Since I cannot overwrite the file, i wanted to append a time-stamp on the
filename so it will create unique excel filenames.
Here is the sample of my event
CREATE EVENT IF NOT EXISTS 'Extract_Users'
ON SCHEDULE EVERY 1 Minute
COMMENT 'Data Extraction' DO SELECT userID, email, id FROM
table_one.user_name
INTO OUTFILE 'C:\path\path\Desktop\test\user.xls'
Thank you!
How to close the Child Windows? in the Selenium WebDriver - By Using the FunctionalClass
How to close the Child Windows? in the Selenium WebDriver - By Using the
FunctionalClass
How to close the Child Windows? in the Selenium WebDriver - By Using the
FunctionalClass Hi i am using the Selenium Web Driver and Frame Work, In
My Application When i click on the
One Link Button, Then Child Window Will be Displaying On the Screen, Now
How To close
Child Windows.
public class Reports
{
public void RPS(WebDriver driver) throws Exception
{
AllpagesLogins ALP= new AllpagesLogins();
//Clicking on the Reports Menu Btn-- Use for Menu Button upper and down
WebElement element1 = driver.findElement(By.id(ALP.RP_Reports_MenuBtn_ID));
((JavascriptExecutor) driver).executeScript("arguments[0].click()",
element1);
System.out.println("Clicked on the Reports Menu Btn");
Thread.sleep(1000);
//Clicking on the Particular Link Button
if(driver.findElement(By.linkText("Congratulations Sandeep
Pushpala!!!")).isDisplayed())
{
System.out.println("Link Button is Displayed");
driver.findElement(By.linkText("Congratulations Sandeep
Pushpala!!!")).click();
System.out.println("Clicked on the Link Button Which is Displayed");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is Not Displayed");
}
//clicking on the First Link Button, It will display the First Child Window
////////////////////////////11111111111111
if(driver.findElement(By.id(ALP.RP_TotalRecipients_LnkBtn_ID)).isEnabled())
{
System.out.println("LnkBtnTotalRecipientsID Link Button is Enabled");
driver.findElement(By.id(ALP.RP_TotalRecipients_LnkBtn_ID)).click();
System.out.println("Clicked on the LnkBtnTotalRecipientsID Button");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is Total Recipients is Not Displayed");
}
//clicking on the Second Link Button, It will display the Second Child
Window
////////////////////////////2222222222222222222
if(driver.findElement(By.id(ALP.RP_SuccessfullRecipientsData_LnkBtn_ID)).isEnabled())
{
System.out.println("SuccessfullRecipientsDataID Link Button is Enabled");
driver.findElement(By.id(ALP.RP_SuccessfullRecipientsData_LnkBtn_ID)).click();
System.out.println("Clicked on the LinkSuccessfullRecipientsDataID Button");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is SuccessfullRecipientsDataID is Not
Displayed");
}
//clicking on the Third Link Button, It will display the Third ![enter
image description here][1]Child Window
///////////////////////////////333333333333333333333333333
if(driver.findElement(By.id(ALP.Rp_NotSucessfullRecipientsData_LnkBtn_ID)).isEnabled())
{
System.out.println("NotSucessfullRecipientsDataID Link Button is Enabled");
driver.findElement(By.id(ALP.Rp_NotSucessfullRecipientsData_LnkBtn_ID)).click();
System.out.println("Clicked on the LinkNotSucessfullRecipientsDataID
Button");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is Successfully Recipients Data ID is Not
Displayed");
}
for Closing the Child Windows I am Using This Code
//Closing the First Child Window
driver.close();
System.out.println("First Child Window is Closed");
Thread.sleep(2000);
//Closing the Second Child Window
driver.close();
System.out.println("Second Child Window is Closed");
Thread.sleep(2000);
//Closing the Third Child Window
driver.close();
System.out.println("Third Child Window is Closed");
Thread.sleep(2000);
FunctionalClass
How to close the Child Windows? in the Selenium WebDriver - By Using the
FunctionalClass Hi i am using the Selenium Web Driver and Frame Work, In
My Application When i click on the
One Link Button, Then Child Window Will be Displaying On the Screen, Now
How To close
Child Windows.
public class Reports
{
public void RPS(WebDriver driver) throws Exception
{
AllpagesLogins ALP= new AllpagesLogins();
//Clicking on the Reports Menu Btn-- Use for Menu Button upper and down
WebElement element1 = driver.findElement(By.id(ALP.RP_Reports_MenuBtn_ID));
((JavascriptExecutor) driver).executeScript("arguments[0].click()",
element1);
System.out.println("Clicked on the Reports Menu Btn");
Thread.sleep(1000);
//Clicking on the Particular Link Button
if(driver.findElement(By.linkText("Congratulations Sandeep
Pushpala!!!")).isDisplayed())
{
System.out.println("Link Button is Displayed");
driver.findElement(By.linkText("Congratulations Sandeep
Pushpala!!!")).click();
System.out.println("Clicked on the Link Button Which is Displayed");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is Not Displayed");
}
//clicking on the First Link Button, It will display the First Child Window
////////////////////////////11111111111111
if(driver.findElement(By.id(ALP.RP_TotalRecipients_LnkBtn_ID)).isEnabled())
{
System.out.println("LnkBtnTotalRecipientsID Link Button is Enabled");
driver.findElement(By.id(ALP.RP_TotalRecipients_LnkBtn_ID)).click();
System.out.println("Clicked on the LnkBtnTotalRecipientsID Button");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is Total Recipients is Not Displayed");
}
//clicking on the Second Link Button, It will display the Second Child
Window
////////////////////////////2222222222222222222
if(driver.findElement(By.id(ALP.RP_SuccessfullRecipientsData_LnkBtn_ID)).isEnabled())
{
System.out.println("SuccessfullRecipientsDataID Link Button is Enabled");
driver.findElement(By.id(ALP.RP_SuccessfullRecipientsData_LnkBtn_ID)).click();
System.out.println("Clicked on the LinkSuccessfullRecipientsDataID Button");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is SuccessfullRecipientsDataID is Not
Displayed");
}
//clicking on the Third Link Button, It will display the Third ![enter
image description here][1]Child Window
///////////////////////////////333333333333333333333333333
if(driver.findElement(By.id(ALP.Rp_NotSucessfullRecipientsData_LnkBtn_ID)).isEnabled())
{
System.out.println("NotSucessfullRecipientsDataID Link Button is Enabled");
driver.findElement(By.id(ALP.Rp_NotSucessfullRecipientsData_LnkBtn_ID)).click();
System.out.println("Clicked on the LinkNotSucessfullRecipientsDataID
Button");
Thread.sleep(2000);
}
else
{
System.out.println("Link Button is Successfully Recipients Data ID is Not
Displayed");
}
for Closing the Child Windows I am Using This Code
//Closing the First Child Window
driver.close();
System.out.println("First Child Window is Closed");
Thread.sleep(2000);
//Closing the Second Child Window
driver.close();
System.out.println("Second Child Window is Closed");
Thread.sleep(2000);
//Closing the Third Child Window
driver.close();
System.out.println("Third Child Window is Closed");
Thread.sleep(2000);
Monday, 26 August 2013
Massive disk i/o on memory reach %70
Massive disk i/o on memory reach %70
Previously system became unresponsive when RAM usage reached around %70.
It was because of massive disk I/O operation, presumably to swap disk. I
tried to tweak swapiness factor and it didn't affect anything at all on
both sides of the extreme. I decided to delete the swap partition
altogether, since my system has 4GB RAM. The swap partition was about 6GB.
It is yet no difference. It seems in whatsoever configuration, %30 of
memory should always be free. This is not a space rocket command and
control system, so I don't understand this cautious policy. Can anyone
please explain? Is there any other setting I could tweak to get the bar of
memory usage up to say %95?
Thanks
Previously system became unresponsive when RAM usage reached around %70.
It was because of massive disk I/O operation, presumably to swap disk. I
tried to tweak swapiness factor and it didn't affect anything at all on
both sides of the extreme. I decided to delete the swap partition
altogether, since my system has 4GB RAM. The swap partition was about 6GB.
It is yet no difference. It seems in whatsoever configuration, %30 of
memory should always be free. This is not a space rocket command and
control system, so I don't understand this cautious policy. Can anyone
please explain? Is there any other setting I could tweak to get the bar of
memory usage up to say %95?
Thanks
Rails select options tag - generating options from associations
Rails select options tag - generating options from associations
I have a view that allows the user to add list_items to one of their
shopping_lists. I want the options for select to be the names of their
lists, but I need those names mapped to respective list_id in order to
have the correct associations. Here's my current select tag:
<tr>
<% item.inventory_items.each do |product| %>
<td>
<%= form_tag("/list_items", method: "post") do %>
<%= hidden_field_tag(:item_id, item.id) %>
<%= hidden_field_tag(:inventory_item_id, product.id) %>
<%= select_tag(:shopping_list_id,
options_for_select(current_user.shopping_lists)) %>
<%= submit_tag("$#{product.price}", class: "btn btn-primary") %>
<% end %>
</td>
<% end %>
</tr>
How can I display the names of a user's shopping_lists as the options, but
return the relative shopping_list_id as the value for that option?
ShoppingList belongs_to :user User has_many :shopping_lists
Currently my select tag renders a dropdown selection of a user's shopping
lists, but the options are listed in the form, '#. Clicking the submit
button doesn't actually add the the item to the list either.
Thanks in advance!
I have a view that allows the user to add list_items to one of their
shopping_lists. I want the options for select to be the names of their
lists, but I need those names mapped to respective list_id in order to
have the correct associations. Here's my current select tag:
<tr>
<% item.inventory_items.each do |product| %>
<td>
<%= form_tag("/list_items", method: "post") do %>
<%= hidden_field_tag(:item_id, item.id) %>
<%= hidden_field_tag(:inventory_item_id, product.id) %>
<%= select_tag(:shopping_list_id,
options_for_select(current_user.shopping_lists)) %>
<%= submit_tag("$#{product.price}", class: "btn btn-primary") %>
<% end %>
</td>
<% end %>
</tr>
How can I display the names of a user's shopping_lists as the options, but
return the relative shopping_list_id as the value for that option?
ShoppingList belongs_to :user User has_many :shopping_lists
Currently my select tag renders a dropdown selection of a user's shopping
lists, but the options are listed in the form, '#. Clicking the submit
button doesn't actually add the the item to the list either.
Thanks in advance!
Need help removing duplicate columns in a mysql result
Need help removing duplicate columns in a mysql result
Ok, basically said, I have a website that returns results by country.
There is a query that returns this, then I use a loop to output the data.
The only problem is that for one of these, there is a sub-50 column and
the results are the same all the way to the sub-36 column. I need help
removing the duplicate columns.
// By country
// sort countries by most subXs in descending order
arsort($country_sub{$dsub});
// print results
echo "<b><span style='font-size:20px;'>By Country</span></b>";
echo "<table><tr style='font-weight:bold;'><td
style='width:100px;'>Country</td><td>sub".$dsub."</td>";
for($i=$dsub-1; $i>=$x; $i--){ echo "<td>sub".$i."</td>"; }
echo "</tr>";
foreach($country_sub{$dsub} as $country => $value){
echo "<tr><td>".$country."</td><td>".$value."</td>";
for($i=$dsub-1; $i>=$x; $i--){
if (isset($country_sub{$i}[$country])) {
echo "<td>".$country_sub{$i}[$country]."</td>";
} else{
echo "<td></td>";
}
echo "</tr>";
}
echo "</table><br/>";
The array $country_sub{$dsub} contains the number of people with that
result or less. The foreach loop is what outputs the top numbers, and the
for loop is what outputs the results itself.
You can see where this code is used at this link:
http://cubingstats.netau.net/3bld/index.php. It's used in the "By Country"
section. All I want is in that table, to show sub 36 and sub 27 (the ones
listed above). I need to launch this by tomorrow, so any help is extremely
useful!
Thanks in advance
Ok, basically said, I have a website that returns results by country.
There is a query that returns this, then I use a loop to output the data.
The only problem is that for one of these, there is a sub-50 column and
the results are the same all the way to the sub-36 column. I need help
removing the duplicate columns.
// By country
// sort countries by most subXs in descending order
arsort($country_sub{$dsub});
// print results
echo "<b><span style='font-size:20px;'>By Country</span></b>";
echo "<table><tr style='font-weight:bold;'><td
style='width:100px;'>Country</td><td>sub".$dsub."</td>";
for($i=$dsub-1; $i>=$x; $i--){ echo "<td>sub".$i."</td>"; }
echo "</tr>";
foreach($country_sub{$dsub} as $country => $value){
echo "<tr><td>".$country."</td><td>".$value."</td>";
for($i=$dsub-1; $i>=$x; $i--){
if (isset($country_sub{$i}[$country])) {
echo "<td>".$country_sub{$i}[$country]."</td>";
} else{
echo "<td></td>";
}
echo "</tr>";
}
echo "</table><br/>";
The array $country_sub{$dsub} contains the number of people with that
result or less. The foreach loop is what outputs the top numbers, and the
for loop is what outputs the results itself.
You can see where this code is used at this link:
http://cubingstats.netau.net/3bld/index.php. It's used in the "By Country"
section. All I want is in that table, to show sub 36 and sub 27 (the ones
listed above). I need to launch this by tomorrow, so any help is extremely
useful!
Thanks in advance
How to background a command chain=?iso-8859-1?Q?=3F_=96_unix.stackexchange.com?=
How to background a command chain? – unix.stackexchange.com
I want to background a command chain like cp a b && mv b c && rm a. I have
tried doing cp a b && mv b c && rm a & but this only backgrounds the last
process. How …
I want to background a command chain like cp a b && mv b c && rm a. I have
tried doing cp a b && mv b c && rm a & but this only backgrounds the last
process. How …
Can I force the windows 7 user list to appear during automatic login?
Can I force the windows 7 user list to appear during automatic login?
On my Windows 7, I have two users and I have configured auto login for one
of these accounts. That's working fine, but is there a way for me to
temporarily get the user list during the boot process, so that I can
choose which user to login as? I don't want to enable it permanentally, I
only want to do this occationally. I am hoping there's a key I can press
(similar to what F8 does during boot). Does anyone know?
On my Windows 7, I have two users and I have configured auto login for one
of these accounts. That's working fine, but is there a way for me to
temporarily get the user list during the boot process, so that I can
choose which user to login as? I don't want to enable it permanentally, I
only want to do this occationally. I am hoping there's a key I can press
(similar to what F8 does during boot). Does anyone know?
How to get TX/RX bytes without ifconfig=?iso-8859-1?Q?=3F_=96_serverfault.com?=
How to get TX/RX bytes without ifconfig? – serverfault.com
Since ifconfig is apparently being deprecated in major Linux
distributions, I thought I'd learn something about the ip tool that's
supposed to be used instead of ifconfig. And here I ran into a ...
Since ifconfig is apparently being deprecated in major Linux
distributions, I thought I'd learn something about the ip tool that's
supposed to be used instead of ifconfig. And here I ran into a ...
Sunday, 25 August 2013
how to get access token after windows azure active directory authentication
how to get access token after windows azure active directory authentication
we have successfully implemented the active directory authentication using
the process given at the url
http://msdn.microsoft.com/en-us/library/windowsazure/dn151790.aspx . Here
we are able to authenticate the user on the
https://login.microsoftonline.com/ and return back to web site but we are
not able to get access token after successful authentication. following
code through which we are able to access the user name, surname etc after
successful authentication but not the access token. can you provide me the
code through which we can get the access token after authentication.
public class HomeController : Controller { public ActionResult Index() {
ClaimsPrincipal cp = ClaimsPrincipal.Current;
string fullname =
string.Format("{0} {1}",
cp.FindFirst(ClaimTypes.GivenName).Value,
cp.FindFirst(ClaimTypes.Surname).Value);
ViewBag.Message = string.Format("Dear {0}, welcome to the Expense
Note App",
fullname);
return View();
}
}
we have successfully implemented the active directory authentication using
the process given at the url
http://msdn.microsoft.com/en-us/library/windowsazure/dn151790.aspx . Here
we are able to authenticate the user on the
https://login.microsoftonline.com/ and return back to web site but we are
not able to get access token after successful authentication. following
code through which we are able to access the user name, surname etc after
successful authentication but not the access token. can you provide me the
code through which we can get the access token after authentication.
public class HomeController : Controller { public ActionResult Index() {
ClaimsPrincipal cp = ClaimsPrincipal.Current;
string fullname =
string.Format("{0} {1}",
cp.FindFirst(ClaimTypes.GivenName).Value,
cp.FindFirst(ClaimTypes.Surname).Value);
ViewBag.Message = string.Format("Dear {0}, welcome to the Expense
Note App",
fullname);
return View();
}
}
Calculate the number of times an angle must be repeated for it to complete a full rotation and for it close
Calculate the number of times an angle must be repeated for it to complete
a full rotation and for it close
I'm trying to calculate the number of times an angle must be repeated to
make a full rotation and become closed.
Example: The internal angle of a pentagon is 108 degrees and it must
repeat 5 times to complete a rotation and it closes at 540 degrees.
How can I calculate these numbers for arbitrary angles like 72 degrees or
117 degrees, etc..
Does anyone have a formula
Ps: I'm using matlab/octave thanks
a full rotation and for it close
I'm trying to calculate the number of times an angle must be repeated to
make a full rotation and become closed.
Example: The internal angle of a pentagon is 108 degrees and it must
repeat 5 times to complete a rotation and it closes at 540 degrees.
How can I calculate these numbers for arbitrary angles like 72 degrees or
117 degrees, etc..
Does anyone have a formula
Ps: I'm using matlab/octave thanks
Sorting Collection and Set
Sorting Collection and Set
I'm having an issue sorting the values and keys from a map from least to
greatest(integers and String's). Here are the two methods, first the
method for values:
public Collection<V> values(){
Collection<V> coll = new LinkedList<V>();
for(int i = 0; i < table.length; i++){
if(table[i] != null){
for(Entry<K, V> nextItem : table[i]){
if(nextItem.value != null){
if(!coll.contains(nextItem.value)){
coll.add(nextItem.value);
}
}
}
}
}
return coll;
}
Expected Output:
120 123 404 911 999
My Output (basically keeps order of wherever it was in the map):
911 999 123 120 404
The above method is used with dot notation for a hashTableChain (an array
who's keys are sorted by their hashCode where the indices of the array are
linkedLists), it returns the values for the given map. I tried sorting it
with Collections.sort(coll) however this requires a List which is
incompatible with Collection to my knowledge. Is there something
compatible with Collection that is either already sorted or can be sorted
in an easy way? The method for the key's:
public Set<K> keySet(){
Set<K> coll = new HashSet<K>();
for(int i = 0; i < table.length; i++){
if(table[i] != null){
for(Entry<K, V> nextItem : table[i]){
coll.add(nextItem.key);
}
}
}
return coll;
}
Expected Output:
ABC ACTG HTML LOL OMG XYZ
My Output (basically keeps order of wherever it was in the map):
XYZ ABC ACTG HTML LOL OMG
Again I tried Collections.sort(coll) to no avail and couldn't find any way
to sort it.
I'm fairly new to java and I'm sure I'm overlooking something, after
searching the web for a while I figured I'd just ask.
Thanks in advance and I very much appreciate the help.
I'm having an issue sorting the values and keys from a map from least to
greatest(integers and String's). Here are the two methods, first the
method for values:
public Collection<V> values(){
Collection<V> coll = new LinkedList<V>();
for(int i = 0; i < table.length; i++){
if(table[i] != null){
for(Entry<K, V> nextItem : table[i]){
if(nextItem.value != null){
if(!coll.contains(nextItem.value)){
coll.add(nextItem.value);
}
}
}
}
}
return coll;
}
Expected Output:
120 123 404 911 999
My Output (basically keeps order of wherever it was in the map):
911 999 123 120 404
The above method is used with dot notation for a hashTableChain (an array
who's keys are sorted by their hashCode where the indices of the array are
linkedLists), it returns the values for the given map. I tried sorting it
with Collections.sort(coll) however this requires a List which is
incompatible with Collection to my knowledge. Is there something
compatible with Collection that is either already sorted or can be sorted
in an easy way? The method for the key's:
public Set<K> keySet(){
Set<K> coll = new HashSet<K>();
for(int i = 0; i < table.length; i++){
if(table[i] != null){
for(Entry<K, V> nextItem : table[i]){
coll.add(nextItem.key);
}
}
}
return coll;
}
Expected Output:
ABC ACTG HTML LOL OMG XYZ
My Output (basically keeps order of wherever it was in the map):
XYZ ABC ACTG HTML LOL OMG
Again I tried Collections.sort(coll) to no avail and couldn't find any way
to sort it.
I'm fairly new to java and I'm sure I'm overlooking something, after
searching the web for a while I figured I'd just ask.
Thanks in advance and I very much appreciate the help.
Saturday, 24 August 2013
Whats a better way to code a command line interface in c++?
Whats a better way to code a command line interface in c++?
I'm using run of the mill C++, and im building a small "Zork-esc" game as
a pet project to exercise my newly learned C++ skills. the following code
works perfectly, however it will be a pain to have to do this for every
command/argument combo so if anybody out there can save me some trouble
then please do :D ...
as it stands i have this function responsible for processing commands at
run-time...
void execute()
{
//###### Command builder ######
cout << ">>>";
char input[100];
cin.getline(input, sizeof(input));
cout << input << endl;
string newin = input;
//###### Execution Phase ######
if(newin=="derp"){
// normally functions go here
cout << "You did it :D" << endl;
}else if(newin=="attack player1 player2"){
// normally functions go here
cout << "player1 attacks player2" << endl;
}else{
// quriky error message for the user
cout << "dafuq?" << endl;
}
execute();
}
it takes your input and compares it to all the possible string
combinations and when it finds a match its suppose to run the
corresponding functions placed inside the IF staments
like i said it works but there is much room for improvement i feel...
I'm using run of the mill C++, and im building a small "Zork-esc" game as
a pet project to exercise my newly learned C++ skills. the following code
works perfectly, however it will be a pain to have to do this for every
command/argument combo so if anybody out there can save me some trouble
then please do :D ...
as it stands i have this function responsible for processing commands at
run-time...
void execute()
{
//###### Command builder ######
cout << ">>>";
char input[100];
cin.getline(input, sizeof(input));
cout << input << endl;
string newin = input;
//###### Execution Phase ######
if(newin=="derp"){
// normally functions go here
cout << "You did it :D" << endl;
}else if(newin=="attack player1 player2"){
// normally functions go here
cout << "player1 attacks player2" << endl;
}else{
// quriky error message for the user
cout << "dafuq?" << endl;
}
execute();
}
it takes your input and compares it to all the possible string
combinations and when it finds a match its suppose to run the
corresponding functions placed inside the IF staments
like i said it works but there is much room for improvement i feel...
ld returned 1 exit status error
ld returned 1 exit status error
I am writing a tester for a file HCTree.hpp that has a build() method but
when I try to run the tester I get "ld returned 1 exit status". What is
the problem? Here is the tester:
int main()
{
HCTree* pt;
vector<int> vec (256,0);
vec[0] = 1;
vec[1] = 3;
vec[2] = 2;
pt->build(vec);
return 0;
}
I am writing a tester for a file HCTree.hpp that has a build() method but
when I try to run the tester I get "ld returned 1 exit status". What is
the problem? Here is the tester:
int main()
{
HCTree* pt;
vector<int> vec (256,0);
vec[0] = 1;
vec[1] = 3;
vec[2] = 2;
pt->build(vec);
return 0;
}
Forums from myBB merged into Wordpress
Forums from myBB merged into Wordpress
So I can create a forum in myBB but when I go to view it it takes me to a
Wordpress 404 page. Even though example.com/forums/ is the forums
directory and wordpress is just the homepage. I have already tried looking
through the forumdisplay.php but as far as I can see there's nothing there
that could cause the issue.
So I can create a forum in myBB but when I go to view it it takes me to a
Wordpress 404 page. Even though example.com/forums/ is the forums
directory and wordpress is just the homepage. I have already tried looking
through the forumdisplay.php but as far as I can see there's nothing there
that could cause the issue.
can't build an rpm file to BIND
can't build an rpm file to BIND
I have tried to build an rpm in linux(centos6.3) by using this command
rpmbuild -ta bind-9.8.2.tar.gz
but I HAVE THIS ERROR:
error : line 21: Unknown tag: Copyright: disributable
what is this error and how can I build rpm without problems ?
I have tried to build an rpm in linux(centos6.3) by using this command
rpmbuild -ta bind-9.8.2.tar.gz
but I HAVE THIS ERROR:
error : line 21: Unknown tag: Copyright: disributable
what is this error and how can I build rpm without problems ?
Drupal 7- populate a select list by a view with contextual filter
Drupal 7- populate a select list by a view with contextual filter
i have a view with only one displayed field changing on current:User by
Contextuel filter.
Now i have a content-type B and i want on add new content a select list
with exactly the default values of the view above.
For example on User A there are perhaps three items to select while User B
has 5 items to select.
Is this possible? And if yes, is this possible without coding and if yes
how can i solve this?
Thanks for all answers and please excuse my english Tom
i have a view with only one displayed field changing on current:User by
Contextuel filter.
Now i have a content-type B and i want on add new content a select list
with exactly the default values of the view above.
For example on User A there are perhaps three items to select while User B
has 5 items to select.
Is this possible? And if yes, is this possible without coding and if yes
how can i solve this?
Thanks for all answers and please excuse my english Tom
bootstrap multiple resolution all layout inline media query css for responsive design including android iphone and web asp.net
bootstrap multiple resolution all layout inline media query css for
responsive design including android iphone and web asp.net
pI have finished a website its working fine in browser now i have been
asked to make it compatible with android, iPhone , iPad, Tablets,and web
etc, Im using bootstrap asp.net Now I'm trying and couldn't find any
answer. I'm using these inline media queries /p precode@media screen and
(min-width:0px) and (max-width:320px){/*Any css will be defined here*/}
@media screen and (min-width:321px) and (max-width:480px){/*Any css will
be defined here*/} @media screen and (min-width:481px) and
(max-width:540px){/*Any css will be defined here*/} @media screen and
(min-width:541px) and (max-width:775px){/*Any css will be defined here*/}
@media screen and (min-width:768px) and (max-width:783px){/*Any css will
be defined here*/} @media screen and (min-width:776px) and
(max-width:1536px){/*Any css will be defined here*/} @media screen and
(min-width:1537px){/*Any css will be defined here*/} /code/pre pBut in
some iPads the css is not applied Now my question is whats the standard
resolution and orientation which will cover all (Android, iPhone, tablets
and Web etc) css /p
responsive design including android iphone and web asp.net
pI have finished a website its working fine in browser now i have been
asked to make it compatible with android, iPhone , iPad, Tablets,and web
etc, Im using bootstrap asp.net Now I'm trying and couldn't find any
answer. I'm using these inline media queries /p precode@media screen and
(min-width:0px) and (max-width:320px){/*Any css will be defined here*/}
@media screen and (min-width:321px) and (max-width:480px){/*Any css will
be defined here*/} @media screen and (min-width:481px) and
(max-width:540px){/*Any css will be defined here*/} @media screen and
(min-width:541px) and (max-width:775px){/*Any css will be defined here*/}
@media screen and (min-width:768px) and (max-width:783px){/*Any css will
be defined here*/} @media screen and (min-width:776px) and
(max-width:1536px){/*Any css will be defined here*/} @media screen and
(min-width:1537px){/*Any css will be defined here*/} /code/pre pBut in
some iPads the css is not applied Now my question is whats the standard
resolution and orientation which will cover all (Android, iPhone, tablets
and Web etc) css /p
Friday, 23 August 2013
Trouble with Bible Style Page Numbers
Trouble with Bible Style Page Numbers
I'm attempting to typeset a Bible for my mom and I'm running into a few
problems and I was hoping someone here could help.
First I'll start with the easy question. I'm currently using two columns
and adding a line to separate them in the center like this:
\documentclass[twoside,twocolumn]{book}
\setlength{\columnseprule}{0.5pt}
After I use \maketitle it inserts a blank page (since it doesn't want to
start new content on a verso page) but the column separation line still
shows up. How do I get the \columnseprule and \headrule to not show up on
this blank page? It doesn't occur on any other blank pages in the
document.
Now the hard question... In the header I want the format to be < Book Name
> < Chapter # >:< Verse # > where the Chapter and Verse numbers are the
first chapter/verse that appears on the page (even [verso] page) or the
last to appear on the page (odd [recto] page). I've almost gotten the odd
page style to work but it isn't working quite right and I'm not sure why.
I have pictures to show my problem, unfortunately since this is my first
time contributing to this website I don't have enough reputation to post
pictures.
In general it seems to work OK. Most pages are shown correctly but
occasionally the verse number displayed will be off by one, either one
before or one after it should be. I suspect it has something to do with
when LaTex decides to place a page break but I don't know how to account
for that.
And I don't have the first clue how to start the even (verso) page style.
I'm trying to make my code very configurable so it is pretty complicated
but I'll try to post the applicable parts here. [If you copy and paste
this it wont compile due to the custom commands I've written for
everything... sorry.] Descriptions for the main commands are below. Thanks
for your help!
\newcommand{\jnumChapters}{0}
\newcommand{\jnumVerses}{0}
\newcommand{\jChapter}[1]{
\ifthenelse{#1=1}{\renewcommand{\jnumChapters}{#1}}
{\renewcommand{\jnumChapters}{#1}\par\bigskip\lettrine
{\ifthenelse{#1=1}
{\noindent\jverseFormat{#1}{#3}}
{#2{\jChapterNumFormat{#1}} {\jverseFormat{#1}{#3}}}}
{\ifthenelse{#1=1}
{\noindent\jverseFormat{#1}{#3}\smallskip\newline}
{\noindent {\jChapterNumFormat{#1}}
#2{\jverseFormat{#1}{#3}}\par\smallskip}}\renewcommand{\jnumVerses}{#1}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]
\jChapter{< Chapter# >} formats the chapter numbers for each chapter. I
format the first chapter number of each book differently than all the
others (thus the \ifthenelse statement).
\jverse{< Verse# >}{< Paragraph Indicator >}{< Verse Text >} Formats each
verse individually. The Paragraph Indicator just lets me know if that
verse needs to start a new paragraph if the text is not going to be
formatted in verse-by-verse format.
I'm attempting to typeset a Bible for my mom and I'm running into a few
problems and I was hoping someone here could help.
First I'll start with the easy question. I'm currently using two columns
and adding a line to separate them in the center like this:
\documentclass[twoside,twocolumn]{book}
\setlength{\columnseprule}{0.5pt}
After I use \maketitle it inserts a blank page (since it doesn't want to
start new content on a verso page) but the column separation line still
shows up. How do I get the \columnseprule and \headrule to not show up on
this blank page? It doesn't occur on any other blank pages in the
document.
Now the hard question... In the header I want the format to be < Book Name
> < Chapter # >:< Verse # > where the Chapter and Verse numbers are the
first chapter/verse that appears on the page (even [verso] page) or the
last to appear on the page (odd [recto] page). I've almost gotten the odd
page style to work but it isn't working quite right and I'm not sure why.
I have pictures to show my problem, unfortunately since this is my first
time contributing to this website I don't have enough reputation to post
pictures.
In general it seems to work OK. Most pages are shown correctly but
occasionally the verse number displayed will be off by one, either one
before or one after it should be. I suspect it has something to do with
when LaTex decides to place a page break but I don't know how to account
for that.
And I don't have the first clue how to start the even (verso) page style.
I'm trying to make my code very configurable so it is pretty complicated
but I'll try to post the applicable parts here. [If you copy and paste
this it wont compile due to the custom commands I've written for
everything... sorry.] Descriptions for the main commands are below. Thanks
for your help!
\newcommand{\jnumChapters}{0}
\newcommand{\jnumVerses}{0}
\newcommand{\jChapter}[1]{
\ifthenelse{#1=1}{\renewcommand{\jnumChapters}{#1}}
{\renewcommand{\jnumChapters}{#1}\par\bigskip\lettrine
{\ifthenelse{#1=1}
{\noindent\jverseFormat{#1}{#3}}
{#2{\jChapterNumFormat{#1}} {\jverseFormat{#1}{#3}}}}
{\ifthenelse{#1=1}
{\noindent\jverseFormat{#1}{#3}\smallskip\newline}
{\noindent {\jChapterNumFormat{#1}}
#2{\jverseFormat{#1}{#3}}\par\smallskip}}\renewcommand{\jnumVerses}{#1}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]
\jChapter{< Chapter# >} formats the chapter numbers for each chapter. I
format the first chapter number of each book differently than all the
others (thus the \ifthenelse statement).
\jverse{< Verse# >}{< Paragraph Indicator >}{< Verse Text >} Formats each
verse individually. The Paragraph Indicator just lets me know if that
verse needs to start a new paragraph if the text is not going to be
formatted in verse-by-verse format.
How to find MX Records in Exchange 2013
How to find MX Records in Exchange 2013
Just finished building out an Exchange 2010 server to host our e-mail
on-site. Called GoDaddy to have the MX Records pointed to the External IP
address of our Exchange server but was asked by GoDaddy what our MX
Records were.
My question is: Where in Exchange 2010 can I find what the MX Records are?
Thanks
Matt
Just finished building out an Exchange 2010 server to host our e-mail
on-site. Called GoDaddy to have the MX Records pointed to the External IP
address of our Exchange server but was asked by GoDaddy what our MX
Records were.
My question is: Where in Exchange 2010 can I find what the MX Records are?
Thanks
Matt
Access messages in Outlook's 'Drafts' folder
Access messages in Outlook's 'Drafts' folder
I would like to use a message that is stored in the 'Drafts' folder as a
template for other messages. Unfortunately, I don't have the correct
syntax:
tell application "Microsoft Outlook"
-- locate the message
set theMessage to the first message in mail folder drafts <== error:
'Can't make mail folder id 107 into type integer'
-- show subject (testing)
display dialog of the subject of theMessage
-- for each contact with category 'foo'
-- copy message
-- add sender
-- add first name to message's body
-- set delivery date to 5 minutes in the future
-- send message
-- end loop
end tell
What am I missing?
I would like to use a message that is stored in the 'Drafts' folder as a
template for other messages. Unfortunately, I don't have the correct
syntax:
tell application "Microsoft Outlook"
-- locate the message
set theMessage to the first message in mail folder drafts <== error:
'Can't make mail folder id 107 into type integer'
-- show subject (testing)
display dialog of the subject of theMessage
-- for each contact with category 'foo'
-- copy message
-- add sender
-- add first name to message's body
-- set delivery date to 5 minutes in the future
-- send message
-- end loop
end tell
What am I missing?
Invalid Date is entered for search
Invalid Date is entered for search
I have a searchable column in jqgrid that is a date field. It currently
displays a message for invalid character if I enter an invalid date and
start the search. I would prefer to have a message that is better formed
for the event like "Invalid date entered".
{ name: 'BDate', index: 'BDate', width: 70, align: 'right', sortable:
true, search: true, formatter: 'date', editrules: { date: true} },
How would I do this?
I have a searchable column in jqgrid that is a date field. It currently
displays a message for invalid character if I enter an invalid date and
start the search. I would prefer to have a message that is better formed
for the event like "Invalid date entered".
{ name: 'BDate', index: 'BDate', width: 70, align: 'right', sortable:
true, search: true, formatter: 'date', editrules: { date: true} },
How would I do this?
WCF Restful web service. Logging request processing
WCF Restful web service. Logging request processing
For example, I have a RESTful web-service with only one operation Process
which uses a lot of other methods from different assemblies. The service
is supposed to log incoming request processing events (I am using log4net
library and log messages into a text file). I am wondering how to ensure
correct logging messages order in a log file in case of simultaneous
queries (from different processes, single processes with a lot of
asynchronous tasks). Is there any way to identify particular request
during processing on server? I could prefix every log message with some ID
in that case... I don't want to extend query itself with additional info.
For example, I have a RESTful web-service with only one operation Process
which uses a lot of other methods from different assemblies. The service
is supposed to log incoming request processing events (I am using log4net
library and log messages into a text file). I am wondering how to ensure
correct logging messages order in a log file in case of simultaneous
queries (from different processes, single processes with a lot of
asynchronous tasks). Is there any way to identify particular request
during processing on server? I could prefix every log message with some ID
in that case... I don't want to extend query itself with additional info.
Thursday, 22 August 2013
connection problems with multiple servers, (ex: mumble and apache)
connection problems with multiple servers, (ex: mumble and apache)
On my server, i have multiple servers such as Apache, ftp, mumble,
counterstrike 1.6. Everything has been working fine until about 2 months
ago, a friend says that he cant connect at all to my server with his
browser or mumble (but counterstrike seems to work). He tried with his
computer and his phone. On mumble, he seems the Root channel and nothing
more, not even himself. In the browser, everything times out. Pinging,
tracert, and CS1.6 works though. After a while we thought we just leave it
as his ISP's (time warner i believe) fault because we didnt know what else
to do.
However recently, another friend has has the exact same issue, so it cant
be ISP because this friend's ISP is FiOS. we tried iperf and it seems to
work both ways.
Also, i THINK this is related, the second friend was testing FTP
connectiosn and gets this message from filezilla when trying to traverse
directories
Status: Directory listing successful
Status: Retrieving directory listing...
Command: CWD Music
Response: 250 OK. Current directory is /Music
Command: PWD
Response: 257 "/Music" is your current location
Command: PASV
Response: 227 Entering Passive Mode (98,119,77,23,96,137).
Command: MLSD
Response: 150 Accepted data connection
Error: Connection timed out
Error: Failed to retrieve directory listing
On my server, i have multiple servers such as Apache, ftp, mumble,
counterstrike 1.6. Everything has been working fine until about 2 months
ago, a friend says that he cant connect at all to my server with his
browser or mumble (but counterstrike seems to work). He tried with his
computer and his phone. On mumble, he seems the Root channel and nothing
more, not even himself. In the browser, everything times out. Pinging,
tracert, and CS1.6 works though. After a while we thought we just leave it
as his ISP's (time warner i believe) fault because we didnt know what else
to do.
However recently, another friend has has the exact same issue, so it cant
be ISP because this friend's ISP is FiOS. we tried iperf and it seems to
work both ways.
Also, i THINK this is related, the second friend was testing FTP
connectiosn and gets this message from filezilla when trying to traverse
directories
Status: Directory listing successful
Status: Retrieving directory listing...
Command: CWD Music
Response: 250 OK. Current directory is /Music
Command: PWD
Response: 257 "/Music" is your current location
Command: PASV
Response: 227 Entering Passive Mode (98,119,77,23,96,137).
Command: MLSD
Response: 150 Accepted data connection
Error: Connection timed out
Error: Failed to retrieve directory listing
Convert an int List into an int number
Convert an int List into an int number
Programming in Python I would like to know how to convert:
list = [1,2,3,4]
to:
list = 1234
i need to make a int with the values of the list
Programming in Python I would like to know how to convert:
list = [1,2,3,4]
to:
list = 1234
i need to make a int with the values of the list
When I add members to my group, their access defaults to "no email"
When I add members to my group, their access defaults to "no email"
When I add members to my group, their access defaults to "no email". I set
Post Permissions to "All members of the group", but that doesn't help with
either old members or the members I have added since.
When I add members to my group, their access defaults to "no email". I set
Post Permissions to "All members of the group", but that doesn't help with
either old members or the members I have added since.
Jquery :lt(10) doesn't work as expected
Jquery :lt(10) doesn't work as expected
I'd like to hide all elements except .any and .input and also first 10.
But first 10 part doesn't work, it only shows 4. What am I doing wrong?
html:
<ul class="filter option-set" data-filter-group="actor">
<li class="any"><a href="#filter-actor-any" data-filter-value=""
class="selected">Any</a></li>
<li><a href="#filter-actor-sandro" data-filter-value="sandro">Sandro</a></li>
<li><a href="#filter-actor-barbara"
data-filter-value="barbara">Barbara</a></li>
<li><a href="#filter-actor-ku" data-filter-value="ku">Ku</a></li>
<li><a href="#filter-actor-cool" data-filter-value="cool">Cool</a></li>
<li><a href="#filter-actor-aid" data-filter-value="aid">Aid</a></li>
<li><a href="#filter-actor-leo" data-filter-value="leo">Leo</a></li>
<li><a href="#filter-actor-john" data-filter-value="john">John</a></li>
<li><a href="#filter-actor-kvara" data-filter-value="kvara">Kvara</a></li>
<li><a href="#filter-actor-kuku" data-filter-value="kuku">Kuku</a></li>
<li><a href="#filter-actor-bubu" data-filter-value="bubu">Bubu</a></li>
<li><a href="#filter-actor-fra" data-filter-value="fra">Fra</a></li>
<li class="input"><input type="text" placeholder="Type and hit Enter to
search" class="js_search"></li>
</ul>
jquery:
$(".filter li").not(".any, .input, :lt(10)").hide();
I'd like to hide all elements except .any and .input and also first 10.
But first 10 part doesn't work, it only shows 4. What am I doing wrong?
html:
<ul class="filter option-set" data-filter-group="actor">
<li class="any"><a href="#filter-actor-any" data-filter-value=""
class="selected">Any</a></li>
<li><a href="#filter-actor-sandro" data-filter-value="sandro">Sandro</a></li>
<li><a href="#filter-actor-barbara"
data-filter-value="barbara">Barbara</a></li>
<li><a href="#filter-actor-ku" data-filter-value="ku">Ku</a></li>
<li><a href="#filter-actor-cool" data-filter-value="cool">Cool</a></li>
<li><a href="#filter-actor-aid" data-filter-value="aid">Aid</a></li>
<li><a href="#filter-actor-leo" data-filter-value="leo">Leo</a></li>
<li><a href="#filter-actor-john" data-filter-value="john">John</a></li>
<li><a href="#filter-actor-kvara" data-filter-value="kvara">Kvara</a></li>
<li><a href="#filter-actor-kuku" data-filter-value="kuku">Kuku</a></li>
<li><a href="#filter-actor-bubu" data-filter-value="bubu">Bubu</a></li>
<li><a href="#filter-actor-fra" data-filter-value="fra">Fra</a></li>
<li class="input"><input type="text" placeholder="Type and hit Enter to
search" class="js_search"></li>
</ul>
jquery:
$(".filter li").not(".any, .input, :lt(10)").hide();
Android...get app to download data from internet without user entering app?
Android...get app to download data from internet without user entering app?
I have a app which connects to a mysql database server and downloads
updated places to sqlite database on the app....I want to app to be able
to do this before user enters it such as notifications you get from
facebook when you have Internet connection..
Any idea how i can do this?
I have a app which connects to a mysql database server and downloads
updated places to sqlite database on the app....I want to app to be able
to do this before user enters it such as notifications you get from
facebook when you have Internet connection..
Any idea how i can do this?
adding days to date in Java
adding days to date in Java
I am adding days to the date by this mean "Add day" which is the standard
procedure, but unfortunately my Pentaho application breaks on
c.setTime(dt);, which I clearly not know the reason as the exception
doesn't give any meaning. So another option is to parse the date and
extract month,year, and day and +1 to the day, but I have to then take
care of Feburary and odd months. I have just these 2 options in my mind
Anyone who can guide me with any other option in java Thanks
I am adding days to the date by this mean "Add day" which is the standard
procedure, but unfortunately my Pentaho application breaks on
c.setTime(dt);, which I clearly not know the reason as the exception
doesn't give any meaning. So another option is to parse the date and
extract month,year, and day and +1 to the day, but I have to then take
care of Feburary and odd months. I have just these 2 options in my mind
Anyone who can guide me with any other option in java Thanks
JSON not showing up in Ember.js app
JSON not showing up in Ember.js app
I have this strange issue in which I can see the returned JSON in the
console but it's not loading,
Here's my code so far,
App = Ember.Application.create({});
App.IndexRoute = Ember.Route.extend({
renderTemplate : function(controller) {
this.render('MyApp', {
controller : controller
});
},
model : function() {
return App.MyTemplateModel.find();
}
});
App.IndexController = Ember.ArrayController.extend({
filteredContent : Ember.computed.oneWay("content"),
last : function() {
var lastName = App.controller.get('selectedProgrammer.last_name');
var filtered = this.get('content').filterProperty('last_name',
lastName);
this.set("filteredContent", filtered);
},
refresh : function() {
var refresh = this.get('content');
this.set("filteredContent", refresh);
}
});
App.MyTemplateModel = Ember.Model.extend({
id : Ember.attr(),
last_name : Ember.attr(),
first_name : Ember.attr(),
suffix : Ember.attr(),
expiration : Ember.attr()
});
App.controller = Ember.Object.create({
selectedProgrammer : null,
content : [Ember.Object.create({
last_name : "Solow",
id : 1
}), Ember.Object.create({
last_name : "Arbogast",
id : 2
}), Ember.Object.create({
last_name : "Dorfman",
id : 3
}), Ember.Object.create({
last_name : "Eliason",
id : 4
})]
});
App.MyTemplateModel.url =
"http://admin:1234@animatorapi.us/api/example/users";
App.MyTemplateModel.adapter = Ember.RESTAdapter.create({
ajaxSettings: function(url, method) {
return {
url: url,
type: method,
dataType: "jsonp",
contentType: 'application/json; charset=utf-8'
};
}
});
App.MyTemplateModel.dataType ="jsonp";
var existing = App.MyTemplateModel.find();
App.MyTemplateModel.camelizeKeys = true;
I had this issue where I was getting "XmlHttpRequest error: Origin null is
not allowed by Access-Control-Allow-Origin", so I had to change dataType
to jsonp.
Here's my HTML as well,
<script type="text/x-handlebars" data-template-name="MyApp">
<input type="text" id="name" placeholder="name!"/>
<button >Button</button>
{{view Ember.TextField valueBinding="userName"}}
<label >{{userName}}</label>
{{#each item in filteredContent }}
<tr><td>
{{id}} <p> </p>
</td></tr>
{{/each}}
<button >filter</button>
{{view Ember.Select
contentBinding="App.controller.content"
optionValuePath="content.id"
optionLabelPath="content.last_name"
selectionBinding="App.controller.selectedProgrammer"}}
<button >refresh</button>
</script>
<script type="text/x-handlebars">
<h1>Application Template</h1>
{{outlet}}
</script>
Any suggestions as where I might be wrong?
I have this strange issue in which I can see the returned JSON in the
console but it's not loading,
Here's my code so far,
App = Ember.Application.create({});
App.IndexRoute = Ember.Route.extend({
renderTemplate : function(controller) {
this.render('MyApp', {
controller : controller
});
},
model : function() {
return App.MyTemplateModel.find();
}
});
App.IndexController = Ember.ArrayController.extend({
filteredContent : Ember.computed.oneWay("content"),
last : function() {
var lastName = App.controller.get('selectedProgrammer.last_name');
var filtered = this.get('content').filterProperty('last_name',
lastName);
this.set("filteredContent", filtered);
},
refresh : function() {
var refresh = this.get('content');
this.set("filteredContent", refresh);
}
});
App.MyTemplateModel = Ember.Model.extend({
id : Ember.attr(),
last_name : Ember.attr(),
first_name : Ember.attr(),
suffix : Ember.attr(),
expiration : Ember.attr()
});
App.controller = Ember.Object.create({
selectedProgrammer : null,
content : [Ember.Object.create({
last_name : "Solow",
id : 1
}), Ember.Object.create({
last_name : "Arbogast",
id : 2
}), Ember.Object.create({
last_name : "Dorfman",
id : 3
}), Ember.Object.create({
last_name : "Eliason",
id : 4
})]
});
App.MyTemplateModel.url =
"http://admin:1234@animatorapi.us/api/example/users";
App.MyTemplateModel.adapter = Ember.RESTAdapter.create({
ajaxSettings: function(url, method) {
return {
url: url,
type: method,
dataType: "jsonp",
contentType: 'application/json; charset=utf-8'
};
}
});
App.MyTemplateModel.dataType ="jsonp";
var existing = App.MyTemplateModel.find();
App.MyTemplateModel.camelizeKeys = true;
I had this issue where I was getting "XmlHttpRequest error: Origin null is
not allowed by Access-Control-Allow-Origin", so I had to change dataType
to jsonp.
Here's my HTML as well,
<script type="text/x-handlebars" data-template-name="MyApp">
<input type="text" id="name" placeholder="name!"/>
<button >Button</button>
{{view Ember.TextField valueBinding="userName"}}
<label >{{userName}}</label>
{{#each item in filteredContent }}
<tr><td>
{{id}} <p> </p>
</td></tr>
{{/each}}
<button >filter</button>
{{view Ember.Select
contentBinding="App.controller.content"
optionValuePath="content.id"
optionLabelPath="content.last_name"
selectionBinding="App.controller.selectedProgrammer"}}
<button >refresh</button>
</script>
<script type="text/x-handlebars">
<h1>Application Template</h1>
{{outlet}}
</script>
Any suggestions as where I might be wrong?
Wednesday, 21 August 2013
Bootstrap customizing responsive design
Bootstrap customizing responsive design
Let's say I have 3 div columns (span4 each) in a row and the last column
gets hidden when the screen is resized below tablet. When this happens, I
like to toggle the other 2 columns' div class to span6 so I don't see any
empty space from hiding it.
I am trying to control this from jQuery but I seem to miss out something.
$(function() {
var $resizable = $('.resize');
if($('.box') === prop(':hidden')) {
$resizable.toggleClass('span6');
}
}(jQuery));
Here is the JS BIN
Let's say I have 3 div columns (span4 each) in a row and the last column
gets hidden when the screen is resized below tablet. When this happens, I
like to toggle the other 2 columns' div class to span6 so I don't see any
empty space from hiding it.
I am trying to control this from jQuery but I seem to miss out something.
$(function() {
var $resizable = $('.resize');
if($('.box') === prop(':hidden')) {
$resizable.toggleClass('span6');
}
}(jQuery));
Here is the JS BIN
execute a (delayed-callback) block synchronously
execute a (delayed-callback) block synchronously
I'll make it simple, look at this code this is just an example:
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// some op
});
is it possible to make the current thread pause until the block returns?
I'll make it simple, look at this code this is just an example:
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// some op
});
is it possible to make the current thread pause until the block returns?
how to put a running process into background and nohup and its stdout to a logfile
how to put a running process into background and nohup and its stdout to a
logfile
I have a process currently occupying a terminal
]$ command some_argument
I want to exit from the terminal and go home, but in the mean time I don't
want to kill this running process.
I want to achieve this something like the following with this running
process :
]$ nohup command some_argument >& logfile &
logfile
I have a process currently occupying a terminal
]$ command some_argument
I want to exit from the terminal and go home, but in the mean time I don't
want to kill this running process.
I want to achieve this something like the following with this running
process :
]$ nohup command some_argument >& logfile &
Configure RequireJS to not reload scripts that were already included on page
Configure RequireJS to not reload scripts that were already included on page
I am looking at integrating RequireJS into an existing web application
which does not use AMD. The page I will be including my scripts on will
already include a number of scripts, including jQuery and some common
in-house scripts.
I was curious what would happen if I loaded some of these scripts with
Require after they had already been loaded in a traditional <script> tag.
Here is what I tried:
index.html
<script src="js/lib/jquery.js"></script>
<script src="js/lib/require.js" data-main="js/init.js"></script>
init.js
require.config({
paths: {
jquery: "js/lib/jquery"
});
require(["jquery"], function($) {
//Do stuff
});
My hope was that Require would be smart enough to see that
js/lib/jquery.js was already loaded on the page, and use it as a module,
rather than reloading the script. I then inspected the page contents and
found that Require had in fact reloaded the script:
<script type="text/javascript" src="/js/libs/jquery.js"></script>
...
<script type="text/javascript" charset="utf-8" async=""
data-requirecontext="_" data-requiremodule="jquery"
src="/js/libs/jquery.js"></script>
I understand that this is probably a bit of a reach to expect Require to
be smart enough to do what I wish it would, but it would be really handy
for devs integrating Require with an existing site if it worked this way.
That way you could move legacy scripts into AMD modules at your leisure,
without having to even change your require code. Maybe I'm just dreaming,
though. :)
Anyone have any ideas how to do this?
I am looking at integrating RequireJS into an existing web application
which does not use AMD. The page I will be including my scripts on will
already include a number of scripts, including jQuery and some common
in-house scripts.
I was curious what would happen if I loaded some of these scripts with
Require after they had already been loaded in a traditional <script> tag.
Here is what I tried:
index.html
<script src="js/lib/jquery.js"></script>
<script src="js/lib/require.js" data-main="js/init.js"></script>
init.js
require.config({
paths: {
jquery: "js/lib/jquery"
});
require(["jquery"], function($) {
//Do stuff
});
My hope was that Require would be smart enough to see that
js/lib/jquery.js was already loaded on the page, and use it as a module,
rather than reloading the script. I then inspected the page contents and
found that Require had in fact reloaded the script:
<script type="text/javascript" src="/js/libs/jquery.js"></script>
...
<script type="text/javascript" charset="utf-8" async=""
data-requirecontext="_" data-requiremodule="jquery"
src="/js/libs/jquery.js"></script>
I understand that this is probably a bit of a reach to expect Require to
be smart enough to do what I wish it would, but it would be really handy
for devs integrating Require with an existing site if it worked this way.
That way you could move legacy scripts into AMD modules at your leisure,
without having to even change your require code. Maybe I'm just dreaming,
though. :)
Anyone have any ideas how to do this?
Modify cursor data before using SimpleCursorAdapter in ListView
Modify cursor data before using SimpleCursorAdapter in ListView
On my android application, I have a table in the Sqlite database that
stores appointments. Each appointment has a StartDateTime column which
stores both the date and the time. In my application, these appointments
are queried and displayed in a ListView via a SimpleCursorAdapter.
SimpleCursorAdapter adapter;
private void populateListView() {
Cursor cursor = Db.Functions.getAppointmentList(); // Cursor
containing all appointments
String[] cols = new String[] { "Subject", "StartDateTime" };
int[] to = new int[] { R.id.lblSubject, R.id.lblTime };
adapter = new SimpleCursorAdapter(
this, R.layout.appointment_info, cursor, cols, to, 0);
ListView listView = (ListView) findViewById(R.id.lstAppts);
listView.setAdapter(adapter);
}
This currently just slaps whatever is in the StartDateTime column straight
into onto R.id.lblTime, however ideally I would like my listview to only
display the time but not the date. This is as far as my knowledge of the
matter goes, so would appreciate it if anyone could explain how I can
refine the cursor results before applying them to the listview. Many
thanks.
On my android application, I have a table in the Sqlite database that
stores appointments. Each appointment has a StartDateTime column which
stores both the date and the time. In my application, these appointments
are queried and displayed in a ListView via a SimpleCursorAdapter.
SimpleCursorAdapter adapter;
private void populateListView() {
Cursor cursor = Db.Functions.getAppointmentList(); // Cursor
containing all appointments
String[] cols = new String[] { "Subject", "StartDateTime" };
int[] to = new int[] { R.id.lblSubject, R.id.lblTime };
adapter = new SimpleCursorAdapter(
this, R.layout.appointment_info, cursor, cols, to, 0);
ListView listView = (ListView) findViewById(R.id.lstAppts);
listView.setAdapter(adapter);
}
This currently just slaps whatever is in the StartDateTime column straight
into onto R.id.lblTime, however ideally I would like my listview to only
display the time but not the date. This is as far as my knowledge of the
matter goes, so would appreciate it if anyone could explain how I can
refine the cursor results before applying them to the listview. Many
thanks.
Tuesday, 20 August 2013
try except handling in python
try except handling in python
I have the following code. I want to come out of else block the moment it
meets with an exception and I want the for loop to continue. But my code
breaks out of the outer for loop as well. Need some help. New to
programming.
for (....):
if (....):
.....
.....
else:
try:
....
except IndexError:
break
Thanks
I have the following code. I want to come out of else block the moment it
meets with an exception and I want the for loop to continue. But my code
breaks out of the outer for loop as well. Need some help. New to
programming.
for (....):
if (....):
.....
.....
else:
try:
....
except IndexError:
break
Thanks
Virtual address space in windows
Virtual address space in windows
All, Forgive me I'm a newbie for the Windows Driver Development, After
read this document from WDK, I have something I didn't understand.
The document says
The range of virtual addresses that is available to a process is called
the virtual address space for the process. Each user-mode process has its
own private virtual address space. For a 32-bit process, the virtual
address space is usually the 2-gigabyte range 0x00000000 through
0x7FFFFFFF. For a 64-bit process, the virtual address space is the
8-terabyte range 0x000'00000000 through 0x7FF'FFFFFFFF. A range of virtual
addresses is sometimes called a range of virtual memory.
My questions about it are :
Supposed there is a computer which has 8-gigabyte memory bank.
Is all the virtual address space actully assigned from this 8-gigabyte
memory?
If one process need to assigned 2g virtual address space, Can I say that
if there are 4 processes running in the system. they totally need
8-gigabyte memory ? If the answer is Yes, Does it means in thes computer
the max number of processes can be ran is 4?
I don't know if I misunderstand something. please correct me. thanks a lot.
All, Forgive me I'm a newbie for the Windows Driver Development, After
read this document from WDK, I have something I didn't understand.
The document says
The range of virtual addresses that is available to a process is called
the virtual address space for the process. Each user-mode process has its
own private virtual address space. For a 32-bit process, the virtual
address space is usually the 2-gigabyte range 0x00000000 through
0x7FFFFFFF. For a 64-bit process, the virtual address space is the
8-terabyte range 0x000'00000000 through 0x7FF'FFFFFFFF. A range of virtual
addresses is sometimes called a range of virtual memory.
My questions about it are :
Supposed there is a computer which has 8-gigabyte memory bank.
Is all the virtual address space actully assigned from this 8-gigabyte
memory?
If one process need to assigned 2g virtual address space, Can I say that
if there are 4 processes running in the system. they totally need
8-gigabyte memory ? If the answer is Yes, Does it means in thes computer
the max number of processes can be ran is 4?
I don't know if I misunderstand something. please correct me. thanks a lot.
logging in using websecurity only works on localhost
logging in using websecurity only works on localhost
[Authorize]
public class SystemController : Controller
{
public ActionResult Index()
{
return View();
}
}
// this method is inside AccountController
[HttpPost]
public ActionResult Login(User acc)
{
if(ModelState.IsValid)
{
if(WebSecurity.Login(acc.username, acc.password))
return RedirectToAction("Index", "System");
}
ModelState.AddModelError("IncorrectDetails", "Wrong details. Please
try again.");
return View(acc);
}
}
When this code is run locally on my PC it works perfectly. I can log in
and log out without problems, and I can't access the SystemController when
I'm logged out. Exactly what I want.
But when I publish the site on my domain, I can't log in for some reason.
It asks me for credentials inside a window:
I don't understand why this pop-up comes first of all, and second of all I
just want the user to log-in with the regular <input type="text"> fields.
The public version has the exact same tables and data inside the database.
Nothing seems wrong with that.
[Authorize]
public class SystemController : Controller
{
public ActionResult Index()
{
return View();
}
}
// this method is inside AccountController
[HttpPost]
public ActionResult Login(User acc)
{
if(ModelState.IsValid)
{
if(WebSecurity.Login(acc.username, acc.password))
return RedirectToAction("Index", "System");
}
ModelState.AddModelError("IncorrectDetails", "Wrong details. Please
try again.");
return View(acc);
}
}
When this code is run locally on my PC it works perfectly. I can log in
and log out without problems, and I can't access the SystemController when
I'm logged out. Exactly what I want.
But when I publish the site on my domain, I can't log in for some reason.
It asks me for credentials inside a window:
I don't understand why this pop-up comes first of all, and second of all I
just want the user to log-in with the regular <input type="text"> fields.
The public version has the exact same tables and data inside the database.
Nothing seems wrong with that.
Setting up two ADSL lines for home/business use
Setting up two ADSL lines for home/business use
As a follow-up to this question which is still unresolved. I have two ADSL
routers with different providers connected to different phone lines to the
internet. As shown in the diagram. These routers have addresses
192.168.0.1 and 192.168.1.1 on my local network.
I want the computer on my home LAN with address 10.0.0.50 (and others) to
be routed through the 192.168.1.1 gateway, and the computer with address
10.0.0.60 (and others) to be routed through the 192.168.0.1 gateway. I
also want to let 10.0.0.50 to communicate with 10.0.0.60 (file sharing,
remote desktop, etc)
I am using shorewall to configure iptables and squid as a transparent
proxy. Is my configuration possible? How should I do it?
As a follow-up to this question which is still unresolved. I have two ADSL
routers with different providers connected to different phone lines to the
internet. As shown in the diagram. These routers have addresses
192.168.0.1 and 192.168.1.1 on my local network.
I want the computer on my home LAN with address 10.0.0.50 (and others) to
be routed through the 192.168.1.1 gateway, and the computer with address
10.0.0.60 (and others) to be routed through the 192.168.0.1 gateway. I
also want to let 10.0.0.50 to communicate with 10.0.0.60 (file sharing,
remote desktop, etc)
I am using shorewall to configure iptables and squid as a transparent
proxy. Is my configuration possible? How should I do it?
Why are system calls so slow on Redhat 5?
Why are system calls so slow on Redhat 5?
My department is considering moving to RHEL5 from RHEL4 but we've hit a
problem. We have some software that executes a bunch of system calls in
succession and we've noticed that it takes much, much longer on RHEL5. The
scripts are written in bash shell but we're also seeing the problem in C
shell, Perl, and Groovy. An example:
foreach run (`seq 1 1000`)
echo `expr 1 - 1` >& /dev/null
end
This script takes .99s to run on a RHEL4 machine but 13.35s to run on an
identical RHEL5 machine.
My department is considering moving to RHEL5 from RHEL4 but we've hit a
problem. We have some software that executes a bunch of system calls in
succession and we've noticed that it takes much, much longer on RHEL5. The
scripts are written in bash shell but we're also seeing the problem in C
shell, Perl, and Groovy. An example:
foreach run (`seq 1 1000`)
echo `expr 1 - 1` >& /dev/null
end
This script takes .99s to run on a RHEL4 machine but 13.35s to run on an
identical RHEL5 machine.
I need help formatting an Excel sheet
I need help formatting an Excel sheet
Im trying to create a database from this website:
http://www.fifa.com/aboutfifa/organisation/footballgovernance/playeragents/list.html
Each country has loads of agents, with contact details next to their
name.(Fax Number and Company name are not required)
The problem is, due to the format of the website
(http://www.fifa.com/aboutfifa/organisation/footballgovernance/playeragents/association=alb.html),
when I copy the data into my Excel sheet each Agent has information spread
over 3 or 4 rows. (Sorry for No pictures, I'm new so have no reputation)
I need each Agent to have all their information on one row,
eg.(Cells in Brackets)
(A1) GRO Alberti (B1) alerti.ago@got.ch (C1) Bosnia (D1) P Hora K2 A 8 41
Dhjetori (E1)Girana (F1) Tel:+42-79/379 82 86.
I tried copy pasting it all manually, but this takes far too long.
Is there any automatic or quicker way of achieving what Im trying to do?
Thank you for any help, it is much appreciated.
Im trying to create a database from this website:
http://www.fifa.com/aboutfifa/organisation/footballgovernance/playeragents/list.html
Each country has loads of agents, with contact details next to their
name.(Fax Number and Company name are not required)
The problem is, due to the format of the website
(http://www.fifa.com/aboutfifa/organisation/footballgovernance/playeragents/association=alb.html),
when I copy the data into my Excel sheet each Agent has information spread
over 3 or 4 rows. (Sorry for No pictures, I'm new so have no reputation)
I need each Agent to have all their information on one row,
eg.(Cells in Brackets)
(A1) GRO Alberti (B1) alerti.ago@got.ch (C1) Bosnia (D1) P Hora K2 A 8 41
Dhjetori (E1)Girana (F1) Tel:+42-79/379 82 86.
I tried copy pasting it all manually, but this takes far too long.
Is there any automatic or quicker way of achieving what Im trying to do?
Thank you for any help, it is much appreciated.
squashTA falied to configure plugin parameters (Eclipse)
squashTA falied to configure plugin parameters (Eclipse)
I've just install squashTA and I try to do this tutorial
https://sites.google.com/a/henix.fr/wiki-squash-ta/tutorials/tuto-3-how-to-test-a-web-application-with-database-checks-with-squash-ta-and-selenium
but when I try to run I have this message in console output:
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building Unnamed - [name of my company]m:0.0.1-SNAPSHOT
[INFO] task-segment: [integration-test]
[INFO]
------------------------------------------------------------------------
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for:
org.squashtest.ta:squash-ta-maven-plugin:1.6.0-RELEASE
Cause: Cannot find setter nor field in
org.squashtest.ta.commons.exporter.html.HtmlSuiteResultExporter for
'exportAttached'
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Tue Aug 20 10:53:10 CEST 2013
[INFO] Final Memory: 24M/59M
[INFO]
------------------------------------------------------------------------
Is there anybody, who had the same problem as my? Thanks for any help!
I've just install squashTA and I try to do this tutorial
https://sites.google.com/a/henix.fr/wiki-squash-ta/tutorials/tuto-3-how-to-test-a-web-application-with-database-checks-with-squash-ta-and-selenium
but when I try to run I have this message in console output:
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building Unnamed - [name of my company]m:0.0.1-SNAPSHOT
[INFO] task-segment: [integration-test]
[INFO]
------------------------------------------------------------------------
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for:
org.squashtest.ta:squash-ta-maven-plugin:1.6.0-RELEASE
Cause: Cannot find setter nor field in
org.squashtest.ta.commons.exporter.html.HtmlSuiteResultExporter for
'exportAttached'
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Tue Aug 20 10:53:10 CEST 2013
[INFO] Final Memory: 24M/59M
[INFO]
------------------------------------------------------------------------
Is there anybody, who had the same problem as my? Thanks for any help!
Monday, 19 August 2013
how to separate a string from text in android
how to separate a string from text in android
I want to split a string from text. my text is
Text: "#FoodType:Veg#\r\n#Ratings:5.0#\r\n#Description:Short Description#"
I want like this
"#FoodType:" + veg + "#". only want veg, that is the value of foodType.
I want to split a string from text. my text is
Text: "#FoodType:Veg#\r\n#Ratings:5.0#\r\n#Description:Short Description#"
I want like this
"#FoodType:" + veg + "#". only want veg, that is the value of foodType.
ember.js can't get pagination from metadata
ember.js can't get pagination from metadata
I do an example like this,but still can't get pagination
this is my store.js.coffee
Eme.serializer = DS.RESTSerializer.create()
Eme.serializer.configure
meta: 'meta'
pagination: 'pagination'
Eme.CustomAdapter = DS.RESTAdapter.extend
serializer: Eme.serializer
namespace: "api/v1"
Eme.Store = DS.Store.extend
revision: 13
adapter: 'Eme.CustomAdapter'
this is my controller
Eme.PluginsController = Em.ArrayController.extend
content: []
pagination: (->
if this.get('model.isLoaded')
console.log @get('model.type')
console.log @get('store').typeMapFor(modelType).metadata
modelType = @get('model.type')
@get('store').typeMapFor(modelType).metadata.pagination
).property('model.isLoaded')
this is response
{
"meta":{
"pagination":{
"total_count":16,
"total_pages":2,
"current_page":1
}
},
"plugins":[{
"id":"1",
"name":"zhangsan",
}]
}
this is my log:
Eme.Plugin plugins_controller.js?body=1:7
Object {}
I do an example like this,but still can't get pagination
this is my store.js.coffee
Eme.serializer = DS.RESTSerializer.create()
Eme.serializer.configure
meta: 'meta'
pagination: 'pagination'
Eme.CustomAdapter = DS.RESTAdapter.extend
serializer: Eme.serializer
namespace: "api/v1"
Eme.Store = DS.Store.extend
revision: 13
adapter: 'Eme.CustomAdapter'
this is my controller
Eme.PluginsController = Em.ArrayController.extend
content: []
pagination: (->
if this.get('model.isLoaded')
console.log @get('model.type')
console.log @get('store').typeMapFor(modelType).metadata
modelType = @get('model.type')
@get('store').typeMapFor(modelType).metadata.pagination
).property('model.isLoaded')
this is response
{
"meta":{
"pagination":{
"total_count":16,
"total_pages":2,
"current_page":1
}
},
"plugins":[{
"id":"1",
"name":"zhangsan",
}]
}
this is my log:
Eme.Plugin plugins_controller.js?body=1:7
Object {}
Improving security with JS
Improving security with JS
I'm trying some little ideas, and I've hit a snag.
At the moment, when a user logs in, their password is stored in a variable
which is handled later. Obviously all one has to do to get hold of the
password is to go into the developer tools or console or whatever and add
a statement like alert(pass.value);.
I know this is unrealistic but its been bugging me. Is there any way of
detecting an alert statement and scrambling the password somehow? A regex
or string replace?
Thanks!
I'm trying some little ideas, and I've hit a snag.
At the moment, when a user logs in, their password is stored in a variable
which is handled later. Obviously all one has to do to get hold of the
password is to go into the developer tools or console or whatever and add
a statement like alert(pass.value);.
I know this is unrealistic but its been bugging me. Is there any way of
detecting an alert statement and scrambling the password somehow? A regex
or string replace?
Thanks!
Select Top n Values Across Columns and Average
Select Top n Values Across Columns and Average
I have a table that has 13 columns, 1 column holds the identifier field
(varchar, 25) and the other 12 hold int values (one for each month of the
year). For each row, I would like to pick the top 6 int values from the 12
columns and calculate the average of those values. I know how to select
the top n from a given column, but how do you do it across multiple
columns? Is it even possible?
I have a table that has 13 columns, 1 column holds the identifier field
(varchar, 25) and the other 12 hold int values (one for each month of the
year). For each row, I would like to pick the top 6 int values from the 12
columns and calculate the average of those values. I know how to select
the top n from a given column, but how do you do it across multiple
columns? Is it even possible?
What happened to all of the DisplayPort splitters?
What happened to all of the DisplayPort splitters?
For a period of time, there were a number of DisplayPort splitters on the
market (like this one, and another made by IBM). Unfortunately, they all
seem to have been discontinued or are impossible to find. The DisplayPort
FAQ states that hubs are available, but I've had little luck finding one.
For a period of time, there were a number of DisplayPort splitters on the
market (like this one, and another made by IBM). Unfortunately, they all
seem to have been discontinued or are impossible to find. The DisplayPort
FAQ states that hubs are available, but I've had little luck finding one.
Sunday, 18 August 2013
What Rule generates the sequence $8,8,10,12,12,14,16,16$?
What Rule generates the sequence $8,8,10,12,12,14,16,16$?
What is the rule that generates the following sequence? I can not solve it.
8 8 10 12 12 14 16 16
For example: 1 3 5 7 9 11 Rule: $n+2$
What is the rule that generates the following sequence? I can not solve it.
8 8 10 12 12 14 16 16
For example: 1 3 5 7 9 11 Rule: $n+2$
How to get the parent iframe size in the embedded page js code?
How to get the parent iframe size in the embedded page js code?
I am writing a signage html page to be shown in full screen automatically.
I use screen.width and .height to get the client's screen size. Now for
the edit page which users can add/delete contents on the signage, I would
like to let users preview the edited result without going to signage site
in fullscreen. So I plan to have a iframe has the same ratio as the client
screen and embedded the signage page into the iframe on the edit page.
The thing is how I can let the signage page change the size to fit in the
iframe? Or how I can get the parent page's iframe from the embedded page?
The screen.width and $(document).width seem to have the same result.
I am writing a signage html page to be shown in full screen automatically.
I use screen.width and .height to get the client's screen size. Now for
the edit page which users can add/delete contents on the signage, I would
like to let users preview the edited result without going to signage site
in fullscreen. So I plan to have a iframe has the same ratio as the client
screen and embedded the signage page into the iframe on the edit page.
The thing is how I can let the signage page change the size to fit in the
iframe? Or how I can get the parent page's iframe from the embedded page?
The screen.width and $(document).width seem to have the same result.
Is it possible to override a rails engine model association in a decorator?
Is it possible to override a rails engine model association in a decorator?
I'm using a rails engine which defines a class with the following relation:
module Blogit
class Post < ActiveRecord::Base
...
belongs_to :blogger, :polymorphic => true
...
end
I'm trying to override this association in a decorator file. Namely, I do
not want this association to exist if possible.
In my decorator file, i'm using a class_eval to extend the class definition.
Blogit::Post.class_eval do
...
end
but I can't seem to override or destroy this relation. Anyone know how to
do this?
I'm using a rails engine which defines a class with the following relation:
module Blogit
class Post < ActiveRecord::Base
...
belongs_to :blogger, :polymorphic => true
...
end
I'm trying to override this association in a decorator file. Namely, I do
not want this association to exist if possible.
In my decorator file, i'm using a class_eval to extend the class definition.
Blogit::Post.class_eval do
...
end
but I can't seem to override or destroy this relation. Anyone know how to
do this?
Notify java app when something has happened by another java app
Notify java app when something has happened by another java app
I want to notify my java app when a DML has occur on my DB. I can call
java.jar in the MySQL trigger with sys_exec('/path/to/javabin -jar
my.jar');
What I'm missing is how to do it JAVA-wise.
I need that my.jar will send to my general app a message(or something).
I need that my general app listen to incoming messages(but not wait for
them), open new thread and execute code.
I have no idea how to do this 2 parts.
Some people suggested semaphores, signals, messaging system. I did some
internet search with not helpful direction. I can't use 3rd party software
due.
I want to notify my java app when a DML has occur on my DB. I can call
java.jar in the MySQL trigger with sys_exec('/path/to/javabin -jar
my.jar');
What I'm missing is how to do it JAVA-wise.
I need that my.jar will send to my general app a message(or something).
I need that my general app listen to incoming messages(but not wait for
them), open new thread and execute code.
I have no idea how to do this 2 parts.
Some people suggested semaphores, signals, messaging system. I did some
internet search with not helpful direction. I can't use 3rd party software
due.
Is this sentence correct: "She didn't have any book with her."
Is this sentence correct: "She didn't have any book with her."
Is this sentence correct? "She didn't have any book with her."
Is this sentence correct? "She didn't have any book with her."
JavaDoc auto generate doesn't work in exlipse
JavaDoc auto generate doesn't work in exlipse
I use Android's official bundle of eclipse+adt and for some reason When I
type '**' and click Enter the JavaDoc auto-generator doesn't add @param,
@return and such annotations (or any annotations at all, all I get is
empty javadoc block).
I did have trouble with auto-completion in general, and I'm guessing this
might be a settings issue, but than again eclipse often runs into some
troubles when fetching auto-complete suggestions showing some nasty error
windows.
I can't find the setting for this so can anyone tell me where they are?
also, if anyone ran into such thing and had a solution can you tell me
what it was? I will type the content of the nasty error window next time
it shows, it's not very easy to reproduce it.
Thanks in advance to anyone..
I use Android's official bundle of eclipse+adt and for some reason When I
type '**' and click Enter the JavaDoc auto-generator doesn't add @param,
@return and such annotations (or any annotations at all, all I get is
empty javadoc block).
I did have trouble with auto-completion in general, and I'm guessing this
might be a settings issue, but than again eclipse often runs into some
troubles when fetching auto-complete suggestions showing some nasty error
windows.
I can't find the setting for this so can anyone tell me where they are?
also, if anyone ran into such thing and had a solution can you tell me
what it was? I will type the content of the nasty error window next time
it shows, it's not very easy to reproduce it.
Thanks in advance to anyone..
textarea does not showing default text
textarea does not showing default text
i've a textarea which get's the default value from a database. for this my
code is:
echo "<textarea readonly='true'>".$row1['description']."</textarea>";
for this code the value isn't coming. my output is like this.
i thought it may be some database problem. but when i write this:
echo "<textarea readonly='true'
placeholder='".$row1['description']."'></textarea>";
the output shows the data.
when the database data is small then placeholder is ok. but if data will
be large then it'll not show a scroll. anybody can help me.
i've a textarea which get's the default value from a database. for this my
code is:
echo "<textarea readonly='true'>".$row1['description']."</textarea>";
for this code the value isn't coming. my output is like this.
i thought it may be some database problem. but when i write this:
echo "<textarea readonly='true'
placeholder='".$row1['description']."'></textarea>";
the output shows the data.
when the database data is small then placeholder is ok. but if data will
be large then it'll not show a scroll. anybody can help me.
Saturday, 17 August 2013
MikTeX 2.9 installs polyglossia in a different location than where it looks for it
MikTeX 2.9 installs polyglossia in a different location than where it
looks for it
I recently did a complete reinstall of Windows 7, installed all updates,
and reinstalled all of my programs, including MikTeX using the 2.9 64-bit
version. I ran a XeLaTeX document I had created and successfully run
before, in order to re-download and autoinstall most of my packages. This
went well, except for polyglossia.sty and gloss-english.ldf, both parts of
the polyglossia package; MikTeX prompts popped up (I had set the
autoinstall on "ask me" at install) twice for the first file and three
times for the second, before moving on and generating the document anyway.
The same thing would happen with those two every time I ran the document;
I tried changing the autoinstall download from "random" to, eventually, a
dozen or so repositories with no better luck. I looked in the directory
cited in the autoinstall prompt, and still no polyglossia directory.
Thinking perhaps it was a glich in the 64-bit version of MikTeX, I
uninstalled it--successfully except that Windows was for some reason
unable to remove the empty MikTeX 2.9 directory from Program Files (86)--I
removed it myself, but had to assert administrator privilege to do so. I
then ran CCleaner on the Windows registry; there were fixes to be made,
but none that appeared to have anything to do with MikTeX. I then
downloaded the 32-bit version and installed it, but everything just went
as before. And I don't even want to think about the manual
download-and-install fiasco that I tried next; it seems you can't get
polyglossia.sty to extract from polyglossia.dtx without polyglossia.sty
installed first.
Then it occurred to me to look in ALL of my C:\Program Files (x86)\MikTeX
2.9\tex subdirectories, not just the xelatex subdirectory where MikTeX was
looking for them, and lo and behold, there polyglossia was... in the latex
subdirectory. For all I know, MikTeX was fetching it and putting it there
every single time I clicked the go-get-it button. So the question becomes:
do I either tell MikTeX where to put it (and how), or where it should be
looking for it, (and again, how)? Or should I just move the polyglossia
directory to C:\Program Files (x86)\MikTeX 2.9\tex\xelatex with a simple
cut-and-paste and be done with it?
looks for it
I recently did a complete reinstall of Windows 7, installed all updates,
and reinstalled all of my programs, including MikTeX using the 2.9 64-bit
version. I ran a XeLaTeX document I had created and successfully run
before, in order to re-download and autoinstall most of my packages. This
went well, except for polyglossia.sty and gloss-english.ldf, both parts of
the polyglossia package; MikTeX prompts popped up (I had set the
autoinstall on "ask me" at install) twice for the first file and three
times for the second, before moving on and generating the document anyway.
The same thing would happen with those two every time I ran the document;
I tried changing the autoinstall download from "random" to, eventually, a
dozen or so repositories with no better luck. I looked in the directory
cited in the autoinstall prompt, and still no polyglossia directory.
Thinking perhaps it was a glich in the 64-bit version of MikTeX, I
uninstalled it--successfully except that Windows was for some reason
unable to remove the empty MikTeX 2.9 directory from Program Files (86)--I
removed it myself, but had to assert administrator privilege to do so. I
then ran CCleaner on the Windows registry; there were fixes to be made,
but none that appeared to have anything to do with MikTeX. I then
downloaded the 32-bit version and installed it, but everything just went
as before. And I don't even want to think about the manual
download-and-install fiasco that I tried next; it seems you can't get
polyglossia.sty to extract from polyglossia.dtx without polyglossia.sty
installed first.
Then it occurred to me to look in ALL of my C:\Program Files (x86)\MikTeX
2.9\tex subdirectories, not just the xelatex subdirectory where MikTeX was
looking for them, and lo and behold, there polyglossia was... in the latex
subdirectory. For all I know, MikTeX was fetching it and putting it there
every single time I clicked the go-get-it button. So the question becomes:
do I either tell MikTeX where to put it (and how), or where it should be
looking for it, (and again, how)? Or should I just move the polyglossia
directory to C:\Program Files (x86)\MikTeX 2.9\tex\xelatex with a simple
cut-and-paste and be done with it?
Given $a\in\mathbb{R}^2\backslash X$ and $v\in\mathbb{R}^2$, $\exists\delta$ such that $t\in[0,\delta) \Rightarrow a+tv\in...
Given $a\in\mathbb{R}^2\backslash X$ and $v\in\mathbb{R}^2$,
$\exists\delta$ such that $t\in[0,\delta) \Rightarrow a+tv\in...
Let $X=\{(x,y)\in\mathbb{R}^2;\;x>0 \;\text{and}\;x^2\leq y\leq2x^2\}$.
Prove that for all $(a,v)\in(\mathbb{R^2}\backslash X)\times \mathbb{R}^2$
there exists $\delta>0$ such that $$0\leq t <\delta \Rightarrow a+tv\in
\mathbb{R}^2\backslash X$$
This problem is in the section of differentiable functions of my book.
Thanks.
$\exists\delta$ such that $t\in[0,\delta) \Rightarrow a+tv\in...
Let $X=\{(x,y)\in\mathbb{R}^2;\;x>0 \;\text{and}\;x^2\leq y\leq2x^2\}$.
Prove that for all $(a,v)\in(\mathbb{R^2}\backslash X)\times \mathbb{R}^2$
there exists $\delta>0$ such that $$0\leq t <\delta \Rightarrow a+tv\in
\mathbb{R}^2\backslash X$$
This problem is in the section of differentiable functions of my book.
Thanks.
javascript str-match cannot use
javascript str-match cannot use
I need to parse url240 and url360 from a string. But i cant do it. On PHP
it is very easy:
preg_match('/&url240=(.*?)&/mis', $string, $C);
But I cant do it on javascript. My javascript code:
var str =
"&url240=http://cs506410v4.vk.me/u170785079/videos/d10bdfccf6.240.mp4&url360=http://cs506410v4.vk.me/u170785079/videos/d10bdfccf6.360.mp4&url480=";
var n=str.match(/url240=/gi);
alert(n);
I need to parse url240 and url360 from a string. But i cant do it. On PHP
it is very easy:
preg_match('/&url240=(.*?)&/mis', $string, $C);
But I cant do it on javascript. My javascript code:
var str =
"&url240=http://cs506410v4.vk.me/u170785079/videos/d10bdfccf6.240.mp4&url360=http://cs506410v4.vk.me/u170785079/videos/d10bdfccf6.360.mp4&url480=";
var n=str.match(/url240=/gi);
alert(n);
Charracters between two exact charracters
Charracters between two exact charracters
Let me show you what I want to do... For example, I have this as an input
......1.......1.................
and what I want to do is
.......1111111..................
So I want to fill the space between the two ones with ones... Also this
should be able to be done too:
......11.....1..................
........11111...................
So I want just the inside...
Any C# help you can give?
Let me show you what I want to do... For example, I have this as an input
......1.......1.................
and what I want to do is
.......1111111..................
So I want to fill the space between the two ones with ones... Also this
should be able to be done too:
......11.....1..................
........11111...................
So I want just the inside...
Any C# help you can give?
Installing Imagemagick on Mac, which identify /usr/local/bin/identify
Installing Imagemagick on Mac, which identify /usr/local/bin/identify
I there i think i almost got imagemagick installed, i have really been
looking for an answer on this.. but there are several but them havent
worked for me i guess im doing something wrong, or i have something wrong.
im a non advanced user on Mac.. thats why.
if i enter Which identify in terminal i got this /usr/local/bin/identify
I follow this steps..
http://www.imagemagick.org/script/install-source.php#unix
But it failed here in this step, cause i think this command is for linux
only:
$ sudo ldconfig /usr/local/lib
Anyway, i dont know where and how to edit this route
/usr/local/bin/identify to be just
/usr/local/bin/
Cause thats what i need right?
If i enter "brew doctor" in this moment i got this errors.
brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/ImageMagick/bin/Magick++-config
/opt/ImageMagick/bin/Magick-config
/opt/ImageMagick/bin/MagickCore-config
/opt/ImageMagick/bin/MagickWand-config
/opt/ImageMagick/bin/Wand-config
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libMagick++-6.Q16.2.dylib
/usr/local/lib/libMagickCore-6.Q16.1.dylib
/usr/local/lib/libMagickWand-6.Q16.1.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
/usr/local/lib/libMagick++-6.Q16.la
/usr/local/lib/libMagickCore-6.Q16.la
/usr/local/lib/libMagickWand-6.Q16.la
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
/usr/local/lib/pkgconfig/ImageMagick++-6.Q16.pc
/usr/local/lib/pkgconfig/ImageMagick++.pc
/usr/local/lib/pkgconfig/ImageMagick-6.Q16.pc
/usr/local/lib/pkgconfig/Magick++-6.Q16.pc
/usr/local/lib/pkgconfig/Magick++.pc
/usr/local/lib/pkgconfig/MagickCore-6.Q16.pc
/usr/local/lib/pkgconfig/MagickWand-6.Q16.pc
/usr/local/lib/pkgconfig/Wand-6.Q16.pc
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libMagick++-6.Q16.a
/usr/local/lib/libMagickCore-6.Q16.a
/usr/local/lib/libMagickWand-6.Q16.a
Ramons-MacBook-Pro:~ Monclee$
I there i think i almost got imagemagick installed, i have really been
looking for an answer on this.. but there are several but them havent
worked for me i guess im doing something wrong, or i have something wrong.
im a non advanced user on Mac.. thats why.
if i enter Which identify in terminal i got this /usr/local/bin/identify
I follow this steps..
http://www.imagemagick.org/script/install-source.php#unix
But it failed here in this step, cause i think this command is for linux
only:
$ sudo ldconfig /usr/local/lib
Anyway, i dont know where and how to edit this route
/usr/local/bin/identify to be just
/usr/local/bin/
Cause thats what i need right?
If i enter "brew doctor" in this moment i got this errors.
brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/opt/ImageMagick/bin/Magick++-config
/opt/ImageMagick/bin/Magick-config
/opt/ImageMagick/bin/MagickCore-config
/opt/ImageMagick/bin/MagickWand-config
/opt/ImageMagick/bin/Wand-config
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libMagick++-6.Q16.2.dylib
/usr/local/lib/libMagickCore-6.Q16.1.dylib
/usr/local/lib/libMagickWand-6.Q16.1.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
/usr/local/lib/libMagick++-6.Q16.la
/usr/local/lib/libMagickCore-6.Q16.la
/usr/local/lib/libMagickWand-6.Q16.la
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
/usr/local/lib/pkgconfig/ImageMagick++-6.Q16.pc
/usr/local/lib/pkgconfig/ImageMagick++.pc
/usr/local/lib/pkgconfig/ImageMagick-6.Q16.pc
/usr/local/lib/pkgconfig/Magick++-6.Q16.pc
/usr/local/lib/pkgconfig/Magick++.pc
/usr/local/lib/pkgconfig/MagickCore-6.Q16.pc
/usr/local/lib/pkgconfig/MagickWand-6.Q16.pc
/usr/local/lib/pkgconfig/Wand-6.Q16.pc
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libMagick++-6.Q16.a
/usr/local/lib/libMagickCore-6.Q16.a
/usr/local/lib/libMagickWand-6.Q16.a
Ramons-MacBook-Pro:~ Monclee$
No Facebook Web/Email Notifications
No Facebook Web/Email Notifications
For the past 2-3 days, no web notifications or email notifications have
been coming. To figure out more into this, here is the snapshots Settings
-> Notifications.
In the above snapshot, no sub-options in the form of check boxes are
appearing. Earlier it used to appear. In the snapshot given in the
question, all sub-options below the heading You've unsubscribed from
emails about: are there.
Even when the email notifications is set to all notifications, it still
shows No notifications, as evident from the below snapshot.
In this regard, a form regarding notification issue was submitted to the
Facebook, but this doesn't guarantee a response from them.
For the past 2-3 days, no web notifications or email notifications have
been coming. To figure out more into this, here is the snapshots Settings
-> Notifications.
In the above snapshot, no sub-options in the form of check boxes are
appearing. Earlier it used to appear. In the snapshot given in the
question, all sub-options below the heading You've unsubscribed from
emails about: are there.
Even when the email notifications is set to all notifications, it still
shows No notifications, as evident from the below snapshot.
In this regard, a form regarding notification issue was submitted to the
Facebook, but this doesn't guarantee a response from them.
How to query a dynamic name from another object in mongoid
How to query a dynamic name from another object in mongoid
I am trying to do a query an object and the name is generated from another
embedded one, and check to see if a user is in it something like :
allOs = MyObject.all
myOs = []
allOs.each do |myO|
sths = myO.somethings
sths.each do |s|
name = "automated_#{s.title}"
myGroup = Group.where(name: name)
if myGroup.includes? current_user
myOS << myO
break
end
end
end
Is there anyway to do it in mongoid, cause this won't be query-able, and
it will load all the objects first which isn't optimized.
I am trying to do a query an object and the name is generated from another
embedded one, and check to see if a user is in it something like :
allOs = MyObject.all
myOs = []
allOs.each do |myO|
sths = myO.somethings
sths.each do |s|
name = "automated_#{s.title}"
myGroup = Group.where(name: name)
if myGroup.includes? current_user
myOS << myO
break
end
end
end
Is there anyway to do it in mongoid, cause this won't be query-able, and
it will load all the objects first which isn't optimized.
Friday, 16 August 2013
Neo4j Spatial: can't run spatial
Neo4j Spatial: can't run spatial
I have been trying to work with Neo4j Spatial for my project, but I can't
make it work.
With limited documentation and examples I figured out how to load OSM map
to the database. But to check if it is loaded, I am trying to execute a
spatial query.
While trying to run my code I get this error:
import.java:69: error: cannot access GremlinGroovyPipeline
.startIntersectSearch(layer, bbox)
^
class file for com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline not found
I understand what's wrong (it can't find the required library), but I
don't know how to fix it. The reason is when I run Neo4j Spatial tests,
LayerTest.java and TestSpatial.java do include GeoPipeline library and it
works perfectly fine. However, when I created my simple java file to test
Neo4j, and trying to execute commands that depend GeoPipeline library I
get the error above.
I read the instructions on github for Neo4j and saw this note:
Note: neo4j-spatial has a mandatory dependency on GremlinGroovyPipeline
from the com.tinkerpop.gremlin.groovy package. The dependency in neo4j is
type 'provided', so when using neo4j-spatial in your own Java project,
make sure to add the following dependency to your pom.xml, too.
However, I am not using Maven to build my app. It is a simple java file,
that I want to run to test if I get how everything works.
here is the code from my java file:
package org.neo4j.gis.spatial;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.geotools.data.DataStore;
import org.geotools.data.neo4j.Neo4jSpatialDataStore;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.neo4j.gis.spatial.osm.OSMDataset;
import org.neo4j.gis.spatial.osm.OSMDataset.Way;
import org.neo4j.gis.spatial.osm.OSMGeometryEncoder;
import org.neo4j.gis.spatial.osm.OSMImporter;
import org.neo4j.gis.spatial.osm.OSMLayer;
import org.neo4j.gis.spatial.osm.OSMRelation;
import org.neo4j.gis.spatial.pipes.osm.OSMGeoPipeline;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import org.neo4j.kernel.impl.batchinsert.BatchInserter;
import org.neo4j.kernel.impl.batchinsert.BatchInserterImpl;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.gis.spatial.pipes.GeoPipeline;
class SpatialOsmImport {
public static void main(String[] args)
{
OSMImporter importer = new OSMImporter("ott.osm");
Map<String, String> config = new HashMap<String, String>();
config.put("neostore.nodestore.db.mapped_memory", "90M" );
config.put("dump_configuration", "true");
config.put("use_memory_mapped_buffers", "true");
BatchInserter batchInserter = new
BatchInserterImpl("target/dependency", config);
importer.setCharset(Charset.forName("UTF-8"));
try{
importer.importFile(batchInserter, "ott.osm", false);
batchInserter.shutdown();
GraphDatabaseService db = new
EmbeddedGraphDatabase("target/dependency");
importer.reIndex(db, 10000);
db.shutdown();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
GraphDatabaseService database = new
EmbeddedGraphDatabase("target/dependency");
try{
SpatialDatabaseService spatialService = new
SpatialDatabaseService(database);
Layer layer = spatialService.getLayer("layer_roads");
LayerIndexReader spatialIndex = layer.getIndex();
System.out.println("Have " + spatialIndex.count() + "
geometries in " + spatialIndex.getBoundingBox());
Envelope bbox = new Envelope(-75.80, 45.19, -75.7, 45.23);
// Search searchQuery = new SearchIntersectWindow(bbox);
// spatialIndex.executeSearch(searchQuery);
// List<SpatialDatabaseRecord> results =
searchQuery.getResults();
List<SpatialDatabaseRecord> results = GeoPipeline
.startIntersectSearch(layer, bbox)
.toSpatialDatabaseRecordList();
doGeometryTestsOnResults(bbox, results);
} finally {
database.shutdown();
}
}
private static void doGeometryTestsOnResults(Envelope bbox,
List<SpatialDatabaseRecord> results) {
System.out.println("Found " + results.size() + " geometries in " +
bbox);
Geometry geometry = results.get(0).getGeometry();
System.out.println("First geometry is " + geometry);
geometry.buffer(2);
}
}
It is very simple right now, but I can't make it work. How do I include
com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline in my app, so it works?
I run everything on Ubuntu 12.04 and java version "1.7.0_25", Java(TM) SE
Runtime Environment (build 1.7.0_25-b15).
Any help is greatly appreciated.
I have been trying to work with Neo4j Spatial for my project, but I can't
make it work.
With limited documentation and examples I figured out how to load OSM map
to the database. But to check if it is loaded, I am trying to execute a
spatial query.
While trying to run my code I get this error:
import.java:69: error: cannot access GremlinGroovyPipeline
.startIntersectSearch(layer, bbox)
^
class file for com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline not found
I understand what's wrong (it can't find the required library), but I
don't know how to fix it. The reason is when I run Neo4j Spatial tests,
LayerTest.java and TestSpatial.java do include GeoPipeline library and it
works perfectly fine. However, when I created my simple java file to test
Neo4j, and trying to execute commands that depend GeoPipeline library I
get the error above.
I read the instructions on github for Neo4j and saw this note:
Note: neo4j-spatial has a mandatory dependency on GremlinGroovyPipeline
from the com.tinkerpop.gremlin.groovy package. The dependency in neo4j is
type 'provided', so when using neo4j-spatial in your own Java project,
make sure to add the following dependency to your pom.xml, too.
However, I am not using Maven to build my app. It is a simple java file,
that I want to run to test if I get how everything works.
here is the code from my java file:
package org.neo4j.gis.spatial;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.geotools.data.DataStore;
import org.geotools.data.neo4j.Neo4jSpatialDataStore;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.neo4j.gis.spatial.osm.OSMDataset;
import org.neo4j.gis.spatial.osm.OSMDataset.Way;
import org.neo4j.gis.spatial.osm.OSMGeometryEncoder;
import org.neo4j.gis.spatial.osm.OSMImporter;
import org.neo4j.gis.spatial.osm.OSMLayer;
import org.neo4j.gis.spatial.osm.OSMRelation;
import org.neo4j.gis.spatial.pipes.osm.OSMGeoPipeline;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import org.neo4j.kernel.impl.batchinsert.BatchInserter;
import org.neo4j.kernel.impl.batchinsert.BatchInserterImpl;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.gis.spatial.pipes.GeoPipeline;
class SpatialOsmImport {
public static void main(String[] args)
{
OSMImporter importer = new OSMImporter("ott.osm");
Map<String, String> config = new HashMap<String, String>();
config.put("neostore.nodestore.db.mapped_memory", "90M" );
config.put("dump_configuration", "true");
config.put("use_memory_mapped_buffers", "true");
BatchInserter batchInserter = new
BatchInserterImpl("target/dependency", config);
importer.setCharset(Charset.forName("UTF-8"));
try{
importer.importFile(batchInserter, "ott.osm", false);
batchInserter.shutdown();
GraphDatabaseService db = new
EmbeddedGraphDatabase("target/dependency");
importer.reIndex(db, 10000);
db.shutdown();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
GraphDatabaseService database = new
EmbeddedGraphDatabase("target/dependency");
try{
SpatialDatabaseService spatialService = new
SpatialDatabaseService(database);
Layer layer = spatialService.getLayer("layer_roads");
LayerIndexReader spatialIndex = layer.getIndex();
System.out.println("Have " + spatialIndex.count() + "
geometries in " + spatialIndex.getBoundingBox());
Envelope bbox = new Envelope(-75.80, 45.19, -75.7, 45.23);
// Search searchQuery = new SearchIntersectWindow(bbox);
// spatialIndex.executeSearch(searchQuery);
// List<SpatialDatabaseRecord> results =
searchQuery.getResults();
List<SpatialDatabaseRecord> results = GeoPipeline
.startIntersectSearch(layer, bbox)
.toSpatialDatabaseRecordList();
doGeometryTestsOnResults(bbox, results);
} finally {
database.shutdown();
}
}
private static void doGeometryTestsOnResults(Envelope bbox,
List<SpatialDatabaseRecord> results) {
System.out.println("Found " + results.size() + " geometries in " +
bbox);
Geometry geometry = results.get(0).getGeometry();
System.out.println("First geometry is " + geometry);
geometry.buffer(2);
}
}
It is very simple right now, but I can't make it work. How do I include
com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline in my app, so it works?
I run everything on Ubuntu 12.04 and java version "1.7.0_25", Java(TM) SE
Runtime Environment (build 1.7.0_25-b15).
Any help is greatly appreciated.
Saturday, 10 August 2013
What should the default constructor do in a RAII class with move semantics?
What should the default constructor do in a RAII class with move semantics?
Move semantics are great for RAII classes. They allow one to program as if
one had value semantics without the cost of heavy copies. A great example
of this is returning std::vector from a function. Programming with value
semantics however means, that one would expect types to behave like
primitive data types. Those two aspects sometimes seem to be at odds.
On the one hand, in RAII one would expect the default constructor to
return a fully initialized object or throw an exception if the resource
acquisition failed. This guarantees that any constructed object will be in
a valid and consistent state (i.e. safe to use).
On the other hand, with move semantics there exists a point when objects
are in a valid but unspecified state. Similarly, primitive data types can
be in an uninitialized state. Therefore, with value semantics, I would
expect the default constructor to create an object in this valid but
unspecified state, so that the following code would have the expected
behavior:
// Primitive Data Type, Value Semantics
int i;
i = 5;
// RAII Class, Move Semantics
Resource r;
r = Resource{/*...*/}
In both cases, I would expect the "heavy" initialization to occur only
once. I am wondering, what is the best practice regarding this? Obviously,
there is a slight practical issue with the second approach: If the default
constructor creates objects in the unspecified state, how would one write
a constructor that does acquire a resource, but takes no additional
parameters? (Tag dispatching comes to mind...)
Move semantics are great for RAII classes. They allow one to program as if
one had value semantics without the cost of heavy copies. A great example
of this is returning std::vector from a function. Programming with value
semantics however means, that one would expect types to behave like
primitive data types. Those two aspects sometimes seem to be at odds.
On the one hand, in RAII one would expect the default constructor to
return a fully initialized object or throw an exception if the resource
acquisition failed. This guarantees that any constructed object will be in
a valid and consistent state (i.e. safe to use).
On the other hand, with move semantics there exists a point when objects
are in a valid but unspecified state. Similarly, primitive data types can
be in an uninitialized state. Therefore, with value semantics, I would
expect the default constructor to create an object in this valid but
unspecified state, so that the following code would have the expected
behavior:
// Primitive Data Type, Value Semantics
int i;
i = 5;
// RAII Class, Move Semantics
Resource r;
r = Resource{/*...*/}
In both cases, I would expect the "heavy" initialization to occur only
once. I am wondering, what is the best practice regarding this? Obviously,
there is a slight practical issue with the second approach: If the default
constructor creates objects in the unspecified state, how would one write
a constructor that does acquire a resource, but takes no additional
parameters? (Tag dispatching comes to mind...)
I need Dracula Theme for NetBeans-PHP
I need Dracula Theme for NetBeans-PHP
I want Dark Theme for my NetBeans. Can any one give me link of NetBeans
dark theme that looks like Dracula theme of PHPStrom??
PHP Strom Dracula theme :
http://appfull.net/uploads/posts/2013-03/1363968810_ps6overview_series_1.png
I want Dark Theme for my NetBeans. Can any one give me link of NetBeans
dark theme that looks like Dracula theme of PHPStrom??
PHP Strom Dracula theme :
http://appfull.net/uploads/posts/2013-03/1363968810_ps6overview_series_1.png
Subscribe to:
Comments (Atom)