Monday 30 September 2013

Unable to adjust php.ini max upload size directive on Centos 6.3

Unable to adjust php.ini max upload size directive on Centos 6.3

Currently i'm setting up Centos 6.3 (64 bit) on vm and installing
Wordpress: Already adjust /etc/php.ini but seems like overwritten by other
settings.
Suspect this is due to selinux feature. My goal is setting up all
Wordpress with all feature working like Media files folder creation
(permission issue), appropriate max memory and max upload size.
Any suggestion welcome. Thanks.
OS environment snapshot: Linux 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22
12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux Apache/2.2.15 (Unix)PHP
5.3.3 (cli) (built: Jul 12 2013 20:35:47) Zend Engine v2.3.0 MySQL
version: 5.1.61 Source distribution

Will re-installing phpmyadmin will have any effect on my Databases?

Will re-installing phpmyadmin will have any effect on my Databases?

I am quiete new and somehow I crashed my phpmyadmin website, it can't be
displayed without errors after changing the port of it once. So does it
has any effect on my databases when I reinstall my phpmyadmin ? I guess it
will not change anything since it doesn't come with mySQL together, but I
want to be sure. So :
Can I simply uninstall and re-install without loosing any data from mySQL
databases?
I use an Ubuntu 12.04 server, thx in advance! if you need more
information...letme know.

psycopg2 not returning results

psycopg2 not returning results

I am trying to use psycopg2 with my postgresql database just running on my
local machine can't get it to return results no matter what I try. It
seems to connect to the database ok, since if I alter any of the config
parameters it throws errors, however, when I run seemingly valid and
result worthy queries, I get nothing.
My db is running and definitely has a table in it:
postgres=# \c
You are now connected to database "postgres" as user "postgres".
postgres=# select * from foos;
name | age
---------+-----
Sarah | 23
Michael | 35
Alice | 12
James | 20
John | 52
(5 rows)
My python code connects to this database but no matter what query I run, I
get None:
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> conn = psycopg2.connect("dbname='postgres' user='postgres'
host='localhost'")
>>> cur = conn.cursor()
>>> print cur.execute("select * from foos;")
None
>>> print cur.execute("select * from foos")
None
>>> print cur.execute("select name from foos")
None
>>> print cur.execute("select f.name from foos f")
None
Am I doing something obviously wrong? How can I start debugging this, I
don't know where to start since it connects just fine?

webbrowser control in not showing the ad link

webbrowser control in not showing the ad link

I am trying to show this link "http://i.wund.com/" but it is not showing
the ad link in the control. however when I tried this link in phone's
browser, it didn't work. I have set the JS enabled. Still not able to see
the whole content. what could be the problem?

Sunday 29 September 2013

Multithreading with swing

Multithreading with swing

I have a question about the use of threads in a gui application. Say (as a
simplistic example) i have a swing application with a series of images. I
have two threads i want to run that fetch an image of a parent
respectively. (So for a given number of students, get a mother image and a
father image from each server endpoint). The returned image of the father
and the mother is then appended on to the image on screen so i have a
series of images with a mother, father, mother, father for multiple
students.
How can i schedule this in a multithreaded environment? Each call to get a
mother or father image has to be in parallel and not block the displaying
of the images on screen. Does the image displayed on the screen refresh
after each thread returns an image? How will this be structured?

PDO statement returns zero rows for date WHERE clause

PDO statement returns zero rows for date WHERE clause

I have two files, one is page that shows the latest additions to my site,
the other is a link to the first page.
problem: if i include a 'like' keyword instead of '=' in the sql, the
query works. however, when i use '=' (which is what i want), it returns
zero rows.
code snippets:
front-page.php
echo "On ".max($last_date).","." we had "."<a
href='/latest-txt.php?date=$md'>".count($last_posts)."</a>"." text posts!"
latest-text.php
$query = $_GET[$md];
$stmt = $db->prepare("SELECT * FROM $db_tb_name WHERE $db_tb_atr_name5 = ?
ORDER BY RAND () LIMIT 0, 15");
if($stmt->execute(array("%$query%"))){
echo "Search Results<ol>";
while($data_fetch = $stmt->fetch(PDO::FETCH_ASSOC)){
echo "<li>";
echo "<div class='tagtext'>AUTHOR: ";
echo substr($data_fetch[$db_tb_atr_name2], 0,160)," "," ";
echo "TAG: ";
echo substr($data_fetch[$db_tb_atr_name3], 0,160)," ";
//echo substr($data_fetch[$db_tb_atr_name4], 0,160)," ";
echo "</div>";
echo "<div class='tagtext'>MESSAGE: ";
echo substr($data_fetch[$db_tb_atr_name], 0,160);
echo "</div>";
//echo substr($data_fetch[$db_tb_atr_name], 0,160);
echo "</li><hr/>";
}
}
echo "</ol>";
can anybody help? thanks.

Android: CookieSyncManager, stopSync and Sync

Android: CookieSyncManager, stopSync and Sync

i am beginner of Android developer, just want to make clear with it. i
just wondering
CookieSncManager.getInstance().stopSync() is it suppose to put inside
onPause() and CookieSncManager.getInstance().sync() put inside onResume();
But based on the documentation that i read (The Following Picture); It is
different with what i thought. Is it something wrong with the
documentation? please correct me, thanks.

Python convert email

Python convert email

I am writing a small program that reads in email and outputs only part of it.
Example
someone.lastname@example.com
I want the output to be someonel
so in this case i want the first part of the email before the "." and then
the first letter of the second part in this case "l"
I need some assistance on how to concatenate these 2 parts taking only one
character from the second part after the "."
thank you in advance

Saturday 28 September 2013

How to determine birth week in current year for 7 day coupon

How to determine birth week in current year for 7 day coupon

I am trying to get my customers birth dates, but with the current
year(sysdate). For example, John Brown was born in 01-JAN-65, I would like
to create a query that retrieves the previous Monday and next Sunday from
John's birthday, so that the customer can see that their coupon is valid
between that time seven day time frame. So for John Brown, the row would
have three columns
FullName, Monday, and Sunday and the data would be John Brown 31-DEC-2012
06-JAN-2013
My table definition is: Table Name - Customers Columns Customer_ID
First_Name Last_Name DOB Phone
I have read Oracle Database 11g's chapter 5 "Storing and Processing Dates
and Times", but did not find a solution to my problem. Please help, thank
you.

does #apt-get..... mean the same as sudo apt-get

does #apt-get..... mean the same as sudo apt-get

I'm looking some command line instructions. I'm supposed to have Ubuntu
Linux Server with Python 2.7 (and why can't there be a simple explanation
of how to get Python 2.7 on your ULS somewhere!).
One of the first command line instructions is: "#apt-get install
build-essential pkg-config git-core python-dev libjpeg62-dev zlib1g-dev
libxslt1-dev groff-base"
What does the # symbol mean? Is it a placeholder for sudo?

json IP to db or file

json IP to db or file

First of all here is my code:
<html>
<head>
<title>the title</title>
<?php
$con=mysqli_connect("localhost","root","","test");
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("grandpaswine");
$query = "SELECT * FROM ips";
$result = mysql_query($query);
$dServer = array();
$rowNum = 0;
while($row = mysql_fetch_assoc($result)){
$dServer[] = $row['ip'];
$dServerC[] = $row['counter'];
$rowNum++;
}
?>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
var a = <?php echo json_encode($dServer); ?>;
var aC = <?php echo json_encode($dServerC); ?>;
var rowNum = <?php echo json_encode($rowNum)?>;
for (var i=0;i<rowNum;i++)
{ var city ;
var lon ;
var lat ;
var ip ;
var all;
var url = encodeURI('http://www.freegeoip.net/json/'+a[i]);
$.getJSON(url, function(jd) {
city = jd.city ;
lon = jd.longitude;
lat = jd.latitude;
ip = jd.ip;
console.log(city+ip);
document.write(city+ip)
});
}
});
</script>
</head>
<body>
</body>
</html>
So I have huge number of IP addresses and I use the www.freegeoip.net/json
to get the ip adresses details. In this code I write the result to the
console and to the page. And it works fine!
BUT
I would like to store the result to somewhere, for example: to file, to
database
How can I do this easily?

Calculator system outprint result

Calculator system outprint result

could somone take a look at my calculator and tell me why its stopping
after asking me for numbers and what i wanna do if its add sub div or
multi but doenst print out the result or do you wanna continune yes or no
. Thanks in advance below is my code
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double a,b,c;
int choice = 0;
a=b=c=0.0;
while(true) {
System.out.println("Enter two numbers");
a = Double.parseDouble(sc.nextLine());
b = Double.parseDouble(sc.nextLine());
System.out.println("Enter your choice");
System.out.println("1. Add");
System.out.println("2. Sub");
System.out.println("3. Mul");
System.out.println("4. Div");
choice = Integer.parseInt(sc.nextLine());
switch(choice) {
case 1 :
c = new Add().doMath(a,b);
break;
case 2 :
c = new Sub().doMath(a,b);
break;
case 3 :
c = new Div().doMath(a,b);
break;
case 4 :
c = new Mul().doMath(a,b);
break;
default:
break;
}
System.out.println(c + "this is the answere");
System.out.println("would you like to continue? (Y/N)");
if("N".equalsIgnoreCase(sc.nextLine())) { // careful with
the paranthesis
break;
}
}
}
}
interface MathOp {
public double doMath(double a, double b);
}
class Add implements MathOp{
public double doMath(double a, double b) {
return (a + b);
}
}
class Sub implements MathOp{
public double doMath(double a, double b) {
return (a - b);
}
}
class Div implements MathOp{
public double doMath(double a, double b){
return (a / b);
}
}
class Mul implements MathOp{
public double doMath(double a, double b){
return (a * b);
}
}

