Saturday, 31 August 2013

Copy file to clipboard in Delphi

Copy file to clipboard in Delphi

Anybody know how to copy file in Delphi? It likes press Ctrl+ C on a file
or folder, and then we can Paste at somewhere ? I just know how to copy a
text by Clipbrd Unit, but i don't know with a file, folder ! Please help
me !

can the order of code make this program faster?

can the order of code make this program faster?

Hi this is my first post, I am learning how to write code so technically I
am a newbie.
I am learning python I am still at the very basics, I was getting to Know
the if statement and I tried to mix it with another concepts(function
definition,input,variables) in order to get a wider vision of python, I
wrote some code without a specific idea of what I wanted to do I just
wanted to mix everything that I have learned so far so probably I over do
it and its not practical, it "works" when I run it.
The question that I have its not about how to do it more efficient or with
less code it is about the order of code in all programming in general.
Here I'll show 2 different order of code that gives the same result with
exactly the same code(but with different order).
on (1) I define a function on the first line.
on (2) I define the same function closer to when I use it on line 5.
which one is faster? is defining a function "closer" to when I need it
impractical for the complexity of larger programs(but does it make it
faster), or defining a function "far" from where I need it makes a larger
program slower when running(but also more practical).
(1)
def t(n1,n2):
v=n1-n2
return abs(v)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()
(2)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
def t(n1,n2):
v=n1-n2
return abs(v)
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()

NSMutableArray with Cyrillic text

NSMutableArray with Cyrillic text

I try to load words from a txt file using following code:
NSURL *filePath = [[NSBundle mainBundle] URLForResource:@"testFile"
withExtension:@"txt"];
NSString*stringPath = [filePath absoluteString];
NSData *drfData = [NSData dataWithContentsOfURL:[NSURL
URLWithString:stringPath]];
NSString *str = [[NSString alloc]initWithData:drfData
encoding:NSUTF8StringEncoding];
Works great, even if I use cyrillic words ("ïðèâåò").
Now, I use following code to add each word as object to my NSMutableArray.
To detect what is a word, I separated them by comma in my testFile.txt
document.
int nLastPoint = 0;
int nCount = 0;
for (int i = 0; i< str.length; i++) {
if ([[str substringWithRange:NSMakeRange(i,
1)]isEqualToString:@","]) {
[lst_wordlist addObject:[[[str
substringWithRange:NSMakeRange(nLastPoint, nCount)]
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]] uppercaseString]];
nLastPoint = i+1;
nCount = 0;
}else{
nCount++;
}
}
int nLength = 0;
for (int i = 0; i< [lst_wordlist count]; i++) {
if ([[lst_wordlist objectAtIndex:i]length]>nLength) {
nLength = [[lst_wordlist objectAtIndex:i]length];
}
}
NSLog(@"%@",lst_wordlist);
Works great, again ONLY if I use english words. With Cyrillic words
doesn't work.
This is my NSLog when I use a cyrillic word.
"\U041f\U0420\U0418\U0412\U0415\U0422",
WORD2,
WORD3,
Any ideas? How can I fix it? I tried to change debugger from LLDB to GDB,
doesn't fix the problem.

webview doesnt work ajax jquery on jelly bean

webview doesnt work ajax jquery on jelly bean

My android web app doesnt work on click jquery ajax. I don't know what
code should i post because .. okay let me tell what i did try. This is
link to my web (forum in malays) http://debatremaja.com/mb/cadang_tajuk .
and this is app in google play store
https://play.google.com/store/apps/details?id=com.debatremaja&hl=en .
Problem + Thumbs up sign in web link above will run
$(".vote_active").click(function(){
var topic_id = $(this).data("topic-id");
var linkto= linktodbcontroller+"insert_vote_by_id_n/"+topic_id;
//window.location.href = linkto;
$(this).next(".sum").load(linkto);
// simple prevent 2nd clicked
$(this).removeClass("clickable");
$(this).css("color","#0c0");
$(this).off("click");
});
And that working fine on
pc web browser , firefox and chrome tested
on mobile browser ( android 4.2.2 cyanogemod firefox)
my app (link above) on android 2.3 emulator
Maybe ajax not working in webview ?
so i did change android code to
loadUrl("w3school jquery demo") // Sorry, i cannot post more than 2 links
But the button in w3school works fine.
Problem only happend on my app webview.
Thanks in advance because i had experiance get my question answered less
an hour after posting. Great comunity in stackoverflow.

create-android-project.sh:line 103:/home/laschweinski/android/android-sdk-linux_86/tools/android:No such file or directory

create-android-project.sh:line
103:/home/laschweinski/android/android-sdk-linux_86/tools/android:No such
file or directory

I want to set development environment of Cocos2d-x for Android in eclipse
using Windows. I am getting this error when execute
create-android-project.sh
Android sdk path is D:\Software\adt-bundle-windows-x86_64-20130522\sdk\tools
NDK path is D:\AndroidGameTool\Android-ndk

Definitive C Input/Output Guide

Definitive C Input/Output Guide

Since the semester recently started a lot of similar questions regarding
IO in C (and C++) keep pouring in and the answers are often the same:
while(!feof()) is bad, use fgets() instead of scanf(), etc.
Do you think a community wiki is needed so all the duplicate questions
could be directed to that single answer? Or do you think they are still
sufficiently different so that those who ask would benefit from a question
tailored to their demands? Some just downvote and comment suggesting
posting on homework.stackexchange.com, but this doesnt't help.
After reading How should duplicate questions be handled? and What's the
etiquette for answering two similar questions? it seems to boil down to
the question how similar are two posts to be considered duplicate.
If you feel that most of the questions were indeed duplicates and that
this could grow into a community wiki page, please post your tricks of the
trade on IO in C including use, best practices, no-nos, notes on history
or implementation details and links to useful resources.

using .htaccess to overtire my URL

using .htaccess to overtire my URL

i need to make this url
http://yadoniaclients.com/yadonia/services/our-services/mobile-application-development
(any page)
to look like this
http://yadoniaclients.com/yadonia/services/ (any page)
this my current .htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^yadonia/(.*)$ yadonia/index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
thanks for your help.

Friday, 30 August 2013

Url rewrite is not working in some cases with XAMPP in Windows 7

Url rewrite is not working in some cases with XAMPP in Windows 7

I have a PHP website hosted at localhost on my Windows 7 PC, running XAMPP
1.8.2.
And I have rewrite rules as below:
Options -Indexes +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?rt=$1 [QSA,L]
</IfModule>
To rewrite the URL so it will always go into something like:
http://mysite.com/index.php?rt=[controller]/[action]/[params]
It works prefect until I found it failed when processing url like:
http://mysite.com/error/xxx. It returns a 404 status other than goes to
http://mysite.com/index.php?rt=error/xxx.
I carefully checked my PHP code and I am sure it is not the cause, and I
upload my website to a remote server and everything is fine. So I am
pretty sure something is not properly configured in my XAMPP (Apache),
that makes the /error/xxx request was treated differently.
Also I found visiting http://mysite.com/error/ gives me 403 but
http://mysite.com/[something_else]/ is fine.
Just in case, I paste my vhost.conf here as well:
<VirtualHost *:80>
DocumentRoot "/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:\htdocs\mysite.dev"
ServerName mysite.dev
</VirtualHost>
And related httpd.conf:
<Directory "E:\htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Any help is appreciated!

Asp.net web api and mvc - avoiding duplication

Asp.net web api and mvc - avoiding duplication

I am exploring ASP.Net web Api and I am trying to use to create a web page
to basically provide option to edit and display some data from DB(MySQL)
with some modifications. I also want to provide a REST Api that would be
used by mobile app. Now I can do this with the ApiController(to provide
REST api) and then the MVC Controller which renders the model(using View
method). This works but there is lot of duplication between the API and
the MVC controller. Is there a design pattern or something that avoids the
redundancy?
I understand that API controller has to return JSON and the MVC controller
has to return the Model for the view.

Thursday, 29 August 2013

How should we parse a specific JSON date format in the ASP.NET C# application?

How should we parse a specific JSON date format in the ASP.NET C#
application?

We are using a third-party vendor for one of our modules in an application
The Web Service Endpoints are provided by a third-party vendor.
For one of the Web Service Endpoints that deals with posting Comments,
our ASP.NET C# web application will get back some JSON data.
I am using James Newton-King Json.NET for processing JSON data.
Within the JSON Data that we receive from the Web Service of the
third-party vendor, we get the following date which is associated with
time that the comment was posted:
\"date_created\": 1375206707,\r\n
Therefore, I created an ASP.NET DataContract C# class that would
correspond to the JSON data that we are receiving.
Furthermore, I have the following DataMember in the C# class that would
correspond to the date of creation associated with the Posted Comment:
[DataMember(Name = "date_created")]
public string ViaFouraCommentCreationDate { get; set; }
Please make suggestions as to how I should parse the following JSON date
format
in the ASP.NET C# world( possibly also involving the James Newton-King
Json.NET):
\"date_created\": 1375206707,\r\n

How can i take only particular fields from the model in mvc4?

How can i take only particular fields from the model in mvc4?

