Saturday, 31 August 2013

Click on NSBezierPath

Click on NSBezierPath

I'm drawing a NSBezierPath line on my NSImageView. I'm creating
NSBezierPath object, setting moveToPoint, setting lineToPoint, setting
setLineWidth: and after that in drawRect of my NSImageView subclass I'm
calling [myNSBezierPath stroke]. It all works just like I want, but I
can't seem to use containsPoint: method... I tried implementing
if([myNSBezierPath containsPoint:[theEvent locationInWindow]]{
//do something
}
in -(void)mouseUp:(NSEvent*)theEvent of my NSImageView subclass but it's
never reacting and I'm sure I'm hitting that line... Am I doing something
wrong? I just need to detect if NSBezierPath is being clicked.
Cheers.

How to free Watch Henderson vs Pettis live streaming UFC?

How to free Watch Henderson vs Pettis live streaming UFC?

Watch UFC live Fighting Click Here To: Watch Henderson vs Pettis
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/
ufc-live-show.blogspot.com/

Henderson vs Pettis Live Fight DETAILS Date : Saturday, August 31, 2013
Competition: UFC MMA Major Events live Live / Repeat:Live 10:00pm ET

grep to get content

grep to get content

Assume i have a file t1.txt
<div class="content"> main </div> <div class="data"> 100 </div>
If i run
grep -o "content.*" t1.txt
it will return
content"> main </div> <div class="data"> 100 </div>
How can i grep the text by the 1st encountered </div>? i want to get
content"> main </div>
Thanks!

SQL Error: Every derived table must have its own alias

SQL Error: Every derived table must have its own alias

I know there are many questions that deal with this error but I've done
what they have asked to fix the issue I thought. Below is what I have done
but I'm still getting the error. The goal of this script is to display all
the zipcodes within a certain radius.
$zip = 94550; // "find nearby this zip code"
$radius = 15; // "search radius (miles)"
$maxresults = 10; // maximum number of results you'd like
$sql = "SELECT * FROM
(SELECT o.zipcode, o.city, o.state,
(3956 * (2 * ASIN(SQRT(
POWER(SIN(((z.latitude-o.latitude)*0.017453293)/2),2) +
COS(z.latitude*0.017453293) *
COS(o.latitude*0.017453293) *
POWER(SIN(((z.longitude-o.longitude)*0.017453293)/2),2)
)))) AS distance
FROM zipcoords z,
zipcoords o,
zipcoords a
WHERE z.zipcode = ".$zip." AND z.zipcode = a.zipcode AND
(3956 * (2 * ASIN(SQRT(
POWER(SIN(((z.latitude-o.latitude)*0.017453293)/2),2) +
COS(z.latitude*0.017453293) *
COS(o.latitude*0.017453293) *
POWER(SIN(((z.longitude-o.longitude)*0.017453293)/2),2)
)))) <= ".$radius."
ORDER BY distance)
ORDER BY distance ASC LIMIT 0,".$maxresults;
$result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
while ($ziprow = mysql_fetch_array($result)) {
$zipcode = $ziprow['zipcode'];
echo "$zipcode<br>";
}
All my columns in the database are varchar. zipcode is the primary and I
would make it INT but it doesn't allow there to be 0's at the beginning of
the zipcodes. So I changed it to varchar and it allowed it. Thanks for the
help!

passing bool array to a function

passing bool array to a function

I am passing a bool array to function and doing some modifications in the
passed array inside the function, the changes that I do in the function
are reflected in the original array that I passed to the function.For
example ,in the code below the output is 1 .Why am I getting this output ?
When we pass an integer variable for example ,the local variable maintains
its local value .How can I retain local copy of the original bool array
locally in the code below.
#include<iostream>
using namespace std;
void fun(bool A[30])
{
A[0]=true;
}
int main()
{
bool used[3];
used[0]=used[1]=used[2]=0;
fun(used);
cout<<used[0];
}

c# asynchronous server with beginReceive

c# asynchronous server with beginReceive

Hi stack overflow members. I'm struggling with some simple code but I
can't get it done. I have this asynchronous server which waits for
connections.
while (clientSocket.Connected)
{
try
{
clientSocket.BeginReceive(so.buffer, 0, 200, SocketFlags.None
, new AsyncCallback(wait),so);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
where so(shorted StateObject) it's my class:
internal class StateObject
{
public TcpClient client;
public byte[] buffer;
public StateObject()
{
buffer = new byte[200];
client = new TcpClient();
}
}
I use this class to put out the information on the callback function.
However I get the system lacked sufficient buffer space or because a queue
was full. I posted a short piece from the actual program. One interesting
issue, is that if I write:
while (clientSocket.Connected)
{
try
{
byte[] buffer = new byte[200];
clientSocket.BeginReceive(buffer, 0, 200, SocketFlags.None
, new AsyncCallback(wait),so);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
it will work, but I will not be able to pull out the buffer from the
asynchronous function(wait). I'm struggling with this and I can't find
answers.

Cannot reference external types in Java

Cannot reference external types in Java

I'm trying to use the special type QuickUnionPathCompressionUF (which is a
class in a file called algs4.jar), but the compiler complains. I'm using
DrJava as an IDE.
error: QuickUnionPathCompressionUF cannot be resolved to a type
My source file (part of which is shown below) is here:
~/Percolation/Percolation.java
and the .jar file is here:
~/algs4/algs4.java
I have an environment variable (CLASSPATH) set to
~/algs4/algs4.jar ~/algs4/stdlib.jar
Both of these files are listed under "Extra Classpath" in my IDE.
Here are the first few lines of the source file.
package Percolation;
//import algs4.QuickUnionPathCompressionUF;
public class Percolation {
private QuickUnionPathCompressionUF grid; // Data structure for
quick-union.
private int size; // Size of the grid.
private boolean[] open; // open sites
/* ...*/
}
Any suggestions?

Friday, 30 August 2013

how to find number of characters matches in two strings?

how to find number of characters matches in two strings?

How can I do this in python?
first string = GOOD MORNING
second string = GOOD BYE
After 5 characters there is no match
in C, it can be done as: length = strspn(str1,str2);
Thanks in advance...

Thursday, 29 August 2013

Cognos Reports - No Prompt Page

Cognos Reports - No Prompt Page

I am new to Cognos reports, so bear with me.
I have a report that has two parameters (call them x and y). I have a
prompt page for x and y. The user can supply those values and click finish
to be taken to the report. I am looking for a way to only show that prompt
page if those parameters are not passed in the url string. If those
parameters are set, I want to go directly to the report. I have tried some
js to automatically act as though the finish button has been called, but I
am just getting cognos errors. Any suggestions as to how I can accomplish
this? The prompt page is having the prompt controls set to the values for
x and y in the url.
js -
<script type="text/javascript">
promptAction('finish');
</script>
cognos error -
The secondary request failed. The requested session does not exist and the
secondary request does not contain enough information to recreate the
session. Contact your Administrator.

Paypal HTML Discount Code

Paypal HTML Discount Code

I would like to add a discount code option to the Buy Now paypall button
option. I want to be able to set up one discount code that customers can
use and receive a discount.
I am a complete novice, but do know where to paste the HTML code if it is
generated for me.
Can you please help
Thanks

Wednesday, 28 August 2013

Java Date Class NullPointerException

Java Date Class NullPointerException

I am trying to set and return the earliest date from a string and I think
I am missing something when setting my date as I keep getting a
nullreferenceexception whenever I try to set the values for Date. Thanks
for any help
private static Date createDate(String input)
{
Date date = null;
if (input == null)
return null;
// Split formatted input into separate values
String tempDates[] = input.split(dateSep);
// Store values as integers
int[] dateValues = {0, 0, 0};
dateValues[0] = Integer.parseInt(tempDates[0]);
dateValues[1] = Integer.parseInt(tempDates[1]);
dateValues[2] = Integer.parseInt(tempDates[2]);
// Sort integers from lowest to highest
Arrays.sort(dateValues);
// Set return date
date.setMonth(dateValues[0]);
date.setDate(dateValues[1]);
date.setYear(dateValues[2]);
System.out.println(date);
// Checking basic date restrictions
if (date.getMonth() <= 0 || date.getMonth() > 12)
throw new IllegalArgumentException("Month is not valid " + month);
if (date.getDay() <= 0 || date.getDay() > 31)
throw new IllegalArgumentException("Day is not valid " + day);
if (date.getYear() <= 0)
throw new IllegalArgumentException("Year is not valid " + year);
return date;
}
}

SQL Using Case in Where clause for null values

SQL Using Case in Where clause for null values

I have a SQL query that I am trying to incorporate the possibility of null
responses in my selections.
Ultimately, this will end up in a SSRS report.
This query works fine, but any null values in p.ReferralReason will always
be returned. I would like the nulls to not be returned if the value of
@Reason is anything but '%':
DECLARE @Reason varchar(100)
SET @Reason = 'Lost To Care'
SELECT p.Person_ID, P.Person_Name, p.ReferralReason
FROM VIEW_Patient p
WHERE
p.ReferralReason like '%' + @Reason + '%'
I would like to incorporate all reasons with the @Reason = '%' If @Reason
is set to '%', I would like to include the null values, but I do not want
to include the null values if @Reason is set to anything else.
This is what I have tried, but it does not work:
DECLARE @Reason varchar(100)
SET @Reason = '%'
SELECT p.Person_ID, P.Person_Name, p.ReferralReason
FROM VIEW_Patient p
WHERE
case
when @Reason = '%' then (p.ReferralReason like '%' + @Reason +
'%' or p.ReferralReason is null)
else p.ReferralReason like '%' + @Reason + '%'
end
MS SQL Server 2008 R2.

How to get details from QR code?

How to get details from QR code?

I got a string from a qr generated image. But how can I get URL out of it.
The string I got is the following.
aHR0cDovL2R1Yml6emxlLWludGVydmlldy5zMy5hbWF6b25hd3MuY29tLzg3M2FhMTA5LnR4dA==
Can anybody help me to get all the information out of it?
Thanks

Inherit from Python's and override __str__

Inherit from Python's and override __str__

I am interested in doing something similar to what Django is doing to
lists, e.g:
In django shell
In [4]: from TimePortal.models import Rules
In [5]: Rules.objects.all()
Out[5]: [<Rules: day_limit>]
I tried doing the following:
class TimeEntryList(list):
def __str__(self):
return ';'.join([str(i) for
i in self.__getslice__(0, self.__len__())])
Which seems to work in a normal Python shell:
In [54]: a=TimeEntryList(('1-2','2-3'))
In [58]: print a
1-2;2-3
In [59]: str(a)
Out[59]: '1-2;2-3'
However in my application a TimeEntryList instance is really a list of
TimeEntry objects defined like this:
class TimeEntry(object):
def __init__(self, start, end):
self.start = start
self.end = end
#self.duration = (self.end - self.start).seconds / 3600.0
@property
def duration(self):
return (self.end - self.start).seconds / 3600.0
@duration.setter
def duration(self, value):
self._duration = value
def __str__(self):
return '{} - {} '.format(dt.strftime(self.start, '%H:%M'),
dt.strftime(self.end, '%H:%M'),)
When I am printing a single entry everything is ok:
>>> print checker.entries[0]
08:30 - 11:00
When I try slicing, results are different:
>>>print self.entries[0:2]
[<TimePortal.semantikCheckers.TimeEntry object at 0x93c7a6c>,
<TimePortal.semantikCheckers.TimeEntry object at 0x93d2a4c>]
my question is:
How do I inherit from list, and define __str__ so that print only slices
works the following is output when issuing print self.entries[0:2]:
['08:30 - 11:00 ', '11:00 - 12:30 ']
I know this gives the desired out:
[str(i) for i in self.entries[:2]]
However my purpose here is learning a new technique and not necessarily
working with what I already know.

How to use external speakers with hdmi cable

How to use external speakers with hdmi cable

I have conected my ps3 to a pc monitor that has a hdmi cable input.
However, the monitor doesn't have built in speakers, so I can't get any
audio. I want to know if there's another way to get audio out from the
ps3.

Tuesday, 27 August 2013

Bootstrap 3.0.0 - what is replacement of bootstrap-responsive.css?

Bootstrap 3.0.0 - what is replacement of bootstrap-responsive.css?

After I upgraded my application to bootstrap 3.0.0 from bootstrap 2.3.2 it
doesn't layout very well, and it seems to be because of missing
bootstrap-responsive.css in this latest release. Does anyone knows the
workaround here? There doesn't seems to be anything in the bootstrap doc
(at least I couldn't locate it)

jquery ellipsis doesn't show dots at the end

jquery ellipsis doesn't show dots at the end

Jquery Ellipsis doesn't show three dots at the end.
HTML:
<div class="slidertext three_lines">SIA "Baltic Metolat" provides
mechanical surface treatment, priming and painting of technical task. We
are able to handle oversized items.</div>
JQuery:
jQuery('.three_lines').ellipsis({
row: 3
});
CSS:
.slidertext {
margin-left: 1px;
margin-top: 10px;
font-size: 12px;
line-height: 20px;
height: 58px;
overflow: hidden;
margin-bottom: 5px;
width: 224px;
}
It shows only three lines, but it doesn't show dots at the end.
Live it could be seen here: http://www.metolat.lv/ (search fo text
"provides mechanical surface").

Which application occupies a serial port I want to open

Which application occupies a serial port I want to open

Hello can anyone please help me with the following, I try to find a delphi
routine which allows me to find which other program is holding a comport.
(A comport I want to open is occupied by another application which
application does that). Thanks

NSURLConnection send data twice on server

NSURLConnection send data twice on server

I am creating an iPhone app where i need to send data to server. Using
NSURLConnection I'm able to send data but my data is getting send twice.
And I'm getting response only once. Can anyone suggest why is this
happening
Here is my code
NSURL *url=[NSURL URLWithString:[APIServiceURL geturl]];
NSMutableURLRequest *req=[NSMutableURLRequest requestWithURL:url];
NSString *msgLength=[NSString stringWithFormat:@"%d",[soapMsg1
length]];
[req addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req addValue:@"http://tempuri.org/InsertPostComment"
forHTTPHeaderField:@"SOAPAction"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMsg1 dataUsingEncoding:NSUTF8StringEncoding]];
// Response
NSHTTPURLResponse *urlResponse=nil;
NSError *error;
connection =nil;
connection=[[NSURLConnection alloc]initWithRequest:req
delegate:self];
NSData *responseData;
;
if (connection)
{
responseData=[NSURLConnection sendSynchronousRequest:req
returningResponse:&urlResponse error:&error];
}
else
{
NSLog(@"not connected to server");
}
if ([responseData length]>0)
{
NSString *responseString=[[NSString
alloc]initWithData:responseData
encoding:NSUTF8StringEncoding];
NSLog(@"responseString %@",responseString);
responseString =nil;}
Thanks

Monday, 26 August 2013

Accessing java member variable that has the name "type"

Accessing java member variable that has the name "type"

I am using a java library in which a class has a member named "type". If I
do something like this:
class MyClass{
public MyClass(){
type = 5;
}
public int type;
}
then the java compiler compiles it fine. But if I try to access it from
scala:
val x = new MyClass()
x.type = 10
I get this message:
identifier expected but 'type' found.
How do I work around this issue?
I am guessing this has come up before but I could not find a related
question.

How to get values of an array in php

How to get values of an array in php

Im trying to get the hashtagged value seperateley. i gets stored in an
array . i cant seem to extract the value
$string = 'Hi #my name #is #batman';
preg_match_all('/#([\p{L}\p{Mn}]+)/u',$string,$matches);
print_r($matches);
that prints phpArray ( [0] => Array ( [0] => #my [1] => #is [2] => #batman
) [1] => Array ( [0] => my [1] => is [2] => batman ) )
How can i get just #my , #is, #batman

Error: main.lua:22: attempt to index field '?' (a nil value)

Error: main.lua:22: attempt to index field '?' (a nil value)

I'm trying to get some 0 and 1 inside a multidimensional table but I can't
get it to work. I've searched through a lot of posts but I couldn't find a
way of solving it. This is the code:
generatedTerrain={
{0,0,0,0,0},
{0,0,0,0,0}
}
x=0
y=0
function mapGen()
for y=1,67 do
generatedTerrain[y]={}
for x=1,89 do
generatedTerrain[x][y] = math.random(0,1) --This doesn't work
end
end
end
mapGen()
end

How to avoid this warning:com.sun.org.apache.xerces.internal.parsers.SAXParser is Sun proprietary API and may be removed in a future...

How to avoid this
warning:com.sun.org.apache.xerces.internal.parsers.SAXParser is Sun
proprietary API and may be removed in a future...

Recently upgraded from JDK1.5 to JDK1.6, during compilation below warning
is thrown.
import com.sun.org.apache.xerces.internal.parsers.SAXParser; ...
org.xml.sax.XMLReader l_oParser = new SAXParser();
..
During compilation - [javac]
C:\Users\project\src\com\test\ecommerce\services\paymentservices\authorization\HistoryTransactionResponseParser.java:14:
warning: com.sun.org.apache.xerces.internal.parsers.SAXParser is Sun
proprietary API and may be removed in a future release [javac] import
com.sun.org.apache.xerces.internal.parsers.SAXParser;
This warning is not shown when compiling with JDK1.5.

Is there something like has_no_term

Is there something like has_no_term

I have a custom post type named 'Projecten' with a taxonomy called
'fases_projecten', in there i have 'concept', 'inontwikkeling' and
'gerealiseerd'. In my template I'm using the following code for displaying
changes between the sevral fases/terms.
`<?php if( has_term( 'concept', 'fases_projecten' ) ) { ?><div
class="status sActiveConcept"><?php } ?>`
For each fase I have a diffrent openingdiv class, but maybe it will happen
that the users of the website forget to choose a fase, witch mess up the
site completely because the openingtag of the div is missing.
So I was wondering if there exsists something like has no term.
What I already tried is
<?php if( has_term( '', 'fases_projecten' ) ) { ?><div
class="status"><?php } ?>
Also when I make do it like this:
<?php if( has_term( 'concept', 'fases_projecten' ) ) { ?><div
class="status sActiveConcept"><?php } ?>
<?php elseif( has_term( 'inontwikkeling', 'fases_projecten' ) ) { ?><div
class="status sActiveDeveloping"><?php } ?>
<?php elseif( has_term( 'gerealiseerd', 'fases_projecten' ) ) { ?><div
class="status sActiveFinished"><?php } ?>
<?php else( has_term( '', 'fases_projecten' ) ) { ?><div
class="status"><?php } ?>
It will not work, I get a servererror.
I hope I explained clear enough, my english is not so good though

A way to rotate plot in R

A way to rotate plot in R

Rotate a plot (with below rotation setting) seems to be impossible in R
according to Google.
So I am looking for a way to do that, but still no success till now.
Rotation setting :
The rotation center is the origin of plot ({0,0})
The given angle will be the angle between the y axis and the plot.
Here is a code where
a is something depending on angle and x axis length. (I think)
b is something depending on angle and y axis length. (I think)
:
speed <- cars$speed
dist <- cars$dist
plot(speed,dist, xlim=c(0,121), ylim=c(0,121))
xTemp <- speed
speed <- speed + (a)
dist <- dist + (b)
par(new=TRUE)
plot(speed,dist, xlim=c(0,121), ylim=c(0,121), col="red")
Any idea of a and b values ?
Here is for example a code in wich the plot is rotated by about 50 degrees
from the y axis (Notice that is is not a true rotation. speed value is
extended after rotation.. I don't now how to fix it.) :
speed <- cars$speed
dist <- cars$dist
plot(speed,dist, xlim=c(0,121), ylim=c(0,121))
xTemp <- speed
speed <- speed + dist
dist <- dist - xTemp
par(new=TRUE)
plot(speed,dist, xlim=c(0,121), ylim=c(0,121), col="red")

Compare two images irrespective of their size

Compare two images irrespective of their size

I just want to compare images like 2D diagrams (like diagrams in reasoning
questions). And I am giving a drawing editor like paint to draw diagrams.
So suppose one draw a image with a square and a circle and again draw a
image with a little bigger square and a smaller circle. The two images are
same but their figures sizes are different. I want to consider those two
images as same and not different.
Can anyone help me to start with?
Thanks, Surodip

Sunday, 25 August 2013

Prove $\log_a(b)$ is irrational given that $a, b$ are positive distinct primes.

Prove $\log_a(b)$ is irrational given that $a, b$ are positive distinct
primes.

I know this is a classical proof by contradiction exercise, and there are
full solutions else where, doing a quick search I didn't find any, but I
would approach this question like this:
Suppose $\log_a(b) = \dfrac{p}{q}$ where $p,q \in \mathbb{Z}$ and
$\gcd(p,q) = 1$. Then this implies $a^{\frac{p}{q}} = b$ which implies
$a^p = b^q$. By the fundamental theorem of arithmetic we know $a^p$ has a
unique prime factorization and so does $b^q$. That means $a^p, b^q$ must
have the same unique prime factorization. If $p,q > 0$ then $a|a^p$ but
$a\not |b^q$ contradiction. Similar argument for if one of $p$ or $q$ less
than $0$.
Would this be a correct proof for this question, are there other common
different proofs?
Thoughts after seeing answers: My confusion for not being able to see the
answer right away was because I thought $\frac{p}{q}$ could be negative,
hence there is another possibility in the proof. But $\log_a(b) < 0$
implies $b < 1$ which is impossible since $b$ is a prime.

FT232R USB UART and Android Device

FT232R USB UART and Android Device

I am now working on communicating with android device with the FT232R USB
UART .If I insert the Ft232R cable into the SAMSUNG Nexus,it works
well(the test app is provided by offical
website:http://www.ftdichip.com/Android.htm),but when I insert it into my
aigopad,the aigopad can not read any info from the FT232R,the device show
that:the device number: 0.So I am sure there is something wrong with my
aigopad,but I do not where is the problem.
My device is aigopad M608 and the android version is 4.0.4.
Looking forward to your help!

Analyzing usage of a proxy server

Analyzing usage of a proxy server

do you know of any tools that one can use to analyze the usage of a proxy
like Squid ? For example, what the users try to access, HTTP requests,
stats.

pass unknown amount of objects using one parameter objective c

pass unknown amount of objects using one parameter objective c

i'm trying to create custom alertView and i'm having problems with
overriding init function
- (id)initWithTitle:(NSString *)title message:(NSString *)message
delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles, ... {
self = [super initWithTitle:title message:message delegate:delegate
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:otherButtonTitles, nil];
//custom initialisaton
return self;
}
how can i use other button titles if there is more than one title?

seven segment display with width

seven segment display with width

I'm in the process of making a seven segment display emulator in python
and have run into a small problem. What I have done is make a list for
each number that has a series of numbers representing a character, like so
["000", "001", "000", "001", "000"] This represents the number 1, with 0
been a space, 1 been a pipe character (|) and 2 been a dash.
This works fine for a width of 1 but I want it to be able to go to any
width. I've tried doing this by multiplying the character count by the
width e.g the number one with a width of two would look like ["000000",
"000011", "000000", "000011", "000000"]
The problem I am having is when it encounters a pipe character it will
print it on the same line rather than underneath it. Like so '| |' when it
should be like
|
|
I've tried using \n to print it on a new line but this messes everything
else up.
Any suggestions on how do this in a better way or how to fix my problem
would be appreciated.
Thanks

Rails: Saving Input whithout Spaces

Rails: Saving Input whithout Spaces

I'm searching on how to Save my Input without the spaces.
I collect the input on my form via
<%= f.input :name %>
and use it also for linking
localhost:3000/users/:name
The Problem is, if someone uses Spaces in his name the link is getting all
ugly with % signs etc.
How can i store the input without spaces ?
E.g.
input is: Hey im John saving as: HeyimJohn

Saturday, 24 August 2013

Attack coastal provinces with ships?

Attack coastal provinces with ships?

I've just started my first game as the Ottomans, and my 10 regiment army
is taking a long time to conquer Albania, so I sent some Light Ships,
Galleys and Cogs over to help. They are in the sea next to the province,
but I can't figure out how to have them support the siege or attack the
one enemy ship present.
I selected the Light Ships and clicked the Detach Blockade button, but
that didn't seem to change anything. The image of the city on the siege
popup shows it's a port city if that matters.

Damn Small Linux with XAMPP Linux to create a webserver on a P4 machine or Mele A2000

Damn Small Linux with XAMPP Linux to create a webserver on a P4 machine or
Mele A2000

A couple of days I'am busy to figure out to create a powerful light weight
server that can be used as webserver to serve some simple sites that using
PHP and mod-rewrite.
The P4-box (actually a laptop, dell latitude c640) i'm using came with
windows XP Prof. The problem is that windows consumes more memory and has
some TCP/IP stack problems (it is limited) because it can only serve up to
10 (and 40 with a hack) connections a time.
Before this have also bought a Mele A2000 ARM device (china thingy) that
comes with Android 4.0, a nice little box that is quiet and is power
friendly, just 5 watts. On this device I also tried several things but
doens't get ARM linux on it and all software solutions on Android uses
Lighttpd which does not support mod rewrite like Apache.
So i start searching the net for a linux distro for the P4-box and found
many, to figure out what is the best, it is very difficult for me because
of my Windows background (don't want a headless system). Tried several
ones and then I found Damn Small Linux (or DSL), looks great and works
okay on a very small footprint. Exactly what i'm looking for.
Then I search on DSL+Apache+PHP+mySQL and found the XAMPP Linux version (I
use also XAMPP on Windows to test websites, and found a blog that XAMPP
must be working on DSL). I found only information how to do it but there
is no iso or disk image around with these two worlds combined (at least i
didn't find it).
I tried to setup a diskimage (2GB) with use of VMWare, that is working
great. The idea is to first try it in VMWare and after that convert the
disk to a physical disc without damaging systems or hardware. I have used
the DSL install to setup a debian installation (the "install to harddrive"
option in the tools menu. Reboot and works okay.
After this i downloaded XAMPP Linux
(http://www.apachefriends.org/en/xampp-linux.html) and follow the
instructions on this page. Installed it as superuser but get errors at the
install, one about SQL (something with syntax error in a command-line
utility) and one error the end (something I didn't understand) but install
proceeds and completes.
Then I tried to run 'lampp' or 'xampp' and the only thing I see is
floating point exceptions (see image) and doesn't look ok.

In short, my questions are:
Is there a DSL+XAMPP image around that I can use (can make my life much
easier ;-))
If not, what i'm doing wrong (is it really possible or is there something
wrong with the latest version of both?)
Is there a lightweight distro with XAMPP installed or
PHP+Apache+mod_rewrite+mySQL available? ARM or x86?
Or is it better to take my hands of this and try to figure out to hack
windows stack to get more connections
Or do you have other suggestions?

how to check if a specific user is signed into google hangout

how to check if a specific user is signed into google hangout

Is there an API call to check if a specific user (whose google+ id is
known) is signed into Google Hangout or not ?
The application I am working on requires me to show a Google Hangout
button to customer X only when customer Y is already logged into a Google
Hangout.
I have already checked the People Google+ API as well as the Hangout API
and I cannot find any call will provide me this info.
Please let me know if this is possible.
Thanks,

Finding $\lim_{x\to 0} \large \frac {\sqrt{x}}{\sin x}$

Finding $\lim_{x\to 0} \large \frac {\sqrt{x}}{\sin x}$

Using L'Hospitals rule I keep on getting $\frac{0}{0}$... But Im not sure
if this is correct?
$$\lim\limits_{x\to 0} \frac{\sqrt{x}}{\sin x}$$
$$\frac{\frac{1}{2}x^{-\frac{1}{2}}}{\cos x}$$
$$\frac{-\frac{1}{4}x^{-\frac{3}{2}}}{-\sin x}$$
Thanks in advance for any help.

iOS Facebook login, handle different access tokens and determine users identity

iOS Facebook login, handle different access tokens and determine users
identity

I have a couple of questions regarding facebook integration and
authentication in my social networking iOS application.
First of all, Users of my application are required to create an account
and login before any content is available to them.
I have a separate backend system, so regular account registration inside
my application is supported. When a user is logged in to an account he or
she is supplied an access token which is used for future backend-requests,
such as image-uploads.
Secondly, A user can choose to log in with Facebook, and thereby acquire
an access token from the successfully opened FBSession.
This leads to my first question: How do I use the access token acquired
from Facebook to authenticate my users with my backend system? Should I
send the acquired token to my backend and have the system use that token
for this particular user until further notice, or is there another way to
go about this?
--
Now lets say that I solved the problem in the first question...
My second question: Imagine that a user created an account and logged in
the normal way (i.e. without facebook) The next time that user wants to
use the application, he or she chooses to log in with facebook.
Now, In my backend-system, how would I know that these two users are the
same, connect them and thereby be able to load the same content for both
cases? Is it even possible to have hybrid accounts that supports double
logins like that? A regular registration only requires email, username and
password, so I cannot think of a way to determine that a
facebook-loggedin-user is the same user as a normal-loggedin-user.
I Hope the above makes sense.

Script works with PHP 5.4.16, but not PHP 5.3.3... where is the faulty code?

Script works with PHP 5.4.16, but not PHP 5.3.3... where is the faulty code?

I'm a beginner in php, and... I was just trying to create this... dynamic
indexing/document_display script using php... What I was trying to do
isn't really important to the question, however. The thing is... my script
does exactly what I want it to do, when hosted on a WAMP server with php
5.4.16... but when uploaded to a LAMP server with php 5.3.3, I get the
error
Fatal error: Can't use function return value in write context in
/users/clentz/testphpindex.php on line 34
I need it to work on this lamp server.
Can anyone tell me what about the following code is causing errors with
the php 5.3.3 interpreter?
<?php
$courses_directory = "./Courses";
$courses_array = scandir($courses_directory);
if (empty($_SERVER['QUERY_STRING']))
{
include 'Misc/common_components/headers/index_header.html';
echo "\r\n\t<h1>Enrolled Courses</h1>";
for ($uwmi_loop_var = 2; isset($courses_array[$uwmi_loop_var]);
$uwmi_loop_var++)
{
if ($uwmi_loop_var == 2)
{
echo "\r\n\t<ul>";
}
if (isset($courses_array[$uwmi_loop_var]))
{
echo "\r\n\t\t<li>" . '<a href="?' .
$courses_array[$uwmi_loop_var] . '">' .
$courses_array[$uwmi_loop_var] . '</a></li>';
}
if (!isset($courses_array[($uwmi_loop_var + 1)]))
{
echo "\r\n\t</ul>\r\n";
}
}
include 'Misc/common_components/footer.html';
}
else if (!empty($_SERVER['QUERY_STRING']))
{
for ($uwmi_loop_var = 2; isset($courses_array[$uwmi_loop_var]);
$uwmi_loop_var++)
{
if (explode("&",$_SERVER['QUERY_STRING'])[0] ==
rawurlencode($courses_array[$uwmi_loop_var]))
{
include "./Courses/" . $courses_array[$uwmi_loop_var] .
"/index.php";
}
}
}
?>
If it helps, you can see the code in a little more visually appealing
format at: pic of the code in a visually appealing format

Wrong Comma Use? Weak Sentence?

Wrong Comma Use? Weak Sentence?

Could someone tell me what's wrong with this sentence?
She also goes on dates with herself, and she ends these nights with bubble
baths.
Is the comma here wrong? Any other issues? How would you write it?

Friday, 23 August 2013

creating a generic static method in java

creating a generic static method in java

I wanted to create a static method which prints the contents of an array.I
wrote one for String[] as below
public static void print(String[] a){
for(String x : a){
System.out.print(x+", ");
}
System.out.println();
}
I thought I could create a method which takes in a generic type ,and
modified the code as below
public class ArrayPrinting<E> {
public static void printArray(E[] a){
for(E x : a){
System.out.print(x+", ");
}
System.out.println();
}
public static void main(String[] args) {
String[] a = {"A","B","C","D","E"};
}
}
But,this gives a compiler error
'Cannot make a static reference to the non-static type E'
So,how do I create such a method?or is it impossible ? Since this is a
static method, I wonder how I can invoke the method without creating an
instance. A call like
ArrayPrinting<E>.printArray(a) doesn't look right ..
Can someone help?

wpf do propertychangedcallback's occur immediately on propertychanges?

wpf do propertychangedcallback's occur immediately on propertychanges?

My general understanding is that when the propertychanges, the local
callback is immediately performed. So I can assume that happens
immediately. However, a bound property's callback will not take place till
the binding propagates, which may not occur immediately. is this correct?

how to do simple concat in awk in mac

how to do simple concat in awk in mac

So I have a file list.txt similar to this one:
186
423
423
234
634
437
And I want an output similar to this:
SET 186 0
SET 423 0
SET 423 0
SET 234 0
SET 634 0
SET 437 0
I tried with this:
sed 's/^ *//g' list.txt | | awk '{a="SET ";b=" 0";print a,$0,b}'
But it prints
0 80349851
0 82988801
0 83003371
0 79515621
0 83228451
Given that
sed 's/^ *//g' list.txt | | awk '{a="SET ";b=" 0";print a,$0}'
Works perfect. So I don't know what I'm doing wrong.
Do you know how to solve this and why print a,$0,b doesn't work?

Wordpress stylesheets and other files not linking up

Wordpress stylesheets and other files not linking up

I've uploaded a clients wordpress site to a test domain: 101share.co.uk .
I had everything working on localhost and changed the urls and stuff
before uploading, from http:// localhost/wincheapguesthouse/ to
http://101share.co.uk .
After uploading and importing the database the result I get seems to be
that many files are not being found, but they are there. In the source
code if I look for , it can't find it. But if I look for or
"http://101share.co.uk/wp-content/themes/retlehs-roots-16aad54/assets/css/app.css"
Then I'm able to find it.
Have I got something wrong with the data base or is there a url I need to
change, I can't change each link because I don't know exactly how much it
is effecting.
I stressing out a little over this because it's a clients site and I need
to get things working for them to see. So any help would be very much
appreciated.

Server Socket disconnects and stops listening

Server Socket disconnects and stops listening

This is a problem I never figured out. I've asked many people, and they
don't even know. Anyways, lets get to the problem. Here's what I tried to
do... Create a client and a server. The client connects to the server, and
sends a message to it every 3 minutes (I reduced the time for testing).
There has to be two independent threads however (one for the client and
server). What I found was, the client would continue to send messages, but
the server would no longer listen on port 1234.
Client:
import java.io.PrintWriter;
import java.net.Socket;
public class Client {
public Client(){
startClient();
}
public void startClient(){
new Thread(new Runnable(){
@Override
public synchronized void run(){
try{
Socket sendChat = new
Socket("localhost", 1234);
PrintWriter writer = new
PrintWriter(sendChat.getOutputStream());
while(true){
Thread.sleep(1000); // normally
180000
writer.println("Hello Server!");
}
}catch(Exception err){
err.printStackTrace();
}
}
}).start();
}
}
Server:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
public class Server {
public Server(){
startServer();
}
public void startServer(){
new Thread(new Runnable(){
@Override
public synchronized void run(){
try{
@SuppressWarnings("resource")
ServerSocket
server
=
new
ServerSocket(1234);
while(true){
final Socket test =
server.accept();
BufferedReader reader = new
BufferedReader(new
InputStreamReader(test.getInputStream()));
while(!test.isClosed()) {
Date date = new Date();
System.out.println("Server
got message from
client " + date);
}
reader.close();
}
}catch(Exception err){
err.printStackTrace();
}
}
}).start();
}
}
Start:
public class Start {
public static void main(String[] args){
new Server();
new Client();
}
}
I would greatly appreciate it if someone could tell me what is wrong,
because I honestly have no clue.

Twitter Bootstrap Carousel Not Loading

Twitter Bootstrap Carousel Not Loading

I having problems with Twitter Bootstrap carousel.
The javascript doesnt seem to load. but it works fine when its on my local
dev ust nto when i push it to server.
<script src="assets/js/bootstrap-carousel.js"></script>
<script
src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/jquery.countdown.js"></script>
<script src="assets/js/script.js"></script>
<script>
$(document).ready(function(){
$('.carousel').carousel({
interval: 6000,
pause: "hover"
});
$(".carousel-inner > .item:first").addClass('active');
$("#nav select").change(function() {
window.location = $(this).find("option:selected").val(); }); });

Thursday, 22 August 2013

Is there a way to use an existing function as a part of a class? If yes, how?

Is there a way to use an existing function as a part of a class? If yes, how?

I have a function that I want to use in different classes. Is this possible?
Example:
int getNumber()
{
// do something here that will use some values like:
int number = num * pi;
return number;
}
class Human
{
int num;
// other member
int getNumber(); // same as above
}
class Robot
{
int num;
// other member
int getNumber(); // same as above
}
The getNumber() function can be short as return num; or long depends on
the computation that will happen inside the function.
The num value inside the getNumber() is the num member of both Human and
Robot class. Although, these classes do not have the parent-child or
friend relationship.

Import single csv file with one data field going to separate table

Import single csv file with one data field going to separate table

I know this one is probably a long shot but I thought I would at least
ask. Say I have a csv file with a list of Products with the following 4
columns/data fields (Product ID, Name, Alias, UOM) that I would like to
import into a database that has 2 tables. One table is the Product table
(Product ID, Name, UOM), second table is Product Alias table with these 2
columns(Product ID, Alias), where each Product ID may have 0 to many alias
names. Is there any way I could treat the Alias column different by the
fact it has a different separator between the comma's like ";" or a period
"." to separate the 0 to many alias names for a given Product ID.
Therefore during the csv import, when it gets the 3rd comma, it would
import that data into this 2nd table but import a new record with
repeating Product ID's for as many alias names are in that comma field.
Hopefully I explained that well enough, let me if I didn't. I'm more
interested in the possible processing of doing this regardless of what
code that is being using but python would be the preferred route.
ProductID, Name, Alias, UOM
122, Widget1, W1;Wid1;Wt1, Each
123, Widget2, , Each
124, Widget3, W3;Wt3, Each

jQuery wave animation on row of icons

jQuery wave animation on row of icons

I have a row of icons on my page and i want to create a wave animation
effect when user hovers over them with the cursor.
I'm using this basic code for starters:
$('#icons > li')
.hover(function() {
$(this).animate({
'top': (-1 * hover_distance)
}, hover_speed);
}, function() {
$(this).animate({
'top': 0
}, hover_speed);
})
;
And it looks OK. But there is one issue: when you move your cursor
frantically over the icons, the animation queue for every icon is becoming
filled with lots of actions (up, down, up, down, up, down, etc) and icons
is going up and down lots of times even if you stop to interact with the
icons.
I want my icons to complete only one cycle (up and down) and then stop the
animation. I'm looking for a most elegant (short, simple, light) solution
for this.
P/S: And you can't just use stop() because it will prevent the "wave
effect" (i.e. when you move your cursor with one fast stroke over the
icons and they move up and down in response, like a real wave).

C: Trying to free malloc'd char array returned from function results in an error

C: Trying to free malloc'd char array returned from function results in an
error

I have a function to convert a short to a byte array here
char *GetBytesShort(short data)
{
char *ptr = (char *) malloc(sizeof(short));
memcpy(ptr, &data, sizeof(short));
return (char *) *ptr;
}
And, in my main.c, I call the function like this
char *data = GetBytesShort(10);
free(data);
However, whenever I try to free the memory, I get an error First-chance
exception at 0x5896586E (msvcr110d.dll) in Project1.exe: 0xC0000005:
Access violation reading location 0x00000004.
If there is a handler for this exception, the program may be safely
continued.
I'm using Visual Studios 2012 Ultimate edition. I've already set the
language to C in Properties -> C/C++ -> Advanced -> Compile As, but to no
avail. And my files have the .c extension, and not the .cpp
Thanks in advance!

Java Main Method, Parameters Differences

Java Main Method, Parameters Differences

I've started learning Java and I was wondering the difference between:
public static void main (String [] args) {}
and
public static void main (String args[]) {}
As you can see they look almost exactly the same but my question here is,
should the '[]' be before the args or after the args? I have a Java
beginners guide and it shows me examples with the '[]' after the args. I
would be grateful if someone could tell me the correct way.
Thanks!.

How to send keystrokes (F5) from terminal to an process?

How to send keystrokes (F5) from terminal to an process?

I'm using an Raspberry Pi in combination with Chromium (kiosk mode) to
show up some stats. The Pi doesn't have an connected keyboard so I
searched for a solution to send keystrokes from the terminal to the
Chromium (tab) process. Normal input does work but how do I send something
like F5 (special key; browser refresh) via this solution?
# pidof chromium
20809 20790 20788 20786 20783
# echo 'some text' > /proc/20809/fd/0

Wednesday, 21 August 2013

Error with T4 template running it by command line

Error with T4 template running it by command line

I'm trying to execute the "Run custom tool" action from command line. In
this way:
C:\Program Files (x86)\Common Files\microsoft
shared\TextTemplating\10.0>TextTransform.exe "C:\Carlos\Automatic Unit
Testing\Examples\T4Example\T4Project\T4Project\MultipleOutputFiles.tt"
When executing that, i'm getting this error:

Aditionally, when hitting the option "Debug T4 template", I get this message:
There was a problem getting an AppDomain to run the transformation from
the host. The process cannot continue.
I hope all this information helps you understand my issue.
I'll wait your asnwers :)
Thank you,

BIDS "Start Debugging" button not working

BIDS "Start Debugging" button not working

This is a very strange issue. In BIDS/Visual Studio, the "Start Debugging"
button does not run the active package that I am working on. Instead it
opens another package in the project (always the same one) and runs that
one instead. I can only run the active package by right clicking on it in
Solution Explorer and selecting "Execute Package". I run BIDS on three
separate machines and the other two machines do not do this. Is this
button programmable? I have not found any setting for this button.
Has anyone else seen this?

While loop in another while loop to echo data from SQL

While loop in another while loop to echo data from SQL

I have 2 tables, table 1 and table 2.
I want to echo all in table 1, an each time I echo all in table 1 I want
to echo all in tabel 2.
I know I can't write a code this form:
while($var = mysqli_fetch_assoc($result))
{
echo $var['data'];
while($var2 = mysqli_fetch_assoc($result2))
{
echo $var2['data2'];
}
}

So how am I supposed to write the code ???

Flash AS3 run function after Exit frame

Flash AS3 run function after Exit frame

i really need some AS3 Script for run some function when i leave a specfic
frame.
my reason is to put some function to stop video and resume my sound of mp3
player AFTER i exit the frame that contain FLV playback .



i use this script and it`s work great in FLash projector but
stage.invalidate(); cause the Third party application maker like Swfkit
and Zinc Not responding after i try to exit from flv playback frame.
Here is my Script :
stage.invalidate();
mene.addEventListener(Event.RENDER,exitingF);
mene.addEventListener(Event.REMOVED_FROM_STAGE, removedF);
function exitingF(e:Event):void{
controller.gotoAndStop(2);
pausePosition = sndChannel.position;
sndChannel.stop();
isPlaying = false;
}
function removedF(e:Event):void{
mene.stop();
controller.gotoAndStop(1);
sndChannel = soundClip.play(pausePosition);
isPlaying = true;
}
all i need is some another way to say flash run some script right after
exit specfic frame ( go to another frame )

Replace watin web control with Gecko in a 64-bit App

Replace watin web control with Gecko in a 64-bit App

In a 64-bit C# window forms app that uses watin web control can I replace
it with geckofx web control or there is no such a solution? Thanks

Any Tips On SEO

Any Tips On SEO

I have read that Google no more uses meta tags to rank your website.
So what are the ways otherwise if I want to increase traffic or optimize
my website for search engines so that more customer would get attracted to
my website. we are running e-commerce business which is confined to a not
very large area.
Its only 5-6 months we have launched our website. Can I get any tips so
that I can optimize my website for searching.

how do i split large SQL database backup files in .net?

how do i split large SQL database backup files in .net?

I am working on backing up and restoration of SQL Database. I am new to
this.I have an issue related to Backup process. I have SQL database and I
am using BACKUP and RESTORE classes to perform backup and restore of
database. I want to make my program more efficient using split backup. I
have aprx 15 to 20 GB of data. so I want to split my my backup files in
specified limit lets say 8-10 GB. I can do this using below SQL
statements:
BACKUP DATABASE AdventureWorks
TO DISK = 'C:\Backup\MultiFile\AdventureWorks1.bak',
DISK = 'C:\Backup\MultiFile\AdventureWorks2.bak',
DISK = 'C:\Backup\MultiFile\AdventureWorks3.bak'
GO
But I want to do this by using Microsoft.SqlServer.Management.Smo.Backup
classes. And I want to get the size of my backup files. Because my
criteria is to split file if my database size exceeds 10 GB otherwise it
will not split my file. SO my issue is how can I get Size of my database
when taking backup. Looking forward to this and Sorry for inconvenience.
Thanks in advance. Quick response is appreciated.

Tuesday, 20 August 2013

Exception not thrown Java

Exception not thrown Java

class ex1
{
static void my() {
System.out.println("asdsdf");
}
public static void main(String args[]) {
try {
for (;;) {
my();
}
} catch (Exception e)//Exception is not caught //Line 1
{
System.out.println("Overflow caught");
} finally {
System.out.println("In Finally");
}
System.out.println("After Try Catch Finally...");
}
}
The catch statement (Line 1) does not handle the overflow exception as
such the output keeps on printing "asdsdf" without throwing an exception.
Can anyone tell me why an infinite loop is not handled as an exception ?.
Or that's the way it's designed and supposed to work ?

Reduce fan speed of ATI GPU with radeon open source driver

Reduce fan speed of ATI GPU with radeon open source driver

I have a Radeon HD 6950 connected to two screens on a machine running
archlinux.
Recently I changed from the proprietary to the open source driver due to
dropped catalyst support. Unfortunately by default the fans are very noisy
by default - apparently the power saving mechanisms do not work properly.
I set /sys/class/drm/card0/device/power_method to profile and
/sys/class/drm/card0/device/power_profile to low. This seems to work
# cat /sys/kernel/debug/dri/0/radeon_pm_info
default engine clock: 800000 kHz
current engine clock: 249990 kHz
default memory clock: 1250000 kHz
current memory clock: 1250000 kHz
voltage: 900 mV
PCIE lanes: 16
Unfortunately it does only help a little with the fan noise. I also tried
dynpm which doesn't really seem to have an effect (possibly due to the
dual head setup).
Previously, with the catalyst drivers, I had issues with fan noise after
suspend, but I was able to use the "ATI Overclocking Utility" to reduce
both shader and memory frequency which muted the fans.
Also I have dual boot windows running and there is no issue with fan noise
in idle on Windows.

QDialog not painting in loop

QDialog not painting in loop

So I have a QDialog class that's launched from a QMainWindow. The
constructor sets up the UI. I declare the object in the QMainWindow, then
i call the method that loops in the QDialog class. The result is that when
the QDialog is shown(dialog->show() is in the constructor) the window
appears without the layout. After the loop completes the layout is then
shown.
I've tried using exec() instead, but then the method does not execute
until after the dialog is closed.

The process cannot access the file because it is being used by another process when replacing a pdf file

The process cannot access the file because it is being used by another
process when replacing a pdf file

I am trying to use the code to replace a file if it exists and I am
getting the error that The process cannot access the file because it is
being used by another process. I am not sure what has a lock on it? Is
there something in my code below I need to clear?
Dim Doc1 As New Document
Dim path As String = "\\server\pdfs\"
Dim myUniqueFileName = String.Format("{0}.pdf", Session("FileName"))
If (Not System.IO.Directory.Exists(path & myUniqueFileName)) Then
Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(Doc1, New
FileStream(path & myUniqueFileName, FileMode.Create))
Doc1.Open()
Dim test As String
test = Session("PDF")
Dim PDFHeader As String
PDFHeader = Session("Header")
Dim imagepath As String = Server.MapPath(".") & "/images/Header.png"
Dim image As iTextSharp.text.Image =
iTextSharp.text.Image.GetInstance(imagepath)
image.ScalePercent(70.0F)
Dim line1 As New iTextSharp.text.pdf.draw.LineSeparator(0.0F,
100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)
Doc1.Add(image)
Doc1.Add(New Paragraph(PDFHeader))
Doc1.Add(New Chunk(line1))
Doc1.Add(New Paragraph(test))
Doc1.Close()
End If

Sencha Touch 2: input placeholder in not centered in Android 4

Sencha Touch 2: input placeholder in not centered in Android 4

I'm trying to center the placeholder text. It looks centered on IOS, but
still left aligned on Android 4.
/*css code is below*/
#myinput input{
text-align:center!important;
}
#myinput input::-webkit-input-placeholder{
text-align:center!important;
}
//the view (.js file) has
{
xtype: 'emailfield',
name: 'myinput',
id: 'myinput',
required: true,
placeHolder: 'myinput (optional)',
listeners: {
//some listeners are here
}
}
What am I missing?

Monday, 19 August 2013

recording live stream video from tv card using ffmpeg at window

recording live stream video from tv card using ffmpeg at window

I want to record live stream every 1 second from tv card(tv signal) using
ffmpeg in window.
first of all, to record live video from tv card, I tried below.
First I tried this.
ffmpeg -list_devices true -f dshow -i dummy
then the result is
" [dshow @ 000000000024e6fe0] DirectShow video devices
[dshow @000000000024e6fe0] "SKYTV HD USB Maxx Video Capture"
[dshow @ 000000000024e6fe0] DirectShow audio devices
[dshow @ 000000000024e6fe0] "Analog Audio In(SKYTV HD USB Ma" "
so I tried
ffmpeg -f dshow -i video="SKYTV HD USB Maxx Video Capture" -r 20 -threads
0 D://test.mkv
But it didn't work. the Error message is
"[dshow@000000000034d920] Could not run filter
video=SKYTV HD USB Maxx Video Capture: Input/output error"
I use the device called 'SKYTV HD USB Maxx Video Capture' for getting tv
signal(TV card).
The First way deosn't work, I tried different way.
ffmpeg -y -f vfwcap -i list
then the result is "
[dshow @ 00000000003fd760] Driver 0
[dshow @ 00000000003fd760] Microsoft WDM Image Capture (Win32)
[dshow @ 00000000003fd760] Version: 6.1.7601.17514 list: Input/output error
"
so I tried
ffmpeg -y -f vfwcap -r 25 -i 0 D://out.mp4
then, there is some out.mp4 file in D drive but the file is nothing. (I
think it is not TV signal)
what should i do to record live video every 1 second from tv card(tv
signal) using ffmpeg in window? And How can I set channel at
tvcard(Because I want to get tv signal, there are many channels).
Please help..!

In phoenix for hbase , upsert OOM when insert 90000 row data

In phoenix for hbase , upsert OOM when insert 90000 row data

run cmd : ./jsvc64/jsvc64 -pidfile ./log/jsvc.pid -outfile ./log/out.txt
-errfile ./log/error.txt -Xmx512m
-Djava.util.Arrays.useLegacyMergeSort=true -cp :./tools/lib/:./tools/
com.g2us.hbase.cmdlog.monitor.CmdLogHbase ./
sql : UPSERT INTO
CMDLOG_20130818(game,roleid,otime,logtype,passport,subgame,cmdid,exception,moreinfo,pname_0,pname_1,pname_2)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
upsert 90000 row data,the exception occored.
how to solve it, thanks .
Exception in thread "Thread-0" java.lang.OutOfMemoryError: GC overhead
limit exceeded at java.lang.reflect.Method.copy(Method.java:143) at
java.lang.reflect.ReflectAccess.copyMethod(ReflectAccess.java:118) at
sun.reflect.ReflectionFactory.copyMethod(ReflectionFactory.java:282) at
java.lang.Class.copyMethods(Class.java:2748) at
java.lang.Class.getMethods(Class.java:1410) at
org.apache.hadoop.hbase.ipc.Invocation.(Invocation.java:67) at
org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:86)
at $Proxy8.getClosestRowBefore(Unknown Source) at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1019)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:885)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:846)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:271) at
org.apache.hadoop.hbase.client.HTable.(HTable.java:211) at
org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:160)
at
org.apache.hadoop.hbase.client.MetaScanner.access$000(MetaScanner.java:54)
at
org.apache.hadoop.hbase.client.MetaScanner$1.connect(MetaScanner.java:133)
at
org.apache.hadoop.hbase.client.MetaScanner$1.connect(MetaScanner.java:130)
at
org.apache.hadoop.hbase.client.HConnectionManager.execute(HConnectionManager.java:383)
at
org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:130)
at
org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:105)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.prefetchRegionCache(HConnectionManager.java:947)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1002)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:889)
at
org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:846)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:271) at
org.apache.hadoop.hbase.client.HTable.(HTable.java:263) at
com.salesforce.phoenix.query.HTableFactory$HTableFactoryImpl.getTable(HTableFactory.java:60)
at
com.salesforce.phoenix.query.ConnectionQueryServicesImpl.getTable(ConnectionQueryServicesImpl.java:133)
at
com.salesforce.phoenix.execute.MutationState.commit(MutationState.java:227)
at
com.salesforce.phoenix.jdbc.PhoenixConnection.commit(PhoenixConnection.java:244)
at com.g2us.hbase.phoenix.HBaseHelper.executeUpdate(HBaseHelper.java:62)
at
com.g2us.hbase.cmdlog.io.BaseLogPoster.upsertRow(BaseLogPoster.java:153)

Link to a different page within an included file, to be loaded on the same parent file

Link to a different page within an included file, to be loaded on the same
parent file

I hope this question makes sense because it seems simple, yet I can't work
out exactly how to word it in an understandable way.
Basically - I have an Ajax system for loading content onto an HTML file
via a seperate PHP file. This is to not need the actual page the browser
has loaded to change, only the content.
What I would like to do it be able to create a link WITHIN one of the
loaded content pages, which will change the content to another page via
the parent. For example:
Load the 'menu' page using Ajax, onto a div contained in the main page
Click a link on the 'menu' page, and a different page is loaded onto the
same div on the main page
Cheers

link_to path ActiveRecord call

link_to path ActiveRecord call

I have users and projects, and I'm trying to create a link to the project
by searching for the project using an ActiveRecord call. This is my
link_to:
<%= link_to "Project ABC" User.first.projects.where('title' => 'Project
ABC') %>
I know that this is not in the routes.rb, so how would I be able to make
it so I can do something like this where I write a query to get the
project and then show it? Would I do something like:
<%= link_to "Project ABC"
show_project_path(User.first.projects.where('title' => 'Project ABC')) %>
If so, would I need anything special in my controller?

Switching Rows into Columns

Switching Rows into Columns

I have a table proj_ctc_grp_usr:
USER_ID PROJ_ID CTC_GRP_ID
2 1 1
2 1 2
3 1 1
3 1 2
4 2 2
Table**ctc_grp:**
CTC_GRP_ID CTC_GRP_DS
1 Bank Contact
2 Dept2
Table*User*
USER_ID USER_FIRST_NM USER_LST_NM
2 saravanakumar rajkumar
3 Soosai Antony
4 Adam Allen
I am using the below query:
SELECT *
FROM ( SELECT PROJ.PROJ_ID,
CTC_GRP_DS
FROM dbo.Project PROJ
left join dbo.PROJ_CTC_GRP_USER PCGU on
PROJ.PROJ_ID = PCGU.PROJ_ID
left join dbo.CTC_GRP CG on PCGU.CTC_GRP_ID =
CG.CTC_GRP_ID
) data
PIVOT
( MAX(CTC_GRP_DS)
FOR CTC_GRP_DS IN ([Bank Contact],[Dept2])
) pvt4
and getting below output...
PROJ_ID Bank Contact Dept2
1 Bank Contact Dept2
2 NULL Dept2
I am trying to display it in below form...
PROJ_ID Bank Contact Dept2
1 saravanakumarRajkumar, soosaiAntony saravanakumarRajkumar, soosaiAntony
2 NULL AllenAdam...
I tried it & end up with no luck...Pls help on it...

Sunday, 18 August 2013

PHP Loop - Get previous array key in associative array

PHP Loop - Get previous array key in associative array

Hi I have this code and array:
<?php
$arr = array(
0 => array('first_name' => 'Ace', 'last_name' => 'Jones'),
1 => array('first_name' => 'Aron', 'last_name' => 'Jones'),
2 => array('first_name' => 'Ben', 'last_name' => 'Jones'),
3 => array('first_name' => 'Billy', 'last_name' => 'Jones'),
4 => array('first_name' => 'Barney', 'last_name' => 'Jones'),
5 => array('first_name' => 'Con', 'last_name' => 'Jones'),
6 => array('first_name' => 'Dan', 'last_name' => 'Jones'),
7 => array('first_name' => 'Earl', 'last_name' => 'Jones'),
8 => array('first_name' => 'East', 'last_name' => 'Jones'),
9 => array('first_name' => 'Fez', 'last_name' => 'Jones')
);
$html = '';
foreach($arr as $k => $v) {
echo $v['first_name'] . '<br />';
}
?>
<table rules="all" style="border:1px solid blue;" cellspacing="2"
cellpadding="2">
<tr>
<td>Label</td>
<td>First Name</td>
<td>Last Name</td>
</tr>
<?php echo $html; ?>
</table>
How can I display once only the label per letter of the first name? Below
is the result I want to accomplish.

Thanks.

pycharm: change documentation font size

pycharm: change documentation font size

Pycharm's included documentation has a pretty small font. I'd like to make
it more readable.
I've found how to change the font size of the editor and menus, but not of
the docs. How do I change this?

Mac OSX 10.7.4 Mountain Lion No Entry Sign Vmware Dell Inspiron 5010

Mac OSX 10.7.4 Mountain Lion No Entry Sign Vmware Dell Inspiron 5010

I have recently downloaded vmware image for Mac OSX 10.7.4 Mountain Lion
and tried to run on vmware 8.0.I have also applied the guest os unlocker
patch but still unable to cross no entry sign issue.

Can a UICollectionViewLayout have supplementary view in front of cell?

Can a UICollectionViewLayout have supplementary view in front of cell?

I'm aiming to have a static header with the cells passing underneath as
the user scrolls. I've created the functionality I'm looking for, however
if the supplementary views have a high zIndex than the cell, it blocks the
didSelectItemAtIndexPath: method.
Is there a way to work around this?
Here's an example of what I'm after;

Excel VBA - Search certain column for a #N/A, copy entire row to new sheet and delete row

Excel VBA - Search certain column for a #N/A, copy entire row to new sheet
and delete row

This is what I have already. It searches column B in sheet 1 for #N/A and
deletes the row.
Sub DeleteErrorRows()
On Error Resume Next
Range("B:B").SpecialCells(xlCellTypeConstants, 16).EntireRow.Delete
On Error GoTo 0
End Sub
What I would like is for it to copy that row onto sheet 2 and then delete?
So I can have a record of what was deleted.
Any help would be much appreciated. Thanks!

Two divs in the same row after and before zoom-in/zoom-out

Two divs in the same row after and before zoom-in/zoom-out

pI have two divs here: a href=http://jsfiddle.net/TXSfN/
rel=nofollowhttp://jsfiddle.net/TXSfN//abr
CSS CODES:/p precode#div1{
background-color: red; display: inline-block; width: 50% } #div2{
background-color: blue; width: 20% display: inline-block; height: 263px;
float: right; } /code/pre pI'm trying to set the two divs in the same line
also after zoom-in/zoom-out in browser(CTRL +/CTRL -). The problem isn't
with setting the two divs in the same line, it's with the zoom-in/out,
when I zoom-in/out the div with the long content get's longer with the
height and the one with the short content stay as it is, so they aren't
now in the same row. Is there a way to set the two divs in the same row
for every action(zoom-in/out) WITHOUT srollbar?. You can check this
solution here: a href=http://jsfiddle.net/wVpwp/1/
rel=nofollowhttp://jsfiddle.net/wVpwp/1//a
, I want the same as it with the
same functions but without the scrollbar(both get longer on zoom in and
both get shorter on zoom out)/p

Saturday, 17 August 2013

PHP MVC- Integrating Controllers and Views

PHP MVC- Integrating Controllers and Views

I am trying to build a web application using MVC design pattern in PHP.
But before starting I tried to implement a small mvc application and
cannot figure out how to deal with following scenario.
I created Index_Controller ,Index_Model and index directory which acts as
controller, model and view for Index page respectively. I tried to
integrate FileUploader in that Index page and created
FileUpload_Controller , FileUpload_Model (because I will store Image
Captions and other data related to file(s) in database) and fileupload
view. Now I am able to view Index Page from this URI :
http://localhost/mvc/index/ and the FileUpload Plugin using this URI :
http://localhost/mvc/fileupload/ but how could I integrate the
FileUploader Plugin in Index and some other (if required) pages. Accessing
http://localhost/mvc/fileupload/ only is meaning less and It should be
integrated in some other views.
I am confused on what should be created using Model , View And Controllers
. I think the way I have created FileUpload Plugin is wrong. I used MVC
for FileUpload because I have to deal with Database also. I think I am not
clear on for what type of entity should I create Models , Views and
Controllers.
Any guideline and help will be much more appreciated. Thank you.

dynamic routing with muiltiple $routeParams AngularJS

dynamic routing with muiltiple $routeParams AngularJS

Using parameters as identifiers to fetch content:
$routeProvider.when('/:category', {
templateUrl: '/views/category.html'
});
But what if I have a second tier?...
$routeProvider.when('/:category/:service', {
templateUrl: '/views/service.html'
});
This works fine for following links with $locationProvider.html5Mode(true)
<a href='/{{items.category}}/{{item.service}}'></a>
However directly invoking a link through address bar
x.com/xCategory/xService does not work.
$routeProvider matches :category before seeing second parameter :service
templateUrl for the /:category route is always taking precedence.
x.com/xCategory/xService will always fetch templateUrl for x.com/xCategory
I'm using nginx rewrite rules so I can fully support pushState:
location / {
try_files $uri /index.html;
}
What is going on here?

Algorithm as figure and without italic and bold formatting?

Algorithm as figure and without italic and bold formatting?

I want to include an algorithm in my latex document, however without
printing most of it in italic and all the keywords in bold font like it's
done by default by e.g. the algorithmicx package. I like this simple
style:
(screenshot of a part of page 3 of
http://research.microsoft.com/pubs/68869/naacl2k-proc-rev.pdf)
The only thing I'd like to add to this style are line numbers. Can anyone
help me, how I get the formatting of the screenshot and the line numbers?
Thanks :-)
So, here is what I have until now:
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{algpascal}
\begin{document}
\alglanguage{pascal}
\begin{algorithm}
\caption{Paull's algorithm}
\begin{algorithmic}[1]
\State Assign an ordering $A_{1}, ..., A_{n}$ to the nonterminals of the
grammar.
\For{i = 1}{n}
\Begin
\For{j = 1}{i-1}
\Begin
\State for each production of the form $A_{i} \rightarrow A_{j} \alpha$
\End
\End
\end{algorithmic}
\end{algorithm}
\end{document}
This ends up as
Based on this I want the following changes:
do and begin shall be on the same line
end shall be vertically aligned to it's associated for (see first
screenshot of this post).
Integration as a figure or at least without a black border and with a
caption below the algorithm would be prefered
bold formatting for keywords should be turned off

Wordpress - How can I remove year condition from main sql query?

Wordpress - How can I remove year condition from main sql query?

I want to customize the main query of wordpress for my custom post type.
Here is how I did it:
function wpa_date_archive_post_types( $query ){
if( $query->is_main_query() && $query->is_date() ):
$query->set( 'post_type' , array( 'movie' ) );
$query->set( 'tag' , '1994' );//For testing pupose I put a
hard coded value...
$query->set( 'post_status' , array( 'publish' ) );
endif;
}
add_action( 'pre_get_posts', 'wpa_date_archive_post_types' );
WP generates the following query:
SELECT
SQL_CALC_FOUND_ROWS wp_posts.*
FROM
wp_posts
INNER JOIN
wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE
1=1
AND
YEAR(wp_posts.post_date)='1994'--WP gets 1994 here from an URL
parameter (year)
AND
(wp_term_relationships.term_taxonomy_id IN (24) )
AND
wp_posts.post_type IN ('movie')
AND
(wp_posts.post_status = 'publish')
GROUP BY
wp_posts.ID
ORDER BY
wp_posts.post_date DESC
LIMIT
0, 5
I want to remove the following line from the final query:
AND
YEAR(wp_posts.post_date)='1994'
I tried to add this PHP code
// ...
if( $query->is_main_query() && $query->is_date() ):
$query->set( 'post_type' , array( 'movie' ) );
$query->set( 'year' , 0 );
$query->set( 'tag' , '1994' );
$query->set( 'post_status' , array( 'publish' ) );
endif;
// ...
But I get a blank page. How can I disable year from sql query ?

Javscript Code isn't working under XP

Javscript Code isn't working under XP

I am using this JS code for show and hide some div elements on my side -
it is working perfectly on W7/W8 and all browsers, but for XP it doesn't
work at all, am I something missing about JS libraries supported in XP or
something?
Thanks for any replies in advance.
<script type="text/javascript">
var divState = {};
function showhide(id) {
if (document.getElementById) {
var divid = document.getElementById(id);
divState[id] = (divState[id]) ? false : true;
//close others
for (var div in divState){
if (divState[div] && div != id){
document.getElementById(div).style.display = 'none';
divState[div] = false;
}
}
divid.style.display = (divid.style.display == 'block' ? 'none'
: 'block');
}
}
</script>

Restore Whole Sticky Note on Windows 7

Restore Whole Sticky Note on Windows 7

I accidentally removed my Sticky Note on Windows 7 and now I've been
trying to get it back. I searched at %AppData%\Microsoft\Sticky
Notes\StickyNotes.snt and could see some of the text that was in my Sticky
Note. How can I get back all of the text? I used signs like * and | in the
note, will this cause any trouble?

Issue to set folder permission

Issue to set folder permission

DirectorySecurity directorySecurity =
Directory.GetAccessControl(@"C:\MyFolder");
SecurityIdentifier fullControl = new SecurityIdentifier(
WellKnownSidType.WorldSid, null);
directorySecurity.AddAccessRule(
new FileSystemAccessRule(
fullControl,
FileSystemRights.Modify | FileSystemRights.Synchronize,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
Directory.SetAccessControl(@"C:\MyFolder", directorySecurity);
With above code I tried to set folder permission. It throwing following
error this access control list is not in canonical form and therefore
cannot be modified. But if set folder permission using command like below.
C:\>cacls c:\MyFolder /t /e /g Everyone:f
Now the expecting scenario is working well. But I want to achieve this
dynamically.

Friday, 16 August 2013

passing " in html value

passing " in html value

I've a variable like:
<?php
$val = 'abc"def\'ad';
?>
my html is like:
<input type="text" value="<?php echo $val; ?>" name="xyz" />
But the input can't show all the text because having "/' is in the middle
of them. But I need the text field to show abc"def'ad . Any idea how to do
it using HTML (not js)?

Saturday, 10 August 2013

How to customize a backend running job completion message?

How to customize a backend running job completion message?

Here is the situation, I am running a command (my own executives), in bash
shell (Ubuntu), say something like this:
[newbie@office currentCaseAFolder]$ FEMSolver &
So that the FEMSolver job is now running in backend, and let's say it
needs around five to ten minutes. But I have more than one cases. so
[newbie@office currentCaseAFolder]$ cd ../currentCaseBFolder
[newbie@office currentCaseBFolder]$ FEMSolver &
[newbie@office currentCaseBFolder]$ cd ../currentCaseCFolder
[newbie@office currentCaseCFolder]$ FEMSolver &
[newbie@office currentCaseCFolder]$ cd ../currentCaseDFolder
[newbie@office currentCaseDFolder]$ FEMSolver &
[newbie@office currentCaseDFolder]$ cd ../../postprocessingFolder
After a coffee time, I come back, and hit return key, some simulations
have finished. so it will show me
[2] + Done FEMSolver &
[4] + Done FEMSolver &
[newbie@office postprocessingFolder]$
But this does not give me the clear information from which folder the job
was sent!! I hope it could somewhere and somehow be customized to have
this effect:
[2] + Done FEMSolver & (from folder currentCaseBFolder)
[2] + Done FEMSolver & (from folder currentCaseDFolder)
[newbie@office postprocessingFolder]$
Any ideas?

Controlling JComponents from other classes

Controlling JComponents from other classes

Is it possible to control instances like variables, jcomponents, timer in
other external classes?
For example this is my Class1
public class Class1 extends JFrame {
JLabel lbl = new JLabel("Hello");
public Class1() {
super("Class1");
Container c = getContentPane();
setLayout(null);
c.add(lbl);
lbl.setBounds(0,0,100,20);
Class2.process();
setSize(200,100);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String var[]) {
new Class1();
}
}
You can see there's Class2.process(); Here's the other class externally
but in the same folder
public class Class2 {
public static void process() {
// I want to control lbl from Class1 class inside this method like
// lbl.setVisible(false);
}
public static void main(String args[]) {
//
}
}
Is it possible? Sorry. I can't find answers on other website.

Friday, 9 August 2013

'-[UITextView autocapitalizationType]: unrecognized selector sent to instance?

'-[UITextView autocapitalizationType]: unrecognized selector sent to
instance?

I would like to create custom subclasses(SubCustomView) of uiview when
click on button and added uitextview class on SubCustomView as subview.
when i initiate uitextview i use initWithFrame:textContainer: method. when
i used this method, the project is crashed. When i use initWithFrame:
method the project is not crashed. I am using following code:
textContainer1 = [[NSTextContainer alloc] initWithSize:CGSizeMake(2,
CGFLOAT_MAX)];
stringTextView = [[UITextView alloc] initWithFrame:CGRectMake(0,
0, frame.size.width, frame.size.height)
textContainer:textContainer1];
//stringTextView = [[UITextView alloc] initWithFrame:CGRectMake(0,
0, frame.size.width, frame.size.height)];
stringTextView.keyboardAppearance = YES;
stringTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight
| UIViewAutoresizingFlexibleWidth;
stringTextView.scrollEnabled = YES;
stringTextView.backgroundColor = [UIColor redColor];
stringTextView.autocapitalizationType =
UITextAutocapitalizationTypeWords;
stringTextView.delegate = self;
[self addSubview:stringTextView];
[stringTextView becomeFirstResponder];
NSString *sampleString=@"GPRisdoingfirst ios 7.0 project";
textStorage = [[NSTextStorage alloc] initWithString:sampleString];
layoutManager = [[CustomLayoutM alloc] init];//CustomLayoutM is
subclass of `NSLayoutManager`
[textStorage addLayoutManager:layoutManager];
[textStorage addAttribute:NSFontAttributeName value:[UIFont
fontWithName:@"Helvetica-Bold" size:30.0] range:NSMakeRange(0,
[textStorage length])];
[layoutManager addTextContainer:textContainer1];
The error is:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UITextView setKeyboardAppearance:]: unrecognized selector sent
to instance 0x93ab000'
First throw call stack:
(
0 CoreFoundation 0x019706f4
__exceptionPreprocess + 180
1 libobjc.A.dylib 0x016f08b6
objc_exception_throw + 44
2 CoreFoundation 0x01a0d983
-[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 libobjc.A.dylib 0x01702959 -[NSObject
forwardInvocation:] + 68
4 CoreFoundation 0x019607ea ___forwarding___ + 458
5 CoreFoundation 0x019605fe
_CF_forwarding_prep_0 + 14
6 UIKit 0x006ff4b3 -[UITextInputTraits
takeTraitsFrom:] + 1075
7 UIKit 0x006ffc2b +[UITextInputTraits
traitsByAdoptingTraits:] + 83
8 UIKit 0x0063a659 -[UIKeyboardImpl
takeTextInputTraitsFromDelegate] + 177
9 UIKit 0x0063acbb -[UIKeyboardImpl
setDelegate:force:] + 1040
10 UIKit 0x0063a8a6 -[UIKeyboardImpl
setDelegate:] + 48
11 UIKit 0x008e535d
-[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] +
640
12 UIKit 0x005c0d5a
-[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 287
13 UIKit 0x005c064b -[UIResponder
becomeFirstResponder] + 550
14 UIKit 0x004c4dab -[UIView(Hierarchy)
becomeFirstResponder] + 114
15 UIKit 0x00b33e69 -[UITextView
becomeFirstResponder] + 79
16 UIKit 0x004c4df8 -[UIView(Hierarchy)
deferredBecomeFirstResponder] + 67
17 UIKit 0x004c4e8c -[UIView(Hierarchy)
_promoteSelfOrDescendantToFirstResponderIfNecessary] + 115
18 UIKit 0x004c514e
__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 224
19 Foundation 0x014a453c -[NSISEngine
withBehaviors:performModifications:] + 107
20 Foundation 0x01334395 -[NSISEngine
withAutomaticOptimizationDisabled:] + 48
21 UIKit 0x004c4fcd -[UIView(Hierarchy)
_postMovedFromSuperview:] + 313
22 UIKit 0x004d00d1 -[UIView(Internal)
_addSubview:positioned:relativeTo:] + 1847
23 UIKit 0x004c35c1 -[UIView(Hierarchy)
addSubview:] + 56
24 PracticeiOS7 0x000085a6 -[TextCurveView
createTextViewMethod] + 518
25 PracticeiOS7 0x00008a9d -[TextCurveView
panMethod:] + 1101
26 UIKit 0x007de61c
_UIGestureRecognizerSendActions + 230
27 UIKit 0x007dd290
-[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 383
28 UIKit 0x007decfd
-[UIGestureRecognizer _delayedUpdateGesture] + 60
29 UIKit 0x007e225d
___UIGestureRecognizerUpdate_block_invoke + 57
30 UIKit 0x007e21de
_UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
31 UIKit 0x007d88d8
_UIGestureRecognizerUpdate + 199
32 UIKit 0x004a6e9a -[UIWindow
_sendGesturesForEvent:] + 1291
33 UIKit 0x004a7dba -[UIWindow
sendEvent:] + 1030
34 UIKit 0x0047bb86 -[UIApplication
sendEvent:] + 242
35 UIKit 0x0046635f
_UIApplicationHandleEventQueue + 11421
36 CoreFoundation 0x018f996f
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
37 CoreFoundation 0x018f92fb
__CFRunLoopDoSources0 + 235
38 CoreFoundation 0x019163ce __CFRunLoopRun + 910
39 CoreFoundation 0x01915bf3
CFRunLoopRunSpecific + 467
40 CoreFoundation 0x01915a0b CFRunLoopRunInMode
+ 123
41 GraphicsServices 0x030fca27 GSEventRunModal + 192
42 GraphicsServices 0x030fc84e GSEventRun + 104
43 UIKit 0x00468f0b UIApplicationMain +
1225
44 PracticeiOS7 0x00009b8d main + 141
45 libdyld.dylib 0x02dec725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException

ArrayList of ArrayLists in Recursion

ArrayList of ArrayLists in Recursion

I've been working on a larger project, and ran into a problem which I have
replicated here in a much simpler fashion. What I'm trying to do is to add
an ArrayList of Integers into another ArrayList. The problem is that every
ArrayList I add into the larger ArrayList gets updated as if they were all
the same.
public class RecursionTest {
static ArrayList<Integer> test = new ArrayList<Integer>();
static ArrayList<ArrayList<Integer>> test1 = new
ArrayList<ArrayList<Integer>>();
public static void testRecurse(int n) {
test.add(n);
if (n % 2 == 0) {
test1.add(test);
}
if (n == 0) {
for (ArrayList<Integer> a : test1) {
for (Integer i : a) {
System.out.print(i + " ");
}
System.out.println();
}
return;
}
testRecurse(n - 1);
}
public static void main(String[] args) {
testRecurse(10);
}
}
The output I get is:
10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
When it should be:
10
10 9 8
10 9 8 7 6
10 9 8 7 6 5 4
10 9 8 7 6 5 4 3 2
10 9 8 7 6 5 4 3 2 1 0
Can someone explain to me what is happening here? And perhaps suggest a
work around for such a situation.

Rails: Passing variable from form to model

Rails: Passing variable from form to model

I have a form, where users can upload a picture and can choose a watermark
from a list. The value in the field is then the URL of the watermark (for
simplification in development). I need to pass the chosen watermark_url to
the model, so that rmagick can add the watermark. I use paperclip for the
uploads.
In my model I have the following:
class Image < ActiveRecord::Base
...
attr_accessor :watermark_url
has_attached_file :picture, :processors => [:watermark], styles: {
thumb: '100x100>',
medium:{
geometry: '300x300>',
watermark_path: Rails.root.join(watermark_url),
position: "Center"}
}
end
watermark_url is a field in the form and in the database (which would not
be necessary). Then I get the following error: undefined local variable or
method `watermark_url'.
Am i missing something here?
Thank you in advance for helping!

Is there a way to Undo a page reload

Is there a way to Undo a page reload

You can unto a closed tab, or go back to the previous page (undoing page
view.. in a way) but
Is there a way to undo a page reload?
(any browser, any addon)

Decentralized Task Scheduling Techniques in .NET

Decentralized Task Scheduling Techniques in .NET

I have been trying to learn more details on CLR 4.0. and the ThreadPool
and the different strategies that Microsoft recommended. I consider myself
fairly up-to-date on a lot of these topics, and use threading and
concurrent code on a daily basis.
I have been goign back through the Parallel Patterns and Practices again
recently, and am a bit caught on the Decentralized Scheduling Techniques
section which gives a brief overview of 'Work Stealing' and local vs
global thread queues.
The questions I have are:
1) Is work stealing opt-in or opt-out? Same for using local thread queues?
Or does this happen by default with CLR 4.0?
2) Do we have control over whether we are using local or global thread
queues? If so, through what API calls?

Which iOS version to target

Which iOS version to target

I will describe my situation briefly and would be very grateful for some
competent advice.
I have recently started learning iOS development and I am half way on this
book:http://rads.stackoverflow.com/amzn/click/0321821521 which is for
iOS5.
Now, there maybe an application I will start writing in a month or so. My
first questions were: which iOS version should I target, iOS6, or iOS7?
My one concern is that I've seen that supporting both iOS6 and iOS7 maybe
a lot of work/complicated, and due to my level of experience I am not sure
if this is good thing to do??.
Shall I still go on with the book I mentioned?
I'd be grateful if someone can answer my questions.

Python Function Return

Python Function Return

If I want to return more that one variable from a function in Python I
have been doing the following:
def foo():
firstName = 'Bob'
lastName = 'Jones'
return [firstName, lastName]
Then if I wanted to find only the first name I would do this
[firstName, dummy] = foo()
However, say I initially had the function
def fooInitial():
firstName = 'Bob'
return firstName
and I called this from many parts of my code, if I wanted to add the
lastName as another output the way I have been doing, I would have to
change everywhere else in my code that was calling it.
Is there a way to do something similar to Matlab where calling a = foo()
gives me the first name (not the first and last in a list) and [a,b]=foo()
gives me the first and last?

Unrecognized Escape Sequence in C#.Net

Unrecognized Escape Sequence in C#.Net

while debugging the code i am getting an error saying
Unrecognized error sequence . what should i have to do to solve this ? Am
i using the proper code here? i got a picture box(for loading profile
picture) and two radio buttons to select the gender. while selecting radio
button i need an image (male.png) to display in my picture box. what
should i do for this. Am i using proper code here ? PLease help ?
private void rbtnmale_CheckedChanged(object sender, EventArgs e)
{
if (rbtnmale.Checked)
{
pictureBox2.Image = Image.FromFile(Application.StartupPath &
"\Resources\male.png");
}
else if(!rbtnmale.Checked)
{
pictureBox2.Image = Image.FromFile(Application.StartupPath &
"\Resources\female.png");
}
}

Thursday, 8 August 2013

chains in an ordered set

chains in an ordered set

prove that any subset of a chain is a chain.
prove that any subset of a totally ordered set is a chain.
defintions: Chain:A subset C of a partially ordered set (X,¡Ü) is called a
chain if C is totally ordered with respect to the induced order. Total
order: A partial order ¡Ü on X is called a total order if for all x1,
x2¡ÊX either x1¡Üx2 or x1¡Ýx2.