Friday 27 September 2013

Play video as background in window with DirectShow

Play video as background in window with DirectShow

I'm almost there. I want to play a MPEG file as a background video inside
a border-less window. I have the window and just after creating it I add
this code:
// Global vars
IGraphBuilder* g_pGraphBuilder;
IMediaControl* g_pMediaControl;
IMediaEventEx* g_pMediaEvent;
IMediaPosition* g_pMediaPosition;
HWND hWndParent;
// WinMain. Creates the window then executes StartVideoBackground()
// bool StartVideoBackground()
RECT grc;
IVideoWindow *pVidWin = NULL;
HRESULT hr = CoInitialize(NULL);
hr = CoCreateInstance(
CLSID_FilterGraph,
NULL,
CLSCTX_INPROC_SERVER,
IID_IGraphBuilder,
(void**)&g_pGraphBuilder
);
g_pGraphBuilder->QueryInterface(
IID_IMediaControl,
(void**)&g_pMediaControl
);
g_pGraphBuilder->QueryInterface(
IID_IMediaEvent,
(void**)&g_pMediaEvent
);
g_pGraphBuilder->QueryInterface(
IID_IMediaPosition,
(void**)g_pMediaPosition
);
g_pGraphBuilder->QueryInterface(
IID_IVideoWindow,
(void **)&pVidWin
);
pVidWin->put_Owner((OAHWND)hWndParent);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
GetClientRect(hWndParent, &grc);
pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom);
hr = pVidWin->put_Visible(OAFALSE);
hr = pVidWin->put_Owner(NULL);
if (!FAILED(g_pGraphBuilder->RenderFile(L"Video.mpeg", NULL)))
g_pMediaControl->Run();
I removed some lines that were checking for errors. The idea is that when
starting the application I can see my border-less main window showing up
and also a second window playing the video. What I'd like is the video to
be played inside the main window, without borders, like a background (over
which I will add more controls). Is that possible?

Set focus after a particular item in an inputbox in jquery/javascript

Set focus after a particular item in an inputbox in jquery/javascript

So lets say I have an input box that looks something like this:
<input id="fuzzyname" value="" placeholder="&Fuzzybear">
I want to use javascript/JQuery so that when I click in that input box it
will put the cursor after the & and the placeholder becomes the value in
the input box.
This is kind of what I have so far:
$("#fuzzyname").focus(function () {
var value = $(this).attr("placeholder");
var symbol = "&";
var cursorIndex = value.indexOf(symbol);
//This is where I want to output the value into the inputbox with
the cursor after cursorIndex
});

Receiving NSNotification on different queue from where was sent, and serial message receipt

Receiving NSNotification on different queue from where was sent, and
serial message receipt

How do you guarantee that a message is sent to an object after that object
has received a notification on a different thread?
Background:
Consider two objects, X and Y. X posts an NSNotification through
NSNotificationCenter on thread Q. Y is registered as an observer of that
notification, but on thread P. Like this:
Y.m
dispatch_async(P, ^{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handler:) name:MyNotification object:X];
};
- (void)handler:notif { ... }
- (void)iHopeYouGetThisMessageAfterYouGotMyNotification:sender
didYou:(BOOL *)b { ... }
X.m
dispatch_async(Q, ^{
[[NSNotificationCenter defaultCenter]
postNotificationName:MyNotification object:self]
[Y iHopeYouGetThisMessageAfterYouGotMyNotification:self didYou:NULL];
};
The question is: if X sends a message to Y after posting the notification,
how do you ensure Y gets the message after observing the notification, not
before?

How to set permanent memory settings for java?

How to set permanent memory settings for java?

I use jre-7u40-linux-x64 on SL6.4. Server with more than 30Gb of RAM.
User's memory limits sets to several gigabytes, but command java returns
error. "Not enough memory heap..."
Under root it's ok and -XshowSettings:vm shows that memory size is
automaticaly estimated.
Under user with options -Xmx256m it's ok also.
So is it possible to set the property(-Xmx256m) permanently?
I tried environtment variables (JAVA_OPTS,JAVA_OPTIONS) and jvm.cfg. With
no results.
Any advices and keywords? Thank you.

Java Eclipse Program Run automatically every week

Java Eclipse Program Run automatically every week

I have a program written in java with Ecplise. It's a big project (it uses
mysql, threads, etc) and i have run it only on my pc. Now i need to
install it on Linux Server and run it automatically every week (on
monday). How can i do that?

Creating Acrylic Photo with PHP

Creating Acrylic Photo with PHP

I have to develop a PHP script to apply acrylic effect on images. Is there
any suitable library to do that?
I have to create such images dynamically:1

Thursday 26 September 2013

window.location.href is not working in my window

window.location.href is not working in my window

I have a website uses ajax to post the data to mysql db along with php.
This problem (non working of "window.location.href") started 3 days before
when I accidently deleted xampp folder, I had a backup of all root files
so I backed up all. But till then this function is not redirecting to the
another page only in my system (have checked with main site at
"http://www.slitify.com/WS0002/source/pages/notifications.html", and the
same page at localhost, in different browsers, in windows xp mode, in
different login account of my pc). These pages work fine when I access the
site from my mobile, or from any other PC.
Have reinstalled xampp, have updated windows but none of the things is
working; please suggest if anybody have any idea for the cause of the
problem?

Wednesday 25 September 2013

How to put Line break in javascript ?

How to put Line break in javascript ?

I want to put line break in javascript. I have used <br/>, \n and %0D%0A
but nothing happened.
Here is my code:
var textpara = 'This is dummy text. It will blink and then show.';
I want this:
This is dummy text.
It will blink and then show.
Any suggestions ?

Thursday 19 September 2013

Javascript doesn't give correct integer output -- Project Euler 20

Javascript doesn't give correct integer output -- Project Euler 20

I'm trying to solve Project Euler Problem 20, while I think to solution is
quite trivial, turns out Javascript doesn't give me the correct output:
var fact = 1;
for (var i = 100; i > 0; i--) {
fact *= i;
}
var summed = 0;
while (fact > 0) {
summed += Math.floor(fact % 10);
fact = fact / 10;
}
console.log(summed); //587
http://jsfiddle.net/9uEFj/
Now, let's try solving 100! from the bottom (that is, 1 * 2 * 3 * ... *
100 instead of 100 * 99 * .. * 1 like before ):
var fact = 1;
for (var i = 1; i <= 100; i++) {
fact *= i;
}
var summed = 0;
while (fact > 0) {
summed += Math.floor(fact % 10);
fact = fact / 10;
}
console.log(summed); //659
http://jsfiddle.net/YX4bu/
What is happening here? Why different multiplication order give me
different result? Also, why none of the results give me the correct result
of problem 20? (648)

Load the style only if the shortcode is found

Load the style only if the shortcode is found