Hi this is My Model(or)Property Field in MVC4
public class LeaveModel : IModel<LeaveModel>
{
public int Id { get; set; }
public int userId { get; set; }
public string givenName { get; set; }
public string shortName { get; set; }
public string leaveType { get; set; }
public string leaveDescription { get; set; }
public string fromDate { get; set; }
public string toDate { get; set; }
public int noOfDays { get; set; }
public string reason { get; set; }
public string status { get; set; }
public string statusDescription { get; set; }
public string createdDate { get; set; }
public string modifiedDate { get; set; }
public int leaveTypeId { get; set; }
public int companyDataId { get; set; }
}
And This is my Controller For Add and Update
[HttpPost]
public HttpResponseMessage Post(LeaveModel vm)
{
if (ModelState.IsValid)
{
HttpResponseMessage response =
Request.CreateResponse(HttpStatusCode.Created, Ileave.Add(vm));
return response;
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
ModelState);
}
}
[HttpPut]
public HttpResponseMessage Put(LeaveModel vm)
{
Ileave.Update(vm);
return Request.CreateResponse(HttpStatusCode.OK);
}
And This is Database interaction codes
public bool Add(LeaveModel vm)
{
try
{
vm.createdDate = vm.modifiedDate = DateTime.Now.ToString();
IDbCommand cmd = Db.GetCommand("sp_LeaveApply",
CommandType.StoredProcedure);
cmd.ParamIn("@LeaveTypeId", vm.leaveTypeId.ToString(),
DbType.Int32);
cmd.ParamIn("@fromDate", vm.fromDate, DbType.String);
cmd.ParamIn("@toDate", vm.toDate, DbType.String);
cmd.ParamIn("@noOfDays", vm.noOfDays.ToString(), DbType.Int32);
cmd.ParamIn("@reason", vm.reason, DbType.String);
cmd.ParamIn("@createdDate", vm.createdDate, DbType.String);
cmd.ParamIn("@modifiedDate", vm.modifiedDate, DbType.String);
Db.OpenConnection();
int i = cmd.ExecuteNonQuery();
if (i == 1)
{
return true;
}
else
{
return false;
}
}
finally
{
Db.CloseConnection();
}
}
public bool Update(LeaveModel vm)
{
try
{
vm.modifiedDate = DateTime.Now.ToString();
IDbCommand cmd = Db.GetCommand("sp_LeaveUpdate",
CommandType.StoredProcedure);
cmd.ParamIn("@Id", vm.Id.ToString(), DbType.Int32);
cmd.ParamIn("@leaveTypeId", vm.leaveTypeId.ToString(),
DbType.Int32);
cmd.ParamIn("@fromDate", vm.fromDate, DbType.String);
cmd.ParamIn("@toDate", vm.toDate, DbType.String);
cmd.ParamIn("@noOfDays", vm.noOfDays.ToString(), DbType.Int32);
cmd.ParamIn("@reason", vm.reason, DbType.String);
Db.OpenConnection();
int i = cmd.ExecuteNonQuery();
if (i == 1)
{
return true;
}
else
{
return false;
}
}
finally
{
Db.CloseConnection();
}
}
See the problem here is at the time of adding i need all the fields and
the the time of updating i need only certain fields to be updated..for
both Add and Update am refering ``same Model Called (LeaveModel)..so here
add is fine but while updating am getting error like DataReaderhas Toomany
fields... I know why this error came but how can i take only certain
fields while updating this is the problem..
Please Help
Thanks in Advance

Wednesday, 28 August 2013

How can I relay mail to multiple SMTP servers?

How can I relay mail to multiple SMTP servers?

We want to use Google Apps for Domains as our email service but the
"corporate" office want's the emails in Exchange. I would like to set up a
relay (is that the proper term) to send any incoming mail to both, Google
and Exchange. That way, we can use Gmail for our daily communication (both
sending & receiving) and the "corporate" people are happy getting a copy
of our incoming stuff.
Or is this completely insane? :)
Thanx!

DateTime problems when movign to production environment

DateTime problems when movign to production environment

I have several forms within my MVC app that have date values which are
chosen via a datepicker tool. This works well when debugging locally but
on deployment to the cloud environment my dates are not being correctly
converted. I have the following code:
string[] uploaddate = form.GetValues("uploaddate");
string[] expirydate = form.GetValues("expirydate");
This gets the date as 31/08/2013 etc. and from here I was converting to
DateTime as follow:
Convert.ToDateTime(uploaddate[0]);
Convert.ToDateTime(expirydate[0]);
When I deploy to the Azure server I receive the following error:
String was not recognized as a valid DateTime.
I think that the instance image has a culture of US while my application
was designed in UK format, how can I go around this problem so that the
information is saved to the database irrespective of the culture of the
user

First-child pseudo-class in css 2.1

First-child pseudo-class in css 2.1

I don't know where to put pseudo class in this definition:
#recently_played_grid li img {
margin-left: 10px;
}
I want to set margin-left to 0px just in a first child of the list. Should
I do
#recently_played_grid li:first-child img
?
It doesn't seem to work

jQuery - trigger a custom event on a link

jQuery - trigger a custom event on a link

I am trying to run this custom 'getOffer()' event using jQuery
<a href="javascript: void getOffer();" title="Submit for offer"><img
src="images/img.jpeg"></a>
I have tried the following but it doesn't seem to work (I am using the
Firefox Firebug console.log window)
$('a[title="Submit for offer"]').trigger('getOffer');
This is the page I am trying this on: http://bit.ly/1dpIMFk Can anyone
suggest any ideas?

To check if paranthesis are balanced- Without stack

To check if paranthesis are balanced- Without stack

Suppose I have a very huge file and I want to check if parenthesis are
balanced. I can't use stack, right? Because it'd result in a stack
overflow. What approach I can use?

Tuesday, 27 August 2013

C++ stringstream, if word is numeric, divide by two

C++ stringstream, if word is numeric, divide by two

I am fairly new to programming and have to create a program which reads
the prompt: "I have 8 dollars to spend." It then needs to print out with
each word on a separate line, and then if any of the strings is numeric,
it needs to be divided by 2. Therefore it should end up printing out as:
I
have
4
dollars
to
spend.
I have managed to do everything, except finding the numeric value and
dividing it by 2. So far I have this:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
string prompt;
string word;
cout << "Prompt: ";
getline(cin, prompt);
stringstream ss;
ss.str(prompt);
while (ss >> word)
{
cout << word << endl;
}
return 0;
}
After looking through various other posts, I cannot manage to get this to
work. I'm assuming its an if/else statement within the while loop along
the lines of, if numeric, set int num to num / 2 then cout << num <<
endl;, else cout << word << endl;, but I can't figure it out.
Thanks in advance.

Contoso University part 5, reading related data without passing parameter

Contoso University part 5, reading related data without passing parameter

I am walking through Contoso University ASP.NET MVC example part 5.
http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with-the-entity-framework-in-an-asp-net-mvc-application
I can't quite understand how the id parameter was passed to the
controller/view when I select a course taught by the instructor. In the
view, the section to display the courses is as following:
@if (Model.Courses != null)
{
<h3>Courses Taught by Selected Instructor</h3>
<table>
<tr>
<th></th>
<th>ID</th>
<th>Title</th>
<th>Department</th>
</tr>
@foreach (var item in Model.Courses)
{
string selectedRow = "";
if (item.CourseID == ViewBag.CourseID)
{
selectedRow = "selectedrow";
}
<tr class="@selectedRow">
<td>
*@Html.ActionLink("Select", "Index", new { courseID =
item.CourseID })*
</td>
<td>
@item.CourseID
</td>
<td>
@item.Title
</td>
<td>
@item.Department.Name
</td>
</tr>
}
</table>
}
The Controller Index function is as following:
public ActionResult Index(int? id, int? courseID)
{
var viewModel = new InstructorIndexData();
viewModel.Instructors = db.Instructors.Include(r =>
r.OfficeAssignment)
.Include(r => r.Courses.Select(c => c.Department))
.OrderBy(i => i.LastName);
if (id != null)
{
ViewBag.InstructorID = id.Value;
viewModel.Courses = viewModel.Instructors.Where(
i => i.InstructorID == id.Value).Single().Courses;
}
if (courseID != null)
{
ViewBag.Courses = courseID.Value;
//eager loading
//viewModel.Enrollments = viewModel.Courses.Where(
// i => i.CourseID == courseID.Value).Single().Enrollments;
//equivalant, but explicit loading
var selectedCourse = viewModel.Courses.Where(x => x.CourseID
== courseID).Single();
db.Entry(selectedCourse).Collection(x => x.Enrollments).Load();
foreach (Enrollment enrollment in selectedCourse.Enrollments)
{
db.Entry(enrollment).Reference(x => x.Student).Load();
}
viewModel.Enrollments = selectedCourse.Enrollments;
}
return View(viewModel);
}
Why in the ** line of view, I don't have to pass id, as in the following:
@Html.ActionLink("Select", "Index", new { id=
ViewBag.InstructorID,courseID = item.CourseID })
Thanks!

Pass a reference to a reference

Pass a reference to a reference

I think it's illegal to pass a reference to a reference in C++.However
,when I run this code it gives me no error.
void g(int& y)
{
std::cout << y;
y++;
}
void f(int& x)
{
g(x);
}
int main()
{
int a = 34;
f(a);
return 0;
}
Doesn't the formal parameter of g() qualify as a reference to a reference ??

Template is re-rendered even though there is no data change

Template is re-rendered even though there is no data change

I'm struggling with an issue that I will explain giving a simple demo.
There's following very simple document in People Collection.
{
"_id" : "vxmLRndHgNocZouJg",
"fname" : "John" ,
"nicks" : [ "Johnny" , "Jo"]
}
Now let's consider following templates. Basically I display username and a
list of nicknames with input field for adding more nicknames.
<head>
<title>test</title>
</head>
<body>
<br/>

</body>
<template name="name">
<input type="text" value="{{fname}}"/>
</template>
<template name="nicks">

<div>
no nicks yet
{{/each}}
<input type="text" name="nicks"/>
<input type="submit"/>
</template>
My client javascript code is as follows:
Template.name.fname = function() {
return People.findOne({"fname" : "John"},{
transform : function(doc) {
return doc.fname;
}
});
}
Template.name.rendered = function() {
console.log('Template "name" rendered!');
}
Template.nicks.nicks = function() {
var john = People.findOne({"fname" : "John"});
if(john) return john.nicks;
}
Template.nicks.events({
'click input[type="submit"]' : function () {
var johnId = People.findOne({"fname" : "John"})._id; // demo code
People.update(johnId,{
$addToSet : {
nicks : $('input[name="nicks"]').val()
}
})
}
});
My problem is that after adding nickname (update of nicks field in a
document) template name is re-rendered (I know because I console.log it).
When I query People collection to provide data for name template I use
transform option so changes in nicks field shouldn't have impact on name
template.
Meteor docs supports this:
Cursors are a reactive data source. The first time you retrieve a cursor's
documents with fetch, map, or forEach inside a reactive computation (eg, a
template or autorun), Meteor will register a dependency on the underlying
data. Any change to the collection that changes the documents in a cursor
will trigger a recomputation.
Why template name is re-rendered then?

