Will changing an events Time-Zone affect other people on shared events?
If I were to normalize an EKEvent 's startDate property using a
NSFormatter or by setting the time zone with
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"hh:mm a"];
[formatter setTimeZone:[NSTimeZone systemTimeZone]];
event.startDate = [formatter dateFromString:[NSString
stringWithFormat:@"%@", [event.startDate]]];
and I later make a change to that event requiring me to call
[self.event.eventStore saveEvent:currentEvent span:EKSpanThisEvent
commit:YES error:nil];
Would it override the time-zone on the server, causing issues for the
person (whom uses GCal) in another state that originally created that
shared calendar event, or is it just a local change?
Saturday, 31 August 2013
iOS how to use .p12 certification?
iOS how to use .p12 certification?
my teacher only gave me a .p12 certification but no developer account. How
can I use it to test my app on the real device? Even publish the app?
Thanks!
my teacher only gave me a .p12 certification but no developer account. How
can I use it to test my app on the real device? Even publish the app?
Thanks!
How to get /, /article to map to same action in PHP Slim
How to get /, /article to map to same action in PHP Slim
I want to map two routes : / and /articles to the same action list_articles.
I tried using this code but it's not working.
$app->get('/:route', function () use($app, $layout) {
echo "test"
})->conditions(array("route" => "(/|articles)"))->name('list_articles');
What am I typing wrong?
I want to map two routes : / and /articles to the same action list_articles.
I tried using this code but it's not working.
$app->get('/:route', function () use($app, $layout) {
echo "test"
})->conditions(array("route" => "(/|articles)"))->name('list_articles');
What am I typing wrong?
Android R file not building when declare-styleable of type enum is added
Android R file not building when declare-styleable of type enum is added
Recently my Android workspace isn't compiling correctly anymore (the R
file isn't created). After trying the usual like cleaning i started
searching deeper. I discovered that when i comment out the items int my
attrs.xml file of the type declare-styleable with the format="enum" the R
file is build but not when they are present (not commented out). Is there
a recent change or something with the way you have the declare enums or
something? Here a piece of the project
working
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<!-- <attr name="swipeMode" format="enum"> -->
<!-- <enum name="none" value="0" /> -->
<!-- <enum name="both" value="1" /> -->
<!-- <enum name="right" value="2" /> -->
<!-- <enum name="left" value="3" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionLeft" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionRight" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeDrawableChecked" format="reference" /> -->
<!-- <attr name="swipeDrawableUnchecked" format="reference" /> -->
</declare-styleable>
</resources>
not working
<?xml version="1.0" encoding="utf-8"?>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<attr name="swipeMode" format="enum">
<enum name="none" value="0" />
<enum name="both" value="1" />
<enum name="right" value="2" />
<enum name="left" value="3" />
</attr>
<attr name="swipeActionLeft" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeActionRight" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeDrawableChecked" format="reference" />
<attr name="swipeDrawableUnchecked" format="reference" />
</declare-styleable>
Recently my Android workspace isn't compiling correctly anymore (the R
file isn't created). After trying the usual like cleaning i started
searching deeper. I discovered that when i comment out the items int my
attrs.xml file of the type declare-styleable with the format="enum" the R
file is build but not when they are present (not commented out). Is there
a recent change or something with the way you have the declare enums or
something? Here a piece of the project
working
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<!-- <attr name="swipeMode" format="enum"> -->
<!-- <enum name="none" value="0" /> -->
<!-- <enum name="both" value="1" /> -->
<!-- <enum name="right" value="2" /> -->
<!-- <enum name="left" value="3" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionLeft" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionRight" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeDrawableChecked" format="reference" /> -->
<!-- <attr name="swipeDrawableUnchecked" format="reference" /> -->
</declare-styleable>
</resources>
not working
<?xml version="1.0" encoding="utf-8"?>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<attr name="swipeMode" format="enum">
<enum name="none" value="0" />
<enum name="both" value="1" />
<enum name="right" value="2" />
<enum name="left" value="3" />
</attr>
<attr name="swipeActionLeft" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeActionRight" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeDrawableChecked" format="reference" />
<attr name="swipeDrawableUnchecked" format="reference" />
</declare-styleable>
H1's are floating into post above in Wordpress theme
H1's are floating into post above in Wordpress theme
I just noticed that on the Wordpress theme I created the H1 article titles
are floating up into the subsequent article when you start to shrink the
browser window. I can't seem to find the reason for this. Any insights
would be greatly appreciated.
ul.info li, .excerpt, .post-link {
float: left;
}
The styles above seem to be pushing the title of the article up but if I
remove it then "posted by, written on, date" all turn into a horizontal
list. Which I don't want.
I don't know if they're related by I noticed when I look at single post
pages if I shrink the browser window the content of the article flows off
the screen.
Thanks in advance for you help everyone. Really confused.
I just noticed that on the Wordpress theme I created the H1 article titles
are floating up into the subsequent article when you start to shrink the
browser window. I can't seem to find the reason for this. Any insights
would be greatly appreciated.
ul.info li, .excerpt, .post-link {
float: left;
}
The styles above seem to be pushing the title of the article up but if I
remove it then "posted by, written on, date" all turn into a horizontal
list. Which I don't want.
I don't know if they're related by I noticed when I look at single post
pages if I shrink the browser window the content of the article flows off
the screen.
Thanks in advance for you help everyone. Really confused.
When can I get away with using short variable names?
When can I get away with using short variable names?
I often find that people stress using variable names that appropriately
and accurately describe what the variable is trying to convey. This is
also often very hard to do in a word or two. I find it true that though
longer names are typically more accepted, they often lead to code that is
even less readable because of mere clutter. I find that once I understand
what a variable conveys, the name is merely an alias for that
understanding, and that the name itself does not necessarily make a
difference. In that case, I would personally almost always prefer shorter
names to longer ones.
Is it ever appropriate to use short variable names? Is it acceptable to
use names that aren't necessarily understood without looking at the rest
of the algorithm or class, but perhaps which are commented at declaration
of the variable or beginning of the algorithm? Or is it generally always
preferable to have longer names that immediately and definitively convey
meaning?
I often find that people stress using variable names that appropriately
and accurately describe what the variable is trying to convey. This is
also often very hard to do in a word or two. I find it true that though
longer names are typically more accepted, they often lead to code that is
even less readable because of mere clutter. I find that once I understand
what a variable conveys, the name is merely an alias for that
understanding, and that the name itself does not necessarily make a
difference. In that case, I would personally almost always prefer shorter
names to longer ones.
Is it ever appropriate to use short variable names? Is it acceptable to
use names that aren't necessarily understood without looking at the rest
of the algorithm or class, but perhaps which are commented at declaration
of the variable or beginning of the algorithm? Or is it generally always
preferable to have longer names that immediately and definitively convey
meaning?
How insert a image in canvas and after insert text in these canvas
How insert a image in canvas and after insert text in these canvas
I'm trying to insert a image in a canvas and after I want to insert a
input text in the same canvas but I cant do it, Anybody can help me?
thanks.
I'm trying to insert a image in a canvas and after I want to insert a
input text in the same canvas but I cant do it, Anybody can help me?
thanks.
How to use a subquery inside another subquery with three tables in mysql?
How to use a subquery inside another subquery with three tables in mysql?
I have three tables in my database, see the structure below :
users
uid | fname | date_joined
1 | john | 2013-08-25 01:00:00
2 | rock | 2013-08-26 01:00:00
3 | jane | 2013-08-27 01:00:00
questions
qid | uid
1 | 1
2 | 1
3 | 2
4 | 3
5 | 3
6 | 1
7 | 1
8 | 2
9 | 2
followers
fid | qid
1 | 2
2 | 1
3 | 2
4 | 1
5 | 2
6 | 3
7 | 2
user table contains all user related fields
questions table contains all question related data with the foreign key uid
followers table stores the information of how many times a question followed
What I want my query to return is :
unique uid,
fname
question count for each user
follower count for each user
I have written a query and its working fine and returning the records as I
want but the followers count is always 0. Here is my query :
SELECT
u.uid, u.fname, u.date_joined ,
(SELECT COUNT(*) FROM questions WHERE questions.uid = u.uid) AS
question_count,
(SELECT COUNT(*) FROM followers WHERE followers.qid IN (
SELECT GROUP_CONCAT(qid) FROM questions WHERE questions.uid = u.uid
)
) AS follow_count
FROM epc_user AS u
ORDRE BY follow_count DESC, question_count DESC, date_joined DESC
I tried several different combinations but none of them worked, maybe I am
writing a wrong query or its not possible to use subquery in another
subquery, whatever it may be. I just want to know if its possible or not
and if possible, can any one help me figuring it out.
Any help would be highly appreciated.
Thanks.
I have three tables in my database, see the structure below :
users
uid | fname | date_joined
1 | john | 2013-08-25 01:00:00
2 | rock | 2013-08-26 01:00:00
3 | jane | 2013-08-27 01:00:00
questions
qid | uid
1 | 1
2 | 1
3 | 2
4 | 3
5 | 3
6 | 1
7 | 1
8 | 2
9 | 2
followers
fid | qid
1 | 2
2 | 1
3 | 2
4 | 1
5 | 2
6 | 3
7 | 2
user table contains all user related fields
questions table contains all question related data with the foreign key uid
followers table stores the information of how many times a question followed
What I want my query to return is :
unique uid,
fname
question count for each user
follower count for each user
I have written a query and its working fine and returning the records as I
want but the followers count is always 0. Here is my query :
SELECT
u.uid, u.fname, u.date_joined ,
(SELECT COUNT(*) FROM questions WHERE questions.uid = u.uid) AS
question_count,
(SELECT COUNT(*) FROM followers WHERE followers.qid IN (
SELECT GROUP_CONCAT(qid) FROM questions WHERE questions.uid = u.uid
)
) AS follow_count
FROM epc_user AS u
ORDRE BY follow_count DESC, question_count DESC, date_joined DESC
I tried several different combinations but none of them worked, maybe I am
writing a wrong query or its not possible to use subquery in another
subquery, whatever it may be. I just want to know if its possible or not
and if possible, can any one help me figuring it out.
Any help would be highly appreciated.
Thanks.
Friday, 30 August 2013
Run a PHP script on server start
Run a PHP script on server start
I'm writing a PHP script (OK, it's a daemon worker) that I'd like to run
in the background, and it follows the following pseudo-code:
do {
// stuff
sleep(60*30); // 30 minutes
} while(1);
Now, how can I set this baby up to run automatically in the event that the
server gets restarted. I don't need to worry about state, since everything
is stored in the MySQL DB - and it should just be able to pick up right
where it left off.
I'm using an Ubuntu 12.04 x64 server, on AWS (if that matters).
Thanks!
I'm writing a PHP script (OK, it's a daemon worker) that I'd like to run
in the background, and it follows the following pseudo-code:
do {
// stuff
sleep(60*30); // 30 minutes
} while(1);
Now, how can I set this baby up to run automatically in the event that the
server gets restarted. I don't need to worry about state, since everything
is stored in the MySQL DB - and it should just be able to pick up right
where it left off.
I'm using an Ubuntu 12.04 x64 server, on AWS (if that matters).
Thanks!
Thursday, 29 August 2013
I am getting an "Unexpected token" error when trying to do JSON.parse on a simple object
I am getting an "Unexpected token" error when trying to do JSON.parse on a
simple object
I have the following code:
var a = localStorageService.get('selectedQuestionSortOrder');
$scope.selectedQuestionOrderBy = JSON.parse(a);
var b = 99;
When I look with the debugger I see:
a
-
Object
key: "questionStatusId"
label: "status"
After I execute the second line I get the message:
SyntaxError: Unexpected token o
at Object.parse (native)
at new <anonymous>
(http://127.0.0.1:81/Content/app/admin/controllers/question-controller.js:71:47)
at d (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:28:304)
at Object.instantiate
(http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:28:434)
at $get (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:53:326)
at http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:44:274
at n (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:7:74)
at k (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:44:139)
at e (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:40:139)
at http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:39:205
Can someone give me some advice as to what might be going wrong?
simple object
I have the following code:
var a = localStorageService.get('selectedQuestionSortOrder');
$scope.selectedQuestionOrderBy = JSON.parse(a);
var b = 99;
When I look with the debugger I see:
a
-
Object
key: "questionStatusId"
label: "status"
After I execute the second line I get the message:
SyntaxError: Unexpected token o
at Object.parse (native)
at new <anonymous>
(http://127.0.0.1:81/Content/app/admin/controllers/question-controller.js:71:47)
at d (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:28:304)
at Object.instantiate
(http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:28:434)
at $get (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:53:326)
at http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:44:274
at n (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:7:74)
at k (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:44:139)
at e (http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:40:139)
at http://127.0.0.1:81/Scripts/angular-v1.1.5.min.js:39:205
Can someone give me some advice as to what might be going wrong?
When iam trying to run spring example i am facing the following exception
When iam trying to run spring example i am facing the following exception
SEVERE: Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class [spring.test.StockValueFetcher] for bean with name 'stockBean'
defined in ServletContext resource [/WEB-INF/applicationContext.xml];
nested exception is java.lang.ClassNotFoundException:
spring.test.StockValueFetcher
and my applicationContext.xml is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="stockBean" class="spring.test.StockValueFetcher">
</bean>
</beans>
i have searched for the same in stackoverflow and other sites but i
couldnot find any helpful solution
SEVERE: Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class [spring.test.StockValueFetcher] for bean with name 'stockBean'
defined in ServletContext resource [/WEB-INF/applicationContext.xml];
nested exception is java.lang.ClassNotFoundException:
spring.test.StockValueFetcher
and my applicationContext.xml is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="stockBean" class="spring.test.StockValueFetcher">
</bean>
</beans>
i have searched for the same in stackoverflow and other sites but i
couldnot find any helpful solution
Wednesday, 28 August 2013
Conditional Compilation #ifdef
Conditional Compilation #ifdef
Hello could anyone give me an example showing how do we use conditional
compilation for different versions of operating system? for example I want
a program that works depending on the version win32 or win64 or on other
platform
Hello could anyone give me an example showing how do we use conditional
compilation for different versions of operating system? for example I want
a program that works depending on the version win32 or win64 or on other
platform
Using RequireJS for Recursive Map
Using RequireJS for Recursive Map
I'm using requireJS for my web application, and I'm stumped on how to use
requireJS to build a recursive map of the same object. For example, my
object is called 'section', and I want to create a child below each using
the same object:
Section
> Section
> Section
> (etc...)
Here is the contents of section.js:
define(['jquery'], function($) {
children = [];
function init() {
require(['jquery', 'section'], function($, section) {
children.push(section.init(mediator, this));
});
return children;
}
return {
init: init
}
}
This has resulted in a self-referencing mess. I don't know how I can
create a new instance of section for the new, child section.
I'm using requireJS for my web application, and I'm stumped on how to use
requireJS to build a recursive map of the same object. For example, my
object is called 'section', and I want to create a child below each using
the same object:
Section
> Section
> Section
> (etc...)
Here is the contents of section.js:
define(['jquery'], function($) {
children = [];
function init() {
require(['jquery', 'section'], function($, section) {
children.push(section.init(mediator, this));
});
return children;
}
return {
init: init
}
}
This has resulted in a self-referencing mess. I don't know how I can
create a new instance of section for the new, child section.
Verified google places listing not showing up in google search
Verified google places listing not showing up in google search
Even though my Google Places listing has been verified nad my google+ page
is verified and both are connected to my webpage, there is no map or
indication that they are connected when i search for my page.
The company name is Ivanka moda, and when i search for it this is what i
get: Ivanka moda Search
But when i search for my neighbour's bike shop i get this (the highlighted
areas are the ones that i want): Ciklo Centar Search
To make thing even more confusing, when i search on a mobile phone the
oposite happens. The map for Ivanka moda turns up, but for Ciklo Centar it
doesn't.
The question is how to make the map and the link with the pin turn up on a
desktop search too?
Thank you!
Even though my Google Places listing has been verified nad my google+ page
is verified and both are connected to my webpage, there is no map or
indication that they are connected when i search for my page.
The company name is Ivanka moda, and when i search for it this is what i
get: Ivanka moda Search
But when i search for my neighbour's bike shop i get this (the highlighted
areas are the ones that i want): Ciklo Centar Search
To make thing even more confusing, when i search on a mobile phone the
oposite happens. The map for Ivanka moda turns up, but for Ciklo Centar it
doesn't.
The question is how to make the map and the link with the pin turn up on a
desktop search too?
Thank you!
301 redirect with ? (question mark) not working in htacces
301 redirect with ? (question mark) not working in htacces
This is probably an easy question, but we can not find why the 301 is not
working. When we have a url with a question mark the 301 redirect in our
.htacces is not working. For example:
/order/order.html?AddID=1078&Rand=666171759380936096
so: Redirect 301 /order/order.html?AddID=1078&Rand=666171759380936096
http://www.domain.nl
In our webmaster tools we have 8000 url's with the same structure
/order/order.html?AddID=.... that say 404 not found. We want to 301
redirect them to the homepage, but we get a 404 not found page instead.
when we use the same redirect with only /order/order.html he is redirected
correct.
This is probably an easy question, but we can not find why the 301 is not
working. When we have a url with a question mark the 301 redirect in our
.htacces is not working. For example:
/order/order.html?AddID=1078&Rand=666171759380936096
so: Redirect 301 /order/order.html?AddID=1078&Rand=666171759380936096
http://www.domain.nl
In our webmaster tools we have 8000 url's with the same structure
/order/order.html?AddID=.... that say 404 not found. We want to 301
redirect them to the homepage, but we get a 404 not found page instead.
when we use the same redirect with only /order/order.html he is redirected
correct.
Reducing Cassandra heap usage
Reducing Cassandra heap usage
Using Cassandra 1.1.5, have been battling slow write performance, JVM GC
lockups, ... in our logs, we see this rather frequently:
WARN [ScheduledTasks:1] 2013-08-28 09:28:51,983 GCInspector.java (line
145) Heap is 0.8589157615524839 full. You may need to reduce memtable
and/or cache sizes. Cassandra will now flush up to the two largest
memtables to free up memory. Adjust flush_largest_memtables_at threshold
in cassandra.yaml if you don't want Cassandra to do this automatically
The largest memtable in our system (as observed through JConsole) runs up
to about 20,000,000 data size (which I assume is ~20MB, if those are
bytes).
If it matters, this column family has almost 1B rows in it.
flush_largest_memtables_at is set to .75, but it seems we hit that almost
continuously. The pattern for this table is heavy writes, and very little
reads. (essentially a clustered log)
Row cache is disabled, key cache is set to 40MB. We have 8GB of heap
associated to the JVM (24GB of physical).
Heap usage is between 6.5 and 7.5GB, mostly.
Advice on what to look at to reduce heap usage here? Surely it's not a
factor of how much data we have in the cluster, is it? (We have gobs of
disk available across this cluster)
Using Cassandra 1.1.5, have been battling slow write performance, JVM GC
lockups, ... in our logs, we see this rather frequently:
WARN [ScheduledTasks:1] 2013-08-28 09:28:51,983 GCInspector.java (line
145) Heap is 0.8589157615524839 full. You may need to reduce memtable
and/or cache sizes. Cassandra will now flush up to the two largest
memtables to free up memory. Adjust flush_largest_memtables_at threshold
in cassandra.yaml if you don't want Cassandra to do this automatically
The largest memtable in our system (as observed through JConsole) runs up
to about 20,000,000 data size (which I assume is ~20MB, if those are
bytes).
If it matters, this column family has almost 1B rows in it.
flush_largest_memtables_at is set to .75, but it seems we hit that almost
continuously. The pattern for this table is heavy writes, and very little
reads. (essentially a clustered log)
Row cache is disabled, key cache is set to 40MB. We have 8GB of heap
associated to the JVM (24GB of physical).
Heap usage is between 6.5 and 7.5GB, mostly.
Advice on what to look at to reduce heap usage here? Surely it's not a
factor of how much data we have in the cluster, is it? (We have gobs of
disk available across this cluster)
How do I stop a form from submitting?
How do I stop a form from submitting?
How to I stop a form from submitting? I have some validation on my form,
and if the the input isn't correct, then the form should't submit... In my
HTML i have this when clicking submit:
<a href="#"
onclick="setTimeout(function(){document.getElementById('form_4').submit()},
1000);" style="position:static" class="btn-more">Vælg</a>
And the my script looks like this:
$("#form_4 a.btn-more").click(function (e) {
//Validate required fields
for (i = 0; i < required.length; i++) {
var input = $('#' + required[i]);
if ((input.val() == "") || (input.val() == emptyerror)) {
input.addClass("needsfilled");
input.val(emptyerror);
errornotice.fadeIn(750);
e.stopPropagation();
return false;
} else {
input.removeClass("needsfilled");
}
}
//if any inputs on the page have the class 'needsfilled' the form will
not submit
if ($(":input").hasClass("needsfilled")) {
return false;
} else {
errornotice.hide();
return true;
}
});
How to I stop a form from submitting? I have some validation on my form,
and if the the input isn't correct, then the form should't submit... In my
HTML i have this when clicking submit:
<a href="#"
onclick="setTimeout(function(){document.getElementById('form_4').submit()},
1000);" style="position:static" class="btn-more">Vælg</a>
And the my script looks like this:
$("#form_4 a.btn-more").click(function (e) {
//Validate required fields
for (i = 0; i < required.length; i++) {
var input = $('#' + required[i]);
if ((input.val() == "") || (input.val() == emptyerror)) {
input.addClass("needsfilled");
input.val(emptyerror);
errornotice.fadeIn(750);
e.stopPropagation();
return false;
} else {
input.removeClass("needsfilled");
}
}
//if any inputs on the page have the class 'needsfilled' the form will
not submit
if ($(":input").hasClass("needsfilled")) {
return false;
} else {
errornotice.hide();
return true;
}
});
Using a microcontroller to turn on LED strip electronics.stackexchange.com
Using a microcontroller to turn on LED strip – electronics.stackexchange.com
I have 60 leds that came in a strip. One meter of the led strip requires:
400 milliamps 12 volts I want to control these LEDs with micro controller.
I'm thinking of using a TIP120 and a ...
I have 60 leds that came in a strip. One meter of the led strip requires:
400 milliamps 12 volts I want to control these LEDs with micro controller.
I'm thinking of using a TIP120 and a ...
Tuesday, 27 August 2013
float object is not callable
float object is not callable
I have multiple for-loops inside a while loop in my Python code. For the
first iteration, everything works fine. For the second iteration of the
while-loop, I get the following error:
File ".\simulated_annealing.py", line 209, in for ii in range(0, 8, 1) :
TypeError: 'float' object is not callable
Below is the relevant piece of my code:
while numpy.absolute(FcostOld) >= 0.001 and l <= L :
Fx = []
Fy = []
Fz = []
V = []
ii = 0
for ii in range(0, 8, 1) : # ... LINE 209
Fx.append([])
Fy.append([])
Fz.append([])
for j in range(0, 13, 1) :
Fx[ii].append(0)
Fy[ii].append(0)
Fz[ii].append(0)
V.append(0.0)
print "\n l = ", l
j = 0
print "j = ", j
i = 0
for i in range(0, 8) :
print "i = ", i
"""
V[i] = 0.0
for j in range(0, 13, 1) :
Fx[i][j] = 0.0
Fy[i][j] = 0.0
Fz[i][j] = 0.0
"""
for j in range(0, 6, 1) :
for k in range(0, Natoms, 1) :
dxxC = x[i][j] - Layer15[k][0]
dyyC = y[i][j] - Layer15[k][1]
dzzC = zC - Layer15[k][2]
rrC = numpy.sqrt(dxxC*dxxC + dyyC*dyyC + dzzC*dzzC)
if rrC <= rcut :
V[i] = V[i] + VrealC(rrC, DeC, alphaC, rC, s6)
Fx[i][j] = Fx[i][j] + frealC(rrC, DeC, alphaC, rC, dxxC, s6)
Fy[i][j] = Fy[i][j] + frealC(rrC, DeC, alphaC, rC, dyyC, s6)
Fz[i][j] = Fz[i][j] + frealC(rrC, DeC, alphaC, rC, dzzC, s6)
for j in range(6, 12, 1) :
for k in range(0, Natoms, 1) :
dxxH = x[i][j] - Layer15[k][0]
dyyH = y[i][j] - Layer15[k][1]
dzzH = zH - Layer15[k][2]
rrH = numpy.sqrt(dxxH*dxxH + dyyH*dyyH +dzzH*dzzH)
if rrH <= rcut :
V[i] = V[i] + VrealH(rrH, DeH, alphaH, rH, s6)
Fx[i][j] = Fx[i][j] + frealH(rrH, DeH, alphaH, rH, dxxH, s6)
Fy[i][j] = Fy[i][j] + frealH(rrH, DeH, alphaH, rH, dyyH, s6)
Fz[i][j] = Fz[i][j] + frealH(rrH, DeH, alphaH, rH, dzzH, s6)
j = 12
for k in range(0, Natoms, 1) :
dxxX = x[i][j] - Layer15[k][0]
dyyX = y[i][j] - Layer15[k][1]
dzzX = zX - Layer15[k][2]
rrX = numpy.sqrt(dxxX*dxxX + dyyX*dyyX +dzzX*dzzX)
if rrX <= rcutX :
V[i] = V[i] + VrealX(rrH, DeH, alphaH, rH, s6)
Fx[i][j] = Fx[i][j] + frealX(rrX, DeX, alphaX, rX, dxxX, s6)
Fy[i][j] = Fy[i][j] + frealX(rrX, DeX, alphaX, rX, dyyX, s6)
Fz[i][j] = Fz[i][j] + frealX(rrX, DeX, alphaX, rX, dzzX, s6)
print "i = ", i
if flag == False :
FcostOld_V = 0 * numpy.sqrt( sum(numpy.power(V[n]-VTarget[n], 2) for n
in range(0,8)) ) / numpy.sqrt( sum((V[n]*V[n]) for n in range(0,8)) )
FcostOld_F = numpy.absolute( sum(Fz[n][m] for n in range(0,8) for m in
range(0,13)) ) / 8
FcostOld = FcostOld_V + FcostOld_F
if flag == True :
FcostNew_V = 0 * numpy.sqrt( sum(numpy.power(V[n]-VTarget[n], 2) for n
in range(0,8)) ) / numpy.sqrt( sum((V[n]*V[n]) for n in range(0,8)) )
FcostNew_F = numpy.absolute( sum(Fz[n][m] for n in range(0,8) for m in
range(0,13)) ) / 8
FcostNew = FcostNew_V + FcostNew_F
if (FcostNew - FcostOld) < 0:
s6Old = s6
FcostOld = FcostNew
DeCOld = DeC
alphaCOld = alphaC
rCOld = rC
DeHOld = DeH
alphaHOld = alphaH
rHOld = rH
DeXOld = DeX
alphaXOld = alphaX
rXOld = rX
if (FcostNew - FcostOld) >= 0 :
P = numpy.exp( -(FcostNew-FcostOld) / kT )
r0 = numpy.random.rand()
if r0 < P :
s6Old = s6
FcostOld = FcostNew
DeCOld = DeC
alphaCOld = alphaC
rCOld = rC
DeHOld = DeH
alphaHOld = alphaH
rHOld = rH
DeXOld = DeX
alphaXOld = alphaX
rXOld = rX
flag = True
range = 0.1
DeC = NewParameter(DeCOld, range)
alphaC = NewParameter(alphaCOld, 2*range)
rC = NewParameter(rC, range/2)
DeH = NewParameter(DeHOld, 5*range)
alphaH = NewParameter(alphaHOld, 2*range)
rH = NewParameter(rH, range/3)
DeX = NewParameter(DeXOld, range)
alphaX = NewParameter(alphaXOld, 2*range)
rX = NewParameter(rX, range/2)
s6 = NewParameter(s6Old, range)
if numpy.mod(l,1) == 0 :
print "\nFcost = ", FcostOld
print Fx[7]
print " l = ", l
l = l + 1
I have multiple for-loops inside a while loop in my Python code. For the
first iteration, everything works fine. For the second iteration of the
while-loop, I get the following error:
File ".\simulated_annealing.py", line 209, in for ii in range(0, 8, 1) :
TypeError: 'float' object is not callable
Below is the relevant piece of my code:
while numpy.absolute(FcostOld) >= 0.001 and l <= L :
Fx = []
Fy = []
Fz = []
V = []
ii = 0
for ii in range(0, 8, 1) : # ... LINE 209
Fx.append([])
Fy.append([])
Fz.append([])
for j in range(0, 13, 1) :
Fx[ii].append(0)
Fy[ii].append(0)
Fz[ii].append(0)
V.append(0.0)
print "\n l = ", l
j = 0
print "j = ", j
i = 0
for i in range(0, 8) :
print "i = ", i
"""
V[i] = 0.0
for j in range(0, 13, 1) :
Fx[i][j] = 0.0
Fy[i][j] = 0.0
Fz[i][j] = 0.0
"""
for j in range(0, 6, 1) :
for k in range(0, Natoms, 1) :
dxxC = x[i][j] - Layer15[k][0]
dyyC = y[i][j] - Layer15[k][1]
dzzC = zC - Layer15[k][2]
rrC = numpy.sqrt(dxxC*dxxC + dyyC*dyyC + dzzC*dzzC)
if rrC <= rcut :
V[i] = V[i] + VrealC(rrC, DeC, alphaC, rC, s6)
Fx[i][j] = Fx[i][j] + frealC(rrC, DeC, alphaC, rC, dxxC, s6)
Fy[i][j] = Fy[i][j] + frealC(rrC, DeC, alphaC, rC, dyyC, s6)
Fz[i][j] = Fz[i][j] + frealC(rrC, DeC, alphaC, rC, dzzC, s6)
for j in range(6, 12, 1) :
for k in range(0, Natoms, 1) :
dxxH = x[i][j] - Layer15[k][0]
dyyH = y[i][j] - Layer15[k][1]
dzzH = zH - Layer15[k][2]
rrH = numpy.sqrt(dxxH*dxxH + dyyH*dyyH +dzzH*dzzH)
if rrH <= rcut :
V[i] = V[i] + VrealH(rrH, DeH, alphaH, rH, s6)
Fx[i][j] = Fx[i][j] + frealH(rrH, DeH, alphaH, rH, dxxH, s6)
Fy[i][j] = Fy[i][j] + frealH(rrH, DeH, alphaH, rH, dyyH, s6)
Fz[i][j] = Fz[i][j] + frealH(rrH, DeH, alphaH, rH, dzzH, s6)
j = 12
for k in range(0, Natoms, 1) :
dxxX = x[i][j] - Layer15[k][0]
dyyX = y[i][j] - Layer15[k][1]
dzzX = zX - Layer15[k][2]
rrX = numpy.sqrt(dxxX*dxxX + dyyX*dyyX +dzzX*dzzX)
if rrX <= rcutX :
V[i] = V[i] + VrealX(rrH, DeH, alphaH, rH, s6)
Fx[i][j] = Fx[i][j] + frealX(rrX, DeX, alphaX, rX, dxxX, s6)
Fy[i][j] = Fy[i][j] + frealX(rrX, DeX, alphaX, rX, dyyX, s6)
Fz[i][j] = Fz[i][j] + frealX(rrX, DeX, alphaX, rX, dzzX, s6)
print "i = ", i
if flag == False :
FcostOld_V = 0 * numpy.sqrt( sum(numpy.power(V[n]-VTarget[n], 2) for n
in range(0,8)) ) / numpy.sqrt( sum((V[n]*V[n]) for n in range(0,8)) )
FcostOld_F = numpy.absolute( sum(Fz[n][m] for n in range(0,8) for m in
range(0,13)) ) / 8
FcostOld = FcostOld_V + FcostOld_F
if flag == True :
FcostNew_V = 0 * numpy.sqrt( sum(numpy.power(V[n]-VTarget[n], 2) for n
in range(0,8)) ) / numpy.sqrt( sum((V[n]*V[n]) for n in range(0,8)) )
FcostNew_F = numpy.absolute( sum(Fz[n][m] for n in range(0,8) for m in
range(0,13)) ) / 8
FcostNew = FcostNew_V + FcostNew_F
if (FcostNew - FcostOld) < 0:
s6Old = s6
FcostOld = FcostNew
DeCOld = DeC
alphaCOld = alphaC
rCOld = rC
DeHOld = DeH
alphaHOld = alphaH
rHOld = rH
DeXOld = DeX
alphaXOld = alphaX
rXOld = rX
if (FcostNew - FcostOld) >= 0 :
P = numpy.exp( -(FcostNew-FcostOld) / kT )
r0 = numpy.random.rand()
if r0 < P :
s6Old = s6
FcostOld = FcostNew
DeCOld = DeC
alphaCOld = alphaC
rCOld = rC
DeHOld = DeH
alphaHOld = alphaH
rHOld = rH
DeXOld = DeX
alphaXOld = alphaX
rXOld = rX
flag = True
range = 0.1
DeC = NewParameter(DeCOld, range)
alphaC = NewParameter(alphaCOld, 2*range)
rC = NewParameter(rC, range/2)
DeH = NewParameter(DeHOld, 5*range)
alphaH = NewParameter(alphaHOld, 2*range)
rH = NewParameter(rH, range/3)
DeX = NewParameter(DeXOld, range)
alphaX = NewParameter(alphaXOld, 2*range)
rX = NewParameter(rX, range/2)
s6 = NewParameter(s6Old, range)
if numpy.mod(l,1) == 0 :
print "\nFcost = ", FcostOld
print Fx[7]
print " l = ", l
l = l + 1
this tropo code in ruby want to convert in php
this tropo code in ruby want to convert in php
This is tropo code and I want to convert it to php code. It is used in a
webapi of tropo. It will work as a connector between phono and tropo. I
have to made a web to phone app with two way communication.
transfer $currentCall.getHeader("x-numbertodial")
require "net/http"
Thread.new do
sleep 600 # Note: Sleep is in seconds so 600 = 10 minutes
http = Net::HTTP.new "api.tropo.com"
request = Net::HTTP::Get.new
"/1.0/sessions/#{$currentCall.sessionId}/signals?action=signal&value=limitreached"
response = http.request request
end
say "hold please while we transfer your call."
transfer $currentCall.getHeader("x-numbertodial"), :allowsignals =>
"limitreached"
say "your limit has been reached."
phone = $currentCall.getHeader "x-numbertodial"
blocked = [
/^+?1?8[024]9/,
/^+?1?26[48]/,
/^+?1?24[26]/,
/^+?1?34[05]/,
/^+?1?[62]84/,
/^+?1?67[10]/,
/^+?1?78[47]/,
/^+?1?8[024]9/,
/^+?1?86[89]/,
/^+?1?441/,
/^+?1?473/,
/^+?1?664/,
/^+?1?649/,
/^+?1?721/,
/^+?1?758/,
/^+?1?767/,
/^+?1?876/,
/^+?1?939/
]
block_call = blocked.any? { |x| phone =~ x }
if block_call
say "calls to this area code are blocked."
else
say "hold please while we transfer your call."
transfer phone, :allowsignals => "limitreached"
say "your limit has been reached."
end
This is tropo code and I want to convert it to php code. It is used in a
webapi of tropo. It will work as a connector between phono and tropo. I
have to made a web to phone app with two way communication.
transfer $currentCall.getHeader("x-numbertodial")
require "net/http"
Thread.new do
sleep 600 # Note: Sleep is in seconds so 600 = 10 minutes
http = Net::HTTP.new "api.tropo.com"
request = Net::HTTP::Get.new
"/1.0/sessions/#{$currentCall.sessionId}/signals?action=signal&value=limitreached"
response = http.request request
end
say "hold please while we transfer your call."
transfer $currentCall.getHeader("x-numbertodial"), :allowsignals =>
"limitreached"
say "your limit has been reached."
phone = $currentCall.getHeader "x-numbertodial"
blocked = [
/^+?1?8[024]9/,
/^+?1?26[48]/,
/^+?1?24[26]/,
/^+?1?34[05]/,
/^+?1?[62]84/,
/^+?1?67[10]/,
/^+?1?78[47]/,
/^+?1?8[024]9/,
/^+?1?86[89]/,
/^+?1?441/,
/^+?1?473/,
/^+?1?664/,
/^+?1?649/,
/^+?1?721/,
/^+?1?758/,
/^+?1?767/,
/^+?1?876/,
/^+?1?939/
]
block_call = blocked.any? { |x| phone =~ x }
if block_call
say "calls to this area code are blocked."
else
say "hold please while we transfer your call."
transfer phone, :allowsignals => "limitreached"
say "your limit has been reached."
end
X-Robots-Tag Wordpress Subsites
X-Robots-Tag Wordpress Subsites
I am wrestling a bit with implementing a flexible X-Robots-Tag solution
with Wordpress subsites. The issue is that I'd like to be using some
subsites for development and would like to tell any engines to index but
don't display any pages. My understanding is that X-Robots-Tag should take
care of this.
I've tried (our_dev is the subsite):
SetEnvIf Request_URI "^/our_dev/(.*)" is_dev
Header set X-Robots-Tag "noindex, nofollow, noarchive" env=is_dev
and many variations of RewriteRules but the URL isn't changing (which
keeps creating an infinite loop); I am just trying to set a header based
on a particular state.
Any help would be wonderful.
I am wrestling a bit with implementing a flexible X-Robots-Tag solution
with Wordpress subsites. The issue is that I'd like to be using some
subsites for development and would like to tell any engines to index but
don't display any pages. My understanding is that X-Robots-Tag should take
care of this.
I've tried (our_dev is the subsite):
SetEnvIf Request_URI "^/our_dev/(.*)" is_dev
Header set X-Robots-Tag "noindex, nofollow, noarchive" env=is_dev
and many variations of RewriteRules but the URL isn't changing (which
keeps creating an infinite loop); I am just trying to set a header based
on a particular state.
Any help would be wonderful.
I want an output as follow [ABCDE], [AB,BC,CD,DE],[ABC,BCD,CDE],[ABCD,BCDE],[ABCDE]
I want an output as follow [ABCDE],
[AB,BC,CD,DE],[ABC,BCD,CDE],[ABCD,BCDE],[ABCDE]
Please look at my code and give me solution asap.
public void algoOne()
{
String str= "A B C D E";
String delims = " ";
StringTokenizer st = new StringTokenizer(str, delims);
while(st.hasMoreTokens())
{
String temp = st.nextToken();
tokensArray.add(temp);
finalStr += " "+ temp;
count = tokensArray.size();
}
System.out.println("Different values of Tokens : " + tokensArray +" <>
"+ count);
}
I want to read the tokens in following way:
[ABCDE], [AB,BC,CD,DE],[ABC,BCD,CDE],[ABCD,BCDE],[ABCDE]
[AB,BC,CD,DE],[ABC,BCD,CDE],[ABCD,BCDE],[ABCDE]
Please look at my code and give me solution asap.
public void algoOne()
{
String str= "A B C D E";
String delims = " ";
StringTokenizer st = new StringTokenizer(str, delims);
while(st.hasMoreTokens())
{
String temp = st.nextToken();
tokensArray.add(temp);
finalStr += " "+ temp;
count = tokensArray.size();
}
System.out.println("Different values of Tokens : " + tokensArray +" <>
"+ count);
}
I want to read the tokens in following way:
[ABCDE], [AB,BC,CD,DE],[ABC,BCD,CDE],[ABCD,BCDE],[ABCDE]
Error in respose while using soapclient to check mydomain availability
Error in respose while using soapclient to check mydomain availability
0 down vote
I am getting following resut when putting _getLastRequest(). stdClass
Object ( [CheckDomainAvailabilityResult] => stdClass Object ( [ResultCode]
=> 201 [ResultMsg] => Authentication Failed: Invalid Authentication
Parameters [TxID] => b06f30a0-3e46-442d-94de-42b6e135f4ab
[AvailabilityStatus] => 3 [LaunchPhase] => GA [DropDate] =>
[BackOrderAvailable] => )
) How canI get rid of the error [AvailabilityStatusDescr] => ErrorOccurred
0 down vote
I am getting following resut when putting _getLastRequest(). stdClass
Object ( [CheckDomainAvailabilityResult] => stdClass Object ( [ResultCode]
=> 201 [ResultMsg] => Authentication Failed: Invalid Authentication
Parameters [TxID] => b06f30a0-3e46-442d-94de-42b6e135f4ab
[AvailabilityStatus] => 3 [LaunchPhase] => GA [DropDate] =>
[BackOrderAvailable] => )
) How canI get rid of the error [AvailabilityStatusDescr] => ErrorOccurred
U-Boot. Where does it all begin?
U-Boot. Where does it all begin?
Newbie question here.
I'm looking at a u-boot boardfile, and it has many functions in it. For
example; board_mmc_init(), enet_board_init(), setup_splash_img(), etc.
Most of these functions don't get called from within the boardfile. They
get called from somewhere else. But I can't figure out where.
In Linux kernel boardfiles there's a machine structure. In there we might
have .init_machine = myboard_init. Then myboard_init(void) will call other
functions which will in turn call other functions. I find this style easy
to read.
My question is; does u-boot have an equivalent of .init_machine? Where do
I look to see where everything 'starts'? Who calls all those loose
functions thrown together inside a u-boot boardfile?
-Andy
Newbie question here.
I'm looking at a u-boot boardfile, and it has many functions in it. For
example; board_mmc_init(), enet_board_init(), setup_splash_img(), etc.
Most of these functions don't get called from within the boardfile. They
get called from somewhere else. But I can't figure out where.
In Linux kernel boardfiles there's a machine structure. In there we might
have .init_machine = myboard_init. Then myboard_init(void) will call other
functions which will in turn call other functions. I find this style easy
to read.
My question is; does u-boot have an equivalent of .init_machine? Where do
I look to see where everything 'starts'? Who calls all those loose
functions thrown together inside a u-boot boardfile?
-Andy
Add Swipe Gesture to display the next Item in the Detailed View
Add Swipe Gesture to display the next Item in the Detailed View
From the Collection View I have passed the details I want via segue to the
Detailed View Controller.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
SportsCollectionViewCell *selectedCell = (SportsCollectionViewCell *)sender;
SportsBrowserViewController *targetVC = (SportsBrowserViewController *)
[segue destinationViewController];
targetVC.targetURL = selectedCell.targetURL;
targetVC.sdesc = selectedCell.description.text;
targetVC.stitle = selectedCell.title.text;
targetVC.simage = selectedCell.image.image;
targetVC.scat = selectedCell.category.text;
targetVC.sdate = selectedCell.date.text;
}
I want to now add a swipe gesture to the destination view controller so
that I can get to the next article without having to go back to the main
page. I have added the following to set up the gesture.
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(swipeHandler:)];
[recognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
[[self view] addGestureRecognizer:recognizer];
}
-(IBAction)swipeHandler:(UISwipeGestureRecognizer *)sender{
NSLog(@"SWIPE");
}
However, I do not know how to move from here. Could someone point me in
the right direction.
From the Collection View I have passed the details I want via segue to the
Detailed View Controller.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
SportsCollectionViewCell *selectedCell = (SportsCollectionViewCell *)sender;
SportsBrowserViewController *targetVC = (SportsBrowserViewController *)
[segue destinationViewController];
targetVC.targetURL = selectedCell.targetURL;
targetVC.sdesc = selectedCell.description.text;
targetVC.stitle = selectedCell.title.text;
targetVC.simage = selectedCell.image.image;
targetVC.scat = selectedCell.category.text;
targetVC.sdate = selectedCell.date.text;
}
I want to now add a swipe gesture to the destination view controller so
that I can get to the next article without having to go back to the main
page. I have added the following to set up the gesture.
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(swipeHandler:)];
[recognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
[[self view] addGestureRecognizer:recognizer];
}
-(IBAction)swipeHandler:(UISwipeGestureRecognizer *)sender{
NSLog(@"SWIPE");
}
However, I do not know how to move from here. Could someone point me in
the right direction.
Monday, 26 August 2013
Safe trackable links from 301 redirect
Safe trackable links from 301 redirect
I want to create a something where a user can submit a link
(http://www.example.com?key=value) then be returned with a new link which
will redirect to the link provided in a way that is traceable.
(http://trackedlink.com/[trackid]).
I was thinking about adding a get value to the end of the link redirect
eg, http://www.example.com?key=value&trackid=[trackid]
My concern is that although extremely unlikely this may override an
already set get value (trackid). Is there any truely safe way to do this?
I want to create a something where a user can submit a link
(http://www.example.com?key=value) then be returned with a new link which
will redirect to the link provided in a way that is traceable.
(http://trackedlink.com/[trackid]).
I was thinking about adding a get value to the end of the link redirect
eg, http://www.example.com?key=value&trackid=[trackid]
My concern is that although extremely unlikely this may override an
already set get value (trackid). Is there any truely safe way to do this?
How to get the values in abcl using Java
How to get the values in abcl using Java
I am search the API for handling the values in abcl using Java.
It works when a fucntion return a list or a string .
When it return a values I only can fetch the first return value,I do not
konw how to fetch the other values.
I am search the API for handling the values in abcl using Java.
It works when a fucntion return a list or a string .
When it return a values I only can fetch the first return value,I do not
konw how to fetch the other values.
Search for string in each open worksheet
Search for string in each open worksheet
I would like to use values from each instance of the string FindString to
populate textboxes in UserForm1.
I am getting the unique WorkSheet per textbox. But the rest of the values
are from the sheet active when I run the module.
This mean the string Rng isn't looping through the WorkSheets, but staying
with the initial WorkSheet. How can I remedy this?
Public Sub FindString()
Dim FindString As Variant
Dim Rng As Range
Dim SheetName As String
Dim ws As Worksheet
Dim i As Integer
Application.ScreenUpdating = False
SheetName = ActiveSheet.Name
FindString = Cells(ActiveCell.Row, 1).Value
FindString = InputBox("Enter the case number to search for:", "Case ID",
FindString)
If FindString = "" Then Exit Sub
If FindString = False Then Exit Sub
i = 1
For Each ws In Worksheets
If ws.Name Like "Lang*" Then
With ws
If Trim(FindString) <> "" Then
With Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
UserForm1.Controls("TextBox" & i) = ws.Name & vbTab & _
Rng.Offset(0, 2).Value & vbTab & _
Rng.Offset(0, 5).Value & vbTab & _
Rng.Offset(0, 6).Value & vbTab & _
Rng.Offset(0, 7).Value & vbTab & _
Rng.Offset(0, 8).Value
i = i + 1
Else: GoTo NotFound
End If
End With
End If
End With
End If
Next ws
Sheets(SheetName).Activate
Application.ScreenUpdating = True
UserForm1.Show
Exit Sub
NotFound: Sheets(SheetName).Activate Application.ScreenUpdating = True
MsgBox "Case ID not found" Exit Sub
End Sub
I would like to use values from each instance of the string FindString to
populate textboxes in UserForm1.
I am getting the unique WorkSheet per textbox. But the rest of the values
are from the sheet active when I run the module.
This mean the string Rng isn't looping through the WorkSheets, but staying
with the initial WorkSheet. How can I remedy this?
Public Sub FindString()
Dim FindString As Variant
Dim Rng As Range
Dim SheetName As String
Dim ws As Worksheet
Dim i As Integer
Application.ScreenUpdating = False
SheetName = ActiveSheet.Name
FindString = Cells(ActiveCell.Row, 1).Value
FindString = InputBox("Enter the case number to search for:", "Case ID",
FindString)
If FindString = "" Then Exit Sub
If FindString = False Then Exit Sub
i = 1
For Each ws In Worksheets
If ws.Name Like "Lang*" Then
With ws
If Trim(FindString) <> "" Then
With Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
UserForm1.Controls("TextBox" & i) = ws.Name & vbTab & _
Rng.Offset(0, 2).Value & vbTab & _
Rng.Offset(0, 5).Value & vbTab & _
Rng.Offset(0, 6).Value & vbTab & _
Rng.Offset(0, 7).Value & vbTab & _
Rng.Offset(0, 8).Value
i = i + 1
Else: GoTo NotFound
End If
End With
End If
End With
End If
Next ws
Sheets(SheetName).Activate
Application.ScreenUpdating = True
UserForm1.Show
Exit Sub
NotFound: Sheets(SheetName).Activate Application.ScreenUpdating = True
MsgBox "Case ID not found" Exit Sub
End Sub
Keep radio button selected after a form submit
Keep radio button selected after a form submit
I am using below code to keep the radio button selection after a form
submission, but it keep resetting to the last button after form submission
<input type="radio" name="button" value="Yes" <?php
if(isset($_POST['button']) == 'Yes') echo ' checked="checked"';?> />Yes
<input type="radio" name="button" value="No" <?php
if(isset($_POST['button']) == 'No') echo ' checked="checked"';?> />No
How can I keep the selection ?
I am using below code to keep the radio button selection after a form
submission, but it keep resetting to the last button after form submission
<input type="radio" name="button" value="Yes" <?php
if(isset($_POST['button']) == 'Yes') echo ' checked="checked"';?> />Yes
<input type="radio" name="button" value="No" <?php
if(isset($_POST['button']) == 'No') echo ' checked="checked"';?> />No
How can I keep the selection ?
Eclipse relative path to server
Eclipse relative path to server
I want to have an absolute portable version of eclipse. Everything like
the path to java or the workspace works fine.
The only thing which makes a problem ist the Tomcat Server. I need a way
to give Eclipse the relativ path of the Tomcat directory on the USB stick.
Is there a way to do that?
I want to have an absolute portable version of eclipse. Everything like
the path to java or the workspace works fine.
The only thing which makes a problem ist the Tomcat Server. I need a way
to give Eclipse the relativ path of the Tomcat directory on the USB stick.
Is there a way to do that?
Cyrillic in glossary/acronym entry
Cyrillic in glossary/acronym entry
I want to define acronyms and terms in Bulgarian. Unfortunately, when I do
so, LaTeX gives a whole lot of errors and do not compile. Anything to
help?
I want to define acronyms and terms in Bulgarian. Unfortunately, when I do
so, LaTeX gives a whole lot of errors and do not compile. Anything to
help?
Catch the click that unselects all in a selectable
Catch the click that unselects all in a selectable
Im using jQuery selectable plugin. Im looking for a way to catch the click
event that unselects all, by clicking inside the selectable.
I have been reading the code for this plugin but I cant find where the
magic happens.
If I catch the click event on the selectable, it works if I use a
setTimeout, but I would rather skip that.
$(selector).selectable();
$(selector).click(function () {
setTimeout(function () {
//Deselect of all items have occured
}, 1);
});
Im using jQuery selectable plugin. Im looking for a way to catch the click
event that unselects all, by clicking inside the selectable.
I have been reading the code for this plugin but I cant find where the
magic happens.
If I catch the click event on the selectable, it works if I use a
setTimeout, but I would rather skip that.
$(selector).selectable();
$(selector).click(function () {
setTimeout(function () {
//Deselect of all items have occured
}, 1);
});
Assertion failure in -[UINib initWithNibName:directory:bundle:]
Assertion failure in -[UINib initWithNibName:directory:bundle:]
I get the error with below message when I touched uitextfield in view
controller.
msg: * Assertion failure in -[UINib initWithNibName:directory:bundle:],
/SourceCache/UIKit/UIKit-2380.17/UINib.m:96 2013-08-26 15:58:43.547
Xpointer[1023:907] * Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Invalid parameter not
satisfying: (name != nil) && ([name length] > 0)'
This error show and always crash everywhere(all view controller).
But I can't fix it.
Help me anyone.
I get the error with below message when I touched uitextfield in view
controller.
msg: * Assertion failure in -[UINib initWithNibName:directory:bundle:],
/SourceCache/UIKit/UIKit-2380.17/UINib.m:96 2013-08-26 15:58:43.547
Xpointer[1023:907] * Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Invalid parameter not
satisfying: (name != nil) && ([name length] > 0)'
This error show and always crash everywhere(all view controller).
But I can't fix it.
Help me anyone.
Sunday, 25 August 2013
How to count lap in GLES2
How to count lap in GLES2
private void initOnScreenControls() {
final AnalogOnScreenControl analogOnScreenControl = new
AnalogOnScreenControl(0, CAMERA_HEIGHT -
this.mOnScreenControlBaseTextureRegion.getHeight(), this.mCamera,
this.mOnScreenControlBaseTextureRegion,
this.mOnScreenControlKnobTextureRegion, 0.1f,
this.getVertexBufferObjectManager(), new
IAnalogOnScreenControlListener() {
@Override
public void onControlChange(final BaseOnScreenControl
pBaseOnScreenControl, final float pValueX, final float pValueY) {
final Body carBody = RacerGameActivity.this.mCarBody;
final Vector2 velocity = Vector2Pool.obtain(pValueX * 5,
pValueY * 5);
carBody.setLinearVelocity(velocity);
Vector2Pool.recycle(velocity);
final float rotationInRad = (float)Math.atan2(-pValueX, pValueY);
carBody.setTransform(carBody.getWorldCenter(), rotationInRad);
RacerGameActivity.this.mCar.setRotation(MathUtils.radToDeg(rotationInRad));
}
@Override
public void onControlClick(final AnalogOnScreenControl
pAnalogOnScreenControl) {
/* Nothing. */
}
});
analogOnScreenControl.getControlBase().setBlendFunction(GLES20.GL_SRC_ALPHA,
GLES20.GL_ONE_MINUS_SRC_ALPHA);
analogOnScreenControl.getControlBase().setAlpha(0.5f);
// analogOnScreenControl.getControlBase().setScaleCenter(0, 128);
// analogOnScreenControl.getControlBase().setScale(0.75f);
// analogOnScreenControl.getControlKnob().setScale(0.75f);
analogOnScreenControl.refreshControlKnobPosition();
this.mScene.setChildScene(analogOnScreenControl);
}
I control car by AnalogOnScreenControl. But, how to i can count Lap of car
when it run around screen because AnalogOnScreenControl alway update new
coodinates. I want to finish lap at x = 64 and y < 64 and count time to
finish lap. Anyone have idea?
private void initOnScreenControls() {
final AnalogOnScreenControl analogOnScreenControl = new
AnalogOnScreenControl(0, CAMERA_HEIGHT -
this.mOnScreenControlBaseTextureRegion.getHeight(), this.mCamera,
this.mOnScreenControlBaseTextureRegion,
this.mOnScreenControlKnobTextureRegion, 0.1f,
this.getVertexBufferObjectManager(), new
IAnalogOnScreenControlListener() {
@Override
public void onControlChange(final BaseOnScreenControl
pBaseOnScreenControl, final float pValueX, final float pValueY) {
final Body carBody = RacerGameActivity.this.mCarBody;
final Vector2 velocity = Vector2Pool.obtain(pValueX * 5,
pValueY * 5);
carBody.setLinearVelocity(velocity);
Vector2Pool.recycle(velocity);
final float rotationInRad = (float)Math.atan2(-pValueX, pValueY);
carBody.setTransform(carBody.getWorldCenter(), rotationInRad);
RacerGameActivity.this.mCar.setRotation(MathUtils.radToDeg(rotationInRad));
}
@Override
public void onControlClick(final AnalogOnScreenControl
pAnalogOnScreenControl) {
/* Nothing. */
}
});
analogOnScreenControl.getControlBase().setBlendFunction(GLES20.GL_SRC_ALPHA,
GLES20.GL_ONE_MINUS_SRC_ALPHA);
analogOnScreenControl.getControlBase().setAlpha(0.5f);
// analogOnScreenControl.getControlBase().setScaleCenter(0, 128);
// analogOnScreenControl.getControlBase().setScale(0.75f);
// analogOnScreenControl.getControlKnob().setScale(0.75f);
analogOnScreenControl.refreshControlKnobPosition();
this.mScene.setChildScene(analogOnScreenControl);
}
I control car by AnalogOnScreenControl. But, how to i can count Lap of car
when it run around screen because AnalogOnScreenControl alway update new
coodinates. I want to finish lap at x = 64 and y < 64 and count time to
finish lap. Anyone have idea?
preventing R nested list from being converted to named vector
preventing R nested list from being converted to named vector
I want to create a nested list, for example,
> L <- NULL
> L$a$b <- 1
> L
$a
$a$b
[1] 1
Since I need to do assignment in loops, I have to use the brackets instead
of the dollar, for example,
> L <- NULL
> a <- "a"
> b <- "b"
> L[[a]][[b]] <- 1
> L
a
1
> b <- "b1"
> L[[a]][[b]] <- 1
Error in L[[a]][[b]] <- 1 :
more elements supplied than there are to replace
That is out of my expectation: L becomes a named vector rather than a
nested list. However if the assigned value is a vector whose length
exceeds 1, the problem will disappear,
> L <- NULL
> L[[a]][[b]] <- 1:2
> L
$a
$a$b
[1] 1 2
> b <- "b1"
> L[[a]][[b]] <- 1
> L
$a
$a$b
[1] 1 2
$a$b1
[1] 1
Most of my assignments are longer than 1, that is the reason my code
seemingly worked but at times failed strangely. I want to know if there is
any way to fix this unexpected behavior, thanks.
I want to create a nested list, for example,
> L <- NULL
> L$a$b <- 1
> L
$a
$a$b
[1] 1
Since I need to do assignment in loops, I have to use the brackets instead
of the dollar, for example,
> L <- NULL
> a <- "a"
> b <- "b"
> L[[a]][[b]] <- 1
> L
a
1
> b <- "b1"
> L[[a]][[b]] <- 1
Error in L[[a]][[b]] <- 1 :
more elements supplied than there are to replace
That is out of my expectation: L becomes a named vector rather than a
nested list. However if the assigned value is a vector whose length
exceeds 1, the problem will disappear,
> L <- NULL
> L[[a]][[b]] <- 1:2
> L
$a
$a$b
[1] 1 2
> b <- "b1"
> L[[a]][[b]] <- 1
> L
$a
$a$b
[1] 1 2
$a$b1
[1] 1
Most of my assignments are longer than 1, that is the reason my code
seemingly worked but at times failed strangely. I want to know if there is
any way to fix this unexpected behavior, thanks.
Change background lists, independently from each other
Change background lists, independently from each other
Background
I would like to vary the style of multiple itemized lists on the same
page, independently from one another.
Code
A short example:
\setuppapersize[A5]
\setupcolors[state=start]
% Itemized in a bullet list by default.
\definestartstop[RegularList][
before={\startitemize[joinedup]},
after={\stopitemize},
]
\defineframed[StyleBulletFramed][
frame=off,
height=0.5em,
width=0.5em,
background=color,
backgroundcolor=red,
]
% First level of indenting (regular bullets) use the bullet style.
\setupitemize[1][broad][
stopper=,
width=\zeropoint,
symbol=,
command=\StyleBulletFramed{},
]
\define[3]\regularlist{\item #1 #2 #3}
\startnotmode[ModeCompactInstructions]
\definestartstop[Instructions][
before={\startitemize[n,joinedup]},
after={\stopitemize},
]
% First level of indenting (regular bullets) use the bullet style.
\setupitemize[1][][
stopper=,
width=\zeropoint,
% ???
%command={\StyleBulletFramed[width=1em,height=1em]{}\hskip0.5em},
]
\define[1]\instruction{\item #1.}
\starttext
\startbodymatter
Chemicals
\startRegularList
\regularlist{80}{ml}{water}
\regularlist{20}{ml}{sodium}
\stopRegularList
Instructions
\startInstructions
\instruction{Drop sodium into water}
\instruction{Run away}
\stopInstructions
\stopbodymatter
\stoptext
This produces:
Problem
The red bullets in the first list are perfect for the first list. However,
the red bullets have issues in the second list:
The bullet size should be larger (large enough to hold a two-digit number)
The bullets should be behind the number
Questions
The first question has me stumped; the second question I can probably use
\defineitemlist to resolve. How would you:
ensure the number is drawn on top of the bullet?
format the lists independently (i.e., larger bullet in second list)?
Missing Resource
I thought I could define a named group, but the \defineitemgroup
documentation is non-existent.
Background
I would like to vary the style of multiple itemized lists on the same
page, independently from one another.
Code
A short example:
\setuppapersize[A5]
\setupcolors[state=start]
% Itemized in a bullet list by default.
\definestartstop[RegularList][
before={\startitemize[joinedup]},
after={\stopitemize},
]
\defineframed[StyleBulletFramed][
frame=off,
height=0.5em,
width=0.5em,
background=color,
backgroundcolor=red,
]
% First level of indenting (regular bullets) use the bullet style.
\setupitemize[1][broad][
stopper=,
width=\zeropoint,
symbol=,
command=\StyleBulletFramed{},
]
\define[3]\regularlist{\item #1 #2 #3}
\startnotmode[ModeCompactInstructions]
\definestartstop[Instructions][
before={\startitemize[n,joinedup]},
after={\stopitemize},
]
% First level of indenting (regular bullets) use the bullet style.
\setupitemize[1][][
stopper=,
width=\zeropoint,
% ???
%command={\StyleBulletFramed[width=1em,height=1em]{}\hskip0.5em},
]
\define[1]\instruction{\item #1.}
\starttext
\startbodymatter
Chemicals
\startRegularList
\regularlist{80}{ml}{water}
\regularlist{20}{ml}{sodium}
\stopRegularList
Instructions
\startInstructions
\instruction{Drop sodium into water}
\instruction{Run away}
\stopInstructions
\stopbodymatter
\stoptext
This produces:
Problem
The red bullets in the first list are perfect for the first list. However,
the red bullets have issues in the second list:
The bullet size should be larger (large enough to hold a two-digit number)
The bullets should be behind the number
Questions
The first question has me stumped; the second question I can probably use
\defineitemlist to resolve. How would you:
ensure the number is drawn on top of the bullet?
format the lists independently (i.e., larger bullet in second list)?
Missing Resource
I thought I could define a named group, but the \defineitemgroup
documentation is non-existent.
Saturday, 24 August 2013
Xcode 5 and localization of .xib files
Xcode 5 and localization of .xib files
I'm trying to localize a .xib file.
The problem: After clicking the "Localize button" in the inspector, I end
up with a list containing "English" and nothing else, well this is normal.
But usually, as I can remember there is a "+" button which lets you add a
language to this list.
I've asked on apple developer forum, because I'm using a beta version, but
the post has been removed (not sure why).
There's a workaround for this?
Thanks.
I'm trying to localize a .xib file.
The problem: After clicking the "Localize button" in the inspector, I end
up with a list containing "English" and nothing else, well this is normal.
But usually, as I can remember there is a "+" button which lets you add a
language to this list.
I've asked on apple developer forum, because I'm using a beta version, but
the post has been removed (not sure why).
There's a workaround for this?
Thanks.
How does an android factory reset work?
How does an android factory reset work?
When performing a factory reset, does Android remove all the added
applications and user data or does it completely reflash an image of the
OS
I am running on jelly bean 4.3 stock
When performing a factory reset, does Android remove all the added
applications and user data or does it completely reflash an image of the
OS
I am running on jelly bean 4.3 stock
How can I watch a demo of my last competitive match?
How can I watch a demo of my last competitive match?
I just had an excellent 4-headshot round with a scout that I'd like to
take another look at. Is there a way to do this?
I know you can record demos manually, but I don't want to always record my
matches as that takes a lot of effort and disk space. Is there
functionality similar to lastreplay.rep in SC:BW that autosaves your last
demo and overwrites it automatically?
I just had an excellent 4-headshot round with a scout that I'd like to
take another look at. Is there a way to do this?
I know you can record demos manually, but I don't want to always record my
matches as that takes a lot of effort and disk space. Is there
functionality similar to lastreplay.rep in SC:BW that autosaves your last
demo and overwrites it automatically?
nginx proxied responses terminating/truncating
nginx proxied responses terminating/truncating
I have this nginx config on a host (host1):
server {
...
location /foo {
proxy_pass http://127.0.0.1:8091/;
}
}
The backend nginx config looks like this:
server {
listen localhost:8091;
root /store;
autoindex on;
}
The backend is actually on a different host (host2), and due to our
firewall config, I need to reverse-tunnel the connections (this may be
irrelevant to the question but including for completeness):
ssh -R8091:localhost:8091 host1
This setup is for serving large-ish files (GBs). The problem is I'm
finding that requests are abruptly terminating/truncating short of their
full size, always a bit >1GB (e.g. 1081376535, 1082474263, ...). No errors
in the logs however, and nothing jumps out from verbose debug logging.
There's always a Content-Length in the response too.
After some digging I found that there's a proxy_max_temp_file_size that's
1GB by default. Indeed, from inspecting the FDs of the nginx worker in
/proc, the temp file is actually being filled up to exactly 1073741824
bytes, and at a rate much faster than the downstream client is able to
receive. Lowering it to 1MB mostly makes the problem go away [1] (as
would, I imagine, disabling it with 0 altogether). But why would this be a
problem? If there was a timeout, why no error message, why is 1GB the
default, and why would the downstream client manage to receive a few
additional (varying number of) bytes beyond the 1073741824th byte?
Anyway, just wondering if anyone might have an inkling as to what's up. If
it makes a difference, both hosts are Ubuntu 12.04.
[1] I say mostly because the problem is replaced by another one, which is
that downloads all stop at exactly 2147484825 bytes, which happens to be
0x80000499, but I haven't done enough debugging to determine if this is
between (as I suspect) the frontend server and the client.
I have this nginx config on a host (host1):
server {
...
location /foo {
proxy_pass http://127.0.0.1:8091/;
}
}
The backend nginx config looks like this:
server {
listen localhost:8091;
root /store;
autoindex on;
}
The backend is actually on a different host (host2), and due to our
firewall config, I need to reverse-tunnel the connections (this may be
irrelevant to the question but including for completeness):
ssh -R8091:localhost:8091 host1
This setup is for serving large-ish files (GBs). The problem is I'm
finding that requests are abruptly terminating/truncating short of their
full size, always a bit >1GB (e.g. 1081376535, 1082474263, ...). No errors
in the logs however, and nothing jumps out from verbose debug logging.
There's always a Content-Length in the response too.
After some digging I found that there's a proxy_max_temp_file_size that's
1GB by default. Indeed, from inspecting the FDs of the nginx worker in
/proc, the temp file is actually being filled up to exactly 1073741824
bytes, and at a rate much faster than the downstream client is able to
receive. Lowering it to 1MB mostly makes the problem go away [1] (as
would, I imagine, disabling it with 0 altogether). But why would this be a
problem? If there was a timeout, why no error message, why is 1GB the
default, and why would the downstream client manage to receive a few
additional (varying number of) bytes beyond the 1073741824th byte?
Anyway, just wondering if anyone might have an inkling as to what's up. If
it makes a difference, both hosts are Ubuntu 12.04.
[1] I say mostly because the problem is replaced by another one, which is
that downloads all stop at exactly 2147484825 bytes, which happens to be
0x80000499, but I haven't done enough debugging to determine if this is
between (as I suspect) the frontend server and the client.
JSF two beans and just one view?
JSF two beans and just one view?
i have got following:
public abstract class aBean{... methods and variables ...}
@ManagedBean, ViewScoped
public class BeanType1 extends aBean{...only one method overritten...}
@ManagedBean, ViewScoped
public class BeanType2 extends aBean{...only one method overritten...}
is it possible to show some users View.xhtml with BeanType1 and some
others (the same) View.xhtml with BeanType2? i need a kind of
view-inheritance; like to use an EL-Expression like #{BEANPARAM.method}
where BEANPARAM can be BeanType1 or BeanType2...
is this possible or do I need two identival views with different beans?
i have got following:
public abstract class aBean{... methods and variables ...}
@ManagedBean, ViewScoped
public class BeanType1 extends aBean{...only one method overritten...}
@ManagedBean, ViewScoped
public class BeanType2 extends aBean{...only one method overritten...}
is it possible to show some users View.xhtml with BeanType1 and some
others (the same) View.xhtml with BeanType2? i need a kind of
view-inheritance; like to use an EL-Expression like #{BEANPARAM.method}
where BEANPARAM can be BeanType1 or BeanType2...
is this possible or do I need two identival views with different beans?
, how to hide some panels on a category?
, how to hide some panels on a category?
I'm using BCGControlBar Library(17), there are some panels on a category,
for example : a b and c. Sometimes I want to show a and b, then c should
be hidden, sometime I want to show b and c, so a should be hidden. Now
what I can do is using
CBCGPRibbonCategory::RemovePanel
to remove panel from category, and add it to category when I want to show
it, but I don't like this way, anyone knows a better method? thanks!
I'm using BCGControlBar Library(17), there are some panels on a category,
for example : a b and c. Sometimes I want to show a and b, then c should
be hidden, sometime I want to show b and c, so a should be hidden. Now
what I can do is using
CBCGPRibbonCategory::RemovePanel
to remove panel from category, and add it to category when I want to show
it, but I don't like this way, anyone knows a better method? thanks!
c# - WP: navigation to the page?
c# - WP: navigation to the page?
I have 10 xaml pages in my Wp app. In every xaml page, i have webbrowser
method to display html page and its content is like below.
1. //.....//
2. //.....//
...
100. //.....//
I decided to have easy navigation. So, i created two textbox, one is for
xaml page and other is for content (1,2, ... 100) So, what my desire is if
user gives, 5 in first textbox and 10 in second textbox it should open
5.xaml and it should be automatically moved to 10. //...//
I have done the code for first textbox. but i dunno how to code for second
textbox.
Here is my code:
TextBox xaml = new TextBox();
xaml.Width = 150;
xaml.MaxLength = 3;
TextBox content = new TextBox();
content.Width = 150;
content.MaxLength = 3;
int num = 0;
if (int.TryParse(xaml.Text, out num) && num > 0 && num < 11)
{
string site;
site = num.ToString();
NavigationService.Navigate(new Uri("/Page" + site + ".xaml",
UriKind.Relative));
}
else
{
MessageBox.Show("Expected Input Range: 1 to 10");
}
I have 10 xaml pages in my Wp app. In every xaml page, i have webbrowser
method to display html page and its content is like below.
1. //.....//
2. //.....//
...
100. //.....//
I decided to have easy navigation. So, i created two textbox, one is for
xaml page and other is for content (1,2, ... 100) So, what my desire is if
user gives, 5 in first textbox and 10 in second textbox it should open
5.xaml and it should be automatically moved to 10. //...//
I have done the code for first textbox. but i dunno how to code for second
textbox.
Here is my code:
TextBox xaml = new TextBox();
xaml.Width = 150;
xaml.MaxLength = 3;
TextBox content = new TextBox();
content.Width = 150;
content.MaxLength = 3;
int num = 0;
if (int.TryParse(xaml.Text, out num) && num > 0 && num < 11)
{
string site;
site = num.ToString();
NavigationService.Navigate(new Uri("/Page" + site + ".xaml",
UriKind.Relative));
}
else
{
MessageBox.Show("Expected Input Range: 1 to 10");
}
Short message encryption with only javascript to generate it in a URL
Short message encryption with only javascript to generate it in a URL
I'd like to present an idea to you that I think might help the privacy of
the average user. I would appreciate any comment or suggestion on this.
I've been struggling for quite some time now with the need for a simple
tool that I could share and use with my contacts who are only average
users and not familiar at all with any cryptographic technology or the
current tools available.
I'm planning to create a solution where one can easily encrypt a text
message or a file with a single password and send it in email or chat or
through whatever channel to somebody else. The solution should be entirely
platform independent and usable without the need to install any extra
softwares.
There are some text encryption websites out there that run client side
encryption from JavaScript entirely. I find this approach currently the
only possible solution. Also, there are libs for JS that already implement
encryption:
http://crypto.stanford.edu/sjcl/ http://code.google.com/p/crypto-js/
Though the mentioned approaches store the message on their server,
requiring you and your contact to trust it entirely. Because the server
might present a different JS code to the user when visiting it after he
gets the message by steeling the password and so revealing the secret.
While many think that it's not a good idea to do anything regarding
cryptographic tasks in JS, I believe there is a need for a tool that is
really platform independent (can be used on any tablet or PC) and still
incredibly easy to use. The idea behind this is that I believe something
is better than nothing. Sending information in plain text in email for
decades with our current technology is wrong in most cases. There are
times when we do need to share sensitive info via email and the other side
might have any kind of system.
I intend to avoid the use of public key cryptography for the following
reasons: - it is very complicated to setup including the signing of each
others' keys - complicated to use it - the user can loose his keys - most
of the time it needs and external software to be used and installed too -
a single password can be easily shared personally one time with my contact
and he or she can keep it written on a paper wherever
The solution I came up with could be the following:
First of all, the browser and the operating system under it sould be
considered trusted.
There would be a static index.html page with embedded JavaScript. The page
shows a textarea for the message and a textbox for the password. When
hitting enter, the JS code generates a URL that itself will contain the
encrypted message in base64 encoding. After digging I figured that 2000
bytes can be used for URLs just fine in every cases, so 1600 or 800
characters could be enough for short messages. This still needs planning.
So the encrypted message would travel with the URL. The website serving
the index.html would of course use SSL with a valid certificate. While it
seems an easy taks, of course it is not. The JS implementation should be
carefully created to avoid easy attacks on it.
(URL shortener services could be used for it too).
Also, the question stands: How can I make sure that my contact can be
certain about the origin of my message?
Well, the other side has to check if the domain is correct. Beside this,
the implementation must avoid the rest of the attacks. If the URL gets
changed during the travel of the email, then maximum the other side won't
be able to decode the message with the password. That's what I believe.
That it can be implemented this way.
About the file sharing. The solution should have a possibility to browse
for a file, then encrypt it, then put it out for download to the user.
This is just for him to be able to create the encrypted form of the file
without the need for external tools. Then he could upload it to the cloud
of his choice wherever (Google drive, Skydrive etc) and use that link in
the URL of the JS solution to send it to his contact.
So if another link travels with the link, then the file from the remote
host gets downloaded, decrypted and sent for download. All in his browser.
If it's an encrypted message in base64 form, then it gets printed on the
page after decryption (by the user providing his password of course).
Pros compared to other solutions: - no need to implement a storage because
no message nor file will be stored on the server, so the big players'
services could be used - therefore no need to reimplement the wheel
regarding the storage question - no need to trust a 3rd party because the
server could easily be ours because it would be extremely easy to set up
and serve it - easy with even a free provider to host the static
index.html - because of its simplicity, the server can be hardened much
better - easy to encrypt with it in practice - if one needs it, he could
use the index.html by clicking on it from his desktop too, but that's not
part of the original idea
My questions to you all are:
Do you find any flaw in my theory above? Could this really serve the
average people by providing a usable tool for them that is more than
nothing in times when they do need to send sensitive info to others?
Or does anything like that exist yet? Are there any better approaches?
Different technology maybe?
Thank You.
I'd like to present an idea to you that I think might help the privacy of
the average user. I would appreciate any comment or suggestion on this.
I've been struggling for quite some time now with the need for a simple
tool that I could share and use with my contacts who are only average
users and not familiar at all with any cryptographic technology or the
current tools available.
I'm planning to create a solution where one can easily encrypt a text
message or a file with a single password and send it in email or chat or
through whatever channel to somebody else. The solution should be entirely
platform independent and usable without the need to install any extra
softwares.
There are some text encryption websites out there that run client side
encryption from JavaScript entirely. I find this approach currently the
only possible solution. Also, there are libs for JS that already implement
encryption:
http://crypto.stanford.edu/sjcl/ http://code.google.com/p/crypto-js/
Though the mentioned approaches store the message on their server,
requiring you and your contact to trust it entirely. Because the server
might present a different JS code to the user when visiting it after he
gets the message by steeling the password and so revealing the secret.
While many think that it's not a good idea to do anything regarding
cryptographic tasks in JS, I believe there is a need for a tool that is
really platform independent (can be used on any tablet or PC) and still
incredibly easy to use. The idea behind this is that I believe something
is better than nothing. Sending information in plain text in email for
decades with our current technology is wrong in most cases. There are
times when we do need to share sensitive info via email and the other side
might have any kind of system.
I intend to avoid the use of public key cryptography for the following
reasons: - it is very complicated to setup including the signing of each
others' keys - complicated to use it - the user can loose his keys - most
of the time it needs and external software to be used and installed too -
a single password can be easily shared personally one time with my contact
and he or she can keep it written on a paper wherever
The solution I came up with could be the following:
First of all, the browser and the operating system under it sould be
considered trusted.
There would be a static index.html page with embedded JavaScript. The page
shows a textarea for the message and a textbox for the password. When
hitting enter, the JS code generates a URL that itself will contain the
encrypted message in base64 encoding. After digging I figured that 2000
bytes can be used for URLs just fine in every cases, so 1600 or 800
characters could be enough for short messages. This still needs planning.
So the encrypted message would travel with the URL. The website serving
the index.html would of course use SSL with a valid certificate. While it
seems an easy taks, of course it is not. The JS implementation should be
carefully created to avoid easy attacks on it.
(URL shortener services could be used for it too).
Also, the question stands: How can I make sure that my contact can be
certain about the origin of my message?
Well, the other side has to check if the domain is correct. Beside this,
the implementation must avoid the rest of the attacks. If the URL gets
changed during the travel of the email, then maximum the other side won't
be able to decode the message with the password. That's what I believe.
That it can be implemented this way.
About the file sharing. The solution should have a possibility to browse
for a file, then encrypt it, then put it out for download to the user.
This is just for him to be able to create the encrypted form of the file
without the need for external tools. Then he could upload it to the cloud
of his choice wherever (Google drive, Skydrive etc) and use that link in
the URL of the JS solution to send it to his contact.
So if another link travels with the link, then the file from the remote
host gets downloaded, decrypted and sent for download. All in his browser.
If it's an encrypted message in base64 form, then it gets printed on the
page after decryption (by the user providing his password of course).
Pros compared to other solutions: - no need to implement a storage because
no message nor file will be stored on the server, so the big players'
services could be used - therefore no need to reimplement the wheel
regarding the storage question - no need to trust a 3rd party because the
server could easily be ours because it would be extremely easy to set up
and serve it - easy with even a free provider to host the static
index.html - because of its simplicity, the server can be hardened much
better - easy to encrypt with it in practice - if one needs it, he could
use the index.html by clicking on it from his desktop too, but that's not
part of the original idea
My questions to you all are:
Do you find any flaw in my theory above? Could this really serve the
average people by providing a usable tool for them that is more than
nothing in times when they do need to send sensitive info to others?
Or does anything like that exist yet? Are there any better approaches?
Different technology maybe?
Thank You.
Open Gallery App in Android
Open Gallery App in Android
I am trying to open inbuilt gallery app pressing a button in my app.
I am trying out on Android 2.3 and above phones. The phones/tablet that I
have are
Samsung S (Android 2.3.5) LG phone (Android 2.3.3) Nexus One (Android
2.3.6) Android Tablet (Android 4.0.3) Galaxy Nexus (Android 4.3)
I tried the following:
Intent intent = new Intent(Intent.ACTION_VIEW, null);
intent.setType("image/*");
startActivity(intent);
above code works fine on Android tablet (4.0.3) and my Nexus phone too..
but if run the same app on any phone which is below 3.0 (gives me error)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.os.Looper.loop(Looper.java:130)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.main(ActivityThread.java:3687)
08-24 11:47:53.628: E/AndroidRuntime(787): at
java.lang.reflect.Method.invokeNative(Native Method)
08-24 11:47:53.628: E/AndroidRuntime(787): at
java.lang.reflect.Method.invoke(Method.java:507)
08-24 11:47:53.628: E/AndroidRuntime(787): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-24 11:47:53.628: E/AndroidRuntime(787): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-24 11:47:53.628: E/AndroidRuntime(787): at
dalvik.system.NativeStart.main(Native Method)
08-24 11:47:53.628: E/AndroidRuntime(787): Caused by:
java.lang.NullPointerException
08-24 11:47:53.628: E/AndroidRuntime(787): at
com.cooliris.media.Gallery.onCreate(Gallery.java:323)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
08-24 11:47:53.628: E/AndroidRuntime(787): ... 11 more
So I tried the following:
Intent intent1= new Intent("android.intent.action.MAIN", null);
intent1.addCategory("android.intent.category.APP_GALLERY");
Intent intent2 = Intent.createChooser(intent1, "Gallery");
startActivity(intent2);
Again this works just fine with phones that are above/equalto 4.0 version.
On 4.0 below phones it gives alert notification by saying:
"No application can perform this action"
Can somebody help me out with opening the Gallery from pressing a button
from my app?
I am trying to open inbuilt gallery app pressing a button in my app.
I am trying out on Android 2.3 and above phones. The phones/tablet that I
have are
Samsung S (Android 2.3.5) LG phone (Android 2.3.3) Nexus One (Android
2.3.6) Android Tablet (Android 4.0.3) Galaxy Nexus (Android 4.3)
I tried the following:
Intent intent = new Intent(Intent.ACTION_VIEW, null);
intent.setType("image/*");
startActivity(intent);
above code works fine on Android tablet (4.0.3) and my Nexus phone too..
but if run the same app on any phone which is below 3.0 (gives me error)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.os.Looper.loop(Looper.java:130)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.main(ActivityThread.java:3687)
08-24 11:47:53.628: E/AndroidRuntime(787): at
java.lang.reflect.Method.invokeNative(Native Method)
08-24 11:47:53.628: E/AndroidRuntime(787): at
java.lang.reflect.Method.invoke(Method.java:507)
08-24 11:47:53.628: E/AndroidRuntime(787): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-24 11:47:53.628: E/AndroidRuntime(787): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-24 11:47:53.628: E/AndroidRuntime(787): at
dalvik.system.NativeStart.main(Native Method)
08-24 11:47:53.628: E/AndroidRuntime(787): Caused by:
java.lang.NullPointerException
08-24 11:47:53.628: E/AndroidRuntime(787): at
com.cooliris.media.Gallery.onCreate(Gallery.java:323)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-24 11:47:53.628: E/AndroidRuntime(787): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
08-24 11:47:53.628: E/AndroidRuntime(787): ... 11 more
So I tried the following:
Intent intent1= new Intent("android.intent.action.MAIN", null);
intent1.addCategory("android.intent.category.APP_GALLERY");
Intent intent2 = Intent.createChooser(intent1, "Gallery");
startActivity(intent2);
Again this works just fine with phones that are above/equalto 4.0 version.
On 4.0 below phones it gives alert notification by saying:
"No application can perform this action"
Can somebody help me out with opening the Gallery from pressing a button
from my app?
Friday, 23 August 2013
How to use PyGame.sprite
How to use PyGame.sprite
I am ditching the python desk top and writing a zombie game with my
friends. I have looked and looked but don't understand it. Could someone
just explain how to use a pre-existing image and make it a sprite, then
check for sprite collision? It is top down, by the way. Thanks in
advanced!
I am ditching the python desk top and writing a zombie game with my
friends. I have looked and looked but don't understand it. Could someone
just explain how to use a pre-existing image and make it a sprite, then
check for sprite collision? It is top down, by the way. Thanks in
advanced!
SQLAlchemy-like relationships without SQLAlchemy
SQLAlchemy-like relationships without SQLAlchemy
SQLAlchemy gives me nice relationships between objects. When I change one
object's member, it's automatically added to the other object's list, etc.
However - I don't want to use a DB. I'd like to keep my objects in the
memory. Is there a module that gives this kind of behavior without using
SQLAlchemy?
SQLAlchemy gives me nice relationships between objects. When I change one
object's member, it's automatically added to the other object's list, etc.
However - I don't want to use a DB. I'd like to keep my objects in the
memory. Is there a module that gives this kind of behavior without using
SQLAlchemy?
Error sending email with gmail "Rails 3.2.6" "ruby 1.8.7"
Error sending email with gmail "Rails 3.2.6" "ruby 1.8.7"
when trying to send an e-mail from a "going" created. I get the error:
"NameError (undefined methodLocal variable or params' for #): app /
mailers / going_mailer.rb: 5: inregistration_confirmation ' app /
controllers / goings_controller.rb: 12: in create ' app / controllers /
goings_controller.rb: 10: increate '"
my GoingsController
class GoingsController < InheritedResources::Baseload_and_authorize_resource
@going2 = Going.new(params[:going])
@procedure = Procedure.find(params[:procedure_id])
@going = @procedure.goings.create(params[:going])
@procedure.status = @going.status
@procedure.date_modified = @going.entry
@procedure.update_attributes({:status_id => @going.status},
:date_modified => @going.entry)
respond_to do |format|
if @going.save
GoingMailer.registration_confirmation(@going2).deliver
format.html { redirect_to(@going2, :notice => 'Going was
successfully created.') }
format.xml { render :xml => @going2, :status => :created, :location =>
@going2 }
else
format.html { render :action => "new" }
format.xml { render :xml => @going2.errors, :status =>
:unprocessable_entity }
end
redirect_to procedure_path(@procedure) end`
my app/GoingMailer
class GoingMailer < ActionMailer::Base
default :from => "email@gmail.com"
def registration_confirmation(going)
@procedure = Procedure.find(params[:procedure_id])
mail(:to => procedure.victim.analist.email, :subject => "Registered")
end
end
my / Config / initializers / setup_mail.rb
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydo.com.br",
:user_name => "myemail@gmail.com",
:password => "mypass$",
:authentication => :plain,
:enable_starttls_auto => true
}
when trying to send an e-mail from a "going" created. I get the error:
"NameError (undefined methodLocal variable or params' for #): app /
mailers / going_mailer.rb: 5: inregistration_confirmation ' app /
controllers / goings_controller.rb: 12: in create ' app / controllers /
goings_controller.rb: 10: increate '"
my GoingsController
class GoingsController < InheritedResources::Baseload_and_authorize_resource
@going2 = Going.new(params[:going])
@procedure = Procedure.find(params[:procedure_id])
@going = @procedure.goings.create(params[:going])
@procedure.status = @going.status
@procedure.date_modified = @going.entry
@procedure.update_attributes({:status_id => @going.status},
:date_modified => @going.entry)
respond_to do |format|
if @going.save
GoingMailer.registration_confirmation(@going2).deliver
format.html { redirect_to(@going2, :notice => 'Going was
successfully created.') }
format.xml { render :xml => @going2, :status => :created, :location =>
@going2 }
else
format.html { render :action => "new" }
format.xml { render :xml => @going2.errors, :status =>
:unprocessable_entity }
end
redirect_to procedure_path(@procedure) end`
my app/GoingMailer
class GoingMailer < ActionMailer::Base
default :from => "email@gmail.com"
def registration_confirmation(going)
@procedure = Procedure.find(params[:procedure_id])
mail(:to => procedure.victim.analist.email, :subject => "Registered")
end
end
my / Config / initializers / setup_mail.rb
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydo.com.br",
:user_name => "myemail@gmail.com",
:password => "mypass$",
:authentication => :plain,
:enable_starttls_auto => true
}
MySQL utf-8 PASSWORD() function outputs different values
MySQL utf-8 PASSWORD() function outputs different values
I have a question regarding mysql. I've been trying to fix this for quite
some time and am out of ideas.
I have a table that conatins user information. Three of this table's
columns are Username, PW and Famille.
The Username I am interested in is '12234567' and the Famille's value is
'Testé'.
I generated the PW column like so:
UPDATE tablename SET PW = PASSWORD(CONCAT(Username,UPPER(Famille))) WHERE
Username ='1234567'
However, once I try to match the column PW with PASSWORD('1234567TESTÉ')
it doesn't work because the outputted values are different. Any help would
be greatly appreciated!
Thanks
I have a question regarding mysql. I've been trying to fix this for quite
some time and am out of ideas.
I have a table that conatins user information. Three of this table's
columns are Username, PW and Famille.
The Username I am interested in is '12234567' and the Famille's value is
'Testé'.
I generated the PW column like so:
UPDATE tablename SET PW = PASSWORD(CONCAT(Username,UPPER(Famille))) WHERE
Username ='1234567'
However, once I try to match the column PW with PASSWORD('1234567TESTÉ')
it doesn't work because the outputted values are different. Any help would
be greatly appreciated!
Thanks
Make Dynamics CRM 2011 field readonly NOT disabled
Make Dynamics CRM 2011 field readonly NOT disabled
I would like to make a inputfield readonly. I am familiar with the
setDisabled() method in XRM, the downside of this method is that it is not
possible to copy/paste values from the fields.
Is there another way then using javascript/jQuery directly to set the
readonly property on the field by using it's field name?
Kind regards Rim
I would like to make a inputfield readonly. I am familiar with the
setDisabled() method in XRM, the downside of this method is that it is not
possible to copy/paste values from the fields.
Is there another way then using javascript/jQuery directly to set the
readonly property on the field by using it's field name?
Kind regards Rim
CPU Utilization of Android dual core device
CPU Utilization of Android dual core device
In android mobile devices, nowadays many models support Dual core
processors. If i want to measure the CPU utilization using top command i
get a single value as 40% or anything.
Consider an example - 50%. Does this mean any of the following ?
Core 1 is completely utilized and Core 2 is free. So 50% out of 100% is
utilized.
50% of Core 1 and 50% of Core 2 is utilized.
How do i say, my application is consuming better CPU ? How do i measure it ?
In android mobile devices, nowadays many models support Dual core
processors. If i want to measure the CPU utilization using top command i
get a single value as 40% or anything.
Consider an example - 50%. Does this mean any of the following ?
Core 1 is completely utilized and Core 2 is free. So 50% out of 100% is
utilized.
50% of Core 1 and 50% of Core 2 is utilized.
How do i say, my application is consuming better CPU ? How do i measure it ?
Thursday, 22 August 2013
How install GraphicsMagick with quantum 16
How install GraphicsMagick with quantum 16
How can I configure GraphicsMagick to use --with-quantum-depth=16 before
installing it with apt-get? Is it possible to do or should I build it from
source?
How can I configure GraphicsMagick to use --with-quantum-depth=16 before
installing it with apt-get? Is it possible to do or should I build it from
source?
In Racket, how to get and set an object's field as if it was a local variable?
In Racket, how to get and set an object's field as if it was a local
variable?
I want to do something like this:
(define-field-magic color car)
(set! color "green")
(pretty-display color)
Instead of this:
(set-field! color car "green")
(pretty-display (get-field color car))
variable?
I want to do something like this:
(define-field-magic color car)
(set! color "green")
(pretty-display color)
Instead of this:
(set-field! color car "green")
(pretty-display (get-field color car))
Logback coloring based on class/package
Logback coloring based on class/package
I've started reading about Logback (currently using log4j and thinking
about switching). I'm interested in the possibilities to color the logged
messages. Browsing through previous questions, I've only seen mentions of
coloring different parts of the message (conversion patterns) or coloring
exceptions.
What I'm interested in, however, is whether logback can color my messages
based on their package or class.
For example, let's say my application is composed of two main components-
a producer and a consumer, and they both are composed of a large
dependency tree. Can I have any message which is logged through the
consumer colored red, and any message which is logged through the producer
colored blue?
Please notice that I don't want this to interfere with log levels (that
is, I still want to have the option to set components to debug/error etc,
ideally without having to mind the coloring.
Thanks!
I've started reading about Logback (currently using log4j and thinking
about switching). I'm interested in the possibilities to color the logged
messages. Browsing through previous questions, I've only seen mentions of
coloring different parts of the message (conversion patterns) or coloring
exceptions.
What I'm interested in, however, is whether logback can color my messages
based on their package or class.
For example, let's say my application is composed of two main components-
a producer and a consumer, and they both are composed of a large
dependency tree. Can I have any message which is logged through the
consumer colored red, and any message which is logged through the producer
colored blue?
Please notice that I don't want this to interfere with log levels (that
is, I still want to have the option to set components to debug/error etc,
ideally without having to mind the coloring.
Thanks!
Set blur event on dynamic boxes
Set blur event on dynamic boxes
I have a page where the user can dynamically add a text input box. I am
wanting to fire an even when the user leaves this input box. This looks OK
on the initial page refresh where there is only one box. In that case the
DOM looks like...
<div id="controls">
<div class="tag" data-tag="1">
<input id="tags_" class="word" type="text" name="tags[]" data-tag="1">
<input id="weights_" class="weight" type="hidden" name="weights[]"
data-tag="1" value="90">
<div class="slider slider-1 ui-slider ui-slider-horizontal ui-widget
ui-widget-content ui-corner-all" aria-disabled="false">
<a class="add-word" href="1" data-tag="1">+</a>
</div>
</div>
...and my js is...
$('.word').blur(function(){
alert("wintas!");
});
So this works OK, but if I add anohter text box dynamically the DOM
becomes...
<div id="controls">
<div class="tag" data-tag="1">
<input id="tags_" class="word" type="text" name="tags[]" data-tag="1">
<input id="weights_" class="weight" type="hidden" name="weights[]"
data-tag="1" value="90">
<div class="slider slider-1 ui-slider ui-slider-horizontal ui-widget
ui-widget-content ui-corner-all" aria-disabled="false">
<a class="ui-slider-handle ui-state-default ui-corner-all" href="#"
style="left: 80%;"></a>
</div>
<a class="remove-word" href="#" data-tag="1">-</a>
</div>
<div class="tag" data-tag="2">
<input class="word" type="text" name="tags[]">
<input class="weight" type="hidden" value="50" name="weights[]">
<div class="slider slider-2 ui-slider ui-slider-horizontal ui-widget
ui-widget-content ui-corner-all" aria-disabled="false">
<a class="add-word" href="1" data-tag="2">+</a>
</div>
</div>
However, the blur event still fires on the first text box. How can I get
my js event to 'update' when I add a new box?
I have a page where the user can dynamically add a text input box. I am
wanting to fire an even when the user leaves this input box. This looks OK
on the initial page refresh where there is only one box. In that case the
DOM looks like...
<div id="controls">
<div class="tag" data-tag="1">
<input id="tags_" class="word" type="text" name="tags[]" data-tag="1">
<input id="weights_" class="weight" type="hidden" name="weights[]"
data-tag="1" value="90">
<div class="slider slider-1 ui-slider ui-slider-horizontal ui-widget
ui-widget-content ui-corner-all" aria-disabled="false">
<a class="add-word" href="1" data-tag="1">+</a>
</div>
</div>
...and my js is...
$('.word').blur(function(){
alert("wintas!");
});
So this works OK, but if I add anohter text box dynamically the DOM
becomes...
<div id="controls">
<div class="tag" data-tag="1">
<input id="tags_" class="word" type="text" name="tags[]" data-tag="1">
<input id="weights_" class="weight" type="hidden" name="weights[]"
data-tag="1" value="90">
<div class="slider slider-1 ui-slider ui-slider-horizontal ui-widget
ui-widget-content ui-corner-all" aria-disabled="false">
<a class="ui-slider-handle ui-state-default ui-corner-all" href="#"
style="left: 80%;"></a>
</div>
<a class="remove-word" href="#" data-tag="1">-</a>
</div>
<div class="tag" data-tag="2">
<input class="word" type="text" name="tags[]">
<input class="weight" type="hidden" value="50" name="weights[]">
<div class="slider slider-2 ui-slider ui-slider-horizontal ui-widget
ui-widget-content ui-corner-all" aria-disabled="false">
<a class="add-word" href="1" data-tag="2">+</a>
</div>
</div>
However, the blur event still fires on the first text box. How can I get
my js event to 'update' when I add a new box?
got EOF withou using Python read function
got EOF withou using Python read function
Is that possible to know if I am in EOF without using read function?
Sometimes using read for judging EOF gives trouble for next round data
processing.
Is that possible to know if I am in EOF without using read function?
Sometimes using read for judging EOF gives trouble for next round data
processing.
JQuery .ajax dont call function
JQuery .ajax dont call function
I have object "game" and when i call create game, its use jquery ajax...
everything works ok, but when i want to call from ajax success function
addLoadEvent it doesnt call it, when i try call this function from
createGame (commented part of code here) its works... do you know why i
cant call it from ajax success? i try console log from success and it was
print in console so ajax works well. Thank everybody for help
var game=new ttt_game();
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function ttt_game () {
this.createGame = createGame;
function createGame(){
/*addLoadEvent(function(){
document.getElementById('player1_n').textContent=player1+':';
document.getElementById('player2_n').textContent=player2+':';
document.getElementById('turn').textContent='Èaká
sa na príchod súpera.';
});*/
$.ajax({
type: "POST",
url: "process.php",
data: {'function': 'create','game_id':
game_id,'player1': player1},
dataType: "json",
success: function(data){
addLoadEvent(function(){
document.getElementById('player1_n').textContent=player1+':';
document.getElementById('player2_n').textContent=player2+':';
document.getElementById('turn').textContent='Èaká
sa na príchod súpera.';
});
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
}
game.createGame();
I have object "game" and when i call create game, its use jquery ajax...
everything works ok, but when i want to call from ajax success function
addLoadEvent it doesnt call it, when i try call this function from
createGame (commented part of code here) its works... do you know why i
cant call it from ajax success? i try console log from success and it was
print in console so ajax works well. Thank everybody for help
var game=new ttt_game();
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function ttt_game () {
this.createGame = createGame;
function createGame(){
/*addLoadEvent(function(){
document.getElementById('player1_n').textContent=player1+':';
document.getElementById('player2_n').textContent=player2+':';
document.getElementById('turn').textContent='Èaká
sa na príchod súpera.';
});*/
$.ajax({
type: "POST",
url: "process.php",
data: {'function': 'create','game_id':
game_id,'player1': player1},
dataType: "json",
success: function(data){
addLoadEvent(function(){
document.getElementById('player1_n').textContent=player1+':';
document.getElementById('player2_n').textContent=player2+':';
document.getElementById('turn').textContent='Èaká
sa na príchod súpera.';
});
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
}
game.createGame();
create 0 KB file after scanning in delphi7 using Delphitwain component
create 0 KB file after scanning in delphi7 using Delphitwain component
I have a problem with transfer image from scanner to my application after
scanning is completed. I have used delphi twain component to perform
scanning and use DelphiTwain1SourceSetupFileXfer and
DelphiTwain1SourceFileTransfer event of twain component. Problem is that,
scanning is done flawlessly but image created at provided location have
0KB size. Any suggestion would be greatly appreciated.
I have a problem with transfer image from scanner to my application after
scanning is completed. I have used delphi twain component to perform
scanning and use DelphiTwain1SourceSetupFileXfer and
DelphiTwain1SourceFileTransfer event of twain component. Problem is that,
scanning is done flawlessly but image created at provided location have
0KB size. Any suggestion would be greatly appreciated.
Wednesday, 21 August 2013
Does Zend disable inlineScript helper in ajax context?
Does Zend disable inlineScript helper in ajax context?
I have some javascript that is only required when a certain jQuery dialog
is loaded. I have put it in an external file and referenced it in the
controller as:
$this->view->inlineScript()->appendFile('/theme/flat/scripts/new-post.js');
In my new-post.ajax.phtml file I have the following line:
<?=$this->inlineScript();?>
But I just can't get it to work. There are no script tags or content
inserted.
If I put the same code in a non-ajax controller and view it works fine.
Is it possible that the ajaxContext action helper disables the
inlineScript view helper? Why? And is there a way around it? (I have quite
a few snippets I am pulling in with ajax, and each has its own javascript
code).
I have some javascript that is only required when a certain jQuery dialog
is loaded. I have put it in an external file and referenced it in the
controller as:
$this->view->inlineScript()->appendFile('/theme/flat/scripts/new-post.js');
In my new-post.ajax.phtml file I have the following line:
<?=$this->inlineScript();?>
But I just can't get it to work. There are no script tags or content
inserted.
If I put the same code in a non-ajax controller and view it works fine.
Is it possible that the ajaxContext action helper disables the
inlineScript view helper? Why? And is there a way around it? (I have quite
a few snippets I am pulling in with ajax, and each has its own javascript
code).
Group summary for a boolean field (cxGrid)
Group summary for a boolean field (cxGrid)
How can I have a boolean field in my cxGrid (displayed in the grid as a
checkbox) display a full (group) summary (count) : total issues + solved
(checked) and unsolved (not checked) ? When I check the checkbox,the issue
is solved. When I uncheck it, it is unsolved. Right now, I only managed to
figure out how to display the total amount of issues. What I need to
display is the count of checked and unchecked items in the same field. So
my header (in the example shown below) would display : DATE: 28.8.2013
(Total issues:2) (Solved:1) (Unsolved:1) Is it possible to accomplish
this?
Something like this :
How can I have a boolean field in my cxGrid (displayed in the grid as a
checkbox) display a full (group) summary (count) : total issues + solved
(checked) and unsolved (not checked) ? When I check the checkbox,the issue
is solved. When I uncheck it, it is unsolved. Right now, I only managed to
figure out how to display the total amount of issues. What I need to
display is the count of checked and unchecked items in the same field. So
my header (in the example shown below) would display : DATE: 28.8.2013
(Total issues:2) (Solved:1) (Unsolved:1) Is it possible to accomplish
this?
Something like this :
Eclipse not exporting full .apk
Eclipse not exporting full .apk
So I updated my Android Application lately and exported it to a .apk so I
could send it to some other android phones. The exportation finished
without errors, and everything was fine. But when I installed the app
using the .apk, it seemed like I got an older- or half version of the app.
Some functions doesn't work at all, and the app takes about 50% less space
on the other phones. On my own phone, the app works perfectly and takes
all the space it's supposed to. The wierd thing is that I'm using the same
.apk to install the app on both my own phone and the other phones.
Is there a possible error or solution for this? I really need the new
functions, or the app won't work well! I also searched for a solution for
hours, so don't blame me if there's already a same question out there.
So I updated my Android Application lately and exported it to a .apk so I
could send it to some other android phones. The exportation finished
without errors, and everything was fine. But when I installed the app
using the .apk, it seemed like I got an older- or half version of the app.
Some functions doesn't work at all, and the app takes about 50% less space
on the other phones. On my own phone, the app works perfectly and takes
all the space it's supposed to. The wierd thing is that I'm using the same
.apk to install the app on both my own phone and the other phones.
Is there a possible error or solution for this? I really need the new
functions, or the app won't work well! I also searched for a solution for
hours, so don't blame me if there's already a same question out there.
Type mismatch error when comparing listboxes
Type mismatch error when comparing listboxes
Dim lastcomp As String
Dim qty As Integer
Dim rs As New ADODB.Recordset
rs.Open "select Prem1Item,Prem1Qty from [TU FAR Before VB] order
by Prem1Item", accCon
Do While Not rs.EOF
If Not IsNull(rs(0).Value) Then
If rs(0).Value <> "n/a" Then
If rs(0).Value <> "" Then
premlist.AddItem rs(0).Value & Format(rs(1).Value,
"00")
End If
End If
End If
rs.MoveNext
Loop
rs.Close
Dim i As Integer
Dim j As Integer
i = 1
For i = 1 To premlist.ListCount
For j = 1 To finallist.ListCount
**If Not finallist(j) = premlist(i) Or finallist(j) =
"" Then**
finallist.AddItem premlist(i)
End If
Next j
Next i
AccessConnection ("Close")
End If
I am trying to take the records and pull all of the items in Prem1Item and
condense then down to not show duplicates and also get the amount from
Prem1Qty and show the total of each item it finds. I was trying to put
them in these listboxs and then export them to a table that has 2 columns
(Premium and Sum)
I am getting error 13 Type mismatch highlighting the area I have put in
Bold. My plans were to get that list populated and then fill the table to
generate my report with.
Any help on this matter would be greatly appreciated.
Dim lastcomp As String
Dim qty As Integer
Dim rs As New ADODB.Recordset
rs.Open "select Prem1Item,Prem1Qty from [TU FAR Before VB] order
by Prem1Item", accCon
Do While Not rs.EOF
If Not IsNull(rs(0).Value) Then
If rs(0).Value <> "n/a" Then
If rs(0).Value <> "" Then
premlist.AddItem rs(0).Value & Format(rs(1).Value,
"00")
End If
End If
End If
rs.MoveNext
Loop
rs.Close
Dim i As Integer
Dim j As Integer
i = 1
For i = 1 To premlist.ListCount
For j = 1 To finallist.ListCount
**If Not finallist(j) = premlist(i) Or finallist(j) =
"" Then**
finallist.AddItem premlist(i)
End If
Next j
Next i
AccessConnection ("Close")
End If
I am trying to take the records and pull all of the items in Prem1Item and
condense then down to not show duplicates and also get the amount from
Prem1Qty and show the total of each item it finds. I was trying to put
them in these listboxs and then export them to a table that has 2 columns
(Premium and Sum)
I am getting error 13 Type mismatch highlighting the area I have put in
Bold. My plans were to get that list populated and then fill the table to
generate my report with.
Any help on this matter would be greatly appreciated.
Cyrillic strings in H2 database
Cyrillic strings in H2 database
I have a problem persisting Cyrillic strings to in-memory H2 database.
Java displays those strings properly, but after I save and retrieve
strings from H2 using Hibernate they are displayed as blank spaces.
The strange thing is those blank-strings are actually grouped - pressing
left-right shifts only one space, but pressing CTRL+right jumps a few
spaces. Is this a Java or H2 issue and how do I work around it?
I have a problem persisting Cyrillic strings to in-memory H2 database.
Java displays those strings properly, but after I save and retrieve
strings from H2 using Hibernate they are displayed as blank spaces.
The strange thing is those blank-strings are actually grouped - pressing
left-right shifts only one space, but pressing CTRL+right jumps a few
spaces. Is this a Java or H2 issue and how do I work around it?
MVC4 Render Scripts Section embedded in areas
MVC4 Render Scripts Section embedded in areas
In my Project I have a the normal _Layout.cshtml in the root Shared =>
/Views/Shared/_Layout.cshtml.
I have an area in my project called MyArea, in it I have a _ViewStart
which points at the _Layout.cshtml in
/Areas/MyArea/Views/Shared/_Layout.cshtml, this _Layout points to the one
in i defined at the start. My only question is: in my root _Layout.cshtml
is:
@RenderSection("scripts", required: false)
So I thought maybe putting this in my MyArea _Layout:
@section Scripts {
@RenderSection("scripts", required: false)
}
But that doesn't render the script where I want it to. So how do you get
it to put the scripts you make in your views to put it into the section
Scripts.
In my Project I have a the normal _Layout.cshtml in the root Shared =>
/Views/Shared/_Layout.cshtml.
I have an area in my project called MyArea, in it I have a _ViewStart
which points at the _Layout.cshtml in
/Areas/MyArea/Views/Shared/_Layout.cshtml, this _Layout points to the one
in i defined at the start. My only question is: in my root _Layout.cshtml
is:
@RenderSection("scripts", required: false)
So I thought maybe putting this in my MyArea _Layout:
@section Scripts {
@RenderSection("scripts", required: false)
}
But that doesn't render the script where I want it to. So how do you get
it to put the scripts you make in your views to put it into the section
Scripts.
Tuesday, 20 August 2013
Is there a way to redirect to a specific page using Tank_auth in Codeigniter?
Is there a way to redirect to a specific page using Tank_auth in Codeigniter?
I'm wondering if there's a way to redirect to a specific page (like
adminpanel_view) in Tank_auth. I looked at the Auth.php controller but
could not figure out how to redirect, if it's even possible..
I tried this:
public function login() //login functie
{
$this->breadcrumbs->page = array('link'=> base_url().'auth/login'
,'title' => 'Login');
$data['breadcrumbs'] = $this->breadcrumbs->get();
if ($this->tank_auth->is_logged_in()) {
// logged in
redirect('members/cpanel');
}
I'm wondering if there's a way to redirect to a specific page (like
adminpanel_view) in Tank_auth. I looked at the Auth.php controller but
could not figure out how to redirect, if it's even possible..
I tried this:
public function login() //login functie
{
$this->breadcrumbs->page = array('link'=> base_url().'auth/login'
,'title' => 'Login');
$data['breadcrumbs'] = $this->breadcrumbs->get();
if ($this->tank_auth->is_logged_in()) {
// logged in
redirect('members/cpanel');
}
python script see traceback when running as background
python script see traceback when running as background
I have a python script running like this on my server:
python script.py &
The script works fine, but constantly I'm adding new things to the script
and re-running it, somedays it runs for days without any problem, but
sometimes the script stops running (Not running out of memory), but since
I started the script as background I have no idea how to check for the
Exception or error that cause the script to stop running. I'm on a Ubuntu
server box running in Amazon. Any advice on how to approach this
inconvenience ?
I have a python script running like this on my server:
python script.py &
The script works fine, but constantly I'm adding new things to the script
and re-running it, somedays it runs for days without any problem, but
sometimes the script stops running (Not running out of memory), but since
I started the script as background I have no idea how to check for the
Exception or error that cause the script to stop running. I'm on a Ubuntu
server box running in Amazon. Any advice on how to approach this
inconvenience ?
CSS3 Modal Box covers up content after it?
CSS3 Modal Box covers up content after it?
So I have no idea why it would cover it up but then when i go to sign out
you see it displayed but in the background. It will only show when i pull
up the sign out modal window.
<!DOCTYPE html>
<html>
<head>
<title>SVHS Library Sign In/Out</title>
<meta name="SVHS-sign_in/out v1.0" content="form">
<link rel="stylesheet" href="_css/main.css">
<link rel="stylesheet" href="_css/modal.css">
<style>
body {
width: 700px;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<header>
<h1>Sign In/Out</h1>
</header>
<!-- SIGN IN MODAL
------------------------------------------------------------------------
------------------------------------------------------------------------------------------->
<a href="#openModal1">Sign In</a>
<div id="openModal1" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Sign In</h2>
<p>
Please fill out and click sign in.
</p>
<form action=".php" method="post" class="">
First Name:
<input type="text" name="fname"><br>
Last Name:
<input type="text" name="lname"><br>
<input type="radio" name="reason" value="check in/out
book">Check In/Out Book<br>
<input type="radio" name="reason" value="use computer">Use
Computer<br>
<input type="radio" name="reason" value="other">Other<br>
<input type="submit" value="Sign In">
</form>
</div>
</div>
<!-- SIGN OUT MODAL
-------------------------------------------------------------------------
------------------------------------------------------------------------------------------->
<a href="#openModal2">Sign Out</a>
<div id="openModal2" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<p>
Please fill out and click sign out.
</p>
<form action=".php" method="post" class="">
First Name:
<input type="text" name="fname"><br>
Last Name:
<input type="text" name="lname"><br>
<input type="submit" value="Sign Out">
</form>
</div>
<!-- FOOTER
--------------------------------------------------------------------------------
------------------------------------------------------------------------------------------->
<footer>
<nav class="nav_footer">
</nav>
<div class="legal">
<p>
This is the footer.
</p>
</div>
</footer>
<!-- Scripts -->
<script type="text/javascript" src="_scripts/java.js"></script>
</body>
</html>
===============CSS======================
.modalDialog {
position: fixed;
font-family: Helvetica, Arial, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }
So I have no idea why it would cover it up but then when i go to sign out
you see it displayed but in the background. It will only show when i pull
up the sign out modal window.
So I have no idea why it would cover it up but then when i go to sign out
you see it displayed but in the background. It will only show when i pull
up the sign out modal window.
<!DOCTYPE html>
<html>
<head>
<title>SVHS Library Sign In/Out</title>
<meta name="SVHS-sign_in/out v1.0" content="form">
<link rel="stylesheet" href="_css/main.css">
<link rel="stylesheet" href="_css/modal.css">
<style>
body {
width: 700px;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<header>
<h1>Sign In/Out</h1>
</header>
<!-- SIGN IN MODAL
------------------------------------------------------------------------
------------------------------------------------------------------------------------------->
<a href="#openModal1">Sign In</a>
<div id="openModal1" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Sign In</h2>
<p>
Please fill out and click sign in.
</p>
<form action=".php" method="post" class="">
First Name:
<input type="text" name="fname"><br>
Last Name:
<input type="text" name="lname"><br>
<input type="radio" name="reason" value="check in/out
book">Check In/Out Book<br>
<input type="radio" name="reason" value="use computer">Use
Computer<br>
<input type="radio" name="reason" value="other">Other<br>
<input type="submit" value="Sign In">
</form>
</div>
</div>
<!-- SIGN OUT MODAL
-------------------------------------------------------------------------
------------------------------------------------------------------------------------------->
<a href="#openModal2">Sign Out</a>
<div id="openModal2" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<p>
Please fill out and click sign out.
</p>
<form action=".php" method="post" class="">
First Name:
<input type="text" name="fname"><br>
Last Name:
<input type="text" name="lname"><br>
<input type="submit" value="Sign Out">
</form>
</div>
<!-- FOOTER
--------------------------------------------------------------------------------
------------------------------------------------------------------------------------------->
<footer>
<nav class="nav_footer">
</nav>
<div class="legal">
<p>
This is the footer.
</p>
</div>
</footer>
<!-- Scripts -->
<script type="text/javascript" src="_scripts/java.js"></script>
</body>
</html>
===============CSS======================
.modalDialog {
position: fixed;
font-family: Helvetica, Arial, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }
So I have no idea why it would cover it up but then when i go to sign out
you see it displayed but in the background. It will only show when i pull
up the sign out modal window.
How to hide submit_tag button
How to hide submit_tag button
I have an simple form:
<%= form_tag icd_test_path, :method => 'get', remote: true do %>
<%= hidden_field_tag(:sicherheit) %>
<%= hidden_field_tag(:id) %>
<%= submit_tag "", :id => 'Scomit' %>
<% end %>
How you can see both text_fields are hidden, now search an way to hide the
submit_tag as well?It want the form hidden because its only triggerd by
jquery!
I have an simple form:
<%= form_tag icd_test_path, :method => 'get', remote: true do %>
<%= hidden_field_tag(:sicherheit) %>
<%= hidden_field_tag(:id) %>
<%= submit_tag "", :id => 'Scomit' %>
<% end %>
How you can see both text_fields are hidden, now search an way to hide the
submit_tag as well?It want the form hidden because its only triggerd by
jquery!
How to solve this difficult system of euqations?
How to solve this difficult system of euqations?
$$1+4\lambda x^{3}-4\lambda y = 0$$ $$4\lambda y^{3}-4\lambda x = 0$$
$$x^{4}+y^{4}-4xy = 0$$
I can't deal with it. How to solve this?
$$1+4\lambda x^{3}-4\lambda y = 0$$ $$4\lambda y^{3}-4\lambda x = 0$$
$$x^{4}+y^{4}-4xy = 0$$
I can't deal with it. How to solve this?
UFW blocking some allowed internal connections
UFW blocking some allowed internal connections
My set up is this:
Server 1 (192.168.1.1) - nginx (load balance) - Ubuntu 12.04 LTS
Server 2 - uwsgi - Debian 7.1
Server 3 - uwsgi - Debian 7.1
UFW on server 2 and server 3, is blocking certain requests coming from
server 1 (nginx) and is showing up in nginx error log as "upstream timed
out". Traffic between nginx and uwsgi server is all on a private network.
This is UFW setup on uwsgi servers:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing)
New profiles: skip
To Action From -- ------ ----
Anywhere on eth1 ALLOW IN Anywhere
Anywhere ALLOW IN 192.168.1.1
Anywhere (v6) on eth1 ALLOW IN Anywhere (v6)
Example UFW block in syslog:
Aug 20 13:56:16 kernel: [1028623.806318] [UFW BLOCK] IN=eth1 OUT=
MAC=68:05:ca:17:c9:fb:68:05:ca:17:ca:0e:08:00 SRC=192.168.1.1
DST=192.168.1.103 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=54877 DF PROTO=TCP
SPT=41652 DPT=8000 WINDOW=14600 RES=0x00 SYN URGP=0
If I disable UFW on Uwsgi servers the timeouts in nginx stops. At the
moment the timeouts/blocks are mostly frequent ajax calls (every 2mins),
but not exclusively.
My set up is this:
Server 1 (192.168.1.1) - nginx (load balance) - Ubuntu 12.04 LTS
Server 2 - uwsgi - Debian 7.1
Server 3 - uwsgi - Debian 7.1
UFW on server 2 and server 3, is blocking certain requests coming from
server 1 (nginx) and is showing up in nginx error log as "upstream timed
out". Traffic between nginx and uwsgi server is all on a private network.
This is UFW setup on uwsgi servers:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing)
New profiles: skip
To Action From -- ------ ----
Anywhere on eth1 ALLOW IN Anywhere
Anywhere ALLOW IN 192.168.1.1
Anywhere (v6) on eth1 ALLOW IN Anywhere (v6)
Example UFW block in syslog:
Aug 20 13:56:16 kernel: [1028623.806318] [UFW BLOCK] IN=eth1 OUT=
MAC=68:05:ca:17:c9:fb:68:05:ca:17:ca:0e:08:00 SRC=192.168.1.1
DST=192.168.1.103 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=54877 DF PROTO=TCP
SPT=41652 DPT=8000 WINDOW=14600 RES=0x00 SYN URGP=0
If I disable UFW on Uwsgi servers the timeouts in nginx stops. At the
moment the timeouts/blocks are mostly frequent ajax calls (every 2mins),
but not exclusively.
Struggling to move Web Role to a smaller vmsize
Struggling to move Web Role to a smaller vmsize
I want to move my web role to a smaller VM size for cost saving purposes.
I changed the vmsize attribute in WebRole in the ServiceDefinition.csdef
accordingly. On publishing I received the following error:
Total requested resources are too large for the specified VM size
So I then reduced the size of the local storage resources in the
ServiceDefinition.csdef. Then I got the error:
The size of local resources cannot be reduced. Affected local resource is
DataFiles in role Website.
From what I have read online, I will need to delete the deployment and
republish it. But this will assign a new IP to my cloud service. I can't
have this happen.
Is there another solution to my problem?
I want to move my web role to a smaller VM size for cost saving purposes.
I changed the vmsize attribute in WebRole in the ServiceDefinition.csdef
accordingly. On publishing I received the following error:
Total requested resources are too large for the specified VM size
So I then reduced the size of the local storage resources in the
ServiceDefinition.csdef. Then I got the error:
The size of local resources cannot be reduced. Affected local resource is
DataFiles in role Website.
From what I have read online, I will need to delete the deployment and
republish it. But this will assign a new IP to my cloud service. I can't
have this happen.
Is there another solution to my problem?
Monday, 19 August 2013
Multiple Fragments in android
Multiple Fragments in android
I have a fragment which inflates a layout which is having horizontal list
view and other views. I have 5 set of arraylist having images which will
be displayed in horizontal list view and i have to display them as 5 rows
in my activity like this ArrayList1{ Product Title Image1 Image2
.....(horizontal list view) } ArryList2{ Product Title Image1 Image2
.....(horizontal list view) } . .
this is my sample code
newFragment = SeasonalFragment.newInstance(3);
getFragmentManager()
.beginTransaction()
.add(newFragment,"Seasonalfragmentcategory2")
.show(newFragment)
.commit();
class SeasonalFragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return
inflater.inflate(R.layout.seasonal_favorites_layout_contents,
container);
}
public static SeasonalFragment newInstance(int fragmentID) {
SeasonalFragment newFragment = new SeasonalFragment();
Bundle args = new Bundle();
args.putInt("FragmentID", fragmentID);
newFragment.setArguments(args);
return newFragment;
}
}
Only one row i am able to display.Please help
I have a fragment which inflates a layout which is having horizontal list
view and other views. I have 5 set of arraylist having images which will
be displayed in horizontal list view and i have to display them as 5 rows
in my activity like this ArrayList1{ Product Title Image1 Image2
.....(horizontal list view) } ArryList2{ Product Title Image1 Image2
.....(horizontal list view) } . .
this is my sample code
newFragment = SeasonalFragment.newInstance(3);
getFragmentManager()
.beginTransaction()
.add(newFragment,"Seasonalfragmentcategory2")
.show(newFragment)
.commit();
class SeasonalFragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
return
inflater.inflate(R.layout.seasonal_favorites_layout_contents,
container);
}
public static SeasonalFragment newInstance(int fragmentID) {
SeasonalFragment newFragment = new SeasonalFragment();
Bundle args = new Bundle();
args.putInt("FragmentID", fragmentID);
newFragment.setArguments(args);
return newFragment;
}
}
Only one row i am able to display.Please help
java code with only a few main entry
java code with only a few main entry
I want to read HBase source code, starting with test cases. I've searched
under the folder /src/test/java, and found
"org/apache/hadoop/hbase/PerformanceEvaluation.java",
"org/apache/hadoop/hbase/rest/PerformanceEvaluation.java"
"org/apache/hadoop/hbase/regionserver/DataBlockEncodingTool.java"
"org/apache/hadoop/hbase/regionserver/EncodedSeekPerformanceTest.java"
have main entry.
But there are many more test source files under the same folder. So I
wonder why only four classes have main entry. Is it sufficient to test
hbase with only the above four main entry?
Since I'm a newbie for Java open source project, anything related will
help. Thanks.
I want to read HBase source code, starting with test cases. I've searched
under the folder /src/test/java, and found
"org/apache/hadoop/hbase/PerformanceEvaluation.java",
"org/apache/hadoop/hbase/rest/PerformanceEvaluation.java"
"org/apache/hadoop/hbase/regionserver/DataBlockEncodingTool.java"
"org/apache/hadoop/hbase/regionserver/EncodedSeekPerformanceTest.java"
have main entry.
But there are many more test source files under the same folder. So I
wonder why only four classes have main entry. Is it sufficient to test
hbase with only the above four main entry?
Since I'm a newbie for Java open source project, anything related will
help. Thanks.
Python: Program unexpectedly terminates
Python: Program unexpectedly terminates
I used Sublime Text 2 and ran the program in the terminal. Here is the code:
print("Welcome to QuizWow!")
while True:
question = input("Enter the number of questions you will ask (up to
10): ")
###Program terminates after input: 'question' is answered by the user.
if question == '1':
qonea = input("Enter the question here: ")
qoneaa = input("Enter the answer here: ")
print ("1: ", qonea)
qoneaguess = input("Enter your guess here: ")
if qoneaguess == qoneaa:
print ("Correct")
else:
print ("Incorrect")
I used Sublime Text 2 and ran the program in the terminal. Here is the code:
print("Welcome to QuizWow!")
while True:
question = input("Enter the number of questions you will ask (up to
10): ")
###Program terminates after input: 'question' is answered by the user.
if question == '1':
qonea = input("Enter the question here: ")
qoneaa = input("Enter the answer here: ")
print ("1: ", qonea)
qoneaguess = input("Enter your guess here: ")
if qoneaguess == qoneaa:
print ("Correct")
else:
print ("Incorrect")
ImproperlyConfigured at /url/ - /static/ isn't a storage module
ImproperlyConfigured at /url/ - /static/ isn't a storage module
I am trying to upload a file.
this is my model.
def custom_path(instance, filename):
return '/'.join(['upload',instance.student.user.username,filename])
class Doc(models.Model):
uploadtime = models.DateTimeField(auto_now_add=True, blank=True)
datei = models.FileField(upload_to=custom_path,default='')
student = models.ForeignKey(Student,related_name='students_file')
title = models.TextField()
desc = models.TextField()
def __unicode__(self):
return self.title
and this is my views.py
def hochgeladen_danke(request):
if request.FILES.get('file'):
student = request.user.get_profile()
student.students_file.create(datei=request.FILES.get('file'),title='t',desc='t')
return
render_to_response('upload.html',{},context_instance=RequestContext(request))
my html:
<form action="/hochgeladen_danke/" method="post"
enctype="multipart/form-data">
{% csrf_token %}
File: <input type="file" name="file"/>
<button type="submit">upload</button>
</form>
my settings.py:
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
MEDIA_URL = "/media/"
STATIC_ROOT = os.path.join(PROJECT_PATH, "static")
STATIC_URL = '/static/'
when i try to upload a file. it is saying:
ImproperlyConfigured at /hochgeladen_danke/
/static/ isn't a storage module.
i dont know why this is happening. my custom_path seems to be right.
need badly help
I am trying to upload a file.
this is my model.
def custom_path(instance, filename):
return '/'.join(['upload',instance.student.user.username,filename])
class Doc(models.Model):
uploadtime = models.DateTimeField(auto_now_add=True, blank=True)
datei = models.FileField(upload_to=custom_path,default='')
student = models.ForeignKey(Student,related_name='students_file')
title = models.TextField()
desc = models.TextField()
def __unicode__(self):
return self.title
and this is my views.py
def hochgeladen_danke(request):
if request.FILES.get('file'):
student = request.user.get_profile()
student.students_file.create(datei=request.FILES.get('file'),title='t',desc='t')
return
render_to_response('upload.html',{},context_instance=RequestContext(request))
my html:
<form action="/hochgeladen_danke/" method="post"
enctype="multipart/form-data">
{% csrf_token %}
File: <input type="file" name="file"/>
<button type="submit">upload</button>
</form>
my settings.py:
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
MEDIA_URL = "/media/"
STATIC_ROOT = os.path.join(PROJECT_PATH, "static")
STATIC_URL = '/static/'
when i try to upload a file. it is saying:
ImproperlyConfigured at /hochgeladen_danke/
/static/ isn't a storage module.
i dont know why this is happening. my custom_path seems to be right.
need badly help
Necessity of synchronized on local variable
Necessity of synchronized on local variable
In the JSON-java library (org.json.JSONArray) I have found this code
snippet with a synchronized block around a method-local variable
public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter();
synchronized (sw.getBuffer()) {
return this.write(sw, indentFactor, 0).toString();
}
}
I do not understand the necessity for the synchronization here, as the
StringWriter is only local to the given method (and, why the
synchronization is on the Buffer). Is the synchronization really necessary
here, and if, why?
In the JSON-java library (org.json.JSONArray) I have found this code
snippet with a synchronized block around a method-local variable
public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter();
synchronized (sw.getBuffer()) {
return this.write(sw, indentFactor, 0).toString();
}
}
I do not understand the necessity for the synchronization here, as the
StringWriter is only local to the given method (and, why the
synchronization is on the Buffer). Is the synchronization really necessary
here, and if, why?
Convertion of Int value to words
Convertion of Int value to words
Kindly let me Know is there any way to convert integer value to Words in
postgresql..
as am trying to convert integer value "10" to "TEN".
Thank You.
Kindly let me Know is there any way to convert integer value to Words in
postgresql..
as am trying to convert integer value "10" to "TEN".
Thank You.
Sunday, 18 August 2013
JSlider get length of bar
JSlider get length of bar
So I'm wondering if there's a way to get the length of the bar of a
JSlider when it is displayed on a JPanel. Note that I'm looking for the
length of the actual bar the knob slides on, not the size of the component
itself. Thanks in advance.
So I'm wondering if there's a way to get the length of the bar of a
JSlider when it is displayed on a JPanel. Note that I'm looking for the
length of the actual bar the knob slides on, not the size of the component
itself. Thanks in advance.
globaltoLocal in addchild
globaltoLocal in addchild
I have an enemy that adds an attack movie clip. More specifically, this
attack movie (We'll call it masterAttack) clip is a blank movie clip that
acts like a super class, that will hold other attacks like a weak and
strong attack. So when my enemy attacks using a timer, it adds the
masterAttack on a global to local point.
Below is the Enemy timer attacking a tile the player is on:
if (Main.tileset[k].tileMiddle.hitTestObject(Main.player.visionPoint))
{
this.addChild(masterAttack);
var pt:Point = this.enemymagic.globalToLocal(new
Point(Main.tileset[k].x, Main.tileset[k].y));
masterAttack.masterEnemyAttackTimer.start();
this.masterAttackx = (pt.x);
this.enemymagic.y = (pt.y);
}
And Below is the masterAttack timer:
function mastertimer(event:TimerEvent) {
addChild(sludgeball); //This is one of the many
attacks pickable by the masterAttack
sludgeball.enemyattackTimer.start();
if (this.sludgeball.currentLabel == "End") {
this.sludgeball.gotoAndPlay(1);
masterEnemyAttackTimer.stop();
if (masterEnemyAttackTimer.running == false)
{
attackStop = true;
this.parent.removeChild(this);
removeChild(sludgeball);
}
}
My problem is, on the first run, the masterAttack will attack the player
wherever it is, then remove itself, which is good. Then the next time it
runs, the masterAttack is not hitting the player. It's as if the
globaltoLocal isn't working after the first run.
I have an enemy that adds an attack movie clip. More specifically, this
attack movie (We'll call it masterAttack) clip is a blank movie clip that
acts like a super class, that will hold other attacks like a weak and
strong attack. So when my enemy attacks using a timer, it adds the
masterAttack on a global to local point.
Below is the Enemy timer attacking a tile the player is on:
if (Main.tileset[k].tileMiddle.hitTestObject(Main.player.visionPoint))
{
this.addChild(masterAttack);
var pt:Point = this.enemymagic.globalToLocal(new
Point(Main.tileset[k].x, Main.tileset[k].y));
masterAttack.masterEnemyAttackTimer.start();
this.masterAttackx = (pt.x);
this.enemymagic.y = (pt.y);
}
And Below is the masterAttack timer:
function mastertimer(event:TimerEvent) {
addChild(sludgeball); //This is one of the many
attacks pickable by the masterAttack
sludgeball.enemyattackTimer.start();
if (this.sludgeball.currentLabel == "End") {
this.sludgeball.gotoAndPlay(1);
masterEnemyAttackTimer.stop();
if (masterEnemyAttackTimer.running == false)
{
attackStop = true;
this.parent.removeChild(this);
removeChild(sludgeball);
}
}
My problem is, on the first run, the masterAttack will attack the player
wherever it is, then remove itself, which is good. Then the next time it
runs, the masterAttack is not hitting the player. It's as if the
globaltoLocal isn't working after the first run.
NoSQL documentation, is there anything like a ER model or Relational model equivalent for NoSQL databases?
NoSQL documentation, is there anything like a ER model or Relational model
equivalent for NoSQL databases?
my question fortunately is up there in the title, I'm wondering, how does
one go about making documentation for NoSQL databases?, is there some kind
of equivalent? or am I missing the whole point?
equivalent for NoSQL databases?
my question fortunately is up there in the title, I'm wondering, how does
one go about making documentation for NoSQL databases?, is there some kind
of equivalent? or am I missing the whole point?
NSdata writeToURL not working
NSdata writeToURL not working
i'm trying to save a NsData file into a directory. that is the code of my
method:
- (void)cacheImage:(NSData *)imageData withTitle:(NSString *)title
{
NSURL *cacheURL = (NSURL *)[[self.fileMenager
URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask]
objectAtIndex:0]; //we take the URL of the cache Directory and comvert
the url of the cache directory into a string
NSURL *imageFolder = [cacheURL
URLByAppendingPathComponent:PHOTO_CACHE_FOLDER];
if ([self.fileMenager isWritableFileAtPath:[cacheURL path]]) { //check
if the cache directory is writable
if (![self.fileMenager createDirectoryAtURL:cacheURL
withIntermediateDirectories:NO attributes:nil error:nil]) {
//check if the directory of our image is already exist
NSURL * fileToWrite = [[imageFolder
URLByAppendingPathComponent:title isDirectory:NO]
URLByAppendingPathExtension:@"jpg"]; //take the complete url
of image
if ([imageData writeToURL:fileToWrite atomically:YES])
//atomically = safe write
{
NSArray *debug = [self.fileMenager
contentsOfDirectoryAtPath:[imageFolder path] error:nil];
for (NSURL *url in debug)
NSLog(@"url prooooo : %@",url);
}
}
}
}
that is an example of url (fileToWrite) where i try to write:
file://localhost/Users/MarcoMignano/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/93B0A0AC-EC13-4050-88CA-F46FBA11001E/Library/Caches/image_cache/Mozart%201.jpg
the point is simple, the method writeToURL return NO, i can't understand
why, the url looks correct.
somebody can help my' thank you.
i'm trying to save a NsData file into a directory. that is the code of my
method:
- (void)cacheImage:(NSData *)imageData withTitle:(NSString *)title
{
NSURL *cacheURL = (NSURL *)[[self.fileMenager
URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask]
objectAtIndex:0]; //we take the URL of the cache Directory and comvert
the url of the cache directory into a string
NSURL *imageFolder = [cacheURL
URLByAppendingPathComponent:PHOTO_CACHE_FOLDER];
if ([self.fileMenager isWritableFileAtPath:[cacheURL path]]) { //check
if the cache directory is writable
if (![self.fileMenager createDirectoryAtURL:cacheURL
withIntermediateDirectories:NO attributes:nil error:nil]) {
//check if the directory of our image is already exist
NSURL * fileToWrite = [[imageFolder
URLByAppendingPathComponent:title isDirectory:NO]
URLByAppendingPathExtension:@"jpg"]; //take the complete url
of image
if ([imageData writeToURL:fileToWrite atomically:YES])
//atomically = safe write
{
NSArray *debug = [self.fileMenager
contentsOfDirectoryAtPath:[imageFolder path] error:nil];
for (NSURL *url in debug)
NSLog(@"url prooooo : %@",url);
}
}
}
}
that is an example of url (fileToWrite) where i try to write:
file://localhost/Users/MarcoMignano/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/93B0A0AC-EC13-4050-88CA-F46FBA11001E/Library/Caches/image_cache/Mozart%201.jpg
the point is simple, the method writeToURL return NO, i can't understand
why, the url looks correct.
somebody can help my' thank you.
Building an app that communicates with a server
Building an app that communicates with a server
Im new to programming in general and am currently trying to get started
building my first mobile app on android.I am thinking of creating an app
which would send requests to a server, which would then process it and
load the data in the app, which the user would then view.
I have the following questions:
Communicating with the server
How would i program the app so that it is able to communicate with the
server (I'm planning to use a web host like godaddy/hostgator etc).
Logging in & Identification
How would i go about uniquely identifying each user of the app?Would it be
possible to identify and create an account for any user who downloads my
app from the marketplace and runs it for the first time(Maybe through the
gmail account they use for the android marketplace?) or would i have to
make each user manually sign up and login the first time they run my app?
I would appreciate it if someone could tell me the best way to get started
and how best to go about developing such an app.
Thanks!
Im new to programming in general and am currently trying to get started
building my first mobile app on android.I am thinking of creating an app
which would send requests to a server, which would then process it and
load the data in the app, which the user would then view.
I have the following questions:
Communicating with the server
How would i program the app so that it is able to communicate with the
server (I'm planning to use a web host like godaddy/hostgator etc).
Logging in & Identification
How would i go about uniquely identifying each user of the app?Would it be
possible to identify and create an account for any user who downloads my
app from the marketplace and runs it for the first time(Maybe through the
gmail account they use for the android marketplace?) or would i have to
make each user manually sign up and login the first time they run my app?
I would appreciate it if someone could tell me the best way to get started
and how best to go about developing such an app.
Thanks!
Curious function problem (EDIT: Not so curious, but didn`t see it at the time of writing)
Curious function problem (EDIT: Not so curious, but didn`t see it at the
time of writing)
This one is directly from my head and although it could be something
trivial I do not see the way to attack it but the problem looks
interesting and I want to share it with you, here it is:
Let us define function $f$ as $f(x)=\displaystyle\frac{\pi}{x}$.
Now, I wonder is there an easy way (or any way?) to prove (or disprove)
that for every interval $[x_1,x_2]\subset \mathbb R\setminus\{0\}$,
$x_1\neq x_2$ there exist irrational number $x_0\in [x_1,x_2]\setminus
\{\displaystyle\frac{a\pi}{b}|\displaystyle\frac{a}{b}\in\mathbb Q\}$,
such that $f(x_0)$ is rational number, in other words, that every interval
$[x_1,x_2]\subset \mathbb R\setminus\{0\}$ contains at least one
irrational number $x_0$ such that $f(x_0)$ is rational and $x_0$ is not
rational multiple of $\pi$.
Any ideas?
time of writing)
This one is directly from my head and although it could be something
trivial I do not see the way to attack it but the problem looks
interesting and I want to share it with you, here it is:
Let us define function $f$ as $f(x)=\displaystyle\frac{\pi}{x}$.
Now, I wonder is there an easy way (or any way?) to prove (or disprove)
that for every interval $[x_1,x_2]\subset \mathbb R\setminus\{0\}$,
$x_1\neq x_2$ there exist irrational number $x_0\in [x_1,x_2]\setminus
\{\displaystyle\frac{a\pi}{b}|\displaystyle\frac{a}{b}\in\mathbb Q\}$,
such that $f(x_0)$ is rational number, in other words, that every interval
$[x_1,x_2]\subset \mathbb R\setminus\{0\}$ contains at least one
irrational number $x_0$ such that $f(x_0)$ is rational and $x_0$ is not
rational multiple of $\pi$.
Any ideas?
Saturday, 17 August 2013
How do I go through directories to see if they have files and display only the directories with files?
How do I go through directories to see if they have files and display only
the directories with files?
Trying to create an Array or something to pass to my view.
The Array/something is supposed to store which directories have files in
them.
Then in my view I want to display only directories with files in them.
def index
@filter = params[:filter]
@type = params[:type]
@content = [] #maybe?
if
directory_path = "public/files/marketing/voip"
directory = Dir.glob("#{directory_path}/#{@filter}/#{@type}")
directory.each do |data| # not sure???
if File.exists?(data) && !File.directory?(data)
# not sure???
@content = Array.new("#{@type}")
end
@view = 'types'
end
#Loop through directories to see if files exist
#If files exist add directory name to @array
end
My view:
<%# Loop through array and create html view for each folder %>
# no idea?
<% @content.each do |o| %>
<% if type.exists %>
<div class="row images">
<div class="span3">
<h5 class="pagination-centered">
<%= link_to (image_tag "/img/folder.jpg", alt: "Buyer's Guides", width:
"75px"), action: "index", filter: @filter, type: "buyers_guides" %>
<%= link_to "Buyer's Guides", action: "index", filter: @filter, type:
"buyers_guides" %>
</h5>
</div>
</div>
I am new to Ruby on Rails, any suggestions?
the directories with files?
Trying to create an Array or something to pass to my view.
The Array/something is supposed to store which directories have files in
them.
Then in my view I want to display only directories with files in them.
def index
@filter = params[:filter]
@type = params[:type]
@content = [] #maybe?
if
directory_path = "public/files/marketing/voip"
directory = Dir.glob("#{directory_path}/#{@filter}/#{@type}")
directory.each do |data| # not sure???
if File.exists?(data) && !File.directory?(data)
# not sure???
@content = Array.new("#{@type}")
end
@view = 'types'
end
#Loop through directories to see if files exist
#If files exist add directory name to @array
end
My view:
<%# Loop through array and create html view for each folder %>
# no idea?
<% @content.each do |o| %>
<% if type.exists %>
<div class="row images">
<div class="span3">
<h5 class="pagination-centered">
<%= link_to (image_tag "/img/folder.jpg", alt: "Buyer's Guides", width:
"75px"), action: "index", filter: @filter, type: "buyers_guides" %>
<%= link_to "Buyer's Guides", action: "index", filter: @filter, type:
"buyers_guides" %>
</h5>
</div>
</div>
I am new to Ruby on Rails, any suggestions?
KeyEventArgs and MouseEventArgs
KeyEventArgs and MouseEventArgs
I'm trying to make a button that handles both enters and clicks. I've set
up my sub procedure to handle both keyups and mouse clicks, however I
cannot access MouseEventArgs from EventrArs nor KeyEventArgs from
System.EventArgs. How can I do such?
I'm trying to make a button that handles both enters and clicks. I've set
up my sub procedure to handle both keyups and mouse clicks, however I
cannot access MouseEventArgs from EventrArs nor KeyEventArgs from
System.EventArgs. How can I do such?
Syntax issues/problems with Jinja2
Syntax issues/problems with Jinja2
Having two seperae issues with jinja2. The first being this page doesn't
seem to want to recognize the index properly for this nested dictionary.
Some info is provided below:
jinja2.exceptions.UndefinedError
UndefinedError: dict object has no element 0
Traceback
File
"/Users/mastergberry/Development/lolsummoners/lol-summoners/lolsummoners/templates/site/profile/ranked_stats.jinja2",
line 44, in block "content"
Display the sourcecode for this frameOpen an interactive python shell in
this frame<td><div class="champion_sprite gtooltip champion{{ championId
}}"></div>{{ champions[(championId)|int]['name'] }}</td>
File
"/Users/mastergberry/Development/lolsummoners/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py",
line 353, in getitem
Display the sourcecode for this frameOpen an interactive python shell in
this framereturn obj[argument]
>>> print player['ranked_stats'].items()[0]
(u'122', {u'MAX_CHAMPIONS_KILLED': 12, u'TOTAL_TRIPLE_KILLS': 4,
u'TOTAL_MINION_KILLS': 2666, u'TOTAL_DAMAGE_DEALT': 2194168,
u'MOST_SPELLS_CAST': 0, u'TOTAL_SESSIONS_PLAYED': 21,
u'TOTAL_TURRETS_KILLED': 22, u'TOTAL_SESSIONS_WON': 0,
u'TOTAL_MAGIC_DAMAGE_DEALT': 236864, u'TOTAL_DAMAGE_TAKEN': 531607,
u'MOST_CHAMPION_KILLS_PER_SESSION': 12, u'TOTAL_PENTA_KILLS': 0,
u'TOTAL_SESSIONS_LOST': 0, u'TOTAL_QUADRA_KILLS': 0,
u'TOTAL_TIME_SPENT_DEAD': 4023, u'TOTAL_PHYSICAL_DAMAGE_DEALT': 1847576,
u'MAX_NUM_DEATHS': 12, u'TOTAL_DOUBLE_KILLS': 17, u'TOTAL_CHAMPION_KILLS':
148, u'TOTAL_UNREAL_KILLS': 0, u'TOTAL_DEATHS_PER_SESSION': 122,
u'TOTAL_GOLD_EARNED': 216944, u'TOTAL_ASSISTS': 109, u'TOTAL_FIRST_BLOOD':
0})
>>> print player['ranked_stats'].items()[0][0]
122
>>> print champions[122]
{'displayName': u'Darius', 'name': u'Darius', 'title': u'the Hand of Noxus'}
<tbody>
{% for championId, data in
player['ranked_stats'].items() %}
<tr>
<td><div class="champion_sprite
gtooltip champion{{ championId
}}"></div>{{
champions[championId|int]['name']
}}</td>
<td>{{ data['TOTAL_SESSIONS_PLAYED']
}}</td>
<td>{{ (data['TOTAL_CHAMPION_KILLS'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
<td>{{
(data['TOTAL_DEATHS_PER_SESSION'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
<td>{{ (data['TOTAL_ASSISTS'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
<td>{{ (data['TOTAL_MINION_KILLS'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
</tr>
{% endfor %}
</tbody>
Happy to provide extra info.
Second problem is this data isn't being added properly.
{% set offenseTotal = 0 %}
<div class="mastery_ Offense">
{% for i in range(511, 571, 10) %}
{% set currentMax = i + 4 %}
{% for j in range(i, currentMax) %}
{% if j in page['offensive'] %}
<div class="masterblock {{ "maxrank"
if page['offensive'][j] ==
denominators[j] }}">
<div class="mastery_icon">
<div data="{{ j }}"
id="tra-target-{{ j }}"
class="masterysprite gtooltip
m{{ j }}" ></div>
<div class="master_rank">{{
page['offensive'][j] }}/{{
denominators[j] }}</div>
{# This was a test case and
isn't even working {% set
offenseTotal = (offenseTotal +
1) %} #}
{% set offenseTotal =
offenseTotal +
page['offensive'][j] %}
</div>
</div>
{% elif j not in [521, 534, 554, 561, 563,
564] %}
<div class="masterblock norank">
<div class="mastery_icon">
<div class="masterysprite m{{
j }}" ></div>
<div class="master_rank">0/{{
denominators[j] }}</div>
</div>
</div>
{% else %}
<div class="masterblock"></div>
{% endif %}
{% endfor %}
{% endfor %}
<div class="masterytitle">
Offense : {{ offenseTotal }}
</div>
</div>
Once again happy to provide extra info. Thanks for any guidance!
Having two seperae issues with jinja2. The first being this page doesn't
seem to want to recognize the index properly for this nested dictionary.
Some info is provided below:
jinja2.exceptions.UndefinedError
UndefinedError: dict object has no element 0
Traceback
File
"/Users/mastergberry/Development/lolsummoners/lol-summoners/lolsummoners/templates/site/profile/ranked_stats.jinja2",
line 44, in block "content"
Display the sourcecode for this frameOpen an interactive python shell in
this frame<td><div class="champion_sprite gtooltip champion{{ championId
}}"></div>{{ champions[(championId)|int]['name'] }}</td>
File
"/Users/mastergberry/Development/lolsummoners/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py",
line 353, in getitem
Display the sourcecode for this frameOpen an interactive python shell in
this framereturn obj[argument]
>>> print player['ranked_stats'].items()[0]
(u'122', {u'MAX_CHAMPIONS_KILLED': 12, u'TOTAL_TRIPLE_KILLS': 4,
u'TOTAL_MINION_KILLS': 2666, u'TOTAL_DAMAGE_DEALT': 2194168,
u'MOST_SPELLS_CAST': 0, u'TOTAL_SESSIONS_PLAYED': 21,
u'TOTAL_TURRETS_KILLED': 22, u'TOTAL_SESSIONS_WON': 0,
u'TOTAL_MAGIC_DAMAGE_DEALT': 236864, u'TOTAL_DAMAGE_TAKEN': 531607,
u'MOST_CHAMPION_KILLS_PER_SESSION': 12, u'TOTAL_PENTA_KILLS': 0,
u'TOTAL_SESSIONS_LOST': 0, u'TOTAL_QUADRA_KILLS': 0,
u'TOTAL_TIME_SPENT_DEAD': 4023, u'TOTAL_PHYSICAL_DAMAGE_DEALT': 1847576,
u'MAX_NUM_DEATHS': 12, u'TOTAL_DOUBLE_KILLS': 17, u'TOTAL_CHAMPION_KILLS':
148, u'TOTAL_UNREAL_KILLS': 0, u'TOTAL_DEATHS_PER_SESSION': 122,
u'TOTAL_GOLD_EARNED': 216944, u'TOTAL_ASSISTS': 109, u'TOTAL_FIRST_BLOOD':
0})
>>> print player['ranked_stats'].items()[0][0]
122
>>> print champions[122]
{'displayName': u'Darius', 'name': u'Darius', 'title': u'the Hand of Noxus'}
<tbody>
{% for championId, data in
player['ranked_stats'].items() %}
<tr>
<td><div class="champion_sprite
gtooltip champion{{ championId
}}"></div>{{
champions[championId|int]['name']
}}</td>
<td>{{ data['TOTAL_SESSIONS_PLAYED']
}}</td>
<td>{{ (data['TOTAL_CHAMPION_KILLS'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
<td>{{
(data['TOTAL_DEATHS_PER_SESSION'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
<td>{{ (data['TOTAL_ASSISTS'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
<td>{{ (data['TOTAL_MINION_KILLS'] /
data['TOTAL_SESSIONS_PLAYED'])|round(1)
}}/game</td>
</tr>
{% endfor %}
</tbody>
Happy to provide extra info.
Second problem is this data isn't being added properly.
{% set offenseTotal = 0 %}
<div class="mastery_ Offense">
{% for i in range(511, 571, 10) %}
{% set currentMax = i + 4 %}
{% for j in range(i, currentMax) %}
{% if j in page['offensive'] %}
<div class="masterblock {{ "maxrank"
if page['offensive'][j] ==
denominators[j] }}">
<div class="mastery_icon">
<div data="{{ j }}"
id="tra-target-{{ j }}"
class="masterysprite gtooltip
m{{ j }}" ></div>
<div class="master_rank">{{
page['offensive'][j] }}/{{
denominators[j] }}</div>
{# This was a test case and
isn't even working {% set
offenseTotal = (offenseTotal +
1) %} #}
{% set offenseTotal =
offenseTotal +
page['offensive'][j] %}
</div>
</div>
{% elif j not in [521, 534, 554, 561, 563,
564] %}
<div class="masterblock norank">
<div class="mastery_icon">
<div class="masterysprite m{{
j }}" ></div>
<div class="master_rank">0/{{
denominators[j] }}</div>
</div>
</div>
{% else %}
<div class="masterblock"></div>
{% endif %}
{% endfor %}
{% endfor %}
<div class="masterytitle">
Offense : {{ offenseTotal }}
</div>
</div>
Once again happy to provide extra info. Thanks for any guidance!
Subscribe to:
Comments (Atom)