I'm writing my first wordpress plugin. How can I load javascript into head
section from the content?
Basically to load a style we call this
function theme_name_scripts() {
wp_enqueue_style('wpscf-styles10', plugin_dir_url( __FILE__ ) .
'css/style.css');
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
But I need to load the style ONLY if the shortcode is found in the text.
So I'm using the following
add_filter('the_content','wpscf_render_plugin');
function wpscf_render_plugin($content) {
if($condition_which_checks_if_shortcode_found) {
//load the scripts here
}
}
How can I do that?
Thanks

Dumping textarea content into JS Alert?

Dumping textarea content into JS Alert?

So, I have a form using TinyMCE editor and for debugging purposes I'd like
to have the content of the textarea dumped into a simple JS alert box on
submit:
<form method="post" action="somepage">
<textarea name="content" style="width:50%"></textarea>
<p>
<input type="submit" value="Submit">
</form>
Do you have an idea how this can me achieved? Thanks a ton! G

MySQL - Multiply column by value depending on that column

MySQL - Multiply column by value depending on that column

How can I write this.. I have table 'Company' with a column 'Size'. The
size references enums. I need to display the average company size as alias
AS 'AverageEstimatedCompanySize' by substituting column 'Size' when column
'Size' is:
1 = 15
2 = 30
3 = 50
4 = 100
5 = 250
In other words, my table shows company size as either 1, 2, 3, 4 or 5.
While 1 is actually a company size of 15.
This is all part of a bigger query:
SELECT COUNT(DISTINCT(ID)) AS 'Total # of Opps', AVG(Size*?) AS
'AverageEstimatedCompanySize'
FROM persontable AS POJT INNER JOIN opportunity
ON POJT.ID = opportunity.id
WHERE opportunity.TimeStamp >= '2012-01-01' AND opportunity.TimeStamp <=
'2012-12-31' AND POJT.JobTitleID IN
(SELECT Id
FROM job
WHERE CategoryID IN
(SELECT id
FROM job_category
WHERE name IN ('Sc', 'Ma', 'Co', 'En', 'Tr')))

XMLDOMNode::childNodes fails to read all nodes

XMLDOMNode::childNodes fails to read all nodes

I am using MSXML to read an XML string from memory. A simplified version
of the structure is below. I am trying to read the //P1 list of Y1 using
XMLDOMNode::childNodes. The function does not fail but it reads only the
first Y1 field (XMLDOMNodeList::length returns 1). If I change the name of
//C1/P1 to //C1/P2, or move the list before //C1, then everything works
fine. I cannot modify the XML string.
Thank you.
<R1>
<T1>123</T1>
<C1>
<P1>2</P1>
</C1>
<P1>
<Y1></Y1>
<Y1></Y1>
</P1>
</R1>

Storyboard on Xcode 5 by default, what about use it just as an editor for view controllers?

Storyboard on Xcode 5 by default, what about use it just as an editor for
view controllers?

I never felt comfortable using storyboard, I always look at them as a sort
of easy way to do easy things, but when customization come out they are
sort of rigid or more verbous than code instead. That's my opinion, but I
must tell the truth I never used them, so of course I might be wrong. The
segue, unwind system it seems to me very inelegant solution and the fact
that they return id object will require casts and a lot of if else coding
to match correct identifier.
It seems that there is no way to create a new custom initializer for view
controllers, for me that's a big deal, beacause I use a lot in abstract
classes.
Saying that, storyboard is the default options on Xcode 5, but not only,
the storyboard editor is really "light years" away from nib editor. You
can zoom, (usefull for auto layout), it seems an easier way if you want to
create different paths between iphone and ipad interface, there are also
more options, very important in iOS7. I'm talking about extendedEdges
property and top/bottom layout guide.

Actual question: I'm wondering if it will be correct and possible to
manage navigation in code "as usual" and use the storyboard as an editor
and container of all application view controllers. Is there someone that
uses this approach?

set a property value from object in task

set a property value from object in task

I have an object called Settings. it has a property called BusyDoingAction
of type bool
public class Settings : ObservableObject
{
private bool busyDoingAction;
public bool BusyDoingAction
{
get { return this.busyDoingAction; }
set
{
this.busyDoingAction= value;
OnPropertyChanged(() => BusyDoingAction);
}
}
I have another class called FileAdding,
private readonly string[] files;
private bool busy;
public FileAdding(string[] files, bool busyAction)
{
this.files = files;
this.busy= busyAction;
}
now, in my ViewModel I have the following:
var fileAdding = new FileAdding(files, Settings.BusyDoingAction);
if (!fileAdding.Initialize())
return;
Task<bool>.Factory.StartNew(() =>
{
fileAdding.Execute(CToken);
return fileAdding.Deinitialize();
}, CToken);
}
and in the FileAdding Initialize() function I have:
public bool Initialize()
{
busy = true;
return true;
}
public bool Deinitialize()
{
busy = false;
return true;
}
the problem is: the BusyDoingAction is not changing in the FileAdding and
iam not getting any value changed notification for that property ..
The Property is bound to the mainGrid in my application, and iam using it
to detect whether the application is busy and enable/disable the grid
depending on the value of BusyDoingAction
I don't know what iam doing wrong, but I need to set the property value of
BusyDoingAction in that busyDoingAction.Intialize/Deinitialize function ..
any help is really appreciated ..

Wednesday 18 September 2013

Selenium Webdriver Upload File sendkeys don't work

Selenium Webdriver Upload File sendkeys don't work

I need to automate upload file.
This does not work:
WebElement FilePath = driver.findElement(By.name(//name));
FilePath.sendKeys(//path);
This is the behavior is manual execution:
Step 1: Click Browse Button

Step 2: Select File from "Upload File" Box

Step 3: Click Open then you will see the file has been selected

Step 4: Click Validate Button


Please Help me.
Thanks.

Can one be a Python and Ruby developer at the same time? [on hold]

Can one be a Python and Ruby developer at the same time? [on hold]

What are the advantages and disadvantages of someone that's programming in
BOTH Python and Ruby?
I feel like Python is really good for number crunching and performance (I
may be wrong here), while Ruby is good with regards to expressiveness,
good metaprogramming, and all that Rails.
Note that this is a two-sided question, so it would be good to have people
who have found themselves working in both Ruby and Python to answer this.
Thanks in advance! :)

Xcode 5 can't open .m file

Xcode 5 can't open .m file

I installed Xcode 5 a few hours ago. I opened my project with it. I have
several .h and .m file in my project. I could view all of them except one
of my .m file. When i clicked that .m file, the cursor became rainbow and
nothing happened.
To be sure , i checked my project folder, go to the that .m file and click
get info. I could see the preview that file. Also i can open it in text
editors.
I couldn't find the problem. Any advice is appreciated.
Best Regards,
Taha

mysql query output projector and whiteboard

mysql query output projector and whiteboard

I've got this small assignment: Find those rooms that have projectors, but
not whiteboards.
CREATE TABLE Equipment (
room VARCHAR(15),
type VARCHAR(20)
);
INSERT INTO Equipment VALUES ('Dreyer-201','projector');
INSERT INTO Equipment VALUES **('Zuse-127','projector');**
INSERT INTO Equipment VALUES ('Shannon-164','projector');
INSERT INTO Equipment VALUES ('Dreyer-201','whiteboard');
INSERT INTO Equipment VALUES **('Zuse-127','whiteboard');**
INSERT INTO Equipment VALUES ('Shannon-164','whiteboard');
This is my answer:
SELECT DISTINCT room, type
FROM Equipment
WHERE type = 'projector' AND NOT type = 'whiteboard'
And it is working - but my output lists the room Zuse-127. I know it
stands alone with both projector and whiteboard, but how can I fix this
problem? So the room Zuse-127 does not show.
Thx for your time ;)

Railo and Tomcat frozen, PID not removed

Railo and Tomcat frozen, PID not removed

I was recently hired at a University that is using Tomcat and Railo.
For the most part Railo runs fine, however occasionally railo freezes and
stops rendering any CFM or CFC pages and just gives a 502 Error. Usually
this can be resolved with service railo_ctl restart, however lately more
errors have come up:
* Shutting down Railo: Sep 18, 2013 11:06:55 AM
org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:457)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:371)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:452)
Tomcat did not stop in time. PID file was not removed.
. . . . . . . . . . . . . . . . . . . . [FAIL]
* The Tomcat/Railo process is not responding. Forcing shutdown...
* Forcing Railo Shutdown: [DONE]
* Starting Railo: * Allow Tomcat to open more than 1024 files: . . . [DONE]
--------------------------------------------------------
It may take a few moments for Railo to start processing
CFML templates. This is normal.
--------------------------------------------------------
And:
* Shutting down Railo: Tomcat did not stop in time. PID file was not removed.
. . . . . . . . . . . . . . . [DONE]
* Starting Railo: * Allow Tomcat to open more than 1024 files: . . . [DONE]
--------------------------------------------------------
It may take a few moments for Railo to start processing
CFML templates. This is normal.
--------------------------------------------------------

SupportMapFragment overriding setOnMyLocationChangeListener

SupportMapFragment overriding setOnMyLocationChangeListener

I'm trying to override setOnMyLocationChangeListener on a
SupportMapFragment using this
map.setOnMyLocationChangeListener(new
GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
LatLng you = new LatLng(location.getLatitude(),
location.getLongitude());
float distanceTo =
location.distanceTo(venueLocation);
String miles = metersToMiles(distanceTo);
dist.setText(miles + " miles away");
LatLngBounds.Builder builder = new
LatLngBounds.Builder();
map.clear();
map.addMarker(new MarkerOptions()
.position(venue)
.title(centerName)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.fu_map_marker)));
map.addMarker(new MarkerOptions()
.title("You are here")
.position(you));
builder.include(venue);
builder.include(you);
LatLngBounds bounds = builder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds,
75));
}
});
Which kind of works, however, before the camera animates using the
LatLngBounds, it automatically zooms to the users location and adds a blue
dot. Is there anyway I can disable this?

ng-grid not displaying columns

ng-grid not displaying columns

I'm new with AngularJS. Right now, I'm trying to get my ng-grid working in
a directive. I populated my table asynchronously (updating the data and
columnDefs properties). It worked fine. Now when I receive the data, I set
a default grouping in code and what I get at launch is : - The columns and
data are not visible but the groups are. - If I resize my window, the
columns and data appear.
I guess it has something to do with refresh, but I couldn't find a way to
trigger a refresh of the component on my own.
Maybe you can help :)

Dynamic radial circle in the middle of the screen

Dynamic radial circle in the middle of the screen

Why is it so difficult to make this little thing work? : /
I want to create something like android's lock screen. I have an XML:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<stroke
android:width="@dimen/dp_5"
android:color="@color/black" />
<gradient
android:type="radial"
android:startColor="@color/green"
android:endColor="@color/red"
android:gradientRadius="@dimen/dp_50" />
</shape>
This circle is a background of a TextView, so the following happens:
1. wrap_content creates a little circle in the center of the screen
2. fill_parent creates an elipse taking the whole screen, instead of a circle

In addition I would like to change the startColor and endColor
programmatically - Didn't find any documentations\threads which solved
this SIMPLE issue.

Tuesday 17 September 2013

RestyGWT cannot parse JSON?

RestyGWT cannot parse JSON?

I'm trying to make RestyGWT work however I have setup the client-side
service and the JAX-RS web service but when the service is invoked:
service.createStuff(content.getText(), new MethodCallback<String>() {
@Override
public void onSuccess(Method method, String resp) {
GWT.log("Response from server: " + resp);
}
@Override
public void onFailure(Method method, Throwable exception) {
GWT.log(exception.getMessage());
}
});
It throws:
Caused by:
org.fusesource.restygwt.client.JsonEncoderDecoder$DecodingException:
Expected a json string, but was given: {"hash":"jr"} at
org.fusesource.restygwt.client.AbstractJsonEncoderDecoder$9.decode(AbstractJsonEncoderDecoder.java:189)
at
org.fusesource.restygwt.client.AbstractJsonEncoderDecoder$9.decode(AbstractJsonEncoderDecoder.java:1)
Where I can plainly see the response is a valid JSON string. What could I
be missing?

Simple example progrma that uses tbb::queueing mutex inside a tbb::parallel_for does not compile

Simple example progrma that uses tbb::queueing mutex inside a
tbb::parallel_for does not compile