How to call a private method?

How to call a private method?

I have done one simple ruby code but it is really exclamatory for me....
irb(main):001:0> class Main
irb(main):002:1> private
irb(main):003:1> def fun
irb(main):004:2> puts "aa"
irb(main):005:2> end
irb(main):006:1> end
=> nil
irb(main):007:0> class Child < Main
irb(main):008:1> def gg
irb(main):009:2> fun
irb(main):010:2> end
irb(main):011:1> end
=> nil
irb(main):012:0> Child.new
=> #<Child:0x24a8b88>
irb(main):013:0> Child.new.gg
aa
but as Expected
irb(main):014:0> Main.new.fun
NoMethodError: private method `fun' called for #<Main:0x23ad950>
from (irb):14
from C:/Ruby200/bin/irb:12:in `<main>'
Any technical explanation will be appreciable thanks...

mongodb - one document in many collections

mongodb - one document in many collections

i'am looking for a good solution on MongoDB for this problem: There are
some Category's and every Category has X items. But some items can be in
in "many" Category's!
I was looking for something like a symbolic link on Unix systems but i
could't not find it.
What i thought is a good idea is: "Category1/item1" is the Object and
"category2/item44232" is only a reference to "item1" so when i change
"item1" it also changes "item44232".
I looked into the MongoDB Data models documentation but there is no real
solution for this.
Thank you for your response !

How to freeze columns and rows in WPF Grid

How to freeze columns and rows in WPF Grid

I'd like to "freeze" the columns and rows in WPF.
I want to implement a table (state machine), where in the first row are
states and in first column are commands. The rest of the cells are filled
with events. To improve usability, I'd like to keep the first row and
first column visible all the time, so even at the very bottom of the table
the states and commands are visible.
The DataGrid offers this kind of functionality but DataGrid cells don't
look flexible enough. I'd like to use Grid. The ScrollViewer is basically
what I need, but i haven't figured out how to use it for multiple Grids at
the same time.
Is there any way to freeze first row and first column (at the same time)?

Monday, 26 August 2013

Sending Certain Sent Emails To Special Folders (Outlook 2010)

Sending Certain Sent Emails To Special Folders (Outlook 2010)

I would like to configure Outlook 2010 in such a way that emails I send to
my attorney automatically are forwarded to a seperate folder other than
the generic "Sent" folder.
A MILLION THANKS.

ColdFusion 10 REST API UTF-8 Characters

ColdFusion 10 REST API UTF-8 Characters

I'm using ColdFusion 10's new REST API and I'm having trouble with UTF-8
characters. It seems that ColdFusion 10's new REST API completely mangles
non-ASCII characters. Is there a way around this?
For example, let's say I have an endpoint like this:
<cfcomponent rest="true" restpath="/widgets" produces="application/json">
<cffunction name="echo" access="remote" httpmethod="PUT"
returntype="string">
<cfreturn GetHttpRequestData().content />
</cffunction>
</cfcomponent>
This endpoint simply responds with exactly what was sent in the request.
Here is my request:
PUT http://www.mycompany.com/rest/v1.0/widgets HTTP/1.1
User-Agent: Fiddler
Host: www.mycompany.com
Content-Length: 15
&#12371;&#12435;&#12395;&#12385;&#12399;
Here is the response I get:
HTTP/1.1 200 OK
Content-Type: application/json
Server: Microsoft-IIS/7.5
Date: Mon, 26 Aug 2013 23:59:09 GMT
Content-Length: 37
ã&#65533;"ã‚"ã&#65533;«ã&#65533;¡ã&#65533;¯
Note how the response is completely different from the request.
To be 100% certain that this is a problem with the request being mangled
by ColdFusion and not a problem with the response being generated by
ColdFusion, I enhanced the endpoint to also log the request body into a
database, and sure enough, it was already mangled.
Any way around this?

Unable to download .mp4 movies via Internet download Manager installed using PlayOnLinux in Ubuntu 12.10

Unable to download .mp4 movies via Internet download Manager installed
using PlayOnLinux in Ubuntu 12.10

I am a newbie in Ubuntu and installed the 12.10 version. I visited several
sites and did all things I was "supposed" to do after installing Ubuntu
12.10.
I love movies a lot and I am addicted to downloading them. I tried
installing Uget along with flashgot but they both seem slow to download. I
miss my Internet Download Manager aka IDM, which I used for Windows, since
it was very fast. Luckily, I came across PlayOnLinux which can help to
install and use non-ubuntu applications.
For my case (of movies), I came across this website on how to use
PlayOnLinux aka POL to download anything. It really work as I've been
browsing and getting +ve feedbacks. I followed the instructions and at the
very end, when trying to download the movies, a POL dialogue appears
saying There is nothing installed
torun.91ac8608ee713b8da469a43046e864d95f4483b9 files. The number varies
according to the movie.
Can someone please tell me what am I supposed to install to run those
files in PlayOnLinux please?
I really do appreciate as I know there are ubuntu gurus in this forum.
Thank you.
yours, relaxedKangaroo

How can the GP 635T GPS module attached to an Arduino send coordinates to the laptop?

How can the GP 635T GPS module attached to an Arduino send coordinates to
the laptop?

I am trying to create a space balloon. I need a way to track the balloon.
I found a GPS Module with built-in antenna which is the GP-635T. However,
after I set it up with the arduino, what is the code or what should I
upload to the arduino so that it sends coordinates to the laptop without
being connected via USB.
Here is the GPS Module:
https://www.sparkfun.com/products/11571

I want to sync the Mail app on my iPhone5 with the Mail app on my Macbook

I want to sync the Mail app on my iPhone5 with the Mail app on my Macbook

I'd gotten an iPhone 5 earlier on in the year and managed to set up my
Hotmail/Outlook account with no hassles. This week I bought an 11" Macbook
Air and setting up the same account on my Macbook is far more complicated:
the smtp server settings for Outlook don't seem to work! So basically I
can receive emails, but cant send them. I was wondering if there was a way
to just sync the email account which is already on my phone, with the Mail
app on my laptop?

Enabling Scroll Bars In Mountain Lion=?iso-8859-1?Q?=3F_=96_apple.stackexchange.com?=

Enabling Scroll Bars In Mountain Lion? – apple.stackexchange.com

In Mountain Lion scroll bars are turned off by default, and are only seen
if actively scrolling. How do you enable them, so that they are seen all
the time ?

Firefox adds 5mm additional margin to @page directive

Firefox adds 5mm additional margin to @page directive

I am writing a CSS style sheet for printing a web page and encountered the
following problem: Firefox adds additional margin to a @page directive.
Here is an example.
HTML:
<html>
<head>
<title>CSS Print Test</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="content">
Print Me!
</div>
</body>
</html>
CSS:
html,
body,
div {
margin: 0;
padding: 0;
}
#content {
border: 1px solid;
}
@page
{
size: A4 portrait;
margin: 30mm 30mm 30mm 30mm;
padding: 0;
}
This should give the page a margin of 3 cm on each side. It works for
Chrome (29.0) and IE 10 but not for Firefox (21.0). When printing the page
with Firefox the margin on each side is something like 35mm.
Is there a simple solution or at least an explanation for this behavior?

$R/I$ when $R$ is the ring of real continuous functions – math.stackexchange.com

$R/I$ when $R$ is the ring of real continuous functions –
math.stackexchange.com

If $R$ is the ring of all real continuous functions on $[0,1]$, I am
trying to find $R/I$ where $$I=\{f\in{R}|f(.5)=0\}$$ Showing $I$ is an
ideal is not a problem since we're defining addition and ...

Sunday, 25 August 2013

12 or 16 column grid for a full width website like pinterest/vevo.com

12 or 16 column grid for a full width website like pinterest/vevo.com

So I'm looking for the right answer for my grid system:
1) Should I use 12 or 16 column grid for a full width website like:
http://xfinitytv.comcast.net
http://www.vevo.com
pinterest.com
2) Can I use bootstrap3 for 16 width
3) what are the challenges for a 16 columns grid vs traditional 12 column
grid?
Thanks.

[ Diet & Fitness ] Open Question : What extra tips are good for fat loss?

[ Diet & Fitness ] Open Question : What extra tips are good for fat loss?

I am an active girl, I run trails, play tennis, and do crossfit. However,
since I have been doing a lot of these workouts 5days a week, I noticed
muscle gain but no fat loss. I have a layer of fat around my whole body
that will not go away, I drink a lot of water, and stick to a strict diet,
with a cheat day. I don't drink alcohol. What Re some extra tips on
getting this layer of fat gone?

Exracting fields in file and storing it in different file in vim

Exracting fields in file and storing it in different file in vim

I have file int the following format:
..
..
..
Name:abc
..
..
Name:xyz
..
..
I want to extract the name and occupation field and save it in another
file out.txt using vim in the following format:
Name:abc
Occupation:def
Name:def
Occupation:ghi
Please don't use any any advanced commands. I am just a beginner.

Saturday, 24 August 2013

Can we say that using "pass by reference" is always better than "pass by value"?

Can we say that using "pass by reference" is always better than "pass by
value"?

In C# or php or other languages, there are 2 ways to pass a value to a
function, pass it by value and pass it by referece.
Pass parameter by value make the value copied in the function, so this
need a extra memory space although the memory space will be reclaimed
after running outside the function.
But passing parameter by reference no need to copy a value, it's save the
memory. From this perspective, can we say that using "pass by reference"
is always better than "pass by value"?

