Multiple Inheritance in C
I am stuck with a classical Multiple Inheritance problem in C.
I have created source files Stack.c and Queue.c. Both of them #include a
file Node.c (which containing functions to allocate and deallocate
memory). Now, I am trying to implement another program in a single file,
for which I need to include both Stack.c and Queue.c. I tried to #include
both the files, but the compiler is throwing a conflicting type error.
What is the most correct way to do so?
Thanks in advance!!
Saturday, 31 August 2013
Mysql subquery sum of votes
Mysql subquery sum of votes
I've got a table of votes, alongside a table of 'ideas' (entries)
Basically, I want to retrieve an object that can be read as:
id,
name,
title,
votes : {
up : x,
down : y
}
So it's simple enough until I get to the subquery and need to do two sets
of SUMs on the positive and negative values of votes.
SELECT id,name,title FROM ideas
LEFT JOIN votes ON ideas.id = votes.idea_id
My (simplified) votes table looks something like:
id
idea_id
value
Where value can be either a positive or negative int.
How would I go about getting the above object in a single query?
Bonus point: How would I also get an aggregate field, where positive and
negative votes are added together?
I've got a table of votes, alongside a table of 'ideas' (entries)
Basically, I want to retrieve an object that can be read as:
id,
name,
title,
votes : {
up : x,
down : y
}
So it's simple enough until I get to the subquery and need to do two sets
of SUMs on the positive and negative values of votes.
SELECT id,name,title FROM ideas
LEFT JOIN votes ON ideas.id = votes.idea_id
My (simplified) votes table looks something like:
id
idea_id
value
Where value can be either a positive or negative int.
How would I go about getting the above object in a single query?
Bonus point: How would I also get an aggregate field, where positive and
negative votes are added together?
Multiple drop down windows that auto-close when opening another
Multiple drop down windows that auto-close when opening another
I have an example of what I'm working on here at JSFiddle
http://jsfiddle.net/OfSilence/zFuUp/. I'm trying to find a way to make the
drop-down that's opened auto close when opening another. All the solutions
I find either keep anything from opening or opening & closing everything
at the same time. Keep in mind on the final page their will be around 30
of these drop-downs. Any help would be greatly appreciated! JSFiddle
I have an example of what I'm working on here at JSFiddle
http://jsfiddle.net/OfSilence/zFuUp/. I'm trying to find a way to make the
drop-down that's opened auto close when opening another. All the solutions
I find either keep anything from opening or opening & closing everything
at the same time. Keep in mind on the final page their will be around 30
of these drop-downs. Any help would be greatly appreciated! JSFiddle
Mobile site problems
Mobile site problems
My website is not working on mobile devices. It loads a different (ugly)
version of my site than the responsive one that I designed. There is a
link to go to the full website on the mobile version but then it never
loads. I have an idx plugin that I think is making it do this? Is there a
way to disable the mobile version of a plugin? I want the mobile version
of my theme, not the plugin.
Any ideas of how to remove this ugly mobile version and make my regular
site load on the mobile device? I tested it here:
http://www.mattkersley.com/responsive/ and this is what it should look
like!
Here is my website: http://jillrea.com
My website is not working on mobile devices. It loads a different (ugly)
version of my site than the responsive one that I designed. There is a
link to go to the full website on the mobile version but then it never
loads. I have an idx plugin that I think is making it do this? Is there a
way to disable the mobile version of a plugin? I want the mobile version
of my theme, not the plugin.
Any ideas of how to remove this ugly mobile version and make my regular
site load on the mobile device? I tested it here:
http://www.mattkersley.com/responsive/ and this is what it should look
like!
Here is my website: http://jillrea.com
Javascript pass parameter to eventListener function whilst in loop
Javascript pass parameter to eventListener function whilst in loop
This code will pass the last value created by the loop the eventListener
function, I need the value at the time the eventListener was created to be
attached.
window.onload = function() {
var el = document.getElementsByClassName('modify');
for (var i = 0; i < el.length; i++) {
var getId=el[i].id.split("_");
document.getElementById("modify_y_"+getId[2]).addEventListener('mouseover',
function() {
document.getElementById("modify_x_"+getId[2]).style.borderBottom =
'#e6665 solid 3px';
}, false);
}
}
This code will pass the last value created by the loop the eventListener
function, I need the value at the time the eventListener was created to be
attached.
window.onload = function() {
var el = document.getElementsByClassName('modify');
for (var i = 0; i < el.length; i++) {
var getId=el[i].id.split("_");
document.getElementById("modify_y_"+getId[2]).addEventListener('mouseover',
function() {
document.getElementById("modify_x_"+getId[2]).style.borderBottom =
'#e6665 solid 3px';
}, false);
}
}
Align CSS Button in Center
Align CSS Button in Center
I've tried using posiotion:center and middle in the CSS and in the HTML
code I've tried align="center;middle" but nothing seems to work. I need
the button to be aligned in the center of the page and not to the left.
I've replaced several codes but still nothing. I've never had this problem
before but I guess there's a first for everything.
http://jsfiddle.net/LnSRb/
Here's the HTML code:
<div id='cssmenu'>
<ul>
<li class='has-sub last' id="iefix"><a rel=nofollow href='#'><span>Choose a
model</span></a>
<ul>
<li id="iefix"><a rel=nofollow href='#'><span>iPhone
3GS</span></a></li>
<li id="iefix"><a rel=nofollow href='#'><span>iPhone 4</span></a></li>
<li id="iefix"><a rel=nofollow href='#'><span>iPhone 4S</span></a></li>
<li class='last' id="iefix"><a rel=nofollow href='#'><span>iPhone
5</span></a>
</li>
</ul>
</li>
</ul>
</div>
I've tried using posiotion:center and middle in the CSS and in the HTML
code I've tried align="center;middle" but nothing seems to work. I need
the button to be aligned in the center of the page and not to the left.
I've replaced several codes but still nothing. I've never had this problem
before but I guess there's a first for everything.
http://jsfiddle.net/LnSRb/
Here's the HTML code:
<div id='cssmenu'>
<ul>
<li class='has-sub last' id="iefix"><a rel=nofollow href='#'><span>Choose a
model</span></a>
<ul>
<li id="iefix"><a rel=nofollow href='#'><span>iPhone
3GS</span></a></li>
<li id="iefix"><a rel=nofollow href='#'><span>iPhone 4</span></a></li>
<li id="iefix"><a rel=nofollow href='#'><span>iPhone 4S</span></a></li>
<li class='last' id="iefix"><a rel=nofollow href='#'><span>iPhone
5</span></a>
</li>
</ul>
</li>
</ul>
</div>
how can get business types from google api?
how can get business types from google api?
i want to show business type from google api in autocomplete? eg: As
customer type character in textbox display him list of business type from
google.
i want to show business type from google api in autocomplete? eg: As
customer type character in textbox display him list of business type from
google.
Friday, 30 August 2013
How to generate ALL floating numbers?
How to generate ALL floating numbers?
I'm trying to generate ALL float numbers to a file on C++ (using gcc). My
first attempt was to use FLT_MIN, FLT_MAX & FLT_EPSILON to generate them,
the code was something like this:
#include <cfloat>
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
FILE* handle = freopen("todos_los_float.in","w",stdout);
for(float x = FLT_MIN; x < FLT_MAX; x = x + FLT_EPSILON)
cout << x << endl;
fclose(handle);
return 0;
}
This is not working, as FLT_EPSILON destroys the precision of the number,
for FLT_MIN it takes a huge jump, and it's stop adding much before
reaching FLT_MAX.
I have thought on working and adding on binary form, and just skip the
special meanings (inf, -inf, NaN) but I'm also not sure which is the best
approach for this. How do you suggest to generate the numbers?
I'm trying to generate ALL float numbers to a file on C++ (using gcc). My
first attempt was to use FLT_MIN, FLT_MAX & FLT_EPSILON to generate them,
the code was something like this:
#include <cfloat>
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
FILE* handle = freopen("todos_los_float.in","w",stdout);
for(float x = FLT_MIN; x < FLT_MAX; x = x + FLT_EPSILON)
cout << x << endl;
fclose(handle);
return 0;
}
This is not working, as FLT_EPSILON destroys the precision of the number,
for FLT_MIN it takes a huge jump, and it's stop adding much before
reaching FLT_MAX.
I have thought on working and adding on binary form, and just skip the
special meanings (inf, -inf, NaN) but I'm also not sure which is the best
approach for this. How do you suggest to generate the numbers?
Thursday, 29 August 2013
WCF service fails to call another WCF service on same machine
WCF service fails to call another WCF service on same machine
I have a website hosted in IIS7 in server A. The website calls a web
service that is also hosted in server A, but the call returns an error
401. I tried referencing to the web service by IP address, host
(A.domain.com), and fully qualified dsn. None worked.
After some research, I found out about the loopback check, and the
BackConnectionHostNames.
Refer to this article
Disabling the loopback check fixes the problem, but is not a desirable
solution.
For the BackConnectionHostNames, I tried adding:
A
A.domain.com
A.full.domain.com
But it didn't work.
I played some with IIS http bindings for the website, I tried adding
A.domain.com to the host name, and I also tried setting the IP, but still
got the same error.
Am I missing something? (I clearly am...) Where else should I be looking at?
Any help appreciated. Thanks
I have a website hosted in IIS7 in server A. The website calls a web
service that is also hosted in server A, but the call returns an error
401. I tried referencing to the web service by IP address, host
(A.domain.com), and fully qualified dsn. None worked.
After some research, I found out about the loopback check, and the
BackConnectionHostNames.
Refer to this article
Disabling the loopback check fixes the problem, but is not a desirable
solution.
For the BackConnectionHostNames, I tried adding:
A
A.domain.com
A.full.domain.com
But it didn't work.
I played some with IIS http bindings for the website, I tried adding
A.domain.com to the host name, and I also tried setting the IP, but still
got the same error.
Am I missing something? (I clearly am...) Where else should I be looking at?
Any help appreciated. Thanks
how to open tor browser using watir?
how to open tor browser using watir?
With my ruby code I want to open Tor Browser instead of Firefox,for this I
tried this code
path='C:\Tor Browser\App\tor.exe'
Selenium::WebDriver::Firefox.path = path
driver = Selenium::WebDriver.for :firefox
ie = Watir::Browser.new :firefox, :driver => driver
I got this error
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:79:in
`connect_until_stable': unable to obtain stable firefox connection in 60
seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:37:in
`block in launch'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/socket_lock.rb:20:in
`locked'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:32:in
`launch'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/bridge.rb:24:in
`initialize'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/driver.rb:31:in
`new'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/driver.rb:31:in
`for'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver.rb:67:in
`for'
from C:/new_trademap/newTrademapTest.rb:28:in `<main>'
What should I have to do ? or there is any other way to do so?
With my ruby code I want to open Tor Browser instead of Firefox,for this I
tried this code
path='C:\Tor Browser\App\tor.exe'
Selenium::WebDriver::Firefox.path = path
driver = Selenium::WebDriver.for :firefox
ie = Watir::Browser.new :firefox, :driver => driver
I got this error
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:79:in
`connect_until_stable': unable to obtain stable firefox connection in 60
seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:37:in
`block in launch'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/socket_lock.rb:20:in
`locked'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/launcher.rb:32:in
`launch'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/firefox/bridge.rb:24:in
`initialize'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/driver.rb:31:in
`new'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/driver.rb:31:in
`for'
from
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver.rb:67:in
`for'
from C:/new_trademap/newTrademapTest.rb:28:in `<main>'
What should I have to do ? or there is any other way to do so?
how to show dash linebelow text view
how to show dash linebelow text view
thisis my code below which show dash line on center of textview i want to
show below the textview see image http://imgur.com/0PB2F2D is show
centerof text view how i change this to show beloe the textview dash line
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/apprentTemp"
android:textColor="#000000"
android:background="@drawable/dotted"
android:paddingLeft="10dp"
android:gravity="left"
/>
<TextView
android:id="@+id/localTime"
android:textColor="#000000"
android:background="@drawable/dotted"
android:gravity="center"
/>
</TableRow>
<---- dashed.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#000000"
android:dashWidth="5px"
android:dashGap="5px" />
</shape>
thisis my code below which show dash line on center of textview i want to
show below the textview see image http://imgur.com/0PB2F2D is show
centerof text view how i change this to show beloe the textview dash line
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/apprentTemp"
android:textColor="#000000"
android:background="@drawable/dotted"
android:paddingLeft="10dp"
android:gravity="left"
/>
<TextView
android:id="@+id/localTime"
android:textColor="#000000"
android:background="@drawable/dotted"
android:gravity="center"
/>
</TableRow>
<---- dashed.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#000000"
android:dashWidth="5px"
android:dashGap="5px" />
</shape>
Wednesday, 28 August 2013
Persist Data Across Wizard Steps using PRG Patternin ASP.NET MVC
Persist Data Across Wizard Steps using PRG Patternin ASP.NET MVC
I am working on a wizard like interface in ASP.Net MVC using the
Post-Redirect-Get pattern. The wizard has only 2 steps. I understand how
to get data from the first step to the second via TempData, but I am
curious as to what is the best way to persist the data to the next (final)
step. Coming from a Classic ASP background I have used hidden fields
and/or session storage to solve this problem is the past, but I wonder if
there is a more elegant way to do this in ASP.NET MVC? For example is
there a way to pass the entire model contained in TempData to the next
step or do I need to split the data up into separate hidden fields/
session variables?
I am working on a wizard like interface in ASP.Net MVC using the
Post-Redirect-Get pattern. The wizard has only 2 steps. I understand how
to get data from the first step to the second via TempData, but I am
curious as to what is the best way to persist the data to the next (final)
step. Coming from a Classic ASP background I have used hidden fields
and/or session storage to solve this problem is the past, but I wonder if
there is a more elegant way to do this in ASP.NET MVC? For example is
there a way to pass the entire model contained in TempData to the next
step or do I need to split the data up into separate hidden fields/
session variables?
Construct std::set from array
Construct std::set from array
Why doesn't C++ provide us with a constructor which takes an array as an
argument? Alternatively, is there anything wrong with defining the
following function?
template <class T>
std::set<T> ArrayToSet(T array[]) {
return std::set<T>(array, array + sizeof(array) / sizeof(array[0]));
}
I think the answer might come down to ideas of dynamic memory allocation,
but I'd like to hear some feedback on this.
Why doesn't C++ provide us with a constructor which takes an array as an
argument? Alternatively, is there anything wrong with defining the
following function?
template <class T>
std::set<T> ArrayToSet(T array[]) {
return std::set<T>(array, array + sizeof(array) / sizeof(array[0]));
}
I think the answer might come down to ideas of dynamic memory allocation,
but I'd like to hear some feedback on this.
Javascript configuration object advice
Javascript configuration object advice
This isn't a problem code, it's more of an advice question. I found the
below code on Better Practices for Javascript.
If I had this code below, what would be the usage for it the script to
pull labels and settings etc.
carousel = function(){
var config = {
CSS:{
classes:{
current:'current',
scrollContainer:'scroll'
},
IDs:{
maincontainer:'carousel'
}
}
labels:{
previous:'back',
next:'next',
auto:'play'
}
settings:{
amount:5,
skin:'blue',
autoplay:false
}
};
function init(){
};
function scroll(){
};
function highlight(){
};
return {config:config,init:init}
}();
This isn't a problem code, it's more of an advice question. I found the
below code on Better Practices for Javascript.
If I had this code below, what would be the usage for it the script to
pull labels and settings etc.
carousel = function(){
var config = {
CSS:{
classes:{
current:'current',
scrollContainer:'scroll'
},
IDs:{
maincontainer:'carousel'
}
}
labels:{
previous:'back',
next:'next',
auto:'play'
}
settings:{
amount:5,
skin:'blue',
autoplay:false
}
};
function init(){
};
function scroll(){
};
function highlight(){
};
return {config:config,init:init}
}();
JQuery mobile multiline button override issue
JQuery mobile multiline button override issue
I'm using Phonegap and JQuery mobile to create an app that uses button
whose content (caption) is fetched via an ajax request and can be pretty
long, so I wanted to have multiline buttons. I searched and found a way to
do so by using the following css :
.ui-btn-inner{
white-space: normal !important;
}
But I can't get it to work.
I have tried to put it between style tags in the head of my page, then
inside the html code of the button itself using style='' . I also tried to
put that piece of code in a css file and link it to the page but it
doesn't work either, even if I put this file in the same folder than my
HTML.
Here is an extract of my JS where I create the button :
for ( var i = 0; i < quizz.questionnaire[index_quest -
1].propositions.length; i++) {
if (quizz.questionnaire[index_quest - 1].fin) {
if (i + 1 == quizz.questionnaire[index_quest - 1].reponse) {
code_source += "<a href='pageFinQz.html' data-role='button'
onclick='localStorage.localScore=++score'>";
code_source += quizz.questionnaire[index_quest -
1].propositions[i];
code_source += "</a><br/>";
} else {
code_source += "<a href='pageFinQz.html' data-role='button'>";
code_source += quizz.questionnaire[index_quest -
1].propositions[i];
code_source += "</a><br/>";
}
} else if (i + 1 == quizz.questionnaire[index_quest - 1].reponse) {
code_source += "<a href='#' data-role='button'
onclick='mapQuestion(quizz, ++index_quest);
localStorage.localScore=++score; return false' rel='external'>";
code_source += quizz.questionnaire[index_quest - 1].propositions[i];
code_source += "</a><br/>";
} else {
code_source += "<a href='#' data-role='button'
onclick='mapQuestion(quizz, ++index_quest); return false'
rel='external'>";
code_source += quizz.questionnaire[index_quest - 1].propositions[i];
code_source += "</a><br/>";
}
}
And the head of my HTML is :
<meta http-equiv="Content-Type" content="text-html" charset="UTF-8"/>
<link rel="stylesheet" type="text/css"
href="../lib/jqm/jquery.mobile-1.3.0.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="../lib/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../lib/cordova-2.4.0.js"></script>
<script type="text/javascript"
src="../lib/jqm/jquery.mobile-1.3.0.js"></script>
style.css is in the same folder than my HTML and contains exactly :
.ui-btn-inner{
white-space: normal !important;
}
I don't really understand why the css seems to not work since it's pretty
simple, but maybe I missed something obvious.
Thanks in advance for your help.
I'm using Phonegap and JQuery mobile to create an app that uses button
whose content (caption) is fetched via an ajax request and can be pretty
long, so I wanted to have multiline buttons. I searched and found a way to
do so by using the following css :
.ui-btn-inner{
white-space: normal !important;
}
But I can't get it to work.
I have tried to put it between style tags in the head of my page, then
inside the html code of the button itself using style='' . I also tried to
put that piece of code in a css file and link it to the page but it
doesn't work either, even if I put this file in the same folder than my
HTML.
Here is an extract of my JS where I create the button :
for ( var i = 0; i < quizz.questionnaire[index_quest -
1].propositions.length; i++) {
if (quizz.questionnaire[index_quest - 1].fin) {
if (i + 1 == quizz.questionnaire[index_quest - 1].reponse) {
code_source += "<a href='pageFinQz.html' data-role='button'
onclick='localStorage.localScore=++score'>";
code_source += quizz.questionnaire[index_quest -
1].propositions[i];
code_source += "</a><br/>";
} else {
code_source += "<a href='pageFinQz.html' data-role='button'>";
code_source += quizz.questionnaire[index_quest -
1].propositions[i];
code_source += "</a><br/>";
}
} else if (i + 1 == quizz.questionnaire[index_quest - 1].reponse) {
code_source += "<a href='#' data-role='button'
onclick='mapQuestion(quizz, ++index_quest);
localStorage.localScore=++score; return false' rel='external'>";
code_source += quizz.questionnaire[index_quest - 1].propositions[i];
code_source += "</a><br/>";
} else {
code_source += "<a href='#' data-role='button'
onclick='mapQuestion(quizz, ++index_quest); return false'
rel='external'>";
code_source += quizz.questionnaire[index_quest - 1].propositions[i];
code_source += "</a><br/>";
}
}
And the head of my HTML is :
<meta http-equiv="Content-Type" content="text-html" charset="UTF-8"/>
<link rel="stylesheet" type="text/css"
href="../lib/jqm/jquery.mobile-1.3.0.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="../lib/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../lib/cordova-2.4.0.js"></script>
<script type="text/javascript"
src="../lib/jqm/jquery.mobile-1.3.0.js"></script>
style.css is in the same folder than my HTML and contains exactly :
.ui-btn-inner{
white-space: normal !important;
}
I don't really understand why the css seems to not work since it's pretty
simple, but maybe I missed something obvious.
Thanks in advance for your help.
scrapy spider bypass deny my rules
scrapy spider bypass deny my rules
hi im trying to use crawlspider and I created my own deny rules
path_deny_base = [ '.(login)', '.(intro)', '(candidate)', '(referral)',
'(reminder)', #'(/search)',
and my rule is
rules = (Rule (SgmlLinkExtractor(deny = path_deny_base,
allow=('https://careers-cooperhealth.icims.com/jobs/'),restrict_xpaths=('*'))
, callback="parse_items", follow= True),
)
still my spider crawled pages like
https://careers-cooperhealth.icims.com/jobs/22660/registered-nurse-prn/login
where login should not be crawled what is the problem here?
hi im trying to use crawlspider and I created my own deny rules
path_deny_base = [ '.(login)', '.(intro)', '(candidate)', '(referral)',
'(reminder)', #'(/search)',
and my rule is
rules = (Rule (SgmlLinkExtractor(deny = path_deny_base,
allow=('https://careers-cooperhealth.icims.com/jobs/'),restrict_xpaths=('*'))
, callback="parse_items", follow= True),
)
still my spider crawled pages like
https://careers-cooperhealth.icims.com/jobs/22660/registered-nurse-prn/login
where login should not be crawled what is the problem here?
Tuesday, 27 August 2013
How can I give shadow effect to the form in vb.net
How can I give shadow effect to the form in vb.net
I am writing code in vb.net.I have a form and i need to give shadow to the
form. I have searched but cannot get the correct answer. please assist me.
Thanks in advance.
I am writing code in vb.net.I have a form and i need to give shadow to the
form. I have searched but cannot get the correct answer. please assist me.
Thanks in advance.
Using namespaces with JAXB and JSON under Jersey 2.2 JAX-RS
Using namespaces with JAXB and JSON under Jersey 2.2 JAX-RS
I am using xjc to compile an XML schema with namespaces and ANY elements.
I will be including elements from external namespaces as needed and need
to handle the situation where a new version of an element definition is
included, or perhaps a element from another namespace with the same name.
Obviously, the XML version of this is working perfectly and I get the
correct QNAME for all elements on the client side, however, for the JSON I
get an unqualified QNAME with only the element name present. This means I
cannot distinguish between and element called "bob" from one namespace,
versus a different element called "bob" from a second namespace.
I have read all the material I can find, and believe this is what I need
to do on the server side, however, i do not know what I need on the client
side:
@Provider
final static class JsonMoxyConfigurationContextResolver implements
ContextResolver<MoxyJsonConfig> {
@Override
public MoxyJsonConfig getContext(Class<?> objectType) {
final MoxyJsonConfig configuration = new MoxyJsonConfig();
Map<String, String> namespacePrefixMapper = new HashMap<String,
String>(2);
namespacePrefixMapper.put("http://schema.jaxbmoxy.examples.jersey.glassfish.org/2013/08/customer",
"c");
namespacePrefixMapper.put("http://schema.jaxbmoxy.examples.jersey.glassfish.org/2013/08/other",
"o");
configuration.setNamespacePrefixMapper(namespacePrefixMapper);
configuration.setNamespaceSeparator('.');
return configuration;
}
}
The "c" schema is the base schema I have defined, and the "o" schema holds
the element definitions I will incorporate through the ANY. For the
example below I am importing o.stats and o.email from the external
namespace. Below is the JSON being generated on the server side:
{"c.customer": [
{
"id": "3",
"personal-info": {
"name": "Bobby Boogie",
"o.stats": [{
"age": "45",
"height": "160 cm",
"weight": "70 kg"
}]
},
"contact-info": {
"address": {
"city": "My Town",
"street": "123 Any Street",
"country": "CA"
},
"phone-number": [
{
"type": "work",
"value": "613-555-1111"
},
{
"type": "cell",
"value": "613-555-2222"
}
]
}
},
{
"id": "2",
"personal-info": {
"name": "Fred Finkleman",
"o.stats": [{
"age": "55",
"height": "182 cm",
"weight": "86 kg"
}]
},
"contact-info": {
"address": {
"city": "Fredsville",
"street": "1 Happy Street",
"country": "US"
},
"phone-number": [
{
"type": "work",
"value": "613-555-1111"
},
{
"type": "cell",
"value": "613-555-2222"
}
],
"o.email": ["fred@email.com"]
}
},
{
"id": "1",
"personal-info": {
"name": "Tom Dooley",
"o.stats": [{
"age": "45",
"height": "160 cm",
"weight": "70 kg"
}]
},
"contact-info": {
"address": {
"city": "My Town",
"street": "123 Any Street",
"country": "CA"
},
"phone-number": [
{
"type": "work",
"value": "613-555-1111"
},
{
"type": "cell",
"value": "613-555-2222"
}
]
}
}
]}
What configuration code do I need on the client side so i can get this to
function correctly? At the moment I have the following:
@Override
protected void configureClient(ClientConfig clientConfig) {
clientConfig.register(new MoxyXmlFeature());
new
ResourceConfig().property(MarshallerProperties.JSON_NAMESPACE_SEPARATOR,
".");
}
Thank you!
I am using xjc to compile an XML schema with namespaces and ANY elements.
I will be including elements from external namespaces as needed and need
to handle the situation where a new version of an element definition is
included, or perhaps a element from another namespace with the same name.
Obviously, the XML version of this is working perfectly and I get the
correct QNAME for all elements on the client side, however, for the JSON I
get an unqualified QNAME with only the element name present. This means I
cannot distinguish between and element called "bob" from one namespace,
versus a different element called "bob" from a second namespace.
I have read all the material I can find, and believe this is what I need
to do on the server side, however, i do not know what I need on the client
side:
@Provider
final static class JsonMoxyConfigurationContextResolver implements
ContextResolver<MoxyJsonConfig> {
@Override
public MoxyJsonConfig getContext(Class<?> objectType) {
final MoxyJsonConfig configuration = new MoxyJsonConfig();
Map<String, String> namespacePrefixMapper = new HashMap<String,
String>(2);
namespacePrefixMapper.put("http://schema.jaxbmoxy.examples.jersey.glassfish.org/2013/08/customer",
"c");
namespacePrefixMapper.put("http://schema.jaxbmoxy.examples.jersey.glassfish.org/2013/08/other",
"o");
configuration.setNamespacePrefixMapper(namespacePrefixMapper);
configuration.setNamespaceSeparator('.');
return configuration;
}
}
The "c" schema is the base schema I have defined, and the "o" schema holds
the element definitions I will incorporate through the ANY. For the
example below I am importing o.stats and o.email from the external
namespace. Below is the JSON being generated on the server side:
{"c.customer": [
{
"id": "3",
"personal-info": {
"name": "Bobby Boogie",
"o.stats": [{
"age": "45",
"height": "160 cm",
"weight": "70 kg"
}]
},
"contact-info": {
"address": {
"city": "My Town",
"street": "123 Any Street",
"country": "CA"
},
"phone-number": [
{
"type": "work",
"value": "613-555-1111"
},
{
"type": "cell",
"value": "613-555-2222"
}
]
}
},
{
"id": "2",
"personal-info": {
"name": "Fred Finkleman",
"o.stats": [{
"age": "55",
"height": "182 cm",
"weight": "86 kg"
}]
},
"contact-info": {
"address": {
"city": "Fredsville",
"street": "1 Happy Street",
"country": "US"
},
"phone-number": [
{
"type": "work",
"value": "613-555-1111"
},
{
"type": "cell",
"value": "613-555-2222"
}
],
"o.email": ["fred@email.com"]
}
},
{
"id": "1",
"personal-info": {
"name": "Tom Dooley",
"o.stats": [{
"age": "45",
"height": "160 cm",
"weight": "70 kg"
}]
},
"contact-info": {
"address": {
"city": "My Town",
"street": "123 Any Street",
"country": "CA"
},
"phone-number": [
{
"type": "work",
"value": "613-555-1111"
},
{
"type": "cell",
"value": "613-555-2222"
}
]
}
}
]}
What configuration code do I need on the client side so i can get this to
function correctly? At the moment I have the following:
@Override
protected void configureClient(ClientConfig clientConfig) {
clientConfig.register(new MoxyXmlFeature());
new
ResourceConfig().property(MarshallerProperties.JSON_NAMESPACE_SEPARATOR,
".");
}
Thank you!
Is there a way to pass an array to currentWhen in EmberJS?
Is there a way to pass an array to currentWhen in EmberJS?
I'm trying to make a link stay 'active' on multiple routes, such as
/#/users and /#/user.
Any ideas?
I'm trying to make a link stay 'active' on multiple routes, such as
/#/users and /#/user.
Any ideas?
PHP date() function returning incorrect values
PHP date() function returning incorrect values
I have a timestamp of "1377592503467" stored in a variable and when I pass
it to php's date() function, it returns a value of "1935-05-26 03:04:11".
Hopefully I am missing something obvious; below is my code. The timestamp
represents 2013-08-27 15:57:45 but that's not what is being returned.
$date = "1377592503467";
$formattedDate = date("Y-m-d h:i:s", $date);
Thank you.
I have a timestamp of "1377592503467" stored in a variable and when I pass
it to php's date() function, it returns a value of "1935-05-26 03:04:11".
Hopefully I am missing something obvious; below is my code. The timestamp
represents 2013-08-27 15:57:45 but that's not what is being returned.
$date = "1377592503467";
$formattedDate = date("Y-m-d h:i:s", $date);
Thank you.
is the facebook developer subscription free
is the facebook developer subscription free
We are a company based in Europe and we need some information about the
subscription to the facebook developer console. - Is the subscription free
for companies? - The facebook developer account will be activated
immediately after the subscription? or there is a delay for companies?
Thanks, Best regards
We are a company based in Europe and we need some information about the
subscription to the facebook developer console. - Is the subscription free
for companies? - The facebook developer account will be activated
immediately after the subscription? or there is a delay for companies?
Thanks, Best regards
Win7 + SysPrep + CloneZilla = lost settings
Win7 + SysPrep + CloneZilla = lost settings
I've just cloned a PC (Win7 + SysPrep + CloneZilla) and after starting up
the new clone, Win7 wants to be reactivated again and the video driver
seems to be missing (as in the aero effect has disappeared from the new
clone) and the internet connection settings seem to be missing too.
All those were set in the master before running SysPrep.
Why have these settings been lost?
The master PC was had windows 7 activated using a volume license key, and
the clone pc is the same make and model as the master computer.
I've just cloned a PC (Win7 + SysPrep + CloneZilla) and after starting up
the new clone, Win7 wants to be reactivated again and the video driver
seems to be missing (as in the aero effect has disappeared from the new
clone) and the internet connection settings seem to be missing too.
All those were set in the master before running SysPrep.
Why have these settings been lost?
The master PC was had windows 7 activated using a volume license key, and
the clone pc is the same make and model as the master computer.
Azure host in virtual network cannot access internet when using my own DNS
Azure host in virtual network cannot access internet when using my own DNS
I configured an Active directory domain controller on an azure virtual
network and as soon as I change the network DNS to that of my AD box, I
have internet connectivity problems from the VM.
I have read various articles on this setup and it seems legit.
Any ideas?
regards
Paul
I configured an Active directory domain controller on an azure virtual
network and as soon as I change the network DNS to that of my AD box, I
have internet connectivity problems from the VM.
I have read various articles on this setup and it seems legit.
Any ideas?
regards
Paul
Monday, 26 August 2013
Hello guys, I need a little help here
Hello guys, I need a little help here
Hello guys I'm currently working on a calculator function using JavaScript
and I wonder why this one doesn't get the values whenever I click a number
or an operator.
I just found this code snippet on the internet and I tried it on mine and
i don't know why it didn't work.
You can try and run my code. Here is my HTML:
<div id="calculator">
<div class="top">
<span class="clear">C</span>
<div class="screen"></div>
</div>
<div class="keys">
<span>7</span>
<span>8</span>
<span>9</span>
<span class="operator">+</span>
<span>4</span>
<span>5</span>
<span>6</span>
<span class="operator">-</span>
<span>1</span>
<span>2</span>
<span>3</span>
<span class="operator">÷</span>
<span>0</span>
<span>.</span>
<span class="eval">=</span>
<span class="operator">x</span>
</div></div>
Here is my JavaScript:
var keys = document.querySelectorAll('#calculator span');
var operators = ['+', '-', 'x', '÷'];
var decimalAdded = false;
for(var i = 0; i < keys.length; i++) {
keys[i].onclick = function(e) {
var input = document.querySelector('.screen');
var inputVal = input.innerHTML;
var btnVal = this.innerHTML;
if(btnVal == 'C') {
input.innerHTML = '';
decimalAdded = false;
}
else if(btnVal == '=') {
var equation = inputVal;
var lastChar = equation[equation.length - 1];
equation = equation.replace(/x/g, '*').replace(/÷/g, '/');
if(operators.indexOf(lastChar) > -1 || lastChar == '.')
equation = equation.replace(/.$/, '');
if(equation)
input.innerHTML = eval(equation);
decimalAdded = false;
}
else if(operators.indexOf(btnVal) > -1) {
var lastChar = inputVal[inputVal.length - 1];
if(inputVal != '' && operators.indexOf(lastChar) == -1)
input.innerHTML += btnVal;
else if(inputVal == '' && btnVal == '-')
input.innerHTML += btnVal;
if(operators.indexOf(lastChar) > -1 && inputVal.length > 1) {
input.innerHTML = inputVal.replace(/.$/, btnVal);
}
decimalAdded =false;
}
else if(btnVal == '.') {
if(!decimalAdded) {
input.innerHTML += btnVal;
decimalAdded = true;
}
}
else {
input.innerHTML += btnVal;
}
e.preventDefault();
}
}
I hope you can help me out with this one guys thank you so much :)
Hello guys I'm currently working on a calculator function using JavaScript
and I wonder why this one doesn't get the values whenever I click a number
or an operator.
I just found this code snippet on the internet and I tried it on mine and
i don't know why it didn't work.
You can try and run my code. Here is my HTML:
<div id="calculator">
<div class="top">
<span class="clear">C</span>
<div class="screen"></div>
</div>
<div class="keys">
<span>7</span>
<span>8</span>
<span>9</span>
<span class="operator">+</span>
<span>4</span>
<span>5</span>
<span>6</span>
<span class="operator">-</span>
<span>1</span>
<span>2</span>
<span>3</span>
<span class="operator">÷</span>
<span>0</span>
<span>.</span>
<span class="eval">=</span>
<span class="operator">x</span>
</div></div>
Here is my JavaScript:
var keys = document.querySelectorAll('#calculator span');
var operators = ['+', '-', 'x', '÷'];
var decimalAdded = false;
for(var i = 0; i < keys.length; i++) {
keys[i].onclick = function(e) {
var input = document.querySelector('.screen');
var inputVal = input.innerHTML;
var btnVal = this.innerHTML;
if(btnVal == 'C') {
input.innerHTML = '';
decimalAdded = false;
}
else if(btnVal == '=') {
var equation = inputVal;
var lastChar = equation[equation.length - 1];
equation = equation.replace(/x/g, '*').replace(/÷/g, '/');
if(operators.indexOf(lastChar) > -1 || lastChar == '.')
equation = equation.replace(/.$/, '');
if(equation)
input.innerHTML = eval(equation);
decimalAdded = false;
}
else if(operators.indexOf(btnVal) > -1) {
var lastChar = inputVal[inputVal.length - 1];
if(inputVal != '' && operators.indexOf(lastChar) == -1)
input.innerHTML += btnVal;
else if(inputVal == '' && btnVal == '-')
input.innerHTML += btnVal;
if(operators.indexOf(lastChar) > -1 && inputVal.length > 1) {
input.innerHTML = inputVal.replace(/.$/, btnVal);
}
decimalAdded =false;
}
else if(btnVal == '.') {
if(!decimalAdded) {
input.innerHTML += btnVal;
decimalAdded = true;
}
}
else {
input.innerHTML += btnVal;
}
e.preventDefault();
}
}
I hope you can help me out with this one guys thank you so much :)
Using sql query to print the result in a serialized format
Using sql query to print the result in a serialized format
I have a database table like this:
C1 C2 C3
---------------------
81 1 10
81 2 20
81 3 30
82 1 40
82 2 50
82 3 60
Note that it has no primary key.
I want to run a query which prints C1 and the various occurrences of C3
values with it. It basically gives me the output in a serialised format. I
mean something like this :
81 10 20 30
82 40 50 60
The one approach I can think of is using a rownum but am not sure if
that;s the way to go about it. Is there a better way for doing this ?
I have a database table like this:
C1 C2 C3
---------------------
81 1 10
81 2 20
81 3 30
82 1 40
82 2 50
82 3 60
Note that it has no primary key.
I want to run a query which prints C1 and the various occurrences of C3
values with it. It basically gives me the output in a serialised format. I
mean something like this :
81 10 20 30
82 40 50 60
The one approach I can think of is using a rownum but am not sure if
that;s the way to go about it. Is there a better way for doing this ?
Parse error: syntax error, unexpected $end when loading any page where this portion of the script is called
Parse error: syntax error, unexpected $end when loading any page where
this portion of the script is called
This is part of an xml file that gets parsed modifying sections of the
page as it loads. The modified version is cached and displayed by the
virtual engine so the actual template files don't get modified.
<file name="catalog/view/theme/*/template/product/product.tpl">
<operation error="skip">
<search position="before"><![CDATA[
<?php if ($price) ?>
]]></search>
<add trim="true"><![CDATA[
<?php if ($call_price < 1) ?>
]]></add>
</operation >
<operation error="skip">
<search position="before" index="1"><![CDATA[
<?php if ($options) { ?>
]]></search>
<add trim="true"><![CDATA[
<?php } else { ?>
<?php if ($call_price) { ?>
<div class="description" style="border-top:none; margin-top:0px;">
<?php echo $text_call_price; ?>
</div>
<?php } ?>
<?php } ?>
]]></add>
</operation>
<operation error="skip">
<search position="replace"><![CDATA[
<input type="button" value="<?php echo $button_cart; ?>"
id="button-cart" class="button" />
]]></search>
<add trim="true"><![CDATA[
<?php if ($disable_button < 1) { ?>
<input type="button" value="<?php echo $button_cart; ?>"
id="button-cart" class="button" />
<?php } else { ?>
<input type="button" value="<?php echo $button_cart; ?>"
id="button-cart" class="button" style="background-image:none;
background-color:#CCC;" disabled="disabled" />
<?php } ?>
]]></add>
</operation>
</file>
this portion of the script is called
This is part of an xml file that gets parsed modifying sections of the
page as it loads. The modified version is cached and displayed by the
virtual engine so the actual template files don't get modified.
<file name="catalog/view/theme/*/template/product/product.tpl">
<operation error="skip">
<search position="before"><![CDATA[
<?php if ($price) ?>
]]></search>
<add trim="true"><![CDATA[
<?php if ($call_price < 1) ?>
]]></add>
</operation >
<operation error="skip">
<search position="before" index="1"><![CDATA[
<?php if ($options) { ?>
]]></search>
<add trim="true"><![CDATA[
<?php } else { ?>
<?php if ($call_price) { ?>
<div class="description" style="border-top:none; margin-top:0px;">
<?php echo $text_call_price; ?>
</div>
<?php } ?>
<?php } ?>
]]></add>
</operation>
<operation error="skip">
<search position="replace"><![CDATA[
<input type="button" value="<?php echo $button_cart; ?>"
id="button-cart" class="button" />
]]></search>
<add trim="true"><![CDATA[
<?php if ($disable_button < 1) { ?>
<input type="button" value="<?php echo $button_cart; ?>"
id="button-cart" class="button" />
<?php } else { ?>
<input type="button" value="<?php echo $button_cart; ?>"
id="button-cart" class="button" style="background-image:none;
background-color:#CCC;" disabled="disabled" />
<?php } ?>
]]></add>
</operation>
</file>
Jquery - How can I check if all of the checkboxes are checked?
Jquery - How can I check if all of the checkboxes are checked?
pFor some reason my code doesn't work?! I need to check checkboxes, if all
are unchecked, then enable hidden field and send value to db, so I can
identify that checkboxes were unchecked./p pstrongQuestion 1:/strong Why
isn't my jquery code working?/p pstrongQuestion 2:/strong I need to record
checked or unchecked values to DB. My plan is to check if none selected in
php. Is this a good practice?/p pstrongHTML/strong/p precodelt;tr
class=more_infogt; lt;th valign=topgt;Other options:lt;/thgt; {foreach
from=$HTML_cOPTIONS key=dbname item=optname} {if !
empty($CARINFO[car].{$dbname})} lt;tdgt;lt;input type=checkbox
id=forced_checkbox name=c_options[] value={$dbname} checked/gt; {$optname}
lt;/brgt;lt;/tdgt; {else} lt;tdgt;lt;input type=checkbox
id=forced_checkbox name=c_options[] value={$dbname}/gt; {$optname}
lt;/brgt;lt;/tdgt; {/if} {/foreach} lt;input type=hidden
id=forceSendCheckBox name=c_options[] value=nocheckboxes/gt; lt;/trgt;
/code/pre pstrongJquery/strong/p
precode$('#check').bind('click',function() { if
($('#forced_checkbox').filter(':not(:checked)').length == 0) {
console.log('at least one checked');
$(#forceSendCheckBox).prop('disabled',true);//do not send this field to DB
} else { console.log('nothing checked');
$(#forceSendCheckBox).prop('disabled',false);//send empty checkboxes } });
/code/pre
pFor some reason my code doesn't work?! I need to check checkboxes, if all
are unchecked, then enable hidden field and send value to db, so I can
identify that checkboxes were unchecked./p pstrongQuestion 1:/strong Why
isn't my jquery code working?/p pstrongQuestion 2:/strong I need to record
checked or unchecked values to DB. My plan is to check if none selected in
php. Is this a good practice?/p pstrongHTML/strong/p precodelt;tr
class=more_infogt; lt;th valign=topgt;Other options:lt;/thgt; {foreach
from=$HTML_cOPTIONS key=dbname item=optname} {if !
empty($CARINFO[car].{$dbname})} lt;tdgt;lt;input type=checkbox
id=forced_checkbox name=c_options[] value={$dbname} checked/gt; {$optname}
lt;/brgt;lt;/tdgt; {else} lt;tdgt;lt;input type=checkbox
id=forced_checkbox name=c_options[] value={$dbname}/gt; {$optname}
lt;/brgt;lt;/tdgt; {/if} {/foreach} lt;input type=hidden
id=forceSendCheckBox name=c_options[] value=nocheckboxes/gt; lt;/trgt;
/code/pre pstrongJquery/strong/p
precode$('#check').bind('click',function() { if
($('#forced_checkbox').filter(':not(:checked)').length == 0) {
console.log('at least one checked');
$(#forceSendCheckBox).prop('disabled',true);//do not send this field to DB
} else { console.log('nothing checked');
$(#forceSendCheckBox).prop('disabled',false);//send empty checkboxes } });
/code/pre
Unable to parse HTML using JSoup
Unable to parse HTML using JSoup
Currently following this tutorial Android XML Adventure – Parsing HTML
using JSoup getting Error message in my TextView.
I have copy and paste jsoup-1.7.2.jar into libs, set <uses-permission
android:name="android.permission.INTERNET"/> in AndroidManifest.xml and
set TextView android:id="@+id/tv" . And this is what my Project Explorer
looks like.
Here is the JsoupActivity.java
package com.jsoupstudyactivity;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.view.Menu;
public class JSoupActivity extends Activity {
// blog url
static final String BLOG_URL = "http://xjaphx.wordpress.com/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// process
try {
((TextView)findViewById(R.id.tv)).setText(getBlogStats());
} catch (Exception ex) {
((TextView)findViewById(R.id.tv)).setText("Error");
}
}
protected String getBlogStats() throws Exception {
String result = "";
// get html document structure
Document document = Jsoup.connect(BLOG_URL).get();
// selector query
Elements nodeBlogStats = document.select("div#blog-stats ul li");
// check results
if(nodeBlogStats.size() > 0) {
// get value
result = nodeBlogStats.get(0).text();
}
// return
return result;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.jsoup, menu);
return true;
}
}
Currently following this tutorial Android XML Adventure – Parsing HTML
using JSoup getting Error message in my TextView.
I have copy and paste jsoup-1.7.2.jar into libs, set <uses-permission
android:name="android.permission.INTERNET"/> in AndroidManifest.xml and
set TextView android:id="@+id/tv" . And this is what my Project Explorer
looks like.
Here is the JsoupActivity.java
package com.jsoupstudyactivity;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.view.Menu;
public class JSoupActivity extends Activity {
// blog url
static final String BLOG_URL = "http://xjaphx.wordpress.com/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// process
try {
((TextView)findViewById(R.id.tv)).setText(getBlogStats());
} catch (Exception ex) {
((TextView)findViewById(R.id.tv)).setText("Error");
}
}
protected String getBlogStats() throws Exception {
String result = "";
// get html document structure
Document document = Jsoup.connect(BLOG_URL).get();
// selector query
Elements nodeBlogStats = document.select("div#blog-stats ul li");
// check results
if(nodeBlogStats.size() > 0) {
// get value
result = nodeBlogStats.get(0).text();
}
// return
return result;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.jsoup, menu);
return true;
}
}
Adding Drupal Field Collection element to a custom form
Adding Drupal Field Collection element to a custom form
I'd like to add a Field Collection Item to my custom form. My form is a
custom event registration (will save data to Event Registration node), and
the field collection is available in Event Registration Content type. I
tried many codes and tries but none of them works.
module_load_include('inc', 'field_collection', 'field_collection.pages');
$field_collection_item = entity_create('field_collection_item',
array('field_name' => 'field_participant'));
$entity_form = field_collection_item_form($form, $form_state,
$field_collection_item);
$form['participant'] = $entity_form;
This loads the field collection item to my form, but I can't add another
Field collection item and the form other elements (company, phone, etc.)
is duplicated. I found another line that maybe should be add:
$field_collection_item->setHostEntity('node', $node);
but in that moment I haven't $node and I'm not sure it has to be.
I'd like to add a Field Collection Item to my custom form. My form is a
custom event registration (will save data to Event Registration node), and
the field collection is available in Event Registration Content type. I
tried many codes and tries but none of them works.
module_load_include('inc', 'field_collection', 'field_collection.pages');
$field_collection_item = entity_create('field_collection_item',
array('field_name' => 'field_participant'));
$entity_form = field_collection_item_form($form, $form_state,
$field_collection_item);
$form['participant'] = $entity_form;
This loads the field collection item to my form, but I can't add another
Field collection item and the form other elements (company, phone, etc.)
is duplicated. I found another line that maybe should be add:
$field_collection_item->setHostEntity('node', $node);
but in that moment I haven't $node and I'm not sure it has to be.
Using dijit.form.DateTextBox Not able to retain proper Time value
Using dijit.form.DateTextBox Not able to retain proper Time value
I am using dijit.form.DateTextBox to update my date field.
<form:input id="date_id" name="date_field" path="createDate"
dojoType="dijit.form.DateTextBox"
disabled="false"
constraints="{datePattern:'dd/MM/yyyy
hh:mm:ss.SS'}"
invalidMessage="invalid"
promptMessage="invalid"
lang="en-us" required="true"/>
now, suppose If my 'createDate' value is '05/01/2012 21:10:17.287', but it
is displaying as '05/01/2012 12:00:00.00' in date text box. Due to which,
while editing this field, I'm not able to keep it as it was.
Is there anyway I can retain that time part '21:10:17.287'.
Kindly suggest.
I am using dijit.form.DateTextBox to update my date field.
<form:input id="date_id" name="date_field" path="createDate"
dojoType="dijit.form.DateTextBox"
disabled="false"
constraints="{datePattern:'dd/MM/yyyy
hh:mm:ss.SS'}"
invalidMessage="invalid"
promptMessage="invalid"
lang="en-us" required="true"/>
now, suppose If my 'createDate' value is '05/01/2012 21:10:17.287', but it
is displaying as '05/01/2012 12:00:00.00' in date text box. Due to which,
while editing this field, I'm not able to keep it as it was.
Is there anyway I can retain that time part '21:10:17.287'.
Kindly suggest.
pseudo random integer number c++ perfect mapping
pseudo random integer number c++ perfect mapping
I looked for a good method to generate an integer inside a range of values.
I think using modulo is not a good method because the values are not
perfectly mapped in the range.
So I map the pseudo random generated number in the range by a double using
divisions.
What do you think about this method?
How would you improve it? (I used the Qt functions but you can easily
replace it by the std functions)
quint8 randquint8(quint8 low = 0, quint8 high = 0)
{
if (low == 0 && high == 0)
{
high = 0xff;
if (RAND_MAX > high)
{
return (qrand() & high);
}
}
else if (low > high)
{
qSwap(low, high);
}
const quint8 numberOfBits = bitCount(RAND_MAX);
quint8 myRand = 0;
int i = qCeil(8.0f / numberOfBits);
while (i--)
{
myRand += qrand();
if (i)
{
myRand <<= numberOfBits;
}
}
if (myRand == 0xff)
{
return high;
}
double factor = (double)0xff / (double)(high - low + 1);
double tmpRand = low + ((double)myRand / factor);
quint32 finalRand = qFloor(tmpRand);
return finalRand;
}
I looked for a good method to generate an integer inside a range of values.
I think using modulo is not a good method because the values are not
perfectly mapped in the range.
So I map the pseudo random generated number in the range by a double using
divisions.
What do you think about this method?
How would you improve it? (I used the Qt functions but you can easily
replace it by the std functions)
quint8 randquint8(quint8 low = 0, quint8 high = 0)
{
if (low == 0 && high == 0)
{
high = 0xff;
if (RAND_MAX > high)
{
return (qrand() & high);
}
}
else if (low > high)
{
qSwap(low, high);
}
const quint8 numberOfBits = bitCount(RAND_MAX);
quint8 myRand = 0;
int i = qCeil(8.0f / numberOfBits);
while (i--)
{
myRand += qrand();
if (i)
{
myRand <<= numberOfBits;
}
}
if (myRand == 0xff)
{
return high;
}
double factor = (double)0xff / (double)(high - low + 1);
double tmpRand = low + ((double)myRand / factor);
quint32 finalRand = qFloor(tmpRand);
return finalRand;
}
Sunday, 25 August 2013
Official Spring Abbreviations
Official Spring Abbreviations
May I know if there is an official abbreviations for Spring commonly use
terms/annotation?
For example
@Component - ExampleComp
@Service - ExampleSvc
@Respository - ExampleRes
I work for a very anal organization that requires justification for all
kinds of abbreviations.
An abbreviation (from Latin brevis, meaning short) is a shortened form of
a word or phrase. Usually, but not always, it consists of a letter or
group of letters taken from the word or phrase. For example, the word
abbreviation can itself be represented by the abbreviation abbr., abbrv.
or abbrev.
May I know if there is an official abbreviations for Spring commonly use
terms/annotation?
For example
@Component - ExampleComp
@Service - ExampleSvc
@Respository - ExampleRes
I work for a very anal organization that requires justification for all
kinds of abbreviations.
An abbreviation (from Latin brevis, meaning short) is a shortened form of
a word or phrase. Usually, but not always, it consists of a letter or
group of letters taken from the word or phrase. For example, the word
abbreviation can itself be represented by the abbreviation abbr., abbrv.
or abbrev.
[ Politics ] Open Question : Should the name Trayvon Martin and the name of any person ended by a gun be stricken from any and all records?
[ Politics ] Open Question : Should the name Trayvon Martin and the name
of any person ended by a gun be stricken from any and all records?
Making people ended by guns into un-persons where it becomes a crime to
even mention their name punishable under reeducation/prison/death is the
only way to protect our freedom of the Second Amendment. FACT.
of any person ended by a gun be stricken from any and all records?
Making people ended by guns into un-persons where it becomes a crime to
even mention their name punishable under reeducation/prison/death is the
only way to protect our freedom of the Second Amendment. FACT.
[ Baby Names ] Open Question : What do you think of Czar as a name for a baby boy?
[ Baby Names ] Open Question : What do you think of Czar as a name for a
baby boy?
Daddy favors the name... im not so sure lol
baby boy?
Daddy favors the name... im not so sure lol
Thrift 0.9 PHP server missing Processor
Thrift 0.9 PHP server missing Processor
I'm writing an application that communicates by Thrift. I'm using Thrift
0.9.0 (installed via homebrew on OSX). I have a working Java server and
client, but I'm struggling to write a PHP server, as the *Processor class
isn't being generated.
The PHP documentation for Thrift is essentially absent, but I'm expecting
the *Processor class to be generated because:
The current (21c0a850) PhpServer.php in the Thrift tutorial references a
CalculatorProcessor class.
Generating the Java code for the tutorial generates a Calculator.Processor
class
When I generate the PHP code from the tutorial.thrift file (thrift -r
--gen php:namespace tutorial.thrift), however, the resulting
Calculator.php doesn't contain a CalculatorProcessor class.
Am I missing something?
I'm writing an application that communicates by Thrift. I'm using Thrift
0.9.0 (installed via homebrew on OSX). I have a working Java server and
client, but I'm struggling to write a PHP server, as the *Processor class
isn't being generated.
The PHP documentation for Thrift is essentially absent, but I'm expecting
the *Processor class to be generated because:
The current (21c0a850) PhpServer.php in the Thrift tutorial references a
CalculatorProcessor class.
Generating the Java code for the tutorial generates a Calculator.Processor
class
When I generate the PHP code from the tutorial.thrift file (thrift -r
--gen php:namespace tutorial.thrift), however, the resulting
Calculator.php doesn't contain a CalculatorProcessor class.
Am I missing something?
C++ running error in my class
C++ running error in my class
I have tried to make my own list for C++. I have this Class:
template <class T>
class List
{
private:
T *value, *valueHelper;
int valueSize;
public:
int size;
List()
{
valueSize = 2;
value = (T*)malloc(sizeof(T) * valueSize);
size = 0;
}
void Add(T val)
{
size++;
if (size > valueSize)
{
valueSize *= 2;
valueHelper = (T*)malloc(sizeof(T) * valueSize);
memcpy(valueHelper, value, sizeof(T) * (valueSize / 2));
free(value);
value = valueHelper;;
}
value[size - 1] = val;
}
T operator[](int P)
{
return value[P];
}
};
When I try to use it in the main it works fine to Int. Buy to Struct it is
doing problems:
struct Material
{
string materialName;
int faceNum;
int meshNum;
Material(): materialName(""), faceNum(0), meshNum(0){};
};
void main()
{
List <Material> myList = List<Material>();
myList.Add(Material());
}
I got running error in the class on the line:
value[size - 1] = val;
Why?
I have tried to make my own list for C++. I have this Class:
template <class T>
class List
{
private:
T *value, *valueHelper;
int valueSize;
public:
int size;
List()
{
valueSize = 2;
value = (T*)malloc(sizeof(T) * valueSize);
size = 0;
}
void Add(T val)
{
size++;
if (size > valueSize)
{
valueSize *= 2;
valueHelper = (T*)malloc(sizeof(T) * valueSize);
memcpy(valueHelper, value, sizeof(T) * (valueSize / 2));
free(value);
value = valueHelper;;
}
value[size - 1] = val;
}
T operator[](int P)
{
return value[P];
}
};
When I try to use it in the main it works fine to Int. Buy to Struct it is
doing problems:
struct Material
{
string materialName;
int faceNum;
int meshNum;
Material(): materialName(""), faceNum(0), meshNum(0){};
};
void main()
{
List <Material> myList = List<Material>();
myList.Add(Material());
}
I got running error in the class on the line:
value[size - 1] = val;
Why?
Saturday, 24 August 2013
K2 for Joomla 2.5 - How to display Items inside of SubCategories
K2 for Joomla 2.5 - How to display Items inside of SubCategories
I recently started learning K2 for Joomla and I am really inexperienced
with PHP.
Currently, this is how K2 works.
https://docs.google.com/document/d/19OQpyZxp7v7uAiGFatOksP9JuwvHUPgNrU_Pv5DJNZA/edit?usp=sharing
This is how I would like K2 to work:
(See Above Link)
Here is a pastebin of the K2 code: (See Above Link)
This was my failed code attempt. :-( (See Above Link)
Can somebody help me achieve what I'm trying to pull off?
Thanks. :-)
I recently started learning K2 for Joomla and I am really inexperienced
with PHP.
Currently, this is how K2 works.
https://docs.google.com/document/d/19OQpyZxp7v7uAiGFatOksP9JuwvHUPgNrU_Pv5DJNZA/edit?usp=sharing
This is how I would like K2 to work:
(See Above Link)
Here is a pastebin of the K2 code: (See Above Link)
This was my failed code attempt. :-( (See Above Link)
Can somebody help me achieve what I'm trying to pull off?
Thanks. :-)
AngularJS & JQuery Plugin issue
AngularJS & JQuery Plugin issue
I've created this responsive tabs to accordion plunker -
http://plnkr.co/edit/plqTygiscmc2j9rB9bW0?p=preview.
The responsiveness happens as it should (like this:
http://webtrendset.com/demo/easy-responsive-tabs/Index.html), however the
tabs functionality isn't working which is the whole idea.
Just wondering what I've missed? Thank you.
I've created this responsive tabs to accordion plunker -
http://plnkr.co/edit/plqTygiscmc2j9rB9bW0?p=preview.
The responsiveness happens as it should (like this:
http://webtrendset.com/demo/easy-responsive-tabs/Index.html), however the
tabs functionality isn't working which is the whole idea.
Just wondering what I've missed? Thank you.
ExtJs: autoCreateViewport not working?
ExtJs: autoCreateViewport not working?
I'm following the Sencha guide exactly, but it seems that
autoCreateViewport isn't working. Nothing renders, launch isn't called,
and I have no warning or errors.
app.js
Ext.application({
name: 'PT',
autoCreateViewport: true,
launch: function() {
console.log('launched'); // never called
}
});
extjs/view/Viewport.js
Ext.define('PT.view.Viewport', {
extend: 'Ext.container.ViewPort',
layout: 'fit',
items: [ { title: 'Hello World', html: 'some text..'} ],
initComponent: function() {
this.callParent();
}
});
Please help. I'm so close to going back to Dojo.
I'm following the Sencha guide exactly, but it seems that
autoCreateViewport isn't working. Nothing renders, launch isn't called,
and I have no warning or errors.
app.js
Ext.application({
name: 'PT',
autoCreateViewport: true,
launch: function() {
console.log('launched'); // never called
}
});
extjs/view/Viewport.js
Ext.define('PT.view.Viewport', {
extend: 'Ext.container.ViewPort',
layout: 'fit',
items: [ { title: 'Hello World', html: 'some text..'} ],
initComponent: function() {
this.callParent();
}
});
Please help. I'm so close to going back to Dojo.
Word Openxml: how to get a text box the right size
Word Openxml: how to get a text box the right size
I'm using PHP to generate docx documents from a database. The generated
document contains column charts which have labels attached (i.e. user
shapes containing textboxes). In an attempt to get the textboxes to
accommodate and display all of the text (i.e. it shouldn't be necessary
for the user to resize a textbox to see all the text) my code calculates
how many characters will fit into 3cm, adds linefeeds to the string as
required and tells me how many lines of text are needed. I have:
<a:xfrm xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:off x="1638276" y="1676399"/>
<a:ext cx="1257325" cy="'.(252000 * $labelLeftLines).'"/>
</a:xfrm>
which I believe should give me a text box around 3.5cm wide (extra .5 for
the internal padding) and a height of .7cm multiplied by whatever is the
value of $labelLeftLines. However, the text box always turns up as 3.cm
wide by .86cm high, which only ever displays one line of text. If I add in
'autofit':
<a:bodyPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
vertOverflow="clip" wrap="square" rtlCol="0">
<a:spAutoFit/>
</a:bodyPr>
the generated file looks just the same, though, when I right click on the
textbox to inspect the properties, 'autofit' is indeed applied. I have to
uncheck it and recheck it to make it affect the textbox. Any openXML gurus
out there?
I'm using PHP to generate docx documents from a database. The generated
document contains column charts which have labels attached (i.e. user
shapes containing textboxes). In an attempt to get the textboxes to
accommodate and display all of the text (i.e. it shouldn't be necessary
for the user to resize a textbox to see all the text) my code calculates
how many characters will fit into 3cm, adds linefeeds to the string as
required and tells me how many lines of text are needed. I have:
<a:xfrm xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:off x="1638276" y="1676399"/>
<a:ext cx="1257325" cy="'.(252000 * $labelLeftLines).'"/>
</a:xfrm>
which I believe should give me a text box around 3.5cm wide (extra .5 for
the internal padding) and a height of .7cm multiplied by whatever is the
value of $labelLeftLines. However, the text box always turns up as 3.cm
wide by .86cm high, which only ever displays one line of text. If I add in
'autofit':
<a:bodyPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
vertOverflow="clip" wrap="square" rtlCol="0">
<a:spAutoFit/>
</a:bodyPr>
the generated file looks just the same, though, when I right click on the
textbox to inspect the properties, 'autofit' is indeed applied. I have to
uncheck it and recheck it to make it affect the textbox. Any openXML gurus
out there?
Euler character of a numerically trivial divisor
Euler character of a numerically trivial divisor
Let $X$ be a projective variety and $D$ be a Cartier divisor on $X$.
Suppose $D$ is ${numerically}$ trivial, then is the Euler character
$\chi(X,D)= \chi(X, \mathcal{O}_X)$?
Here numerically trivial means the intersection number of the divisor $D$
with any curve is zero.
I saw somebody mentioned this result followed from Riemann-Roch, but did
not see the reason.
Let $X$ be a projective variety and $D$ be a Cartier divisor on $X$.
Suppose $D$ is ${numerically}$ trivial, then is the Euler character
$\chi(X,D)= \chi(X, \mathcal{O}_X)$?
Here numerically trivial means the intersection number of the divisor $D$
with any curve is zero.
I saw somebody mentioned this result followed from Riemann-Roch, but did
not see the reason.
Java Serialization for Extended Class
Java Serialization for Extended Class
In java serialization class Mp3player extends ElectronicDevice implements
Serializable in this code super class electronicdevice is not implemented
serializable. here super class is also getting serialized. my
understanding is super class is also gets serialized due to extends.let me
know my understanding is correct or not.
import java.io.*;
class ElectronicDevice { ElectronicDevice()
{ System.out.print("ed ");
}}
class Mp3player extends ElectronicDevice implements Serializable {
Mp3player() { System.out.print("mp "); }
}
class MiniPlayer extends Mp3player {
MiniPlayer() { System.out.print("mini "); }
public static void main(String[] args) {
MiniPlayer m = new MiniPlayer();
try {
FileOutputStream fos = new FileOutputStream("dev.txt");
Obje`enter code here`ctOutputStream os = new ObjectOutputStream(fos);
os.writeObject(m); os.close();
FileInputStream fis = new FileInputStream("dev.txt");
ObjectInputStream is = new ObjectInputStream(fis);
MiniPlayer m2 = (MiniPlayer) is.readObject();
is.close();
System.out.println();
} catch (Exception x) { System.out.print("x "); }
} }
In java serialization class Mp3player extends ElectronicDevice implements
Serializable in this code super class electronicdevice is not implemented
serializable. here super class is also getting serialized. my
understanding is super class is also gets serialized due to extends.let me
know my understanding is correct or not.
import java.io.*;
class ElectronicDevice { ElectronicDevice()
{ System.out.print("ed ");
}}
class Mp3player extends ElectronicDevice implements Serializable {
Mp3player() { System.out.print("mp "); }
}
class MiniPlayer extends Mp3player {
MiniPlayer() { System.out.print("mini "); }
public static void main(String[] args) {
MiniPlayer m = new MiniPlayer();
try {
FileOutputStream fos = new FileOutputStream("dev.txt");
Obje`enter code here`ctOutputStream os = new ObjectOutputStream(fos);
os.writeObject(m); os.close();
FileInputStream fis = new FileInputStream("dev.txt");
ObjectInputStream is = new ObjectInputStream(fis);
MiniPlayer m2 = (MiniPlayer) is.readObject();
is.close();
System.out.println();
} catch (Exception x) { System.out.print("x "); }
} }
When I changed my parent layout from linear to frame or relative it gives me error
When I changed my parent layout from linear to frame or relative it gives
me error
On my previous xml code my app was running correctly:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="82dp" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/button1"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Send" />
</RelativeLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="380dp" />
</LinearLayout>
Now when I changed my xml ,and now when I make relative layout or frame
layout as a parent my app gives me error "unfortunately it is stopped", My
new xml is:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="86dp"
android:layout_gravity="bottom" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Send" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/button1"
android:ems="10" />
</RelativeLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="372dp" >
</ListView>
</FrameLayout>
Logcat:
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809)
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:998)
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.BackStackRecord.run(BackStackRecord.java:622) 08-24
19:08:24.050: E/AndroidRuntime(674): at
android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1330)
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.Activity.performStart(Activity.java:4474) 08-24 19:08:24.050:
E/AndroidRuntime(674): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928)
08-24 19:08:24.050: E/AndroidRuntime(674): ... 11 more
me error
On my previous xml code my app was running correctly:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="82dp" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/button1"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Send" />
</RelativeLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="380dp" />
</LinearLayout>
Now when I changed my xml ,and now when I make relative layout or frame
layout as a parent my app gives me error "unfortunately it is stopped", My
new xml is:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="86dp"
android:layout_gravity="bottom" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Send" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/button1"
android:ems="10" />
</RelativeLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="372dp" >
</ListView>
</FrameLayout>
Logcat:
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:809)
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:998)
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.BackStackRecord.run(BackStackRecord.java:622) 08-24
19:08:24.050: E/AndroidRuntime(674): at
android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1330)
08-24 19:08:24.050: E/AndroidRuntime(674): at
android.app.Activity.performStart(Activity.java:4474) 08-24 19:08:24.050:
E/AndroidRuntime(674): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928)
08-24 19:08:24.050: E/AndroidRuntime(674): ... 11 more
Friday, 23 August 2013
Windows security is asking for UserName and password when connecting to RemoteDebugger
Windows security is asking for UserName and password when connecting to
RemoteDebugger
I have set up a Remote debugger on another PC and when I try to connect to
it using Visual Studio it asks me for Credentials, I have try'ed using
Home Sharing Usernames and Passwords but nothing works. Also the Remote PC
I am trying to connect to I have not set any password for it.
This is the window asking me for credentials:
i.stack.imgur.com/IYBnm.png
RemoteDebugger
I have set up a Remote debugger on another PC and when I try to connect to
it using Visual Studio it asks me for Credentials, I have try'ed using
Home Sharing Usernames and Passwords but nothing works. Also the Remote PC
I am trying to connect to I have not set any password for it.
This is the window asking me for credentials:
i.stack.imgur.com/IYBnm.png
How to only allow certain number of forward slashes using regular expression?
How to only allow certain number of forward slashes using regular expression?
I'm routing my application and I'd like to only allow a maximum of 2
directory subpaths following a directory path of tags/. Hyphens and alnums
are the only allowable characters.
The following will all validate and be returned to the router as a single
match:
tags/how-to-bake
tags/how-to-bake/cookies
If there are more than 2 subpaths (or 2+ slashes, in other words) the
router should return no match.
My server redirects on trailing slashes (to the non-trailing slash URL) so
they don't need to be taken into consideration.
I'm currently using tags/([\w+\-\/]+)$ but this will allow infinitely many
subpaths, and I am forced to check the subpath length (forward slash
count) after the router returns a match.
I'm not sure how I can allow only 0 or 1 forward slashes in the character
set I wrote, while having word characters possibly follow, and then have
them all returned as a single match.
Is this possible with a regular expression?
I'm routing my application and I'd like to only allow a maximum of 2
directory subpaths following a directory path of tags/. Hyphens and alnums
are the only allowable characters.
The following will all validate and be returned to the router as a single
match:
tags/how-to-bake
tags/how-to-bake/cookies
If there are more than 2 subpaths (or 2+ slashes, in other words) the
router should return no match.
My server redirects on trailing slashes (to the non-trailing slash URL) so
they don't need to be taken into consideration.
I'm currently using tags/([\w+\-\/]+)$ but this will allow infinitely many
subpaths, and I am forced to check the subpath length (forward slash
count) after the router returns a match.
I'm not sure how I can allow only 0 or 1 forward slashes in the character
set I wrote, while having word characters possibly follow, and then have
them all returned as a single match.
Is this possible with a regular expression?
Generated url's are seems to be wrong
Generated url's are seems to be wrong
I created an application with signalR references in visual studio. Created
a hub. When running application on IIS Express, everything works fine.
When I transfer it to IIS8, in firebug I see that URL's of signalR are
wrong, for instance:
http://localhost/signalr/negotiate?connectionData=......
The problem that there is a missing site name, should be:
http://localhost/MYSITE/signalr/negotiate?connectionData=......
This is the script I am using to init connection:
<script type="text/javascript">
var proxy;
$(function () {
var connection = $.hubConnection();
proxy = connection.createHubProxy('chatHub');
proxy.on('newMessage', onNewMessage);
connection.start();
$('#send').click(onSend);
});
function onNewMessage(message) {
$('#messages').append('<li>' + $('#message').val() + '</li>');
}
function onSend() {
proxy.invoke('newMessage', $().val());
}
</script>
I tried to send connection to $.hubConnection(), but then site name is
getting doubled:
http://localhost/MYSITE/MYSITE/signalr/negotiate?connectionData=......
I created an application with signalR references in visual studio. Created
a hub. When running application on IIS Express, everything works fine.
When I transfer it to IIS8, in firebug I see that URL's of signalR are
wrong, for instance:
http://localhost/signalr/negotiate?connectionData=......
The problem that there is a missing site name, should be:
http://localhost/MYSITE/signalr/negotiate?connectionData=......
This is the script I am using to init connection:
<script type="text/javascript">
var proxy;
$(function () {
var connection = $.hubConnection();
proxy = connection.createHubProxy('chatHub');
proxy.on('newMessage', onNewMessage);
connection.start();
$('#send').click(onSend);
});
function onNewMessage(message) {
$('#messages').append('<li>' + $('#message').val() + '</li>');
}
function onSend() {
proxy.invoke('newMessage', $().val());
}
</script>
I tried to send connection to $.hubConnection(), but then site name is
getting doubled:
http://localhost/MYSITE/MYSITE/signalr/negotiate?connectionData=......
With namespaced third-party libraries, do you use 'use' statements or call the class directly?
With namespaced third-party libraries, do you use 'use' statements or call
the class directly?
When using external namespaced libraries or classes, do you do in your code:
use /com/libwebsite/Package/Lib as Lib;
$stuff = Lib::getStuff();
or call directly?
$stuff = /com/libwebsite/Package/Lib::getStuff();
Thanks!
the class directly?
When using external namespaced libraries or classes, do you do in your code:
use /com/libwebsite/Package/Lib as Lib;
$stuff = Lib::getStuff();
or call directly?
$stuff = /com/libwebsite/Package/Lib::getStuff();
Thanks!
Python: select() returns immediately without no data to read (telnetlib)
Python: select() returns immediately without no data to read (telnetlib)
I want to use select.select() to block the loop until some data is ready
to be readed from a list of telnet sessions. However, the below code does
not work and the call to "select.select()" returns inmediatly with no data
to read. I'm using python 2.7.3 under Ubuntu 10.4.
tn = telnetlib.Telnet(IP,23,TIMEOUT)
# [... logging and password omitted ..]
while True:
logging.info("%d - waiting on select for data" % self.id)
read_ready, write_ready, expt_ready = select.select([ tn.get_socket()
],[],[])
logging.info("%d - select returned" % self.id)
if len(read_ready) == 1:
data = tn.read_eager()
logging.info("%d read %d characters" % (self.id, len(data)))
# ... continue processing the data...
An example of the output:
2013-08-23 10:37:28,634 - INFO: 1 - waiting on select for data
2013-08-23 10:37:28,672 - INFO: 1 - select returned
2013-08-23 10:37:28,673 - INFO: 1 read 0 characters
2013-08-23 10:37:28,833 - INFO: 1 - waiting on select for data
2013-08-23 10:37:28,874 - INFO: 1 - select returned
2013-08-23 10:37:28,874 - INFO: 1 read 0 characters
2013-08-23 10:37:29,029 - INFO: 1 - waiting on select for data
2013-08-23 10:37:29,073 - INFO: 1 - select returned
2013-08-23 10:37:29,074 - INFO: 1 read 0 characters
I want to use select.select() to block the loop until some data is ready
to be readed from a list of telnet sessions. However, the below code does
not work and the call to "select.select()" returns inmediatly with no data
to read. I'm using python 2.7.3 under Ubuntu 10.4.
tn = telnetlib.Telnet(IP,23,TIMEOUT)
# [... logging and password omitted ..]
while True:
logging.info("%d - waiting on select for data" % self.id)
read_ready, write_ready, expt_ready = select.select([ tn.get_socket()
],[],[])
logging.info("%d - select returned" % self.id)
if len(read_ready) == 1:
data = tn.read_eager()
logging.info("%d read %d characters" % (self.id, len(data)))
# ... continue processing the data...
An example of the output:
2013-08-23 10:37:28,634 - INFO: 1 - waiting on select for data
2013-08-23 10:37:28,672 - INFO: 1 - select returned
2013-08-23 10:37:28,673 - INFO: 1 read 0 characters
2013-08-23 10:37:28,833 - INFO: 1 - waiting on select for data
2013-08-23 10:37:28,874 - INFO: 1 - select returned
2013-08-23 10:37:28,874 - INFO: 1 read 0 characters
2013-08-23 10:37:29,029 - INFO: 1 - waiting on select for data
2013-08-23 10:37:29,073 - INFO: 1 - select returned
2013-08-23 10:37:29,074 - INFO: 1 read 0 characters
Thursday, 22 August 2013
Why Form1.resx dont allow me to Edit/Add resources?
Why Form1.resx dont allow me to Edit/Add resources?
I add one Windows Form name as Form1.cs in my project and try to edit
local resource file of same Form1.cs ( Form1.resx ) file, while editing VS
pop up following confirmation box:
I don't understand why VS restrict me to add local resource file of Form1.cs.
I add one Windows Form name as Form1.cs in my project and try to edit
local resource file of same Form1.cs ( Form1.resx ) file, while editing VS
pop up following confirmation box:
I don't understand why VS restrict me to add local resource file of Form1.cs.
require_once format produces different behaviours
require_once format produces different behaviours
I'm trying to find the ideal way to integrate files into others throughout
a directory hierarchy in my project.
I've noticed that the following works in Eclipse PDT:
require_once '/../../services/impl/UserService.php';
require_once ('ui/controller/AbstractController.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/myproject/daos/impl/UserDAO.php';
$dirName = dirname(__FILE__); require_once $dirName . '/../AsbtractDAO.php';
All of these resolve yet the way they're formulated is completely
different. Any ideas why ?
Also, what are the pros/cons of each ? What standard could I adopt that's
the most robust ?
I'm trying to find the ideal way to integrate files into others throughout
a directory hierarchy in my project.
I've noticed that the following works in Eclipse PDT:
require_once '/../../services/impl/UserService.php';
require_once ('ui/controller/AbstractController.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/myproject/daos/impl/UserDAO.php';
$dirName = dirname(__FILE__); require_once $dirName . '/../AsbtractDAO.php';
All of these resolve yet the way they're formulated is completely
different. Any ideas why ?
Also, what are the pros/cons of each ? What standard could I adopt that's
the most robust ?
not printing my code in if /else statement
not printing my code in if /else statement
So im creating jeapordy in java, and i dont care that i spelt it wrong(if
i did) but i only have one question coded so far with only one answer, and
it asks the question but only prints out you are wrong even if the answer
is right.
it is asking the first history question and the answer is george, but it
is printing out that the answer is wrong. the first history question is
also worth 100. i have not began to code the math part yet.
thanks if you can help fin my problem! its probably really simple as i am
a beginner.
import java.util.Random;
import java.util.Scanner;
public class game {
public static void main (String[] args){
//Utilites
Scanner s = new Scanner(System.in);
Random r = new Random();
//Variables
String[] mathQuestions;
mathQuestions = new String[3];
mathQuestions[0] = ("What is the sum of 2 + 2");
mathQuestions[1] = ("What is 100 * 0");
mathQuestions[2] = ("What is 5 + 5");
String[] historyQuestions;
historyQuestions = new String[3];
historyQuestions[0] = ("What is General Washingtons first name?");
historyQuestions[1] = ("Who won WWII, Japan, or USA?");
historyQuestions[2] = ("How many states are in the USA?");
//Intro
System.out.println("Welome to Jeapordy!");
System.out.println("There are two categories!\nMath and History");
System.out.println("Math History");
System.out.println("100 100");
System.out.println("200 200");
System.out.println("300 300");
System.out.println("Which category would you like?");
String categoryChoice = s.nextLine();
System.out.println("For how much money?");
int moneyChoice = s.nextInt();
if (categoryChoice.equalsIgnoreCase("history")){
if (moneyChoice == 100){
System.out.println(historyQuestions[0]);
String userAnswer = s.nextLine();
s.nextLine();
if (userAnswer.equalsIgnoreCase("george")){
System.out.println("Congratulations! You were
right");
}
else{
System.out.println("Ah! Wrong answer!");
}
}
}
}
}
So im creating jeapordy in java, and i dont care that i spelt it wrong(if
i did) but i only have one question coded so far with only one answer, and
it asks the question but only prints out you are wrong even if the answer
is right.
it is asking the first history question and the answer is george, but it
is printing out that the answer is wrong. the first history question is
also worth 100. i have not began to code the math part yet.
thanks if you can help fin my problem! its probably really simple as i am
a beginner.
import java.util.Random;
import java.util.Scanner;
public class game {
public static void main (String[] args){
//Utilites
Scanner s = new Scanner(System.in);
Random r = new Random();
//Variables
String[] mathQuestions;
mathQuestions = new String[3];
mathQuestions[0] = ("What is the sum of 2 + 2");
mathQuestions[1] = ("What is 100 * 0");
mathQuestions[2] = ("What is 5 + 5");
String[] historyQuestions;
historyQuestions = new String[3];
historyQuestions[0] = ("What is General Washingtons first name?");
historyQuestions[1] = ("Who won WWII, Japan, or USA?");
historyQuestions[2] = ("How many states are in the USA?");
//Intro
System.out.println("Welome to Jeapordy!");
System.out.println("There are two categories!\nMath and History");
System.out.println("Math History");
System.out.println("100 100");
System.out.println("200 200");
System.out.println("300 300");
System.out.println("Which category would you like?");
String categoryChoice = s.nextLine();
System.out.println("For how much money?");
int moneyChoice = s.nextInt();
if (categoryChoice.equalsIgnoreCase("history")){
if (moneyChoice == 100){
System.out.println(historyQuestions[0]);
String userAnswer = s.nextLine();
s.nextLine();
if (userAnswer.equalsIgnoreCase("george")){
System.out.println("Congratulations! You were
right");
}
else{
System.out.println("Ah! Wrong answer!");
}
}
}
}
}
Use socket descriptor from another process with Mono
Use socket descriptor from another process with Mono
I have a BBS door written in C# that I'd like to get working on Linux. The
Socket class of the .NET framework doesn't support opening existing socket
handles, so different work-arounds need to be implemented for both Windows
and Linux.
For Linux, I had a look at the Socket.cs file and see this takes place in
DuplicateAndClose():
var si = new SocketInformation ();
si.Options =
(islistening ? SocketInformationOptions.Listening : 0) |
(connected ? SocketInformationOptions.Connected : 0) |
(blocking ? 0 : SocketInformationOptions.NonBlocking) |
(useoverlappedIO ? SocketInformationOptions.UseOnlyOverlappedIO : 0);
si.ProtocolInformation = Mono.DataConverter.Pack ("iiiil",
(int)address_family,
(int)socket_type,
(int)protocol_type,
isbound ? 1 : 0,
(long)socket);
socket = (IntPtr) (-1);
return si;
Since I don't have access to Mono.DataConverter from Windows, I had a look
at the source for it as well and came up with this:
SocketInformation SI = new SocketInformation();
SI.Options = SocketInformationOptions.Connected;
SI.ProtocolInformation = new byte[24];
Int32 AF = (Int32)AddressFamily.InterNetwork;
Int32 ST = (Int32)SocketType.Stream;
Int32 PT = (Int32)ProtocolType.Tcp;
Int32 Bound = 0;
Int64 Socket = (Int64)ASocketHandle;
unsafe
{
fixed (byte* target = &SI.ProtocolInformation[0])
{
uint* source = (uint*)&AF;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[4])
{
uint* source = (uint*)&ST;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[8])
{
uint* source = (uint*)&PT;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[12])
{
uint* source = (uint*)&Bound;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[16])
{
long* source = (long*)&Socket;
*((long*)target) = *source;
}
}
So now that I have the SocketInformation populated, I should be able to do
this:
Socket S = new Socket(SI);
S.Send(new byte[] { 65, 66, 67, 68 });
And the remote user should see ABCD. But instead the call to Send throws
an exception with the message "The descriptor is not a socket".
So at first I thought what I wanted to do just wasn't possible, but then I
tried pinvoking a call to send():
Socket S = new Socket(SI);
send(S.Handle, new byte[] { 65, 66, 67, 68 }, 4, SocketFlags.None);
Where send() is declared as:
[DllImport("libc")]
private extern static int send(IntPtr sock, byte[] buf, int count,
SocketFlags flags);
And it works just fine!
So if a pinvoked call to send() is fine with the descriptor, what am I
doing wrong to have the managed S.Send() call fail saying it's not a
socket descriptor? I'm assuming it has something to do with how I'm
populating SocketInformation, but if nothing else the handle seems to be
populated correctly since I'm able to use it with the pinvoked send()...
I have a BBS door written in C# that I'd like to get working on Linux. The
Socket class of the .NET framework doesn't support opening existing socket
handles, so different work-arounds need to be implemented for both Windows
and Linux.
For Linux, I had a look at the Socket.cs file and see this takes place in
DuplicateAndClose():
var si = new SocketInformation ();
si.Options =
(islistening ? SocketInformationOptions.Listening : 0) |
(connected ? SocketInformationOptions.Connected : 0) |
(blocking ? 0 : SocketInformationOptions.NonBlocking) |
(useoverlappedIO ? SocketInformationOptions.UseOnlyOverlappedIO : 0);
si.ProtocolInformation = Mono.DataConverter.Pack ("iiiil",
(int)address_family,
(int)socket_type,
(int)protocol_type,
isbound ? 1 : 0,
(long)socket);
socket = (IntPtr) (-1);
return si;
Since I don't have access to Mono.DataConverter from Windows, I had a look
at the source for it as well and came up with this:
SocketInformation SI = new SocketInformation();
SI.Options = SocketInformationOptions.Connected;
SI.ProtocolInformation = new byte[24];
Int32 AF = (Int32)AddressFamily.InterNetwork;
Int32 ST = (Int32)SocketType.Stream;
Int32 PT = (Int32)ProtocolType.Tcp;
Int32 Bound = 0;
Int64 Socket = (Int64)ASocketHandle;
unsafe
{
fixed (byte* target = &SI.ProtocolInformation[0])
{
uint* source = (uint*)&AF;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[4])
{
uint* source = (uint*)&ST;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[8])
{
uint* source = (uint*)&PT;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[12])
{
uint* source = (uint*)&Bound;
*((uint*)target) = *source;
}
fixed (byte* target = &SI.ProtocolInformation[16])
{
long* source = (long*)&Socket;
*((long*)target) = *source;
}
}
So now that I have the SocketInformation populated, I should be able to do
this:
Socket S = new Socket(SI);
S.Send(new byte[] { 65, 66, 67, 68 });
And the remote user should see ABCD. But instead the call to Send throws
an exception with the message "The descriptor is not a socket".
So at first I thought what I wanted to do just wasn't possible, but then I
tried pinvoking a call to send():
Socket S = new Socket(SI);
send(S.Handle, new byte[] { 65, 66, 67, 68 }, 4, SocketFlags.None);
Where send() is declared as:
[DllImport("libc")]
private extern static int send(IntPtr sock, byte[] buf, int count,
SocketFlags flags);
And it works just fine!
So if a pinvoked call to send() is fine with the descriptor, what am I
doing wrong to have the managed S.Send() call fail saying it's not a
socket descriptor? I'm assuming it has something to do with how I'm
populating SocketInformation, but if nothing else the handle seems to be
populated correctly since I'm able to use it with the pinvoked send()...
Vim autocommand not triggering on search?
Vim autocommand not triggering on search?
I've got the following line in my .vimrc:
autocmd BufNewFile,BufReadPost $HOME/git/repo/* set sw=2 ts=2 et
I use this because I need to follow the conventions of a particular git
repository. However, I've noticed that when I search with the ':vim'
command I don't get the intended indentation settings applied.
Let's say that I search for the string abc using :vim /abc/ ** and this
opens the first hit in the file X - vim opens a new buffer for the file
because it was not previously opened. Why does it not trigger the
BufReadPost event?
I've got the following line in my .vimrc:
autocmd BufNewFile,BufReadPost $HOME/git/repo/* set sw=2 ts=2 et
I use this because I need to follow the conventions of a particular git
repository. However, I've noticed that when I search with the ':vim'
command I don't get the intended indentation settings applied.
Let's say that I search for the string abc using :vim /abc/ ** and this
opens the first hit in the file X - vim opens a new buffer for the file
because it was not previously opened. Why does it not trigger the
BufReadPost event?
PHP Framework Comparision CakePHP2 vs CodeIgniter vs Yii vs Symfony2
PHP Framework Comparision CakePHP2 vs CodeIgniter vs Yii vs Symfony2
I usually work with cakePHP old version but we thinking to move another
framework. We are working with big data sets(using PostgreSQL and MySQL)
so speed is important for us. Also it shouldn't be take much more time to
learn for me. I read many articles, cakePHP2 and Yii come forward. But I
couldn't decide. Which is better for me so i can decide what i will use.
I usually work with cakePHP old version but we thinking to move another
framework. We are working with big data sets(using PostgreSQL and MySQL)
so speed is important for us. Also it shouldn't be take much more time to
learn for me. I read many articles, cakePHP2 and Yii come forward. But I
couldn't decide. Which is better for me so i can decide what i will use.
Calls to service request credentials only on one method, and always fails
Calls to service request credentials only on one method, and always fails
I have a Silverlight website and a WCF service. They use Windows
authentication. The Silverlight site correctly picks up the current user
and passes this to the WCF service so that it can load the correct menu
(if the user is not found or has no permissions, nothing is loaded). The
service is hosted in a Windows service.
On one particular method, the same one every time, the user is asked for
credentials - then regardless of what they enter, the method fails. To get
to that method, half-a-dozen service calls have already been made without
challenging for credentials and worked perfectly.
The issue only occurs with the service on the test server, I can't
replicate it when I run the service locally, but I can replicate it when
running the Silverlight client locally - an exception is thrown when
retrieving the response from the service (the ever-helpful Silverlight
'NotFound' error). Because of the length of time the method should take, I
believe it is challenging for credentials immediately on request but
failing when the result gets back. No exceptions are thrown by the
service.
The test service and the local dev service use exactly the same
configuration.
I've used Fiddler to check whether it is clientaccesspolicy/crossdomain
problems, but these are loaded fine (and both the client on the test
server and the WCF service are on the same domain).
Does anyone have any ideas why one particular method might be challenging
for credentials when the service is on the test server but not when
running locally, or any clues to debugging why this might be the case?
I have a Silverlight website and a WCF service. They use Windows
authentication. The Silverlight site correctly picks up the current user
and passes this to the WCF service so that it can load the correct menu
(if the user is not found or has no permissions, nothing is loaded). The
service is hosted in a Windows service.
On one particular method, the same one every time, the user is asked for
credentials - then regardless of what they enter, the method fails. To get
to that method, half-a-dozen service calls have already been made without
challenging for credentials and worked perfectly.
The issue only occurs with the service on the test server, I can't
replicate it when I run the service locally, but I can replicate it when
running the Silverlight client locally - an exception is thrown when
retrieving the response from the service (the ever-helpful Silverlight
'NotFound' error). Because of the length of time the method should take, I
believe it is challenging for credentials immediately on request but
failing when the result gets back. No exceptions are thrown by the
service.
The test service and the local dev service use exactly the same
configuration.
I've used Fiddler to check whether it is clientaccesspolicy/crossdomain
problems, but these are loaded fine (and both the client on the test
server and the WCF service are on the same domain).
Does anyone have any ideas why one particular method might be challenging
for credentials when the service is on the test server but not when
running locally, or any clues to debugging why this might be the case?
Wednesday, 21 August 2013
What is the function of the four pins on my SSD?
What is the function of the four pins on my SSD?
While searching for an answer, I found this question on SU what is the
purpose of this 4 pin interface on sata hdds and why doesnt it exist on
SSDs?
Well, on my Kingston HyperX SSD drive, they do exist.
So if Spread Spectrum Clocking and reduced power spin up is not needed,
what would be the function of these four pins?
All of my search attempts show only a few variants that apply to 2.5"
spinning platter drives depending on vendor and none for SSD, to include
the attached SU question.
Any ideas?
While searching for an answer, I found this question on SU what is the
purpose of this 4 pin interface on sata hdds and why doesnt it exist on
SSDs?
Well, on my Kingston HyperX SSD drive, they do exist.
So if Spread Spectrum Clocking and reduced power spin up is not needed,
what would be the function of these four pins?
All of my search attempts show only a few variants that apply to 2.5"
spinning platter drives depending on vendor and none for SSD, to include
the attached SU question.
Any ideas?
Java SwingWorker with JDialog showing JProgressBar during JDBC network operation
Java SwingWorker with JDialog showing JProgressBar during JDBC network
operation
I have a frame which has a button, when it is pressed a JDialog with a
progress bar is shown and some data is being fetched using jdbc driver
(progress bar is being updated). I needed a cancel button, so I spent some
time figuring out how to connect everything. It seems to be working, but I
sincerely am not sure if this way is any good. If someone has some spare
time please check this code and tell me if anything is wrong with it -
mainly with the whole SwingWorker and cancellation stuff.
On my pc (linux) the unsuccessful network connection attempt
(someNetworkDataFetching method) takes a whole minute to timeout, do I
have to worry about the SwingWorkers which are still working (waiting to
connect despite being cancelled) when I try to create new ones?
Note: you need mysql jdbc driver library to run this code.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
public class Test extends JFrame {
private JProgressBar progressBar = new JProgressBar();
private JLabel label = new JLabel();
private DataFetcherProgress dfp;
/**
* This class holds retrieved data.
*/
class ImportantData {
ArrayList<String> chunks = new ArrayList<>();
void addChunk(String chunk) {
// Add this data
chunks.add(chunk);
}
}
/**
* This is the JDialog which shows data retrieval progress.
*/
class DataFetcherProgress extends JDialog {
JButton cancelButton = new JButton("Cancel");
DataFetcher df;
/**
* Sets up data fetcher dialog.
*/
public DataFetcherProgress(Test owner) {
super(owner, true);
getContentPane().add(progressBar, BorderLayout.CENTER);
// This button cancels the data fetching worker.
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
df.cancel(true);
}
});
getContentPane().add(cancelButton, BorderLayout.EAST);
setLocationRelativeTo(owner);
setSize(200, 50);
df = new DataFetcher(this);
}
/**
* This executes data fetching worker.
*/
public void fetchData() {
df.execute();
}
}
class DataFetcher extends SwingWorker<ImportantData, Integer> {
DataFetcherProgress progressDialog;
public DataFetcher(DataFetcherProgress progressDialog) {
this.progressDialog = progressDialog;
}
/**
* Update the progress bar.
*/
@Override
protected void process(List<Integer> chunks) {
if (chunks.size() > 0) {
int step = chunks.get(chunks.size() - 1);
progressBar.setValue(step);
}
}
/**
* Called when worker finishes (or is cancelled).
*/
@Override
protected void done() {
System.out.println("done()");
ImportantData data = null;
try {
data = get();
} catch (InterruptedException | ExecutionException |
CancellationException ex) {
System.err.println("done() exception: " + ex);
}
label.setText(data != null ? "Retrieved data!" : "Did not
retrieve data.");
progressDialog.setVisible(false);
}
/**
* This pretends to do some data fetching.
*/
private String someNetworkDataFetching() throws SQLException {
DriverManager.getConnection("jdbc:mysql://1.1.1.1/db", "user",
"pass");
// Retrieve data...
return "data chunk";
}
/**
* This tries to create ImportantData object.
*/
@Override
protected ImportantData doInBackground() throws Exception {
// Show the progress bar dialog.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
dfp.setVisible(true);
}
});
ImportantData data = new ImportantData();
try {
int i = 0;
// There is a network operation here (JDBC data retrieval)
String chunk1 = someNetworkDataFetching();
if (isCancelled()) {
System.out.println("DataFetcher cancelled.");
return null;
}
data.addChunk(chunk1);
publish(++i);
// And another jdbc data operation....
String chunk2 = someNetworkDataFetching();
if (isCancelled()) {
System.out.println("DataFetcher cancelled.");
return null;
}
data.addChunk(chunk2);
publish(++i);
} catch (Exception ex) {
System.err.println("doInBackground() exception: " + ex);
return null;
}
System.out.println("doInBackground() finished");
return data;
}
}
/**
* Set up the main window.
*/
public Test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
label.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().add(label, BorderLayout.CENTER);
// Add a button starting data fetch.
JButton retrieveButton = new JButton("Do it!");
retrieveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fetchData();
}
});
getContentPane().add(retrieveButton, BorderLayout.EAST);
setSize(400, 75);
setLocationRelativeTo(null);
progressBar.setMaximum(2);
}
// Shows new JDialog with a JProgressBar and calls its fetchData()
public void fetchData() {
label.setText("Retrieving data...");
dfp = new DataFetcherProgress(this);
dfp.fetchData();
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
// Use jdbc mysql driver
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
return;
}
// Show the Frame
new Test().setVisible(true);
}
});
}
}
operation
I have a frame which has a button, when it is pressed a JDialog with a
progress bar is shown and some data is being fetched using jdbc driver
(progress bar is being updated). I needed a cancel button, so I spent some
time figuring out how to connect everything. It seems to be working, but I
sincerely am not sure if this way is any good. If someone has some spare
time please check this code and tell me if anything is wrong with it -
mainly with the whole SwingWorker and cancellation stuff.
On my pc (linux) the unsuccessful network connection attempt
(someNetworkDataFetching method) takes a whole minute to timeout, do I
have to worry about the SwingWorkers which are still working (waiting to
connect despite being cancelled) when I try to create new ones?
Note: you need mysql jdbc driver library to run this code.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
public class Test extends JFrame {
private JProgressBar progressBar = new JProgressBar();
private JLabel label = new JLabel();
private DataFetcherProgress dfp;
/**
* This class holds retrieved data.
*/
class ImportantData {
ArrayList<String> chunks = new ArrayList<>();
void addChunk(String chunk) {
// Add this data
chunks.add(chunk);
}
}
/**
* This is the JDialog which shows data retrieval progress.
*/
class DataFetcherProgress extends JDialog {
JButton cancelButton = new JButton("Cancel");
DataFetcher df;
/**
* Sets up data fetcher dialog.
*/
public DataFetcherProgress(Test owner) {
super(owner, true);
getContentPane().add(progressBar, BorderLayout.CENTER);
// This button cancels the data fetching worker.
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
df.cancel(true);
}
});
getContentPane().add(cancelButton, BorderLayout.EAST);
setLocationRelativeTo(owner);
setSize(200, 50);
df = new DataFetcher(this);
}
/**
* This executes data fetching worker.
*/
public void fetchData() {
df.execute();
}
}
class DataFetcher extends SwingWorker<ImportantData, Integer> {
DataFetcherProgress progressDialog;
public DataFetcher(DataFetcherProgress progressDialog) {
this.progressDialog = progressDialog;
}
/**
* Update the progress bar.
*/
@Override
protected void process(List<Integer> chunks) {
if (chunks.size() > 0) {
int step = chunks.get(chunks.size() - 1);
progressBar.setValue(step);
}
}
/**
* Called when worker finishes (or is cancelled).
*/
@Override
protected void done() {
System.out.println("done()");
ImportantData data = null;
try {
data = get();
} catch (InterruptedException | ExecutionException |
CancellationException ex) {
System.err.println("done() exception: " + ex);
}
label.setText(data != null ? "Retrieved data!" : "Did not
retrieve data.");
progressDialog.setVisible(false);
}
/**
* This pretends to do some data fetching.
*/
private String someNetworkDataFetching() throws SQLException {
DriverManager.getConnection("jdbc:mysql://1.1.1.1/db", "user",
"pass");
// Retrieve data...
return "data chunk";
}
/**
* This tries to create ImportantData object.
*/
@Override
protected ImportantData doInBackground() throws Exception {
// Show the progress bar dialog.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
dfp.setVisible(true);
}
});
ImportantData data = new ImportantData();
try {
int i = 0;
// There is a network operation here (JDBC data retrieval)
String chunk1 = someNetworkDataFetching();
if (isCancelled()) {
System.out.println("DataFetcher cancelled.");
return null;
}
data.addChunk(chunk1);
publish(++i);
// And another jdbc data operation....
String chunk2 = someNetworkDataFetching();
if (isCancelled()) {
System.out.println("DataFetcher cancelled.");
return null;
}
data.addChunk(chunk2);
publish(++i);
} catch (Exception ex) {
System.err.println("doInBackground() exception: " + ex);
return null;
}
System.out.println("doInBackground() finished");
return data;
}
}
/**
* Set up the main window.
*/
public Test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
label.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().add(label, BorderLayout.CENTER);
// Add a button starting data fetch.
JButton retrieveButton = new JButton("Do it!");
retrieveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fetchData();
}
});
getContentPane().add(retrieveButton, BorderLayout.EAST);
setSize(400, 75);
setLocationRelativeTo(null);
progressBar.setMaximum(2);
}
// Shows new JDialog with a JProgressBar and calls its fetchData()
public void fetchData() {
label.setText("Retrieving data...");
dfp = new DataFetcherProgress(this);
dfp.fetchData();
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
// Use jdbc mysql driver
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
return;
}
// Show the Frame
new Test().setVisible(true);
}
});
}
}
What is EF Default Id Naming Convention Code First?
What is EF Default Id Naming Convention Code First?
I am using EF code first approach. I started to make mapping files(I come
from nihbernate background) but found out that you really don't need them
unless you need to do some changes.
I am wondering what will it use for the naming convention of my Id's?
Will it be Product_Id or ProductId?
Edit
Based on the comments so far this leaves me a bit puzzled. I was asking
because I added 2 new classes(ie tables) and hooked them up and recreated
my database.
Both of the FK in my tables that have a relationship to my new tables all
have "Product_Id" and I thought maybe it was because I had no mapping for
it.
I just tried using mapping and same issue.
All other tables relationships have Camel Upper Case.
I am using EF code first approach. I started to make mapping files(I come
from nihbernate background) but found out that you really don't need them
unless you need to do some changes.
I am wondering what will it use for the naming convention of my Id's?
Will it be Product_Id or ProductId?
Edit
Based on the comments so far this leaves me a bit puzzled. I was asking
because I added 2 new classes(ie tables) and hooked them up and recreated
my database.
Both of the FK in my tables that have a relationship to my new tables all
have "Product_Id" and I thought maybe it was because I had no mapping for
it.
I just tried using mapping and same issue.
All other tables relationships have Camel Upper Case.
J Oliver EventStoreRepository is not returning snapshots
J Oliver EventStoreRepository is not returning snapshots
I am using the EventStore framework made by J Oliver. I have notices that
when I create a snapshot, it is not being passed to my aggregate factory
and I am wondering why. This is my aggregate factory method constructing
aggregates:
public IAggregate Build(Type type, Guid id, IMemento snapshot)
{
ConstructorInfo constructor =
type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance,
null, new[] { typeof(Guid) }, null);
IAggregate aggregate = constructor.Invoke(new object[] { id }) as
IAggregate;
}
The snapshot parameter is null when it should be filled with a snapshot
since when I add this to the method:
Snapshot snapshotContainer = _store.Advanced.GetSnapshot(id, int.MaxValue);
snapshot = snapshotContainer == null ? null : snapshotContainer.Payload as
IMemento;
it shows me that snapshot is filled. What is going on here?
I am using the EventStore framework made by J Oliver. I have notices that
when I create a snapshot, it is not being passed to my aggregate factory
and I am wondering why. This is my aggregate factory method constructing
aggregates:
public IAggregate Build(Type type, Guid id, IMemento snapshot)
{
ConstructorInfo constructor =
type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance,
null, new[] { typeof(Guid) }, null);
IAggregate aggregate = constructor.Invoke(new object[] { id }) as
IAggregate;
}
The snapshot parameter is null when it should be filled with a snapshot
since when I add this to the method:
Snapshot snapshotContainer = _store.Advanced.GetSnapshot(id, int.MaxValue);
snapshot = snapshotContainer == null ? null : snapshotContainer.Payload as
IMemento;
it shows me that snapshot is filled. What is going on here?
Extending an abstract class - implementing abstract methods
Extending an abstract class - implementing abstract methods
Greetings and salutations!
I currently have an abstract class A, and many classes subclassing it. The
code common to all the subclasses I've put in the oneMethod() and the code
that's specific to each implementation I've put into two abstract methods.
public abstract class AbstractA {
public oneMethod() {
//do some intelligent stuff here
abstractMethodOne();
abstractMethodTwo();
}
protected abstract void abstractMethodOne();
protected abstract void abstractMethodTwo();
}
I have a class that overwrites the oneMethod() method.
public class B extends AbstractA {
@Override
public oneMethod() {
//do some other intelligent stuff here
}
}
is there any way to skip making a stub implementation of the two abstract
methods in the subclass? I mean the only place they're used is in the
overridden method.
Any help is appreciated!
Greetings and salutations!
I currently have an abstract class A, and many classes subclassing it. The
code common to all the subclasses I've put in the oneMethod() and the code
that's specific to each implementation I've put into two abstract methods.
public abstract class AbstractA {
public oneMethod() {
//do some intelligent stuff here
abstractMethodOne();
abstractMethodTwo();
}
protected abstract void abstractMethodOne();
protected abstract void abstractMethodTwo();
}
I have a class that overwrites the oneMethod() method.
public class B extends AbstractA {
@Override
public oneMethod() {
//do some other intelligent stuff here
}
}
is there any way to skip making a stub implementation of the two abstract
methods in the subclass? I mean the only place they're used is in the
overridden method.
Any help is appreciated!
How to see password as we type it
How to see password as we type it
In debian wheezy terminal i type
su -
It ask for password, which i type but it dont show anything as
Password:
I want to it to show at least some asterisks as the placeholder for the
password characters as follow:
Password: ************
In debian wheezy terminal i type
su -
It ask for password, which i type but it dont show anything as
Password:
I want to it to show at least some asterisks as the placeholder for the
password characters as follow:
Password: ************
jcrop changing imge src after page load
jcrop changing imge src after page load
I am using jcrop for image cropping on the fly and want the user to have
the option of changing the image before they start to crop.
For some reason I cannot get the image to change.
jsfiddle http://jsfiddle.net/UUKP4/2/
When I look at the code in firefly it shows two img elements and one being
inside a jcrop container with no id.
how can I change the image?
code
#jcrop_target { width:200px; }
$(function () {
$('#jcrop_target').Jcrop();
});
function chageImage() {
alert("hello");
$('#jcrop_target').attr('src',
'http://eofdreams.com/data_images/dreams/cat/cat-06.jpg');
}
<img src="http://jcrop-cdn.tapmodo.com/v0.9.10/demos/demo_files/pool.jpg"
id="jcrop_target" />
<input type='button' value='change image' id='changeImage'
onclick='chageImage();'>
I am using jcrop for image cropping on the fly and want the user to have
the option of changing the image before they start to crop.
For some reason I cannot get the image to change.
jsfiddle http://jsfiddle.net/UUKP4/2/
When I look at the code in firefly it shows two img elements and one being
inside a jcrop container with no id.
how can I change the image?
code
#jcrop_target { width:200px; }
$(function () {
$('#jcrop_target').Jcrop();
});
function chageImage() {
alert("hello");
$('#jcrop_target').attr('src',
'http://eofdreams.com/data_images/dreams/cat/cat-06.jpg');
}
<img src="http://jcrop-cdn.tapmodo.com/v0.9.10/demos/demo_files/pool.jpg"
id="jcrop_target" />
<input type='button' value='change image' id='changeImage'
onclick='chageImage();'>
Tuesday, 20 August 2013
File not Found when loading multipack spritesheet in Cocos2d
File not Found when loading multipack spritesheet in Cocos2d
I'm attempting to use multipacking via TexturePacker to handle multiple
animations for the same sprite. I added all my images in TexturePacker and
published them, no problem. I've added them to the Resources folder in my
project and I even see them in Finder.
When I attempt to call this
-(CCSpriteBatchNode*)createSpritesheet {
[[CCSpriteFrameCache sharedSpriteFrameCache]
addSpriteFramesWithFile:@"Clea1.plist"];
CCSpriteBatchNode *spritesheet = [CCSpriteBatchNode
batchNodeWithFile:@"Clea1.png"];
return spritesheet;
}
I wind up with the following errors:
2013-08-21 00:08:13.024 HFZ[10498:a0b] -[CCFileUtils
fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found:
Clea1.plist
2013-08-21 00:08:13.025 HFZ[10498:a0b] cocos2d: CCSpriteFrameCache: Trying
to use file 'Clea1.png' as texture
2013-08-21 00:08:13.025 HFZ[10498:a0b] -[CCFileUtils
fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found:
Clea1.png
2013-08-21 00:08:13.026 HFZ[10498:a0b] cocos2d: Couldn't find file:Clea1.png
2013-08-21 00:08:13.026 HFZ[10498:a0b] cocos2d: CCSpriteFrameCache: Frame
'CleaStand00.png' not found
I really don't understand why this is happening. Before I tried the
multipack solution, I was attempting to use one spritesheet per animation,
but this seemed like the better route to go. Any ideas on this?
I'm attempting to use multipacking via TexturePacker to handle multiple
animations for the same sprite. I added all my images in TexturePacker and
published them, no problem. I've added them to the Resources folder in my
project and I even see them in Finder.
When I attempt to call this
-(CCSpriteBatchNode*)createSpritesheet {
[[CCSpriteFrameCache sharedSpriteFrameCache]
addSpriteFramesWithFile:@"Clea1.plist"];
CCSpriteBatchNode *spritesheet = [CCSpriteBatchNode
batchNodeWithFile:@"Clea1.png"];
return spritesheet;
}
I wind up with the following errors:
2013-08-21 00:08:13.024 HFZ[10498:a0b] -[CCFileUtils
fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found:
Clea1.plist
2013-08-21 00:08:13.025 HFZ[10498:a0b] cocos2d: CCSpriteFrameCache: Trying
to use file 'Clea1.png' as texture
2013-08-21 00:08:13.025 HFZ[10498:a0b] -[CCFileUtils
fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found:
Clea1.png
2013-08-21 00:08:13.026 HFZ[10498:a0b] cocos2d: Couldn't find file:Clea1.png
2013-08-21 00:08:13.026 HFZ[10498:a0b] cocos2d: CCSpriteFrameCache: Frame
'CleaStand00.png' not found
I really don't understand why this is happening. Before I tried the
multipack solution, I was attempting to use one spritesheet per animation,
but this seemed like the better route to go. Any ideas on this?
Failed to use content url() to style an element
Failed to use content url() to style an element
http://i.imgur.com/pBnCN0p.jpg
trying to style the circled elements in the above picture. I would love to
add a jsfiddle here but because I'm using a plugin called caroufredsel and
my limited knowledge on Javascript and jquery I don't think its possible
for me to provide one. So sorry about that. But here is my css and html
code,
<div class="list_carousel">
<ul id="foo2">
<li>c</li>
<li>a</li>
<li>r</li>
<li>o</li>
<li>u</li>
<li>F</li>
<li>r</li>
<li>e</li>
<li>d</li>
<li>S</li>
<li>e</li>
<li>l</li>
<li> </li>
</ul>
<div class="clearfix"></div>
<a id="prev2" class="prev" href="#"><img
src="image/images/carousel_control_03.png"/></a>
<a id="next2" class="next" href="#"><img
src="image/images/carousel_control_05.png"></a>
<div id="pager2" class="pager"></div>
</div>
here is the css:
.list_carousel {
background-color: #ccc;
margin: 0 76px 30px 76px;
width: 808px;
}
.list_carousel ul {
margin: 0;
padding: 0;
list-style: none;
display: block;
}
.list_carousel li {
font-size: 40px;
color: #999;
text-align: center;
background-color: #eee;
border: 5px solid #999;
width: 180px;
height: 250px;
padding: 0;
margin: 6px;
display: block;
float: left;
}
.list_carousel.responsive {
width: auto;
margin-left: 0;
}
.clearfix {
float: none;
clear: both;
}
.prev {
float: left;
margin-left: -30px;
margin-top: -140px;
}
.next {
float: right;
margin-right: -30px;
margin-top: -140px;
}
.pager {
float: left;
width: 300px;
text-align: center;
}
.pager a {
margin: 0 5px;
text-indent: -999px;
overflow: hidden;
background: transparent
url(image/images/carousel_control_10.png);
}
.pager a.selected {
text-decoration: underline;
}
.timer {
background-color: #999;
height: 6px;
width: 0px;
}
I tried to add both background: url() and contentF url() to .pager a but
nothing happened, I also tried to use text-indent:-999px to push the text
away so the background will show but nothing happens as well. Also here is
the javascript that came with the plugin, I don't know if it will help any
but I will include here as well.
$('#foo2').carouFredSel({
auto: false,
prev: '#prev2',
next: '#next2',
pagination: "#pager2",
mousewheel: true,
swipe: {
onMouse: true,
onTouch: true
}
});
http://i.imgur.com/pBnCN0p.jpg
trying to style the circled elements in the above picture. I would love to
add a jsfiddle here but because I'm using a plugin called caroufredsel and
my limited knowledge on Javascript and jquery I don't think its possible
for me to provide one. So sorry about that. But here is my css and html
code,
<div class="list_carousel">
<ul id="foo2">
<li>c</li>
<li>a</li>
<li>r</li>
<li>o</li>
<li>u</li>
<li>F</li>
<li>r</li>
<li>e</li>
<li>d</li>
<li>S</li>
<li>e</li>
<li>l</li>
<li> </li>
</ul>
<div class="clearfix"></div>
<a id="prev2" class="prev" href="#"><img
src="image/images/carousel_control_03.png"/></a>
<a id="next2" class="next" href="#"><img
src="image/images/carousel_control_05.png"></a>
<div id="pager2" class="pager"></div>
</div>
here is the css:
.list_carousel {
background-color: #ccc;
margin: 0 76px 30px 76px;
width: 808px;
}
.list_carousel ul {
margin: 0;
padding: 0;
list-style: none;
display: block;
}
.list_carousel li {
font-size: 40px;
color: #999;
text-align: center;
background-color: #eee;
border: 5px solid #999;
width: 180px;
height: 250px;
padding: 0;
margin: 6px;
display: block;
float: left;
}
.list_carousel.responsive {
width: auto;
margin-left: 0;
}
.clearfix {
float: none;
clear: both;
}
.prev {
float: left;
margin-left: -30px;
margin-top: -140px;
}
.next {
float: right;
margin-right: -30px;
margin-top: -140px;
}
.pager {
float: left;
width: 300px;
text-align: center;
}
.pager a {
margin: 0 5px;
text-indent: -999px;
overflow: hidden;
background: transparent
url(image/images/carousel_control_10.png);
}
.pager a.selected {
text-decoration: underline;
}
.timer {
background-color: #999;
height: 6px;
width: 0px;
}
I tried to add both background: url() and contentF url() to .pager a but
nothing happened, I also tried to use text-indent:-999px to push the text
away so the background will show but nothing happens as well. Also here is
the javascript that came with the plugin, I don't know if it will help any
but I will include here as well.
$('#foo2').carouFredSel({
auto: false,
prev: '#prev2',
next: '#next2',
pagination: "#pager2",
mousewheel: true,
swipe: {
onMouse: true,
onTouch: true
}
});
How to get different style in nested element depending to depth level?
How to get different style in nested element depending to depth level?
i have nested element and i want that every level have different style
level 1, 5, 9, 13 ... (4n+1) style1
level 2, 6, 10, 14... (4n+2) style2
level 3, 7, 11, 17... (4n+3) style3
level 4, 8, 12, 18... (4n+3) style4
view exemples
how to get the 3rd exemple style without using many class when i have
infinity level of nested ul
<ul>
</ul>
i have nested element and i want that every level have different style
level 1, 5, 9, 13 ... (4n+1) style1
level 2, 6, 10, 14... (4n+2) style2
level 3, 7, 11, 17... (4n+3) style3
level 4, 8, 12, 18... (4n+3) style4
view exemples
how to get the 3rd exemple style without using many class when i have
infinity level of nested ul
<ul>
</ul>
How to fix Initialize applet error
How to fix Initialize applet error
Your help is much appreciated. Can anyone tell me (using code) why when I
run this program (that is supposed to display my image) tells me: Start:
applet not initialized.
In the console box, I get this error:
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
HERE IS MY CODE-----
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
public class Memory extends JPanel {
ImageIcon dots = new ImageIcon("Dots1.jpg");
private JLabel Hi = new JLabel("Hi");
//ImageIcon Dots = new ImageIcon(this.getClass().getResource("Dots.jpg"));
Memory(){
new ImageIcon(getClass().getResource("/resources/Dots1.jpg")).getImage();
Hi.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/resources/jpg/Dots1.jpg")));
Hi.setPreferredSize(new Dimension(100,100));
this.add(Hi);
}
}
Your help is much appreciated. Can anyone tell me (using code) why when I
run this program (that is supposed to display my image) tells me: Start:
applet not initialized.
In the console box, I get this error:
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
HERE IS MY CODE-----
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
public class Memory extends JPanel {
ImageIcon dots = new ImageIcon("Dots1.jpg");
private JLabel Hi = new JLabel("Hi");
//ImageIcon Dots = new ImageIcon(this.getClass().getResource("Dots.jpg"));
Memory(){
new ImageIcon(getClass().getResource("/resources/Dots1.jpg")).getImage();
Hi.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/resources/jpg/Dots1.jpg")));
Hi.setPreferredSize(new Dimension(100,100));
this.add(Hi);
}
}
How do I get HTML syntax highlighting inside PHP strings & heredoc syntax?
How do I get HTML syntax highlighting inside PHP strings & heredoc syntax?
I'm using Sublime Text with the Pastels on Dark theme. My language of
choice is PHP. How can I get HTML syntax highlighting inside PHP strings &
heredoc syntax?
I'm using Sublime Text with the Pastels on Dark theme. My language of
choice is PHP. How can I get HTML syntax highlighting inside PHP strings &
heredoc syntax?
Return a JSON from Facebook Page Feed
Return a JSON from Facebook Page Feed
Is it possible to get a JSON file of Feeds from An FB Page without Access
Token? http://www.facebook.com/feeds/page.php?format=json&id="fbpage_id"
for Windows Store App using C#. thanks in advance,
Is it possible to get a JSON file of Feeds from An FB Page without Access
Token? http://www.facebook.com/feeds/page.php?format=json&id="fbpage_id"
for Windows Store App using C#. thanks in advance,
jQuery .show not working in .each
jQuery .show not working in .each
Here is my jquery code.I'm trying to show.Here is my code
$('#divTalentAgent a').each(function () {
$(this).show();
});
The above code doesn't work.But if i modify it as below
$('#divTalentAgent a').each(function () {
alert('hi');
$(this).show();
});
It works..
Here is my jquery code.I'm trying to show.Here is my code
$('#divTalentAgent a').each(function () {
$(this).show();
});
The above code doesn't work.But if i modify it as below
$('#divTalentAgent a').each(function () {
alert('hi');
$(this).show();
});
It works..
Monday, 19 August 2013
Add into video tag using jQPlayer
Add into video tag using jQPlayer
I am struggling with the problem of adding ontimeupdate="timeUpdate()"
into video tag (HTML5). I am using jQPlayer which is HTML5 Video Player
Plugin for jQuery.
https://github.com/vebersol/jQPlayer
I cannot seem to figure out how to do this. Your help will be much
appreciated.
Thank you
I am struggling with the problem of adding ontimeupdate="timeUpdate()"
into video tag (HTML5). I am using jQPlayer which is HTML5 Video Player
Plugin for jQuery.
https://github.com/vebersol/jQPlayer
I cannot seem to figure out how to do this. Your help will be much
appreciated.
Thank you
Posting a form via PHP over email
Posting a form via PHP over email
I'm after a little advice. Someone has asked if I can help with a form
system they use. Basically at the moment a user fills out a form (large
over 150 fields) when submitting it is all validated with jQuery and PHP
then it shows the form on a confirmation page. At this point the user is
asked to Print off the form and give it to the client. The data is not
stored anywhere. I have been asked if I can adapt it to email the form and
that's where I need some advice. The form at the moment is all formatted
with CSS and like I said it has over 150 fields. The client wants that
exact report emailed so will I need to covert every line of code for which
there are 650 odd lines to php so it can be emailed? The code is a mix of
HTML, JavaScript PHP Echoing values and then of course css stylesheets are
attached.
I suppose what I am basically asking is there any easier / better /
quicker way of emailing the whole page with values?
Thanks for your help.
I'm after a little advice. Someone has asked if I can help with a form
system they use. Basically at the moment a user fills out a form (large
over 150 fields) when submitting it is all validated with jQuery and PHP
then it shows the form on a confirmation page. At this point the user is
asked to Print off the form and give it to the client. The data is not
stored anywhere. I have been asked if I can adapt it to email the form and
that's where I need some advice. The form at the moment is all formatted
with CSS and like I said it has over 150 fields. The client wants that
exact report emailed so will I need to covert every line of code for which
there are 650 odd lines to php so it can be emailed? The code is a mix of
HTML, JavaScript PHP Echoing values and then of course css stylesheets are
attached.
I suppose what I am basically asking is there any easier / better /
quicker way of emailing the whole page with values?
Thanks for your help.
Android/Qt Access Databases
Android/Qt Access Databases
I need to access the file,
/data/data/com.google.android.music/databases/music.db
It's currently denied. I'm using Qt to target the Android platform. I
think it's easier to just use Qt's methods to read the database than
fiddle with the JNI/NDK.
The default permissions, which aren't working out for me, are as follows-
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Many thanks for any help!
I need to access the file,
/data/data/com.google.android.music/databases/music.db
It's currently denied. I'm using Qt to target the Android platform. I
think it's easier to just use Qt's methods to read the database than
fiddle with the JNI/NDK.
The default permissions, which aren't working out for me, are as follows-
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Many thanks for any help!
jquery inputmask hiding numbers when skipping optional mask (second one)
jquery inputmask hiding numbers when skipping optional mask (second one)
I have a simple mask for phone number with optional numbers(due to
different formats for various cities) . I have applied mask 9[9][9] 999[9]
9999. Where [9] is optional.
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/Scripts/jquery-ui-1.8.24.js"></script>
<script src="~/Scripts/jquery.inputmask.js"></script>
<input id="Phone1"/>
<script type="text/javascript" >
$(function() {
$("#Phone1").inputmask("9[9][9] 999[9] 9999");
});
</script>
This works fine for the numbers: 1 123 1234, 12 123 1234 etc.
but when I enter 123 123{space bar} the input field value become 12___ and
last 4 digits digits I entered disappear. Is this a bug or am I not using
correctly? This happens only when I have two groups of optional numbers
and I enter all the numbers in the first group and press spacebar for the
second optional number. Please help.
I have a simple mask for phone number with optional numbers(due to
different formats for various cities) . I have applied mask 9[9][9] 999[9]
9999. Where [9] is optional.
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/Scripts/jquery-ui-1.8.24.js"></script>
<script src="~/Scripts/jquery.inputmask.js"></script>
<input id="Phone1"/>
<script type="text/javascript" >
$(function() {
$("#Phone1").inputmask("9[9][9] 999[9] 9999");
});
</script>
This works fine for the numbers: 1 123 1234, 12 123 1234 etc.
but when I enter 123 123{space bar} the input field value become 12___ and
last 4 digits digits I entered disappear. Is this a bug or am I not using
correctly? This happens only when I have two groups of optional numbers
and I enter all the numbers in the first group and press spacebar for the
second optional number. Please help.
jboss 4.x startup failed when http requests coming
jboss 4.x startup failed when http requests coming
Jboss 4.3 application published on the web if we have http requests during
application server startup then application start could failed with
absolutely different errors like:
too many files opened, too many sockets opened, ...
what is the easiest way to redirect all requests to some static page until
all applications started?
the problem is not reproduced on last jboss versions, but we can't change
it right now.
below is the part of the log we can see that just after the server is
started socket connection pool is already full.
2013-08-19 16:29:27,760 INFO deploy, ctxPath=/prototype,
warUrl=.../tmp/deploy/tmp5399168696811762709prototype-exp.war/
{org.jboss.web.tomcat.service.TomcatD
2013-08-19 16:29:31,719 INFO deploy, ctxPath=/svn,
warUrl=.../tmp/deploy/tmp8105161025572918667svn-exp.war/
{org.jboss.web.tomcat.service.TomcatDeployer}
2013-08-19 16:29:32,495 INFO Initializing Spring root
WebApplicationContext
{org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/svn]}
2013-08-19 16:29:37,691 INFO Initializing Spring FrameworkServlet
'sventon'
{org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/svn]}
2013-08-19 16:29:38,843 INFO Starting Coyote HTTP/1.1 on
http-0.0.0.0-8080 {org.apache.coyote.http11.Http11Protocol}
2013-08-19 16:29:38,883 INFO Starting Coyote AJP/1.3 on ajp-0.0.0.0-8009
{org.apache.coyote.ajp.AjpProtocol}
2013-08-19 16:29:39,380 INFO JBoss (MX MicroKernel) [4.2.3.GA (build:
SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 2m:8s:911ms
{org.jboss.system.serv
2013-08-19 16:29:40,759 ERROR Socket accept failed
{org.apache.tomcat.util.net.JIoEndpoint}
java.net.SocketException: Too many open files
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
at java.net.ServerSocket.implAccept(ServerSocket.java:453)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at
org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)
at
org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:309)
at java.lang.Thread.run(Thread.java:619)
2013-08-19 16:29:41,644 ERROR Socket accept failed
{org.apache.tomcat.util.net.JIoEndpoint}
java.net.SocketException: Too many open files
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
at java.net.ServerSocket.implAccept(ServerSocket.java:453)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at
org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)
at
org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:309)
at java.lang.Thread.run(Thread.java:619)
Jboss 4.3 application published on the web if we have http requests during
application server startup then application start could failed with
absolutely different errors like:
too many files opened, too many sockets opened, ...
what is the easiest way to redirect all requests to some static page until
all applications started?
the problem is not reproduced on last jboss versions, but we can't change
it right now.
below is the part of the log we can see that just after the server is
started socket connection pool is already full.
2013-08-19 16:29:27,760 INFO deploy, ctxPath=/prototype,
warUrl=.../tmp/deploy/tmp5399168696811762709prototype-exp.war/
{org.jboss.web.tomcat.service.TomcatD
2013-08-19 16:29:31,719 INFO deploy, ctxPath=/svn,
warUrl=.../tmp/deploy/tmp8105161025572918667svn-exp.war/
{org.jboss.web.tomcat.service.TomcatDeployer}
2013-08-19 16:29:32,495 INFO Initializing Spring root
WebApplicationContext
{org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/svn]}
2013-08-19 16:29:37,691 INFO Initializing Spring FrameworkServlet
'sventon'
{org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/svn]}
2013-08-19 16:29:38,843 INFO Starting Coyote HTTP/1.1 on
http-0.0.0.0-8080 {org.apache.coyote.http11.Http11Protocol}
2013-08-19 16:29:38,883 INFO Starting Coyote AJP/1.3 on ajp-0.0.0.0-8009
{org.apache.coyote.ajp.AjpProtocol}
2013-08-19 16:29:39,380 INFO JBoss (MX MicroKernel) [4.2.3.GA (build:
SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 2m:8s:911ms
{org.jboss.system.serv
2013-08-19 16:29:40,759 ERROR Socket accept failed
{org.apache.tomcat.util.net.JIoEndpoint}
java.net.SocketException: Too many open files
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
at java.net.ServerSocket.implAccept(ServerSocket.java:453)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at
org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)
at
org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:309)
at java.lang.Thread.run(Thread.java:619)
2013-08-19 16:29:41,644 ERROR Socket accept failed
{org.apache.tomcat.util.net.JIoEndpoint}
java.net.SocketException: Too many open files
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
at java.net.ServerSocket.implAccept(ServerSocket.java:453)
at java.net.ServerSocket.accept(ServerSocket.java:421)
at
org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)
at
org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:309)
at java.lang.Thread.run(Thread.java:619)
Sunday, 18 August 2013
Accessing properties of another object in Rails
Accessing properties of another object in Rails
Currently I am working on CRM app as a demo project. Currently I'm having
difficulty wrapping my head around how to access properties of one object
from another. I'm trying to do something along the lines of:
<%= note.client.first_name %>
In this case, I have a note for each client and the appropriate
association set up between the two. The models look like so:
class Note < ActiveRecord::Base
belongs_to :client
belongs_to :user
end
class Client < ActiveRecord::Base
has_many :users
has_many :notes
end
And the databases look like so:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :first_name
t.string :last_name
t.string :designation
t.string :phone
t.string :email
t.string :password_digest
t.timestamps
end
end
end
Is there any easy way of accessing the :first_name property of the client
id associated with the note?
Currently I am working on CRM app as a demo project. Currently I'm having
difficulty wrapping my head around how to access properties of one object
from another. I'm trying to do something along the lines of:
<%= note.client.first_name %>
In this case, I have a note for each client and the appropriate
association set up between the two. The models look like so:
class Note < ActiveRecord::Base
belongs_to :client
belongs_to :user
end
class Client < ActiveRecord::Base
has_many :users
has_many :notes
end
And the databases look like so:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :first_name
t.string :last_name
t.string :designation
t.string :phone
t.string :email
t.string :password_digest
t.timestamps
end
end
end
Is there any easy way of accessing the :first_name property of the client
id associated with the note?
Can Kendo Grid be always in edit mode?
Can Kendo Grid be always in edit mode?
Does anyone know if the kendo grid could be always set to edit mode at all
times?
We don't want the user to click on a cell or a button to activate the edit
mode. We want it the widgets to be displayed and available at all times.
Is it possible at all?
Does anyone know if the kendo grid could be always set to edit mode at all
times?
We don't want the user to click on a cell or a button to activate the edit
mode. We want it the widgets to be displayed and available at all times.
Is it possible at all?
Django prefetch_related, prefetching instances of through module in manytomany relation
Django prefetch_related, prefetching instances of through module in
manytomany relation
I have some model classes which structures are as follows:
class Reaction(models.Model):
participants = models.ManyToManyField(Participant,
through=ReactionParticipant,
related_name='reactions')
category = models.ForeignKey(Category,
related_name='reactions')
name = models.CharField(max_length=200)
description = models.TextField(blank=True, null=True)
disabled = models.BooleanField(default=False)
def get_reactant(self):
rps = self.reactionparticipants.select_related()
.filter(disabled=False,
participant_type=u'reactant')
if rps.exists():
rp = rps[0]
participant = rp.participant.reactant_persian_name
return participant
class Participant(models.Model):
reactant_english_name = models.TextField(null=True, blank=True)
operational_group = models.ForeignKey(OperationalGroup,
related_name='participants')
disabled = models.BooleanField(default=False)
class ReactionParticipant(models.Model):
reaction = models.ForeignKey('Reaction',
related_name='reactionparticipants')
participant = models.ForeignKey('Participant',
related_name='reactionparticipants')
participant_type = models.CharField(choices=CHOICES, max_length=70)
disabled = models.BooleanField(default=False)
When rendering my view, i do sth like this :
reactions =
Reaction.objects.filter(**filter_kwargs).prefetch_related('reactionparticipants')
return render_to_response(... , {'reactions:reactions, ... } ,context ... )
And inside my templates, i do sth like :
<div class="table-col col-13">{{ reaction.get_reactant }}</div>
That call for every row, is resulting in 2 new database hits when
get_reactant is called, which is not really good.
I guess I've prefetched all through model instances where i say :
.filter(**filter_kwargs).prefetch_related('reactionparticipants')
Does this have to do anything with the filter i've made inside my
get_reactant def ? Any ideas how to remove these database hits ?
Thanks in advance
(Anyways, This is for saving thousands of chemical reactions which all
have at most 2 reactants and one product )
manytomany relation
I have some model classes which structures are as follows:
class Reaction(models.Model):
participants = models.ManyToManyField(Participant,
through=ReactionParticipant,
related_name='reactions')
category = models.ForeignKey(Category,
related_name='reactions')
name = models.CharField(max_length=200)
description = models.TextField(blank=True, null=True)
disabled = models.BooleanField(default=False)
def get_reactant(self):
rps = self.reactionparticipants.select_related()
.filter(disabled=False,
participant_type=u'reactant')
if rps.exists():
rp = rps[0]
participant = rp.participant.reactant_persian_name
return participant
class Participant(models.Model):
reactant_english_name = models.TextField(null=True, blank=True)
operational_group = models.ForeignKey(OperationalGroup,
related_name='participants')
disabled = models.BooleanField(default=False)
class ReactionParticipant(models.Model):
reaction = models.ForeignKey('Reaction',
related_name='reactionparticipants')
participant = models.ForeignKey('Participant',
related_name='reactionparticipants')
participant_type = models.CharField(choices=CHOICES, max_length=70)
disabled = models.BooleanField(default=False)
When rendering my view, i do sth like this :
reactions =
Reaction.objects.filter(**filter_kwargs).prefetch_related('reactionparticipants')
return render_to_response(... , {'reactions:reactions, ... } ,context ... )
And inside my templates, i do sth like :
<div class="table-col col-13">{{ reaction.get_reactant }}</div>
That call for every row, is resulting in 2 new database hits when
get_reactant is called, which is not really good.
I guess I've prefetched all through model instances where i say :
.filter(**filter_kwargs).prefetch_related('reactionparticipants')
Does this have to do anything with the filter i've made inside my
get_reactant def ? Any ideas how to remove these database hits ?
Thanks in advance
(Anyways, This is for saving thousands of chemical reactions which all
have at most 2 reactants and one product )
Can org-mode babel tangle produce leiningen directories?
Can org-mode babel tangle produce leiningen directories?
We want to automate the production of a Leiningen project tree entirely
from an org-mode babel file. We want to do this so that we can also create
beautiful, typeset documentation via org-latex-export-to-pdf. We want no
less than full literate programming in Clojure from org-mode.
The following command:
$ lein new ex1
produces a tree that looks like this:
ex1
ex1/.gitignore
ex1/doc
ex1/doc/intro.md
ex1/project.clj
ex1/README.md
ex1/resources
ex1/src
ex1/src/ex1
ex1/src/ex1/core.clj
ex1/test
ex1/test/ex1
ex1/test/ex1/core_test.clj
We want to do the identical thing just by running org-babel-tangle, and no
more, in our org-mode buffer in emacs.
A difficulty arises: whereas tangle is happy to produce files in existing
subdirectories like src and test, it seems reluctant to produce the
subdirectories if they don't exist. That means we must create the
directory structure by some other means -- unless we can get tangle to do
it for us, and that's the subject of this StackOverflow question.
There are six files in the directory structure created by Leiningen. I can
remove them all and re-create them from my org-file with BEGIN_SRC blocks
such as the following
#+BEGIN_SRC clojure :tangle ./ex1/src/ex1/core.clj
(ns ex1.core)
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
#+END_SRC
Notice particularly the name of the subdirectory path
#+BEGIN_SRC clojure :tangle ./ex1/src/ex1/core.clj
All is well if our directory structure already exists. org-mode's tangle
will create or update all six files described above and create new files
in any existing directory. We don't know how to get tangle to produce the
directories; it complains that there is no such directory.
A copy of the desired .org file can be found here if you would like more
details.
We want to automate the production of a Leiningen project tree entirely
from an org-mode babel file. We want to do this so that we can also create
beautiful, typeset documentation via org-latex-export-to-pdf. We want no
less than full literate programming in Clojure from org-mode.
The following command:
$ lein new ex1
produces a tree that looks like this:
ex1
ex1/.gitignore
ex1/doc
ex1/doc/intro.md
ex1/project.clj
ex1/README.md
ex1/resources
ex1/src
ex1/src/ex1
ex1/src/ex1/core.clj
ex1/test
ex1/test/ex1
ex1/test/ex1/core_test.clj
We want to do the identical thing just by running org-babel-tangle, and no
more, in our org-mode buffer in emacs.
A difficulty arises: whereas tangle is happy to produce files in existing
subdirectories like src and test, it seems reluctant to produce the
subdirectories if they don't exist. That means we must create the
directory structure by some other means -- unless we can get tangle to do
it for us, and that's the subject of this StackOverflow question.
There are six files in the directory structure created by Leiningen. I can
remove them all and re-create them from my org-file with BEGIN_SRC blocks
such as the following
#+BEGIN_SRC clojure :tangle ./ex1/src/ex1/core.clj
(ns ex1.core)
(defn foo
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
#+END_SRC
Notice particularly the name of the subdirectory path
#+BEGIN_SRC clojure :tangle ./ex1/src/ex1/core.clj
All is well if our directory structure already exists. org-mode's tangle
will create or update all six files described above and create new files
in any existing directory. We don't know how to get tangle to produce the
directories; it complains that there is no such directory.
A copy of the desired .org file can be found here if you would like more
details.
Subscribe to:
Posts (Atom)