here is a toy example I'm playing with to learn how to use TBB.
Parallel::operator() should run in parallel, but it has a critical region
that should only be accessed by a single processor at a time, so the
message it prints does not get scrambled. My problem is that it fails to
compile and the message isn't really helping me mutch. What am I doing
wrong?
Also, is this considered tha proper way to implement a mutex inside a
parallel_for?
#include <iostream>
#include <vector>
#include <cmath>
#include <tbb/tbb.h>
typedef tbb::queuing_mutex Mutex;
struct Parallel
{
Mutex mutex;
std::vector<int> * values;
Parallel(std::vector<int> * values_) : values(values_) {}
void operator()( tbb::blocked_range< unsigned int > & range ) const {
for(unsigned int i = range.begin(); i < range.end(); ++i) {
{
Mutex::scoped_lock lock(mutex);
if ( (*values)[i] > 40)
{
std::cout << "NO SCRAMBLING ALLOWED!" << std::endl;
}
lock.release();
}
}
}
};
int main() {
const int someValue = 20000;
std::vector<int> data(someValue);
for(int i = 0; i < someValue; ++i) {
data[i] = std::rand();
}
tbb::parallel_for( tbb::blocked_range<unsigned int>(0, data.size()),
Parallel(&data) );
}
Bellow is the error message:
/path-to-src/main.cpp: In member function 'void
Parallel::operator()(tbb::blocked_range<unsigned int>&) const':
/path-to-src/main.cpp:20:46: error: no matching function for call to
'tbb::queuing_mutex::scoped_lock::scoped_lock(const Mutex&)'
/path-to-src/main.cpp:20:46: note: candidates are:
In file included from /usr/include/tbb/tbb.h:65:0,
from /path-to-src/main.cpp:4:
/usr/include/tbb/queuing_mutex.h:80:9: note:
tbb::queuing_mutex::scoped_lock::scoped_lock(tbb::queuing_mutex&)
/usr/include/tbb/queuing_mutex.h:80:9: note: no known conversion for
argument 1 from 'const Mutex {aka const tbb::queuing_mutex}' to
'tbb::queuing_mutex&'
/usr/include/tbb/queuing_mutex.h:77:9: note:
tbb::queuing_mutex::scoped_lock::scoped_lock()
/usr/include/tbb/queuing_mutex.h:77:9: note: candidate expects 0
arguments, 1 provided
/usr/include/tbb/queuing_mutex.h:66:11: note:
tbb::queuing_mutex::scoped_lock::scoped_lock(const
tbb::queuing_mutex::scoped_lock&)
/usr/include/tbb/queuing_mutex.h:66:11: note: no known conversion for
argument 1 from 'const Mutex {aka const tbb::queuing_mutex}' to 'const
tbb::queuing_mutex::scoped_lock&'

Cannot create android application using eclipse

Cannot create android application using eclipse

Today I just downloaded and installed Eclipse via the
developer.android.com tutorials. I had almost initiated my first Android
Application when I came across this error:



This template depends on the Android Support library, which is either not
installed, or the template depends on a more recent version than the one
you have installed.
Required version: Installed versoin: 18
You can install it or upgrade it by clicking the Install button below, or
alternatively, you can install it outside of Eclipse with the SDK Manager,
then click on "Check Again" to proceed.



I don't understand the error. It does not specify a required version, and
my version is the most up to date version. Neither the [Install/Upgrade]
nor the [Check Again] buttons appear to function. I have also tried to
delete and reinstall the Android Support Library via the SDK Manager
multiple times.
Can any one help me? Thanks in advance!

Scrollbar scroll 'size'

Scrollbar scroll 'size'

How would I, instead of 'scrolling' as much height as I want, a fixed height?
I.e a div is 50px high and each time I scroll down I want to go down 50px
instead of just 'stopping' where you want.
Thanks in advance.

I want to print the image in table cell

I want to print the image in table cell

I try to print the image using ajax function but in this line it will not
work the ajax function if i removed this ajax will work properly how can i
fix this???
tbl_row += "<td><img src="<?php echo
base_url().'images/'.'"+v.ad_id+"'.'/'.'"+v.ad_id+"'.'_thumb.jpg'; ?>"
alt="" /></td>"

Impossible to delete Facebook Objects

Impossible to delete Facebook Objects