N random choice according to probability

N random choice according to probability

this code is to get random numbers but with probability : that 8 is
returned if r= 0 to 0.8 and 2 is returned if r= 0.8 to 0.2
#include<stdio.h>
#include<pthread.h>
#include<stdlib.h>
int main()
{
srand(time(NULL));
double r = rand() / (double)RAND_MAX;
double sum = 8 + 2;
if (r < 8 / sum) {
printf("80% \n");
} else {
printf("20% \n");
}
}
but if I have more than two numbers ,say n how can I handle it,,,, can I
handle it with multi if else statement or what ?

Attempting to access property on JavaScript Object = Undefined

Attempting to access property on JavaScript Object = Undefined

I have this JavaScript object
Object {VoteTag: Object, ResortVoteTag: Array[1]}
ResortVoteTag: Array[1]
0: Object
id: "1"
resort_id: "1561"
tag_id: "4"
user_id: "31"
vote: "3"
length: 1
VoteTag: Object
id: "4"
tag: "Snowboarders"
type: "slopes"
I'm trying to access the vote property in the ResortVoteTag array however
I am unable to do so.
This is the following code I'm using.
$.ajax({
url: "/Votetags/alltags",
async: false,
dataType: 'json',
}).done(function ( data ) {
for(var i = 0; i < data.length; i++){
console.log(data[i].ResortVoteTag.id);
}
});

Add only some IDs to MYSQL Query

Add only some IDs to MYSQL Query

I got the following code and like to add a part, which controls which IDS
should be shown. Each row has an ID, and i would like to enter for example
the ID 3,4 and 7 to show up. Any ideas how i can do this? Thanks a lot!
$itemsStmt = $pdo->query(
'SELECT '
. '*, '
. 'COUNT(v.voting_weight) AS cStimmen '
. 'FROM abl_gewinnspiel g '
. 'LEFT OUTER JOIN votes v '
. 'ON '
. 'v.vote_item_id = g.ID '
. 'GROUP BY g.ID '
. 'ORDER BY cStimmen DESC');
$voteItems = $itemsStmt->fetchAll();
Thought about . 'WHERE ID = (23,45,56)', But it does not work.

Objective C - Login to java enabled website with username & password

Objective C - Login to java enabled website with username & password

I am new to iPhone development/Objective C but I have good programming
experience in C/C++. This is my first app in my learning.
My question is that I need to login to a website which shows the HTML code
like below. I am sure this is the part that handle the login. Because I
use this website for login testing, unfortunately, it is not possible to
give the URL here.
</div>
</div>
<script type="text/javascript">
$(function () {
$('#txtLoginID").watermark('login email');
$('#txtPwd").watermark('password);
$('.BtLogin').click(function () { $('.alert.error.server').hide();
});
});
</script>
Can someone explain how I should the basic Objective C code to login to
this website with username & password?
I think we can use method "stringByEvaluatingJavaScriptFromString" but I
am having trouble getting this login.
Can someone help me here?'
Regards,
Mathew

Fetching image from url with javascript

Fetching image from url with javascript


I am trying to show an image on my page from a different url.

<body>
<div id="container">
<br />
<canvas width="500px" height="375px" id="canvas">
</canvas>
<img src="http://yinoneliraz-001-site1.smarterasp.net/MyPicture.png" />
</div>
<script>
var img = new Image;
img.src = "http://yinoneliraz-001-site1.smarterasp.net/MyPicture.png";
var timer = setInterval(function () { MyTimer() }, 200);
function MyTimer() {
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0,500,675);
img = new Image;
img.src =
"http://yinoneliraz-001-site1.smarterasp.net/MyPicture.png";
}
</script>
The image on the other site is being saved every 1.5 seconds.
The result is that I cant view the image.
Any ideas why?

Thanks!

c++ access violation at initialising DX

c++ access violation at initialising DX

I intended to create a window and initialise Direct9 but I found VS2010
indicated that access violation on DX_Init() funtion, I'm quire confused
where I got wrong.
#include <Windows.h>
#include <d3dx9.h>
#include <sstream>
#include <string>
#include "D3D9.h"
#define memclear(var) \
memset(&wndClassData, 0x00, sizeof(var));
WNDCLASSEX wndClassData;
LRESULT CALLBACK MainWindowProc(HWND hWnd,UINT uMsg,WPARAM wParam, LPARAM
lParam)
{
switch(uMsg){
case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;`enter code here`}
struct DXGlobals{
IDirect3D9 *pD3D;
IDirect3DDevice9 *pDevice;
};
enter code here
DXGlobals gDX;
//I have some problems on this section
void DX_Init(HWND hWnd)
{
gDX.pD3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
memclear(d3dpp);
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
HRESULT hr = gDX.pD3D->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp,
&gDX.pDevice
);
}
//problem end here
void DX_Update(){
}
void DX_Dispose(){
gDX.pD3D->Release();
gDX.pDevice->Release();
}
int CALLBACK WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
//WNDCLASSEX wndClassData;
memclear(wndClassData);
wndClassData.cbSize = sizeof(WNDCLASSEX);
wndClassData.lpfnWndProc = MainWindowProc;
wndClassData.hInstance = hInstance;
wndClassData.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
wndClassData.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndClassData.lpszClassName="ColourMatchingWindow";
//memset(&wndClassData, 0x00, sizeof(wndClassData));
ATOM wndClass = RegisterClassEx(&wndClassData);
HWND mainWnd = CreateWindow(
(LPCSTR)wndClass,
"ColourMatching",
WS_OVERLAPPEDWINDOW|WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
DX_Init(mainWnd);
MSG msg;
for(;;){
while(PeekMessage(&msg, NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(msg.message==WM_QUIT){
break;
}
DX_Update();
}
DX_Dispose();
return 0;
}
}

Friday, 23 August 2013

Error message -> shouldOverrideUrlLoading Webview Android

Error message -> shouldOverrideUrlLoading Webview Android

I need solved a problem with Webview and the method ShouldOverrideUrlLoading.
I want to display a message indicating that the user doesn't have the
twitter app installed on your phone
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
}else if(url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}else if (url != null && url.startsWith("market://")) {
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} else if (url != null && url.startsWith("twitter://")) {
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}else{
Toast.makeText(getApplicationContext(), "Twitter app is necesary",
Toast.LENGTH_SHORT).show();
}
return false;
}
The error that show "The application has stopped unexpectedly. Please try
again"
Can anyone help?

How to apply a jQuery function to a child page in an iframe?

How to apply a jQuery function to a child page in an iframe?

Here's a brainteaser:
I have an iframe in a window, and a navbar that links to it:
<div class="nav">
<a href="link.html" target="iframe-content" id='debug">#Debug<a>
</div>
<iframe name="iframe-content" src="page.html"></iframe>
I've then got a simple jQuery function to inset a class when a link in the
nav is clicked.
$(window).load(function() {
$("#debug").click(function() {
$('body').toggleClass("debug");
});
});
Now my question is how do I get the toggleclass to apply to the inline
frame (page.html) and not the parent page?

Create a custom table in java

Create a custom table in java

I would like to create a table looking like this but with the titles
in-sync with the table:

Any tips on how make the columns being aligned with the rows and also
allow auto resize in x-axis? For this I used GridBagLayout. Also tried
with JTable but had problems to customize it to hide all default JTable
components(like in my picture).
public class MyTableExample extends JFrame {
public MyTableExample(){
JPanel contentPanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
contentPanel.add(getTitles(),c);
c.gridy = 2;
contentPanel.add(getRow(),c);
c.gridy = 3;
contentPanel.add(getRow(),c);
// MainPanel: Helps positioning the contentPanel
JPanel mainPanel = new JPanel(new GridBagLayout());
c.weighty = 1;
c.anchor = GridBagConstraints.NORTH;
c.insets = new Insets(20,20,20,20);
mainPanel.add(contentPanel,c);
this.add(mainPanel);
this.pack();
this.setVisible(true);
}
private JPanel getRow(){
JPanel rowPanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
rowPanel.setOpaque(false);
JLabel col1 = new JLabel("#rowItem");
JComboBox<String> col2 = new JComboBox<String>();
JButton col3 = new JButton("rowItem");
JLabel col4 = new JLabel("rowItem");
rowPanel.add(col1,c);
rowPanel.add(col2,c);
rowPanel.add(col3,c);
rowPanel.add(col4,c);
return rowPanel;
}
private JPanel getTitles(){
JPanel titlePanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
titlePanel.setOpaque(false);
JLabel t1 = new JLabel("T1");
JLabel t2 = new JLabel("Title2");
JLabel t3 = new JLabel("Title33333333");
JLabel t4 = new JLabel("T4");
titlePanel.add(t1,c);
titlePanel.add(t2,c);
titlePanel.add(t3,c);
titlePanel.add(t4,c);
return titlePanel;
}
public static void main(String[] args){
new MyTableExample();
}
}

How do I get the remote IP-Address of clients connecting to a rebol3 based server?

How do I get the remote IP-Address of clients connecting to a rebol3 based
server?

Atm I'm playing with Carl's basic tcp test scripts and would like to know:
"How to get the IP-Address of clients connecting to the server?" Any
ideas? I tried to probe a client subport at the server-side but it doesn't
show the remote-ip. Can someone give me hints on gathering that
information. I know how it works within rebol2, but I'm not familiar with
the R3 port model.

Thursday, 22 August 2013

sendmail is not delivering messages to recipients

sendmail is not delivering messages to recipients

I have run into a number of problems getting sendmail to work. None of the
solutions I've tried have worked.
First: sendmail was hanging for 60 seconds and then not sending the email.
To solve this, I used suggestions from the web to set my /etc/hostname to
a fully qualified domain name (FQDN) and then put that in /etc/hosts as
well. This did get rid of the hanging, but I still never receieve any
emails sent from sendmail.
Second: Installed postfix
This did not fix the issue. Sending an email via sendmail or mail at the
command line both fail. Example:
echo "a message" | sendmail someemail@gmail.com
echo "a message" | mail someemail@gmail.com
Both commands return instantly without error, but no email is ever
recieved at the gmail account.
I made sure a port was open at 25 in the router as well (although this
shouldn't be an issue as Thunderbird can send emails behind the router).
I need to get this working for PHP but cannot figure out where in the many
steps from the program to the remote email server it is failing. How would
I figure this out?

Can someone help me improve speed?

Can someone help me improve speed?

As of now this generates a dictionary full of points that a player can
move to and the cost of that move. My problem is that it takes ages to
process.
I understand that although a square is already checked as added my method
checks the same square again, but when I dont do this than the moveable
area gets all screwed up and it does not return what it should.
Can i get some pointers on how to speed this up, Please include
examplecode. I was thinking about a few extra threads but that would leave
me processing this in quadrents and if i need to form movements around an
object on the grid then I dont think ill be able to build off of cells
belonging to other threads.
This code works right now, it is just slow as snot and its unacceptable
for my program.
Please note that This is not path finding, I am only looking for all
possible moves, not the shortest way to get to a spot.
class MoveCompiler
{
public Board Board;
public MoveCompiler(Board board)
{
Board = board;
}
Dictionary<Coordinate, int> MovesList = new Dictionary<Coordinate,
int>(new Coordinate.EqualityComparer());
public Dictionary<Coordinate, int> getMoves( int startRow, int
startColumn, int actionPointsUsed,int maxActionPoints, bool
firstDiagnol)
{
int moveCost = 1;
if (!firstDiagnol)
{
moveCost = 2;
}
if (actionPointsUsed + moveCost <= maxActionPoints)
{
if (IfCheck(startRow + 1, startColumn + 1))
{
if (!Board.cellAt(new Coordinate(startRow + 1,
(startColumn + 1))).InUse)
{
MovesList.Add(new Coordinate(startRow + 1,
(startColumn + 1)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow + 1, (startColumn
+ 1))).InUse = true;
}getMoves(startRow + 1, startColumn + 1, actionPointsUsed
+ moveCost, maxActionPoints, !firstDiagnol);
}
if (IfCheck(startRow + 1, startColumn - 1))
{
if (!Board.cellAt(new Coordinate(startRow + 1,
(startColumn - 1))).InUse)
{
MovesList.Add(new Coordinate(startRow + 1,
(startColumn - 1)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow + 1, (startColumn
- 1))).InUse = true;
}getMoves(startRow + 1, startColumn - 1, actionPointsUsed
+ moveCost, maxActionPoints, !firstDiagnol);
}
if (IfCheck(startRow - 1, startColumn - 1))
{
if (!Board.cellAt(new Coordinate(startRow - 1,
(startColumn - 1))).InUse)
{
MovesList.Add(new Coordinate(startRow - 1,
(startColumn - 1)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow - 1, (startColumn
- 1))).InUse = true;
}getMoves(startRow - 1, startColumn - 1, actionPointsUsed
+ moveCost, maxActionPoints, !firstDiagnol);
}
if (IfCheck(startRow - 1, startColumn + 1))
{
if (!Board.cellAt(new Coordinate(startRow - 1,
(startColumn + 1))).InUse)
{
MovesList.Add(new Coordinate(startRow - 1,
(startColumn + 1)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow - 1, (startColumn
+ 1))).InUse = true;
}getMoves(startRow - 1, startColumn + 1, actionPointsUsed
+ moveCost, maxActionPoints, !firstDiagnol);
}
}
if (actionPointsUsed + 1 <= maxActionPoints)
{
if (IfCheck(startRow - 1, startColumn))
{
if (!Board.cellAt(new Coordinate(startRow - 1,
(startColumn))).InUse)
{
MovesList.Add(new Coordinate(startRow - 1,
(startColumn)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow - 1,
(startColumn))).InUse = true;
}getMoves(startRow - 1, startColumn, actionPointsUsed + 1,
maxActionPoints, firstDiagnol);
}
if (IfCheck(startRow + 1, startColumn))
{
if (!Board.cellAt(new Coordinate(startRow + 1,
(startColumn))).InUse)
{
MovesList.Add(new Coordinate(startRow + 1,
(startColumn)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow + 1,
(startColumn))).InUse = true;
}getMoves(startRow + 1, startColumn, actionPointsUsed + 1,
maxActionPoints, firstDiagnol);
}
if (IfCheck(startRow, startColumn + 1))
{
if (!Board.cellAt(new Coordinate(startRow, (startColumn +
1))).InUse)
{
MovesList.Add(new Coordinate(startRow, (startColumn +
1)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow, (startColumn +
1))).InUse = true;
}getMoves(startRow, startColumn + 1, actionPointsUsed + 1,
maxActionPoints, firstDiagnol);
}
if (IfCheck(startRow, startColumn - 1))
{
if (!Board.cellAt(new Coordinate(startRow, (startColumn -
1))).InUse)
{
MovesList.Add(new Coordinate(startRow, (startColumn -
1)), actionPointsUsed + moveCost);
Board.cellAt(new Coordinate(startRow, (startColumn -
1))).InUse = true;
}getMoves(startRow, startColumn - 1, actionPointsUsed + 1,
maxActionPoints, firstDiagnol);
}
}
return MovesList;
}
private bool IfCheck(int desiredRow, int desiredColumn)
{
bool ReturnMe= false;
if (desiredRow <= Board.BOARDHEIGHT && desiredRow >= 1)
if (desiredColumn + 1 <= Board.BOARDWIDTH && desiredColumn >= 1)
if (!Board.cellAt(new Coordinate(desiredRow,
desiredColumn)).hasCharacter)
//if (!Board.cellAt(new Coordinate(desiredRow,
(desiredColumn))).InUse)
if (Board.cellAt(new Coordinate(desiredRow,
desiredColumn)).isPassable)
ReturnMe = true;
return ReturnMe;
}
private void VH()
{
}
}

Animating the mask for a UIView

Animating the mask for a UIView

I can create a mask like this:
CALayer *mask = [CALayer layer];
mask.contents = (id)[[UIImage imageNamed:@"mask.png"] CGImage];
mask.frame = CGRectMake(0, 0, 10, 10);
self.content.layer.mask = mask;
And this will correctly reveal the top left 10 pixels of my content
(because mask.png is just a black image). However I want to animate the
mask to reveal the rest of the content:
[UIView animateWithDuration:3.0
animations:^{
mask.frame = self.content.bounds;
}
completion:^(BOOL finished){
}];
The problem is that there's no animation. The entire content gets
displayed immediately. Why does this happen, and how can I animate the
mask so that the content is revealed from the upper left?

how to wark with flask wtforms

how to wark with flask wtforms

You've gone incognito. Pages you view in this window won't appear in your
browser history or search history, and they won't leave other traces, like
cookies, on your computer after you close all open incognito windows. Any
files you download or bookmarks you create will be preserved, however.
Going incognito doesn't affect the behavior of other people, servers, or
software. Be wary of: Websites that collect or share information about you
Internet service providers or employers that track the pages you visit
Malicious software that tracks your keystrokes in exchange for free
smileys Surveillance by secret agents People standing behind you

How to Write Linq for C# ; Differences in Linq Queries

How to Write Linq for C# ; Differences in Linq Queries

If
from lang in Languages
from title in lang.Titles
where lang.name == "Arabic" && title.Type=="Movie"
Select new {title.Name, title.ReleaseYear}
is the same as
Languages
.Where(l=>l.Name == "Arabic")
.SelectMany(l=>l.Titles)
.Where(t=>t.Type=="Movie")
.Select(t=>new{
t.Name, t.ReleaseYear
})
Is there any difference in the 2 ( Query results are same, i mean backend )
Can you choose either or and consider the rest just "Preference"? - or is
one more versitile?

video call not going from polycom's end terminal(Lifesize team 220)!

video call not going from polycom's end terminal(Lifesize team 220)!

We are using polycom video conferencing solution with RMX 2000 as
multiparty confrlerencing unit, DMA 4000 as gatekeeper to register devices
and also act as SIP proxy. RPAD acts for firewall traversal. Except RPAD
all other servers are kept in MZ. Rpad is in DMZ. The end terminal used is
of Lifesize Team 220. Now the situation is I am able to make call(using
H.323) from internet to the end terminal but not the reverse, that is from
end terminal to devices kept in internet. As per the network guy the
packets have not been initiated at all from the end terminal. So probably
its some configuration issue of the rpad or dma or rmx. Need some help in
this. What could be the possible issue/solution?

Wednesday, 21 August 2013

Process.Start opens multiple instances

Process.Start opens multiple instances

I have the following code:
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)
+ "\\Internet Explorer\\iexplore.exe", "http:\\\\someurl.com");
It runs fine, but opens two instances of IE (Needless to say, I'm
expecting one). Is there something obvious I'm missing here, or is it a
more detailed issue? I'm using Visual C# 2010 Express if that matters, and
.NET 4 Client Profile.

Adding a Third column of data in Mathematica

Adding a Third column of data in Mathematica

I have a very large table of data something like:
lista = {{2,8},{3,4},{5,2}..}
I would like to add x to every element so it would be
lista ={{x,2,8},{x,3,4},{x,5,2}.....}
This seems to me like it should be rather trivial but I have not been able
to find a solution.
I would appreciate any help, Ben

How to have a newly plugged in keyboard to function to its full potential?

How to have a newly plugged in keyboard to function to its full potential?

Everytime I changed keyboard, it works slower, which means the cursor
moves very slow, compared to the previously attached keyboard, unless I
restart my PC.
Is there a way I can get it to maximize its functionality without having
to restart my PC?