I'm trying to delete an object created by a story, but I'm getting the
following error :
(#100) Cannot delete object not created via the API
I used the FB.api in javascript to create a story with news.reads (works),
I can delete the story with the ID too. But the object created for the
story still exists, I can see it in the Graph API, but cannot delete it.
I want to fix this issue because if I try to create a story with the same
article link, if I change the content (the same link refers to a new
article), facebook will keep the old settings (title, image and
description don't change).

Sunday 15 September 2013

Confused by my attempt to use GetBoundingClientRect()

Confused by my attempt to use GetBoundingClientRect()

var rect = document.getElementById("object").getBoundingClientRect();
console.log("rect.top, rect.right, rect.bottom, rect.left");
<div id="object"></div>
.object {
background: red;
width: 20px;
height: 20px;
position: relative;
top: 200px;
}
Super elementary question... I am trying to get the coordinates of
#object, but the console returns rect.top, rect.right, rect.bottom,
rect.left instead of the actual coordinates of #object. What am I missing?
JSFiddle: http://jsfiddle.net/tCraA/2/

Javascript chosen alternative

Javascript chosen alternative

i'm looking for a good alternative for Chosen/Select2 but without jQuery -
it have to be pure javascript implementation.
Thanks in advance for you help

Combobox add range alternative C#

Combobox add range alternative C#

I basically want to add ages from 1 to 100, but I don't want to type each
one in the string[], something like add 1 then increment until 100
I have this at the moment
cmbAge.Items.AddRange(new string[] {"1", "2","3","4",...});
Thank you in advance

CakePHP data change during validation and beforeSave is not being save with the changes

CakePHP data change during validation and beforeSave is not being save
with the changes

I'm saving data sent from a form.
In the Controller I am doing :
$this->User->create();
$this->User->save($this->request->data)
The $this->request->data looks like this:
'User' => array(
'password' => '*****',
'username' => 'ddddd',
'role' => '256/aa01bdf80d42beb48dd3225acddf447fdd7a39f3',
'parent_id' => '0/b6ba9bd57f6c70cf738891d4c6fac22abed4161d'
)
There are validation rules that works on 'role' and 'parent_id' to insure
the role/parent ids are among those the user can access.
The validation changes the field values if the data is valid.
I also have a Tree behavior that is setting some tree fields in a
beforeSave() filter in the behavior.
The validation rule is writing the change to $this->data->[$model][$field]
as shown below.
public function checkListHash($check, $field) {
$explodedCheck = explode('/', $check[$field]);
if ($this->secureId($explodedCheck[0], $explodedCheck[1])) {
$this->data['User'][$field] = $explodedCheck[0];
return true;
}
return false;
}
The beforeFilter() in the behavior is changing the data array with
statements like this:
$Model->data[$Model->alias][$ancestors] = $ancestorList;
When validation and the beforeFilter() processing is complete, I have a
beautiful and correct array of data at $this->User->data that looks like
this:
'User' => array(
'password' => '*****',
'active' => '0',
'role' => '256',
'parent_id' => '0',
'node' => '0',
'username' => 'ddddd',
'modified' => '2013-09-15 09:55:02',
'created' => '2013-09-15 09:55:02',
'ancestor_list' => ',0,'
)
However, $this->request->data is unchanged. And that is what is being save.
Clearly I'm not understanding the relationship of these various ways to
get to the data. I've tried a variety of ways to address the data in the
three contexts:
Controller
Model
Behavior
And I've tried $this->User->create($this->request->data); before the
Controller save() statement.
In the controller, what I'm seeing as available data arrays:
PRIOR TO THE SAVE
$this->request->data = $this->data = proper data from the form
$this->User->data = some default, unpopulated array
PRIOR TO THE SAVE when I use $this->User->create($this->request->data)
all three arrays contain raw form data
AFTER THE SAVE in either case
$this->request->data = $this->data = exactly as before
$this->User->data = the properly massaged data
Can anyone sort me out?
Don Drake

$(window).width() won't update after pinch zoom (chrome IOS)

$(window).width() won't update after pinch zoom (chrome IOS)

I'm trying to align a div to the center using $(window).width(). on
Windows this trick works well, as $(window).width() changes when zooming
the page.
However, When zooming the page on Chrome IOS, $(window).width() returns
always the same value, causing the div to be aligned to center only when
the page is not zoomed in (nor zoomed out)
any ideas?
Thanks.

PHP Optional Function Arguments

PHP Optional Function Arguments

I'm a little stuck trying to create a function that takes a single,
optional argument. Instead of this being a string I'd like it to be the
result of a function (or even better, a DateTime object). Essentially - I
want the user to either pass in a DateTime object, or for the function to
resort to todays date if no arguments are supplied. Is this possible with
PHP? By trying to create the new object in the function header as such
function myDateFunction($date = new DateTime()){
//My function goes here.
}
causes PHP to fall over.
Many thanks.

How to fit and center an unknown sized image in a div element with a relative size using only pure CSS

How to fit and center an unknown sized image in a div element with a
relative size using only pure CSS

I am working on a CSS animated HTML block. I created a fully responsible
grid, so these blocks have relative sizes. The block contains a big image
to ensure to display the content on all screens correctly. The images in
the blocks have 100% width to fit the content, and they also have CSS
transitions and transforms.
I would like to center these images vertically, but using only pure CSS. I
tried a lot of variations of display, position and vertical-align
properties, but no one worked for me. I could easily achieve the proper
animation with the background property, but I don't want to create a lot
of css classes for all the images (not even with js or jquery).
So could you tell me how to solve this issue with pure CSS? I also created
a jsfiddle to demonstrate the problem.

Saturday 14 September 2013

OpenGL ES showing contents of previous frame when switching from UIView to EAGLView

OpenGL ES showing contents of previous frame when switching from UIView to
EAGLView

My game has two views: a UIKit menu screen and the EAGLView. No matter
what I try -- inserting glClear() willy-nilly -- whenever the EAGLView
comes back into view it flashes the contents of the previous frame for
just a split second.
I'm really at a loss. It seems like all I should have to do is call
glClear() before every frame, which I'm doing. Does it have something to
do with switching contexts between my UIView menu and my EAGLView game?
It's only the first frame that flashes the contents of whatever was last
displayed. I'm using OpenGLES1.1 by the way.
-Nick

How to disable entity framework from creating Nullable property's

How to disable entity framework from creating Nullable property's

Is there a way to disable or to stop the entity framework from creating
Nullable properties in complex class?
Example, when I add a new stored procedure to the entity framework it
generates a class like the one below.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your
application.
// Manual changes to this file will be overwritten if the code is
regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace StorefrontSystemDL
{
using System;
public partial class proc_InsertLeafHorizontal_Result
{
public Nullable<int> SizeID { get; set; }
public Nullable<int> FinishID { get; set; }
public Nullable<int> SitelineID { get; set; }
}
}
How can i, do i, or is there a settings that i can set to where the entity
framework does not create properties with Nullable types

Grid not working after updating to Boostrap 3. Content is still stacking

Grid not working after updating to Boostrap 3. Content is still stacking

I'm new at this... I'm attempting to use the bootstrap grid system. Before
I changed to 3 it was fine, but when I changed over, the grid stopped
working. I'm attempting to put a logo at the top with some options for
social aspects to the right of it in its own respective grids.
But it ends up just putting the new text?content under the logo. No grid.
Here's the code :
<div class = "container">
<div class="row">
<div class="col-md-4">
<img src="Red_Feather_Rogers_supplyf.gif">
</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
To clarify I do end the container div at the end of the body.Also the text
is just temporary. the goal is to add buttons for social media.

web.py + uwsgi - custom 404 not working

web.py + uwsgi - custom 404 not working

I tried googling and browsing around but wasn't able to find an answer, so
apologies if this question has already been answered somewhere.
I'm unable to serve custom 404 pages when using uwsgi + nginx for web.py
applications. Using web.py server everything works as it should, but while
using nginx I'm only getting the default web.py 'not found' page.
Could anyone point me in the right direction here?
My configs:
nginx:
server {
listen 80;
set $webappsdir /srv/www/webapps/;
server_name *.devserver.local;
if ($host ~* ^(.*)\.devserver\.local$) {
set $appname $1;
}
location /static/ {
try_files $uri =404;
}
location /templates/ {
try_files $uri =404;
}
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi_vhosts.sock;
uwsgi_param UWSGI_CHDIR /srv/www/webapps/$appname;
uwsgi_param UWSGI_PYHOME /srv/www/webapps/$appname;
uwsgi_param UWSGI_SCRIPT index;
}
}
/srv/www/webapps/example/index.py:

import web
urls = (
'/', 'index'
)
app = web.application(urls, globals())
app.notfound = notfound
class index:
def GET(self):
return "Hello, world!"
def notfound():
return web.notfound("404. Not found")
if __name__ == "__main__": app.run()
application = app.wsgifunc()

Thanks in advance, Jakub

is it possible to detect android orientation without AUTO ROTATION ON?

is it possible to detect android orientation without AUTO ROTATION ON?

i want to use a service to detect the orientation. But by using
broadcaster listening to CONFIGURATION_CHANGED or onConfigurationChanged,
it only works if the auto rotation is on. So is there a way to detect the
orientation without the auto rotation on?

String Invoke Issue

String Invoke Issue

I am using a backgroundworker and I think there is a cross thread thing..
But I cant solve it.
my code is here
private void bgworkerGameLoad_DoWork(object sender,
System.ComponentModel.DoWorkEventArgs e)
{
var arg = e.Argument.ToString();
var liste = webHelper.ShowGame("http://www.abx.com/" + arg);
txtHowToPlay.Invoke(new Action(() => txtHowToPlay.Text =
String.Format("Oyun Bilgi: {0}", liste[0])));
txtInfo.Invoke(new Action(() => txtInfo.Text =
String.Format("Nasýl Oynanýr: {0}", liste[1])));
bgworkerGameLoad.ReportProgress(0,liste[2]);
}
private void bgworkerGameLoad_RunWorkerCompleted(object sender,
System.ComponentModel.RunWorkerCompletedEventArgs e)
{
if (FlashPlayerActive)
UnLoad();
string url="";
Invoke(new MethodInvoker(() =>
{
url= e.UserState.ToString();
Thread.Sleep(2);
}));
axShockwaveFlash1.Movie = url;
LoadFlash();
pbWaitForChannelLoading.Visible = false;
axShockwaveFlash1.Play();
}
the problem is that I cant get the e.UserState.ToString() for my
shocwaveplayer. I used a local string variable but its the same result.
it is occured targetofaninvocation exception in program.cs
Application.Run(new FrmMain());;
but that code is in frmMain.cs
this is detail of the exception
System.Reflection.TargetInvocationException was unhandled
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib StackTrace: at
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[]
arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) at
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
Boolean skipVisibilityChecks) at
System.Delegate.DynamicInvokeImpl(Object[] args) at
System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry
tme) at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object
obj) at System.Threading.ExecutionContext.runTryCode(Object userData) at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData) at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) at
System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry
tme) at System.Windows.Forms.Control.InvokeMarshaledCallbacks() at
System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam) at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.Run(Form mainForm) at XXX.Program.Main()
in c:\Users..............\Program.cs:line 23 at
System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at
System.Threading.ThreadHelper.ThreadStart_Context(Object state) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart() InnerException:
System.NullReferenceException Message=Object reference not set to an
instance of an object. Source=System.Windows.Forms StackTrace: at
System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate
method, Object[] args, Boolean synchronous) at
System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) at
System.Windows.Forms.Control.Invoke(Delegate method) at
XXX.FrmMain.bgworkerGameLoad_RunWorkerCompleted(Object sender,
RunWorkerCompletedEventArgs e) in c:\Users..........\FrmMain.cs:line 332
at
System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs
e) at
System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
InnerException:
what is my mistake? I tried to use delegate but its the same..

Changing Steam name and avatar

Changing Steam name and avatar

I would change username(not the login name) and the avatar of my steam
account (So I know the account login name and the account password). If it
could be done by locally(where the steam is currently logged in) is still
could be a good solution by using Java. If somebody know any way for doing
this, please make a response to this question.
With respect, Robert.

Friday 13 September 2013

How to create Modals with Bootstrap & Emberjs?

How to create Modals with Bootstrap & Emberjs?

I have a simple use case in which I am displaying a list from JSON and
when I click on any one of them, user should see a modal displaying more
information from the same JSON.
I tried to use Bootstrap for Ember but I get errors on console:
Uncaught ReferenceError: Ember is not defined bs-core.min.js:1
Uncaught ReferenceError: Bootstrap is not defined bs-modal.min.js:1
Uncaught ReferenceError: Bootstrap is not defined bs-button.min.js:1
Uncaught ReferenceError: Bootstrap is not defined app.js
Even though I am following the configuration instructions.
Any help would be appreciated.

jquery columnizer and display:none

jquery columnizer and display:none

I'm using jquery plugin columnizer to split a div with text into two
columns. It doesn't work properly when the div has property display:none,
the same if the parent div has display:none. I know this behaviour is not
surprising: the div is hidden so the plugin is not able to count
width/height properly. But maybe there could be a way to solve it, knowing
that the parent div can be toggled?
HTML
<div class="button">
</div>
<div class="parent" style="display:none">
<div class="child">
<h1>Title</h1>
<p>Text text text text text text text text text text text text text</p>
<p>Text text text text text text text text text text text text text</p>
<p>Text text text text text text text text text text text text text</p>
</div>
</div>
jQuery
$('.button').click(function() {
$('.parent').slideToggle(700);
});
$('.child').columnize({columns:3});

Qt and grouping by by rectangle with qt designer

Qt and grouping by by rectangle with qt designer

Suppose i have a QFrame, I have 3 categories widgets in my Frame, Such as
:CheckBoxes , Buttons and texts.
My questions is , How put every category in a rectangle ? (i didn't found
in qt-designer)

Add a field to the ModelAdmin Form

Add a field to the ModelAdmin Form

I want to give users the possibility to create multiple events at once.
Therefore I would like to add a field to the admin-add-page where a number
of repetitions can be specified. Then I want to override the save function
and create multiple events (based on the input). I started writing some
code but the admin add page does not update at all. I will show you the
code below:
In admins.py:
class EventAdmin(admin.ModelAdmin):
form = EventForm
admin.site.register(Event, EventAdmin)
In forms.py
from django import forms
from django.db import models
from calendar_app.models import Event
class EventForm(forms.ModelForm):
name = models.CharField(max_length=100) # just for testing purpose
class Meta:
model = Event
def __init__(self, *args, **kwargs):
super(EventForm, self).__init__(*args, **kwargs)
if not kwargs.has_key('instance'):
self.fields['name'] = forms.CharField(label='Name')
self.base_fields['name'] = forms.CharField(label='Name')
def save(self, commit=True):
model = super(EventForm, self).save(commit=False)
# Save all the fields...
if commit:
model.save()
return model
But the "name" field is not showing up when I add an event. Any ideas?
Thanks!

Dragging pictures in a slideshow

Dragging pictures in a slideshow

I've googled around for a while but can't find an answer for this. I have
a slideshow type div on my site, where you can use the scrollbar to look
through the images.
<div id="container" style="overflow-x: scroll; overflow-y: hidden; width:
700px; height: 300px;">
<div class="content" style="float: left; width: 700px; height: 300px;
background: url('images/1.png')"></div>
<div class="content" style="float: left; width: 700px; height: 300px;
background: url('images/2.png')"></div>
<div class="content" style="float: left; width: 700px; height: 300px;
background: url('images/3.png')"></div>
</div>
just so you get the idea.. What I'd like to do is have the user able to
use their mouse on the picture itself and swipe the divs, instead of using
the scroll bar. Im assuming this would use jquery with drag and drop.
honestly I don't really know where to start, any ideas?

The lack of non-capturing Task.Yield forces me to use Task.Run, why follow that?

The lack of non-capturing Task.Yield forces me to use Task.Run, why follow
that?

Apologies in advance if this question is opinion-based. The lack of
Task.Yield version which wouldn't capture the execution context was
already discussed here. Apparently, this feature was present in some form
in early versions of Async CTP but was removed because it could easily be
misused.
IMO, such feature could be as easily misused as Task.Run itself. Here's
what I mean. Imagine there's an awaitable SwitchContext.Yield API which
schedules the continuation on ThreadPool, so the execution will always
continues on a thread different from the calling thread. I could have used
it in the following code, which starts some CPU-bound work from a UI
thread. I would consider it a convenient of continuing the CPU-bound work
on a pool thread:
class Worker
{
static void Log(string format, params object[] args)
{
Debug.WriteLine("{0}: {1}", Thread.CurrentThread.ManagedThreadId,
String.Format(format, args));
}
public async Task UIAction()
{
// UI Thread
Log("UIAction");
// start the CPU-bound work
var cts = new CancellationTokenSource(5000);
var workTask = DoWorkAsync(cts.Token);
// possibly await for some IO-bound work
await Task.Delay(1000);
Log("after Task.Delay");
// finally, get the result of the CPU-bound work
int c = await workTask;
Log("Result: {0}", c);
}
async Task<int> DoWorkAsync(CancellationToken ct)
{
// start on the UI thread
Log("DoWorkAsync");
// switch to a pool thread and yield back to the UI thread
await SwitchContext.Yield();
Log("after SwitchContext.Yield");
// continue on a pool thread
int c = 0;
while (!ct.IsCancellationRequested)
{
// do some CPU-bound work on a pool thread: counting cycles :)
c++;
// and use async/await too
await Task.Delay(50);
}
return c;
}
}
Now, without SwitchContext.Yield, DoWorkAsync would look like below. It
adds some extra level of complexity in form of an async delegate and task
nesting:
async Task<int> DoWorkAsync(CancellationToken ct)
{
// start on the UI thread
Log("DoWorkAsync");
// Have to use async delegate
// Task.Run uwraps the inner Task<int> task
return await Task.Run(async () =>
{
// continue on a pool thread
Log("after Task.Yield");
int c = 0;
while (!ct.IsCancellationRequested)
{
// do some CPU-bound work on a pool thread: counting cycles :)
c++;
// and use async/await too
await Task.Delay(50);
}
return c;
});
}
That said, implementing SwitchContext.Yield may actually be quite simple
and (I dare to say) efficient:
public static class SwitchContext
{
public static Awaiter Yield() { return new Awaiter(); }
public struct Awaiter : System.Runtime.CompilerServices.INotifyCompletion
{
public Awaiter GetAwaiter() { return this; }
public bool IsCompleted { get { return false; } }
public void OnCompleted(Action continuation)
{
ThreadPool.QueueUserWorkItem((state) => ((Action)state)(),
continuation);
}
public void GetResult() { }
}
}
So, my question is, why should I prefer the second version of DoWorkAsync
over the first one, and why would using SwitchContext.Yield be considered
a bad practice?

Thursday 12 September 2013

How to adjust all the Points in the screen using CImg

How to adjust all the Points in the screen using CImg

I have to draw Lines which has bigger double values like (3000.00,4500.45).
CImg<unsigned char> img(800,800,1,3,20);
img.draw_line( 3000.00, 4500.45, 3478.567, 4500.45, RED);
But i want to keep my screen size limited to 800x800
I thought to take Modulus of the Point's coordinates within 800 Like
3000.00%800=600
I can fit 600 in my Screen . But the problem is , CPP does not support
modulus of double value .
double a = 3000.00;
printf("%lf",a%800.0); //Expected 600 but exception
**Invalid operand of type double,double to binary operator%**
How can I fit these large points in my screen using CImg ?

Find a random integer which creates another integer, when using percentages

Find a random integer which creates another integer, when using percentages

I am sorry about the confusing title, let me clarify my problem:
My Java program is supposed to ask a math question with percentages.
It should create a question in this format:
25% of 4616 = ?
The requirements are:
the percentage is always dividable by 5 (no problem)
the number (here 4616) has to be between 100 and 9999 (also not a problem)
the number as well as the result has to be an integer (this is my problem)
Is there any fast method to find a random number which fulfills the last
requirement?
The only solution I can think of is to find the percentage, then create a
loop which will not stop until a random number is found which fulfills the
requirement (in the example until number % 4 == 0 is true)
But this loop could run thousands of times until a correct number is found.
Is there a better method for my problem?

How to query to get only rows where a change took place? (changes can go back and forth)

How to query to get only rows where a change took place? (changes can go
back and forth)

I'm working with a table that has dozens of rows per customer, each with a
date and several columns representing various statuses. I'm only
interested in pulling the rows where a change took place in one particular
column (specifically 0 to 1 or 1 to 0, see status column below).
I can't simply use row_number() over (partition by customer_id, status
order by date) because the status can go back and forth between 0 and 1.
Here's a sample of what I'm trying to do (note that there are two
different Customer IDs in this example):
Original Table
Row Customer ID Status Date 1 123 0 3/12/2013 2 123 0 3/31/2013 3 123 1
4/13/2013 4 123 1 4/15/2013 5 123 1 5/17/2013 6 123 0 6/25/2013 7 123 0
6/28/2013 8 456 0 8/2/2013 9 456 1 5/10/2013 10 456 0 5/18/2013 11 456 1
8/23/2013 12 456 1 9/7/2013
I want to only show rows where a changed occurred for each Customer ID (in
this case, row 3, 6, 9, 10, 11 from above)
Desired Query Output
Customer ID Status Date 123 1 4/13/2013 123 0 6/25/2013 456 1 5/10/2013
456 0 5/18/2013 456 1 8/23/2013

System.Speech recognition error

System.Speech recognition error

I am writing a speech recognition program using system.speech from MS. I
have been going through the online tutorials and all the great info on
StackOverflow however i seem to keep running into an issue where the
recognizer seems to throw an error.
Below is the code I am using (minus the grammar creation).
Grammar grammarQuestionsSingle;
Grammar grammarQuestionsShort;
Grammar grammarQuestionsLong;
Grammar grammarStatement;
//Grammar grammarDeclarationShort;
//Grammar grammarDeclarationLong;
Grammar grammarCommandsSingle;
Grammar grammarCommandsShort;
Grammar grammarCommandsLong;
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
CreateGrammar grammar = new CreateGrammar();
Think brain = new Think();
bool privacy, completed;
//bool timer;
public void OpenEars()
{
completed = true;
if (grammarQuestionsSingle == null || grammarQuestionsShort ==
null || grammarQuestionsLong == null || grammarStatement == null
|| grammarCommandsSingle == null || grammarCommandsShort == null
|| grammarCommandsLong == null)
{
grammarQuestionsSingle = grammar.createGrammarQuestionsSingle();
grammarQuestionsShort = grammar.createGrammarQuestionsShort();
grammarQuestionsLong = grammar.createGrammarQuestionsLong();
grammarStatement = grammar.createGrammarStatement();
grammarCommandsSingle = grammar.createGrammarCommandsSingle();
grammarCommandsShort = grammar.createGrammarCommandsShort();
grammarCommandsLong = grammar.createGrammarCommandsLong();
}
recognizer.RequestRecognizerUpdate();
if (!grammarQuestionsSingle.Loaded)
{
recognizer.LoadGrammar(grammarQuestionsSingle);
}
if (!grammarQuestionsShort.Loaded)
{
recognizer.LoadGrammar(grammarQuestionsShort);
}
if (!grammarQuestionsLong.Loaded)
{
recognizer.LoadGrammar(grammarQuestionsLong);
}
if (!grammarStatement.Loaded)
{
recognizer.LoadGrammar(grammarStatement);
}
if (!grammarCommandsSingle.Loaded)
{
recognizer.LoadGrammar(grammarCommandsSingle);
}
if (!grammarCommandsShort.Loaded)
{
recognizer.LoadGrammar(grammarCommandsShort);
}
if (!grammarCommandsLong.Loaded)
{
recognizer.LoadGrammar(grammarCommandsLong);
}
DictationGrammar dictationGrammar = new
DictationGrammar("grammar:dictation");
dictationGrammar.Name = "DictationQuestion";
recognizer.LoadGrammar(dictationGrammar);
recognizer.RequestRecognizerUpdate();
recognizer.SetInputToDefaultAudioDevice();
Listening();
}
public void Listening()
{
while (!completed)
{
Thread.Sleep(333);
}
recognizer.SpeechRecognized += recognizer_SpeechRecognized;
recognizer.RecognizeAsync(RecognizeMode.Single);
}
private void recognizer_SpeechRecognized(object sender,
SpeechRecognizedEventArgs e)
{
completed = false;
SemanticValue sem = e.Result.Semantics;
if (!privacy)
{
if (e.Result.Grammar.Name=="CommandsSingle" &&
sem["keyCommandsSingle"].Value.ToString() == "go to sleep")
{
privacy = true;
brain.useMouth("ear muffs are on");
completed = true;
Listening();
}
else
{
brain.Understanding(sender, e);
completed = true;
}
}
else
{
if (e.Result.Grammar.Name == "CommandsSingle" &&
sem["keyCommandsSingle"].Value.ToString() == "wake up")
{
privacy = false;
brain.useMouth("I am listening again");
completed = true;
Listening();
}
}
completed = true;
Listening();
}
}
It recognizes the first phrase correctly but as soon as it completes the
actions in the speechrecognized handler, it throws the exception
"Cannot perform this operation while the recognizer is doing recognition.".
I have tried with the recognition being all in a single method however it
has the same results. This was my most recent attempt prior to posting
this question. What am I doing wrong?
As to clarify...
The program launches into the systray and calls this class.OpenEars().
OpenEars then calls class.Listening() which has the RecognizeAsync. After
speaking the first phrase and the recognizer hearing it correctly and
following the handler, the second phrase when spoken ends up triggering
the exception.