Time Machine backup between networks

Time Machine backup between networks

I have a computer on network A that I would like to backup via Time
Machine to a drive connected to a computer on network B. Can this be done?
Would I need a VPN? I just need the network B computer's drive to show up
as Shared to the computer on network A.

Playframework 2.x Apache Tika issue

Playframework 2.x Apache Tika issue

i am uploading file using upload from then after getting uploaded file i
am using Apache tika top extract content,metadata from uploaded file and
applying but some error is coming
have a look of my playframework controller code :
public static Result upload() {
MultipartFormData body = request().body().asMultipartFormData();
FilePart picture = body.getFile("doc");
if (picture != null) {
String fileName = picture.getFilename();
int eof = fileName.lastIndexOf('.');
String ext = fileName.substring(eof + 1);
file = picture.getFile();
InputStream is;
try {
is = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Parser ps=new AutoDetectParser();
BodyContentHandler bch=new BodyContentHandler();
Metadata metadata=new Metadata();
try {
ps.parse(is, bch, metadata, new ParseContext());
} catch (IOException | SAXException | TikaException e) {
e.printStackTrace();
}
String sw=bch.toString();
return ok(sw+" entity extracted and saved" + ext);
}else {
flash("error", "Missing file");
return redirect(routes.Application.index());
}
but when i am running this web application i am using commands:
rahul@inext:~/playframwrk apps/EntWebPrj$ play
[info] Loading project definition from /home/rahul/playframwrk
apps/EntWebPrj/project
[info] Set current project to EntWebPrj (in build
file:/home/rahul/playframwrk%20apps/EntWebPrj/)
_ _
_ __ | | __ _ _ _| |
| '_ \| |/ _' | || |_|
| __/|_|\____|\__ (_)
|_| |__/
play! 2.1.2 (using Java 1.7.0_25 and Scala 2.10.0),
http://www.playframework.org
> Type "help play" or "license" for more information.
> Type "exit" or use Ctrl+D to leave this console.
[EntWebPrj] $ ~run
it is giving error :
if you want to see full error then full error
and some of error is :
sbt.PlayExceptions$CompilationException: Compilation error[error: package
org.apache.tika.exception does not exist]
at
sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349)
~[na:na]
at
sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349)
~[na:na]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
at
sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:349)
~[na:na]
at
sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:346)
~[na:na]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
[warn] play - No application found at invoker init
i added tika jar file.
Give me some idea to fix this issue.

c# multi line strings allowing variable calling

c# multi line strings allowing variable calling

I have googled but cannot find an answer for this question:
I know about multi-line strings in c#. But how can I create a string like:
string temp = @"DECLARE @rolename varchar(max)
SET @rolename ='***'
EXEC sp_addrolemember N'db_execute',@rolename"
* represents there I have to delcare a variable having some value like
(object.variable).
Is this possible??

IllegalArgumentException: Numbers of source Raster bands and source color space components do not match For a color image Exception

IllegalArgumentException: Numbers of source Raster bands and source color
space components do not match For a color image Exception

File file = new File("path");
BufferedImage bufferedImage = ImageIO.read( file );
here is the code and below is the image to get the exception in the topic.
Download image:
https://skydrive.live.com/?cid=19547371C4F3B839&id=19547371C4F3B839%21105
Simply if someone can obtain a java.awt.image.BufferedImage object from
the image given that's enough (should not convert the image to gray scale
one).
You are a genius if you can answer this :D. Plz help.

Tuesday, 20 August 2013

Android - PHP or Java Webservice

Android - PHP or Java Webservice

I was wondering what peoples thoughts are with using PHP or Java
Webserices to connect with MYsql...or any other ways.
Between the two what do you find easier and safer?

HLS Video Doesn't Upscale in Browser

HLS Video Doesn't Upscale in Browser

I am attempting to get an HLS stream to work in a browser (Webkit).
It first appears to work, the video starts, playing the
medium(480p)stream. Unfortunately, the stream quality doesn't improve over
time as it should.
Does anyone have a source that discusses either a tool or simple method to
manage the changes of these different streams? or.. Perhaps a direction in
which to follow so I can write my own controller for switching between the
streams?
Thank you for you help.

jQuery animate callback wont work Firefox IE, works in Chrome

jQuery animate callback wont work Firefox IE, works in Chrome

console.log('1');
jQuery('#inner-content').animate({
'width': jQuery('#inner-content-wrapper').width() + 'px'
}, {
duration: 800,
queue: false,
complete: function(){
console.log('2');
}
});
console.log('3');
Console output Chrome v28: 1,3,2
Console output Firefox v23: 1,3 Animation works but complete is never
executed, this also doesn't work in IE 10

What type of model relationship should I use for two foreign key references in same row?

What type of model relationship should I use for two foreign key
references in same row?

I'm trying to create an Event model that has two references to the Contact
model.
Why two? Because a Contact can either be of type Client or Organizer.
How can I add two foreign key columns to my Event model?

Android SDK Manager is executing in cmd but not opening

Android SDK Manager is executing in cmd but not opening

Config Details:
Windows 8 Pro 32bit
adt-bundle-windows-x86-20130717
jdk-6u26-windows-i586 32bit
Directories:
For Java - C:\Program Files\Java\jdk1.6.0_26
For Android Root - Z:\Program Files\Android
For Android SDK - Z:\Program Files\Android\sdk
Environmental Variables:
var_name: JAVA_HOME
var_value: C:\Program Files\Java\jdk1.6.0_26\
var_name: JDK_HOME
var_value: C:\Program Files\Java\jdk1.6.0_26\
var_name: Path
var_value: C:\Program Files\Java\jdk1.6.0_26\bin
Modification: 1) set java_exe= "%JAVA_HOME%\bin\java.exe" if not defined
java_exe goto :EOF
2) for /f %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a
3) for /f %%a in ('"%~dps0\find_java.exe" -s -w') do set javaw_exe=%%a
First i downloaded adt-bundle then extracted into Android Root directory
(i installed java far earlier) then i installed ADT Plugins from
https://dl-ssl.google.com/android/eclipse/ and successfully connected
Eclipse IDE with Android SDK. Now i am trying to Android SDK Components
but when i clicked on Window-> Android SDK Manager in Eclipse a dialogue
box opened said SDK Manager will open in a while but it didn't. Whenever i
try to open SDK Manager everytime a cmd prompt for a second then disappear
and nothing happened while AVD Manager open properly.
Then i went through some solution in several forums and modified some line
of code (as of modification 1 in tools\android.bat ; 2 and 3 in
tools\lib\find_java.bat)
Now in command line
Z:\Program Files\Android\sdk\tools>android
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see
java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
Z:\Program Files\Android\sdk\tools>
As you can see that my attempts are successful and android.bat is
executing but the problem is when i try to open SDK Manager directly or
via IDE again nothing happened but executing in cmd. I cannot understand
what happening actually and i am unable to found anything related with
this in any forum. Please Help. Thanks in advance.

MarkLogic 5 return elements wrapped in CDATA

MarkLogic 5 return elements wrapped in CDATA

I'm trying to get MarkLogic 5 to return items wrapped in a CDATA tag but
it simply refuses to. Doesn't barf, just doesn't do it. Am I barking up
the wrong tree using: -
xquery version "1.0-ml";
declare option xdmp:output "cdata-section-elements = text";
<text><![CDATA[\begin{eqnarray}
\fl {R}_{\mathrm{sw}(e)}=\nonumber\\ \fl \biggl \{
\frac{3{L}_{1}{L}_{2}{Q}_{\mathrm{after}}}{1 2{k}_{h}{A}_{h}\Delta
T({L}_{1}+{L}_{2})-({L}_{1}+{L}_{2})^{2}({Q}_{\mathrm{before}}-{Q}_{\mathrm{after}})}-1\biggr
\} \nonumber\\ \times
~\frac{{L}_{1}{L}_{2}}{({L}_{1}+{L}_{2}){k}_{h}{A}_{h}}-{R}_{j}-{R}_{\mathrm{CNT}},
\end{eqnarray} ]]>
</text>
Simply returns without the CDATA tag which is contrary to all
documentation I can find. I've tried returning the content several ways,
e.g., xdmp:quote but as I need to parse the content using XSLT at the
other end it really needs to be wrapped in a CDATA element.
The content is normally deeply nested but I've simplified here for ease.
Any clues?

Grep to extract the word matching the given pattern

Grep to extract the word matching the given pattern

I have a log file with entries like
INFO 2013-08-16 13:46:48,660 Index=abc:12 insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=abcd:12 insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=def:134 insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=abkfe insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=lmkfe insertTotal=11
INFO 2013-08-16 13:46:48,660 Index=lmkfe insertTotal=11
I would like to grep and extract the words that match my pattern which is
abc:<some_number> and def:<some_number>.
$ cat "log.txt" | grep -w "abc" -w "def" >> "failed_values.txt";
So in this case, my failed_values.txt should only have
abc:12
def:134
The key to note is that my pattern ends with a : followed by a number and
then a space e. g. abc:122.

Monday, 19 August 2013

Definition of weak solutions

Definition of weak solutions

Why are weak solutions defined like:
A function $u \in H^1(\Omega)$ is a weak solution of $$ Lu=div(A\nabla
u)+b\cdot\nabla u+cu=f+divF, in \Omega $$ if $$ \int_\Omega \nabla
\phi\cdot (A\nabla u-F)dx=\int_\Omega\phi(b\cdot \nabla u+cu-f) dx $$
holds for every $\phi \in C_0^\infty(\Omega).$
I mean, we define this new notion "weak solutions" in order to generalize
classical solutions. Then we just need one purpose which is "classical
solution $\Rightarrow$ weak solution" and if everything is sufficiently
smooth, then it follows that a weak solution is automatically a classical
one. If this is our motivation to define weak solutions, then there would
have tons of methods to do.
My point is why this type of definition of weak solutions is so important.
Is there any other motivations like from geometry or other subjects to
make this definition so outstanding and is there any other type of
definitions of generalized solutions?

Associate SSL certificate for SQL Server which does not use the FQDN

Associate SSL certificate for SQL Server which does not use the FQDN

We would like to connect securely to SQL 2008 R2 over the internet for
reporting purposes. Speed is not a huge concern for these smaller data
sets, and users are going to be using simple reporting programs (e.g.
Access) that require ODBC connections, rather than an API of sorts. In
this scenario we have a SQL Server running on a local network (e.g.
sql.mydomain.local) which is being accessed from the outside world via NAT
(e.g. sql.mydomain.com, port xyz). This works fine with no security,
however we need to encrypt the connections. The simple way to do that is
to add SSL to the SQL server. Here is where I run into issues though:
If I get a certificate for the external name (sql.mydomain.com), SQL
Server refuses to see or use the external SSL cert as it is not the
servers name or FQDN, since it is configured locally (per
http://technet.microsoft.com/en-us/library/ms191192.aspx). Manually adding
the cert via HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL
Server\MSSQL.x\MSSQLServer\SuperSocketNetLib doesn't seem to change that
behavior for me.
If I use a self-signed certificate from the domain controller, I'm able to
see and use the cert in SQL. However external connections obviously
complain that the cert is not trusted. If I add the domain controller as a
trusted publisher, then SQL complains that the server name doesn't match
the certificate name when I attempt to connect to it.
All of the paths forward seem a little wonky: 1. Setup a local domain for
only that server with the public name (e.g. mydomain.com) and add the
machine there so that the FQDN matches the external certificate generated
from a trusted publisher, hopefully SQL will see and use the cert then. 2.
Have the users modify their hosts file to create a cname of
sql.mydomain.local to sql.mydomain.com.
Am I missing something in my understanding so far? Is there any way to get
around SQL's limitations regarding use of a cert which is not the FQDN? If
I purchase a certificate for sql.mydomain.com with a Subject Alternative
Name of sql.mydomain.local, will SQL see and use it?

Primary Key error when trying to create Foreign Key

Primary Key error when trying to create Foreign Key

Running into a problem creating a Foreign Key after creating a
Parent/Child table scheme with partitioning setup.
CREATE TABLE [dbo].[MessageHeader](
[MessageReceivedHeaderID] [int] IDENTITY(1,1) NOT NULL,
[MessageReceivedHeaderGlobalId] [uniqueidentifier] NULL,
[CreatedDateTime] [datetime] NOT NULL
)
GO
ALTER TABLE [dbo].[MessageHeader]
ADD CONSTRAINT [PC_MessageHeader_CreatedDateTime_1]
PRIMARY KEY CLUSTERED ([MessageHeaderID], [CreatedDateTime] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS
= OFF)
ON [PS_Monthly] ([CreatedDatetime])
CREATE TABLE [dbo].[MessageDataInfo](
[MessageDataInfoID] [int] IDENTITY(1,1) NOT NULL,
[MessageHeaderID] [int] NOT NULL,
[CreatedDateTime] [datetime] NOT NULL)
GO
ALTER TABLE [dbo].[MessageDataInfo]
ADD CONSTRAINT [PC__CreatedDateTime_1]
PRIMARY KEY CLUSTERED ([MessageDataInfoID], [CreatedDateTime])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF)
ON [PS_Monthly] ([CreatedDatetime])
GO
ALTER TABLE [dbo].[MessageDataInfo] WITH CHECK
ADD CONSTRAINT [FK_HeaderID]
FOREIGN KEY([MessageHeaderID])
REFERENCES [dbo].[MessageHeader] ([MessageHeaderID])
What happens is I get the error:
Msg 1776, Level 16, State 0, Line 1 There are no primary or candidate keys
in the referenced table 'dbo.MessageHeader' that match the referencing
column list in the foreign key 'FK_HeaderID'.
I am not sure why this is happening because that column is obviously the
Primary Key! Any help is appreciated.

Total average curvature of an immersed torus.

Total average curvature of an immersed torus.

How to prove that the total average curvature of an immersed torus of
$R^3$ such that has nontrivial self-intersection must $> 8 \pi$? I don't
have any idea about it.

Sunday, 18 August 2013

IMG won't show on remote site

IMG won't show on remote site