Sample example program to get the malloc consolidate error

Sample example program to get the malloc consolidate error

I want to test the mcheck functionality on my PC first to detect the
malloc consolidate error. This way, i will be sure that this will help to
figure out a similar crash on embedded-linux box. Unfortunately, the crash
takes atleast 3-4 days. Thus, I am looking for a sample program that will
generate the similar kind of crash as shown below.
Program terminated with signal 6, Aborted.
#0 0x2c73ebb8 in __syscall_kill (pid=900, sig=6) at kill.c:15
15 static inline _syscall2(int, __syscall_kill, __kernel_pid_t, pid,
int, sig);
Current language: auto; currently c
#0 0x2c73ebb8 in __syscall_kill (pid=900, sig=6) at kill.c:15
__res = 716485696
__err = 16
#1 0x2c73eb5c in kill (pid=900, sig=6) at kill.c:19
No locals.
#2 0x2aafb2e0 in pthread_kill (thread=900, signo=6) at signals.c:73
handle = (pthread_handle) 0x2ab3f2e0
pid = 900
#3 0x2aafbbb8 in raise (sig=6) at signals.c:241
retcode = 6
#4 0x2c730a5c in abort () at abort.c:94
sigset = {__val = {32, 0 <repeats 31 times>}}
#5 0x2c738054 in __malloc_consolidate (av=0x2c798860) at free.c:227
fb = (mfastbinptr *) 0x2c798864
maxfb = (mfastbinptr *) 0x2c798880
p = (mchunkptr) 0x2c798894
nextp = (mchunkptr) 0x4a2b2948
unsorted_bin = (mchunkptr) 0x2c798894
first_unsorted = (mchunkptr) 0x4a22f7e0
nextchunk = (mchunkptr) 0x2c798894
size = 0
nextsize = 0
prevsize = 0
nextinuse = 1
bck = (mchunkptr) 0x4a2b2948
fwd = (mchunkptr) 0x4a2b2948
#6 0x2c735ff0 in __malloc_inner (bytes=300) at malloc.c:912
av = (mstate) 0x2c798860
nb = 304
idx = 32
bin = (mbinptr) 0x2ac0dab4
fb = (mfastbinptr *) 0x2ae11e50
victim = (mchunkptr) 0x2ac0d9a4
size = 719396432
victim_index = 718311332
remainder = (mchunkptr) 0x49759b58
remainder_size = 40000
block = 719396432
bit = 718500504
map = 719396432
fwd = (mchunkptr) 0x1
bck = (mchunkptr) 0x4a2164ac
sysmem = (void *) 0x4975c9ac
#7 0x2c736c18 in malloc (bytes=300) at malloc.c:1172

is retaining a static array makes a leak on non-arc project?

is retaining a static array makes a leak on non-arc project?

I got a test code below.
(By this example I faced that an interface cannot be statically allocated
without retain.)
By this codeblock I understood what really retain is.
I wantto be sure if this makes a leak and should I release it in somewhere
else. simply I dont wantto reinitialize each time the array. and made it
static.(disadvantage on memory but advantage on speed)
should I release this retained static array somewhere ? is it a safe code
or have I totaly remove static and retain words and just init with
arrayObjects method classically ? so what may you prefer for me ?
+(NSUInteger)getCoordYByX:(int)ax
{
NSUInteger ret_=-1;
static NSArray *coordsX=nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
coordsX=[[NSArray arrayWithObjects:
[NSNumber numberWithInt:50],
[NSNumber numberWithInt:170],
[NSNumber numberWithInt:190],
[NSNumber numberWithInt:210],
[NSNumber numberWithInt:350],
nil]retain];
/*it is more longer. cropped for test purposes*/
});
ret_=[[coordsX objectAtIndex:ax] unsignedIntegerValue];
return ret_;
}

Wednesday 11 September 2013

Get list of calls to a method and arguments passed with the call from source code

Get list of calls to a method and arguments passed with the call from
source code

Question
Given the following code, I want to extract muffinize and all the
arguments passed with it:
$ask = false
muffinize("Shoop")
muffinize("Woop") if($ask == true)
if($ask == false)
muffinize("Pants")
end
This is the output that I would expect:
Call#:Args
1:"Shoop"
2:"Woop"
3:"Pants"
What I'm doing so far
I'm parsing the source code with Ripper to find the locations where the
method is called. Then I'm finding the range of characters in the line of
code where the method is called. After extracting the method from the
line, I'm then analyzing it with the Parser gem. I will post the code as
an answer once I've complete it, but I'm interested in hearing if there's
a better way to do this. I don't know code parsing that well so I'm kind
of flailing around blindly at this point.
Why not just use a Regex
A regex would still capture commented code blocks. There's probably other
corner cases that I haven't considered yet.

Change encoding of text file (shell archive or script for antique kernel text to ASCII text, with CRLF, LF line terminators)

Change encoding of text file (shell archive or script for antique kernel
text to ASCII text, with CRLF, LF line terminators)

I'm writing a small bash script to look up the 1st line of FILEA in FILEB,
if it matches then it returns over a text with the filename.
Problem is when i'm extracting text from FILEA and then comparing it with
a simple == as an if condition, it returns as different.
I've narrowed down the issue being to the encoding of the 2 files i'm
using being different
(FILEA=shell archive or script for antique kernel text)
(FILEB=ASCII text, with CRLF, LF line terminators)
Is there a way to convert FILEA to ASCII to avoid this issue when
comparing through UNIX? Or outside of UNIX would work for me too.
Really appreciate any help or comment.
Thanks

How to resize UILabel in code

How to resize UILabel in code

I have got a UILabel which is placed in between two UITableViews inside a
scrollview. What I want is to resize the UILabel height depending upon the
total text , which gets generated at runtime.
I have a solution but it doesnt work
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
CGRect titleLabelBounds = self.lblPreparation.bounds;
titleLabelBounds.size.height = CGFLOAT_MAX;
// Change limitedToNumberOfLines to your preferred limit (0 for no limit)
CGRect minimumTextRect = [self.lblPreparation
textRectForBounds:titleLabelBounds limitedToNumberOfLines:0];
CGFloat titleLabelHeightDelta = minimumTextRect.size.height -
self.lblPreparation.frame.size.height;
CGRect titleFrame = self.lblPreparation.frame;
titleFrame.size.height += titleLabelHeightDelta;
self.lblPreparation.frame = titleFrame;
lblPreparation.text = @"sdjshdjshd sjhdjdd jjsjjsdhjsd \njsdhjshjshdjs
djs djsdh";
}
This above solution was proposed in a question but doesn't seem to be
working for me. Please suggest a suitable way.

Trouble restoring database using T-sql

Trouble restoring database using T-sql

backup database Clinical_Data_Extension to
disk='c:\Clinical_Data_Extension_full.bak'
restore filelistonly from disk='c:\Clinical_Data_Extension_full.bak'
restore database Clinical_Data from
disk='c:\Clinical_Data_Extension_full.bak'
with move 'Clinical_Data_Extension' to 'C:\Program Files\Microsoft SQL
Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data.mdf',
move 'Clinical_Data_Extension_log' to 'C:\Program Files\Microsoft SQL
Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data.ldf',
REPLACE
Error:
Msg 3234, Level 16, State 2, Line 3
Logical file 'Clinical_Data_Extension' is not part of database
'Clinical_Data'. Use RESTORE FILELISTONLY to list the logical file names.
Msg 3013, Level 16, State 1, Line 3
RESTORE DATABASE is terminating abnormally.
Yet for some reason the following identical code works fine:
backup database Clinical_Data to disk='c:\Clinical_Data_full.bak'
restore filelistonly from disk='c:\Clinical_Data_full.bak'
restore database Clinical_Data_Extension from
disk='c:\Clinical_Data_full.bak'
with move 'Clinical_Data' to 'C:\Program Files\Microsoft SQL
Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data_Extension.mdf',
move 'Clinical_Data_log' to 'C:\Program Files\Microsoft SQL
Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Clinical_Data_Extension.ldf',
REPLACE
Basically, what I am doing is creating database "Clinical_Data_Extension"
and doing work on it. Once I am done, I have a script for removing
"Clinical_Data", and then I use the script which I mentioned first to
restore "Clinical_Data" using data from "Clinical_Data_Extension"
essentially overwriting "Clinical_Data". However for some reason the first
script gives me an error and the second does not yet they are totally
identical. Why do you think this would happen?

redirect to a content page when a link is clicked

redirect to a content page when a link is clicked

ive just started PHP and MYSQL, and been trying to figure out how i can
redirect to a page and display the content.
i have this PHP code that lists all my topic rows from my database
while ($row = $result->fetch_array()) {
echo '<a href="#"><p class="list" st>' . $row['topic'] . '<br /></a>';
}
it will list all the topics inside the <a href> markup.
when link is clicked, i will be redirected to a page where the content is
displayed based on the topic link.
i just need the logic how to create that page. basically i have page.php
which i plan to put the logic. but i dont know how to start.

Show a message if the browser is not internet explorer 9 or greater

Show a message if the browser is not internet explorer 9 or greater

I would like to show my users a bar like this, if they are not browsing
the site with IE9 or greater

I found this nice jquery plugin, but I dont want to use popups.
http://jreject.turnwheel.com/
Please notice the site where I will implement this is a Sharepoint 2013
site, so I will use a content editor webpart to include the html content
you provide and the bar should be at the top of everything else.
Please incluse css if needed to make it look as the screenshot?
The screenshot is just a guide of what I need, the real condition is: Show
the bar if:
browser is not IE
ie is older than version 9

Avoiding iCloud conflicts with non CoreData app

Avoiding iCloud conflicts with non CoreData app

I am working on a non CoreData based app (sqlite), now that it must be
ported to iPad, all hell has broken loose.
Since syncing is not needed, I am trying to stay with my good old sqlite
solution. However I have noticed that even now I have an ugly problem: if
the same app is used by the same user in different devices. The database
file is automatically backed up to iCloud, but now more than one device
want to upload different databases into the same location.
Which one is the common solution to this problem? My immediate guess is
saving the database into a subfolder like .../Documents/some_type_of_id/
and use iCloud to backup different databases and settings for each device.
How should I generate that ID? My first choice seems to be this:
[[[UIDevice currentDevice] identifierForVendor] UUIDString]
However, now that I am getting my hands dirty, I am wondering which
equivalent solution should be used with a Mac app (same iCloud user on
different macs). UIDevice is not within the Mac SDK.
How should I generate a Mac unique ID?
Although I am asking now about UIDs, my first concern is still avoiding
iCloud conflicts. I would appreciate any guidance or references to how
properly handle this case.

Tuesday 10 September 2013

Silverlight infragistics remove styling on combobox when it is disabled

Silverlight infragistics remove styling on combobox when it is disabled

Im having real trouble removing the styling on infragistics combobox
(NetAdvantage 2012.2) under silverlight. In its current state its barely
visible with the opacity set down which makes the text light grey. See the
difference between a combobox and a regular textbox below.
Every styling change I make just does not effect the opacity on the
combobox when it is disabled.

below is the styling im trying to set at the moment. I have tried a
hundred different combos of code but this where im trying to make the
changes. I have changed the opacity on disabled to 0 hoping that would
remove whatever item sits over the top of combobox. Please let me know if
im way off course here.
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetName="DisabledVisualElement"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame
KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetName="FocusVisualElement"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame
KeyTime="00:00:00">
<SplineDoubleKeyFrame.Value>
<System:Double>1</System:Double>
</SplineDoubleKeyFrame.Value>
</SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>

C++ fast dynamic type/subtype check

C++ fast dynamic type/subtype check

As the title suggests, I am looking for a fast way of runtime
typechecking. To illustrate my problem, imagine you have a class hierarchy
like the following:
Base
/ \
A D
/ \ / \
C B F E
\ /
G
My program holds all instances of any class in a single list as Base_ptr
because all these classes share common tasks. Now at some point some
derived classes will need to know about the existence of an instance of
another class. So far so good, I know about dynamic_cast and the
typeid()-operator, but both have some mayor drawbacks:
dynamic_cast consumes a lot of processing time if the types are
incompatible (e.g. try to cast instances of E to C)
typeid() does not work in "isTypeOrSubtype"-cases, e.g. you need all
instances of D or derived from D (so Es, Fs and Gs as well)
The ideal solution would be some kind of "isTypeOrSubtype"-test and only
casting, if this test returns successfully. I got an own approach with
some macro definitions and precalculated classname hashes, but it is very
ugly and hardly maintainable. So I am looking for a cleaner and faster way
of dynamic type and subtype checking that can check far more than
20million times per second.

Django/Heroku: How to load settings file from Procfile

Django/Heroku: How to load settings file from Procfile

I'm trying to set my Procfile to load a specific settings file on Heroku:
web: newrelic-admin run-program python manage.py run_gunicorn -b
0.0.0.0:\$PORT
-w 9 -k gevent --max-requests 250 --preload --settings=setting_files.site1
However the standard settings.py loads instead. Any idea why this might be
happening?

Same program Running on TC not on GCC

Same program Running on TC not on GCC

I have written a recursive program to generate a dynamic tree and run
BFS(breadth first search) on that. and it will give nodes printed in BFs
order.. It's working perfect on TC but giving segmentation fault In GCC ..
M using mintlinux.... here is the code BFS

Understanding coldfusion code

Understanding coldfusion code

There is a variable being set as follows (through custom tag invocation)
<cfset str = Trim( THISTAG.GeneratedContent ) />
The contents of THISTAG.GeneratedContent looks like
FNAME|MNAME|LNAME Test|Test|Test
The code I am having trouble understanding is as follows:
<cfset str = str.ReplaceAll(
"(?m)^[\t ]+|[\t ]+$",
""
) />
<cfset arrRows = str.Split( "[\r\n]+" ) />
The above line of code should generate array with contents as
arrRows[1] = FNAME|MNAME|LNAME
arrRows[2] = Test|Test|Test
But on dumping the array shows following output:
FNAME|MNAME|LNAME Test|Test|Test
I do not understand what both regular expressions are trying to achieve.

JSF nested templates file not found exception

JSF nested templates file not found exception

I'm having a problem using template that has another nested template
within it.
I get
java.io.FileNotFoundException
at
org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContextURLConnection.java:403)
I have this basic template :
(./resources/css/template.xhtml)
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="css" name="stylesheet.css"/>
<title><ui:insert name="title"> Facelets template </ui:insert></title>
</h:head>
<h:body>
<div id="top" class="top_content">
<ui:insert name="top">Top</ui:insert>
</div>
<div>
<div id="content" class="center_content">
<ui:insert name="content">Content</ui:insert>
</div>
</div>
</h:body>
and templateLogin which "inherits" template :
(./resources/css/templateLogin.xhtml)
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="./resources/css/template.xhtml">
<ui:define name="title">
Some title
</ui:define>
<ui:define name="top">
<div id="top">
...code here
</div>
</ui:define>
</ui:composition>
and I have welcome file which is welcome file of the web application which
uses templateLogin:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="./resources/css/templateLogin.xhtml">
<ui:define name="title">
Welcome title
</ui:define>
As I said, I get file not found exception. When I define as template
template.xhtml for the welcome file , there's no error. It's as it doesn't
see templateLogin.xhtml in the specified path, but it's definetely there.
Any ideas? Thanks.

Why my page show horizontal scrollbar on small screen?

Why my page show horizontal scrollbar on small screen?

I have responsive HTML page and it show scrollbar when width is smaller
then 691px, how to hide that scrollbar? What make that scrollbar to show
up?

How to call a function inside yii framework controller from core php file?

How to call a function inside yii framework controller from core php file?

I am working in yii framework.I am getting stuck at a point where I have
to call a function inside controller in yii framework from core php file.
Actually I am going to create html snapshot.
my folder structure is
seoPravin--
--protected
--modules
--kp
--Dnycontentcategoriescontroller.php
--DnycontentvisitstatController.php
--themes
--start.php (This is my customized file)
--index.php
1) Code of start.php file :--
<!DOCTYPE HTML>
<html>
<head>
<?php
if (!empty($_REQUEST['_escaped_fragment_']))
{
$yii=dirname(__FILE__).'/yii_1.8/framework/yii.php';
require_once($yii);
$escapeFragment=$_REQUEST['_escaped_fragment_'];
$arr=explode('/',$escapeFragment);
include 'protected/components/Controller.php';
include
'protected/modules/'.$arr[0].'/controllers/'.$arr[1].'Controller.php';
echo DnycontentcategoriesController::actiongetDnyContent();
//gettting error at this point
?>
</head>
<body>
<?php
//echo "<br> ".$obj->actiongetDnyContent();
}
?>
</body>
</html>
2) yii side controller function : This function work for normal but when I
am calling using escaped_fragment it gives error
public static function actiongetDnyContent()
{
if (!empty($_REQUEST['_escaped_fragment_']))//code inside if
statement not working
{
$escapedFragment=$_REQUEST['_escaped_fragment_'];
$arr=explode('/',$escapedFragment);
$contentTitleId=end($arr);
$model = new Dnycontentvisitstat(); //Error got at this line
}
else //Below code is working properly
{
$dependency = new CDbCacheDependency('SELECT
MAX(createDateTime) FROM dnycontent');
$content = new Dnycontent();
$content->contentTitleId = $_GET['contentTitleId'];
$content = $content->cache(2592000,$dependency)->getContent();
$userId=105;
$ipAddress=Yii::app()->request->userHostAddress;
echo "{\"contents\":[".CJSON::encode($content)."]} ";
$model = new Dnycontentvisitstat();
$model->save($_GET['contentTitleId'], $userId, $ipAddress);
}
}
error:
Fatal error: Class 'Dnycontentvisitstat' not found in
C:\wamp\www\seoPravin\protected\modules\KnowledgePortal\controllers\DnycontentcategoriesController.php
on line 289
code is working for normal url but not working for _esaped_fragment