I have a webpage where the images are not being found (running chrome). I
synced the remote directory with my local one, so all files should be
identical, however I can see the images locally but not on the remote
site. Can anyone explain why?
I have the following directory where my index.html is:
icons/circle/*.png, where * is some generic social media i.e. (facebook,
twitter, etc.)
using this code to show it on html
<img class="social-media" src="icons/circle/facebook.png">
But it only shows when I view my webpage locally, not when everything is
uploaded to the server.
See webpage footer at dmacmill.com
Full directory listing:

Parsing a text file into a list in python

Parsing a text file into a list in python

I'm completely new to Python, and I'm trying to read in a txt file that
contains a combination of words and numbers. I can read in the txt file
just fine, but I'm struggling to get the string into a format I can work
with.
import matplotlib.pyplot as plt
import numpy as np
from numpy import loadtxt
f= open("/Users/Jennifer/Desktop/test.txt", "r")
lines=f.readlines()
Data = []
list=lines[3]
i=4
while i<12:
list=list.append(line[i])
i=i+1
print list
f.close()
I want a list that contains all the elements in lines 3-12 (starting from
0), which is all numbers. When I do print lines[1], I get the data from
that line. When I do print lines, or print lines[3:12], I get each
character preceded by \x00. For example, the word "Plate" becomes:
['\x00P\x00l\x00a\x00t\x00e. Using lines = [line.strip() for line in f]
gets the same result. When I try to put individual lines together in the
while loop above, I get the error "AttributeError: 'str' object has no
attribute 'append'."
How can I get a selection of lines from a txt file into a list? Thank you
so much!!!

Android build error in vendor_module_check.mk

Android build error in vendor_module_check.mk

I am trying to build android 4.2.2 for maguro, but I keep getting the
following build error:
vendor_module_check.mk:53 vendor/broadcom/maguro/proprietary/bcm4330.hcd
has unknown owner
Does anyone know how to solve this ?
Thanks.

How to create dynamic tabs in JSF

How to create dynamic tabs in JSF

I am querying database and fetching some value in bean.Depending on the
value returned from bean i have to create tabs dynamically.If the value is
3 there should be 3 tabs

How can I show text touching div borders?

How can I show text touching div borders?

I have a DIV. Inside that DIV I put some some text. The div is positioned
absolutely. It has style="border:1 px solid black" so it shows as a nice
rectangle. Now within this rectangle I want to show text which touched
either top or bottom border (whichever is easier):
The thing is: 1) I don't want to underline the text- this is not the issue
2) I don't want to manually position the text within the DIV
3) The point is: I set the position of the DIV and the text automatically
touches the border (top or bottom border)- no matter what font-family or
font-size I set.

Computation of the mean of a random variable to estimate algorithm complexity

Computation of the mean of a random variable to estimate algorithm complexity

I made an incremental algorithm which I would like to evaluate the
complexity. The algorithm works with a sliding window of size n.
To study the complexity, the window is considered full and the data
present are ${x_{1},...,x_{n}}$ . They are assumed to be random, i.i.d,
but with no assumption regarding their distribution. In particular, they
are not necessarily bounded. Finally, the most recent data is $x_{n+1}$.
The complexity of the algorithm depends on the distance from $x_{n+1}$ to
its "nearest lower value" $x_{l}$ whose index is $l=\max\left\{
k\in\{1...n\}\;st\;x_{k}<x_{n+1}\right\}$. The distance $d$ is then
$d=n+1-l$.
$d$ is obviously a random variable, and I would like to determine its
mean, which would give the algorithm complexity.
I first thought $d$ was a geometric variable with argument 1/2 since
$P\left(x_{n+1}\geq x_{n}\right)=1/2$ (which I cannot prove either), so
$E\left[d\right]=2$ but it is not the case. Indeed, $x_{n+1}$ and $x_{n}$
are not independent so $d$ does not follow a geometric law. Moreover, I
did some experiments on Excel to compute $E\left[d\right]$ using different
distributions and it seems it does not depend on the distribution of the
$x_{i}$ but on $n$ (I can not post the image, it confirms this result).
Below is a track I have tried to follow to determine $E\left[d\right]$
which proved unsuccessful:
$E\left[d\right]=\sum_{k=1...n}kP\left(d=k\right)$
and
$\begin{eqnarray*} P\left(d=k\right) & = & P\left(x_{n-k}<x_{n+1}\cap
x_{n-k+1}\geq x_{n+1}\cap...\cap x_{n}\geq x_{n+1}\right)\\ & = &
\forall\lambda_{1},\lambda_{2}\in\mathbb{R}\int_{\lambda_{1}<\lambda_{2}}P\left(x_{n-k}<\lambda_{1}\cap
x_{n+1}\in\left[\lambda_{1};\lambda_{2}\right]\cap\bigcup_{j=n-k+1...n}x_{j}\geq\lambda_{2}\right)d\lambda_{2}d\lambda_{2}\\
& = &
\int_{\lambda_{1}<\lambda_{2}}P\left(x_{n-k}<\lambda_{1}\right)P\left(x_{n+1}\in\left[\lambda_{1};\lambda_{2}\right]\right)\sum_{j=n-k+1...n}P\left(x_{j}\geq\lambda_{2}\right)d\lambda_{2}d\lambda_{2}\\
& = &
\int_{\lambda_{1}<\lambda_{2}}F_{X}\left(\lambda_{1}\right)\left(F_{X}\left(\lambda_{2}\right)-F_{X}\left(\lambda_{1}\right)\right)\sum_{j=n-k+1...n}\left(1-F_{X}\left(\lambda_{2}\right)\right)d\lambda_{2}d\lambda_{2}
\end{eqnarray*}$
But I can not go any further ? Do you have any idea ? Thanks in advance !

Saturday, 17 August 2013

Fibonacci sequence in Java using for statements

Fibonacci sequence in Java using for statements

I tried making a Java program executing the Fibonacci sequence.
Here's my code:
import java.io.*;
public class Fibonacci{
public static void main(String[]args){
BufferedReader Data=new BufferedReader (new
InputStreamReader(System.in));
int ctr1=0;
int ctr2=0;
int num1=0;
int num2=0;
int num3=0;
try{
System.out.println("How many numbers would you want to see?");
ctr2=Integer.parseInt(Data.readLine());
for(int ans=0; ctr1==ctr2; ctr1++){
num1++;
System.out.println(num2 + "\n" + num1);
ans=num1+num2;
System.out.println(ans);
ans=num3;
}
}catch(IOException err){
System.out.println("Error!" + err);
}catch(NumberFormatException err){
System.out.println("Invald Input!");
}
}
}
Obviously, I'm a beginner in Java and I don't know how to properly use the
for statement. Would somebody be kind enough to make my code work? Or
maybe make a way shorter code that works. I'm a beginner so be cool.
Thanks :)

Run Applescript with Growl 2.1 Rules

Run Applescript with Growl 2.1 Rules

Currently, I have a flow set up that results in a file -- 'cb.txt' --
being added to my Dropbox. I get a Growl notification with the Application
Name 'Dropbox' and the Note Title 'cb.txt added'. I want the 'cb.txt
added' notification to run an applescript that will copy the text from
cb.txt to my clipboard. The rules for Growl's notification can be found
here.
Here is the applescript I want to run (when I run it by itself via
Applescript, it successfully adds the contents of cb.txt to the
clipboard):
set the_file to "HardDrive:Users:Me:Dropbox:Folder:cb.txt"
set the_text to (do shell script "cat " & quoted form of (POSIX path of
the_file))
set the clipboard to the_text
I have saved this file to ~/Library/Application
Scripts/com.Growl.GrowlHelperApp as an apple script. I have also saved
another version using this code:
using terms from application "Growl"
on perform action with notification
ignoring case
if notification's app name is Dropbox then
if notification's note title contains "cb.txt added" then
set the_file to "Macintosh
HD:Users:Caleb:Dropbox:Apps:CBApp:cb.txt"
set the_text to (do shell script "cat " & quoted form
of (POSIX path of the_file))
set the clipboard to the_text
end if
end if
end ignoring
end perform action
end using terms from
The previous script does not do anything when run. I have this saved as
Rules.scpt:
using terms from application "Growl"
on evaluate notification with notification
--Rules go in here
--Ultimately return what you want Growl to do with the notification
end evaluate notification
end using terms from
Obviously, I'm a bit stuck. If anybody could give me advice on how to get
my working applescript code to run when I receive a specific Growl
notification, I would appreciate it!

Flot Bar Graph Align Bars with X-Axis Labels

Flot Bar Graph Align Bars with X-Axis Labels

Hello I am trying to plot a bar chart with 31 days data. However when I
plot it, the label for each data is not directly in the center below its
bar, when i set the bars to
align: "center"
, the first bar and last bar gets cut into half.
Here is the jsfiddle: http://jsfiddle.net/3T6qc/
How do I set it so that i see the full bars and have the labels directly
below in the center? Take note that I am using flot as the plotting
library.

Create DetailsView from codebehind

Create DetailsView from codebehind

I'm new to Asp.net and have looked around for how to do this, but haven't
been able to find it.
I would like to create a detailsview entirely from codebehind. This is
because I need certain fields to load based on the user's permissions.
Also, I would like the ability to edit the detailsview to be only
accessible to certain users. Is there a way to do this?

Different types of lists

Different types of lists

Hello I am studying Java and I am just confused about a question that
keeps coming up in my exams.
We are told to use a class for our collections.
Usually in my main class I just make an arraylist of the type I need like
bank accounts or whatever. But I think we are supposed to make a class for
all our data. I tried this and made them static and have the class
abstract because I don't need to make copies of the class itself.
What I want to know is why don't people just make a list type that can do
everything an arraylist and list can do in one, why is there different
types? What are the benifits of having different types? Ps does a
collection just mean a class for all your data?

Google Chrome selects whole column if I want to select a row

Google Chrome selects whole column if I want to select a row

Whenever I try to select a row, Google Chrome select the entire column. If
I press CTRL+C (CMD+C) and CTRL+V (CMD+V), only the row -just as expected-
is copied/inserted.

It works fine on Firefox, Safari and Opera:
You can view a life-example by visiting Metahill and joining as Guest.

Trianlgle homework

Trianlgle homework

The triangle formed by A(-2,-3) , B(1,3) and C(10,k) is roght-angled
triangle at A, find a)the value of k, b)the area of triangle ABC, c)the
length of AM where M is the mid-point of BC.

Friday, 16 August 2013

Qt:exe file not running

Qt:exe file not running

I started using Qt 5.1 with MinGW on Windows 7. I use QtCreator to create
the application in debug mode. When I run the exe of any application as a
standalone it shows the following error...how ever the same application
runs smoothly...I tried setting the environment variable PATH to the bin
of the QTCreator and MinGW bin (which QtCreator uses) I am new to this
windows environment and MinGW.. any suggestions are welcome...

Thursday, 8 August 2013

_com_util::ConvertStringToBSTR - Access Violation

_com_util::ConvertStringToBSTR - Access Violation

I'm invoke COM server's method and randomly get access violation error in
the _com_util::ConvertStringToBSTR:
g_quote->RegisterQuote(_bstr_t(pszTicker), _bstr_t(_T("*")));
More information:
int GetQuotesEx(LPCTSTR pszTicker, int nPeriodicity, int nLastValid, int
nSize, struct Quotation* pQuotes, GQEContext* pContext) {
const RecentInfoMap::const_iterator it = g_mapRecentInfo.find(pszTicker);
if (it == g_mapRecentInfo.end()) {
g_quote->RegisterQuote(_bstr_t(pszTicker), _bstr_t("*"));
return nLastValid + 1;
}
}
I don't know why this bug happens. I can provide additional info if needed.

Salesforce - Custom page for new related list of Custom Object

Salesforce - Custom page for new related list of Custom Object

I have custom objects A and B. The relationship between A & B is set using
a custom object C, with object A & B (master detail) as fields of C.
I have created a custom lookup page to bind object B (to A) which is set
as related list to Object A.
I want to invoke the custom page when I click on New button in the related
list. How can I achieve this?
Thanks.

C# LuaInterface class operators

C# LuaInterface class operators

I'm using LuaInterface in C# and I "exported" some custom C# classes to be
used in Lua. For instance:
local myVector = Vector2(10, 100)
But, when I want to use class operators like in this example:
local v1 = Vector2(1, 1)
local v2 = Vector2(2, 2)
local v3 = v1 + v2
I'm getting the following error: attempt to perform arithmetic on local
'p1' (a userdata value)
The C# variant of the class does have the + operator:
public static cVector2 operator +(cVector2 vector1, cVector2 vector2)
{
return new cVector2(vector1.X + vector2.X, vector1.Y + vector2.Y);
}
I know that you should make use of the Lua metatables and add a function
to "__mul" for the * operator for example. But doesn't LuaInterface does
that automatically? And if not, how could I automate this myself?

fisher exact test for testing ratios of two columns

fisher exact test for testing ratios of two columns

I am trying to see if the ratios of Non_syn_snps to Total_SNps is
significant or not for all 10 chromosomes. Here is the dataframe
Ch Non_Syn Total_Snps ratios
1 A01 4658 23657 0.1968973
2 A02 3347 16685 0.2005993
3 A03 7292 36963 0.1972784
4 A04 2608 13161 0.1981612
5 A05 1883 10665 0.1765588
6 A06 4141 22033 0.1879454
When i tried to do fisher test on the fourth column
fisher.test(data_total[,4])
I am getting this error "Error in fisher.test(test_fish[, 4]) : if 'x' is
not a matrix, 'y' must be given"
I even tried to convert this to matrix and do the same thing but still i
am getting the same error.
Can somebody tell me what i am doing wrong here? Also is it ok to just use
the fourth column for fisher test?
Thanks Upendra

Cannot add or update a child row: a foreign key constraint fails

Cannot add or update a child row: a foreign key constraint fails

I'm trying to use an SQL script to automatically add a schedule to and
from every airport. Here is the code I have so far:
INSERT INTO phpvms_schedules (depicao, arricao, distance)
SELECT
depart.icao,
arrive.icao,
ROUND(GreaterCircleNm(depart.lat,depart.lng,arrive.lat,arrive.lng),2)
as Nm
FROM phpvms_airports AS depart
INNER JOIN phpvms_airports AS arrive ON depart.icao <> arrive.icao
GreaterCircleNm function:
DROP FUNCTION IF EXISTS GreaterCircleNm;
DELIMITER go
CREATE FUNCTION GreaterCircleNm( lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2
FLOAT ) RETURNS float
BEGIN
DECLARE pi, q1, dist FLOAT;
SET pi = PI();
SET lat1 = lat1 * pi / 180;
SET lon1 = lon1 * pi / 180;
SET lat2 = lat2 * pi / 180;
SET lon2 = lon2 * pi / 180;
SET q1 = ACOS(sin(lat1)*sin(lat2)+COS(lat1)*COS(lat2)*COS(lon1-lon2));
SET dist = q1*180*60/pi;
RETURN dist;
END;
go
DELIMITER ;
All in all I really need help fixing this error:
1452 - Cannot add or update a child row: a foreign key constraint fails
(virtu259_phpvms.phpvms_schedules, CONSTRAINT phpvms_schedules_ibfk_1
FOREIGN KEY (code) REFERENCES phpvms_airlines (code) ON UPDATE CASCADE)
phpvms_airports:

phpvms_schedules: