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

how to count in a SQL subquery

how to count in a SQL subquery

I have three tables: Users, Courses, Enrollments. the Enrollments table is
the one that has the foreign keys so I can make Joins, respectively:
users.pk1 = enrollments.u_pk1 and courses.pk1 = enrollments.c_pk1. the
Users table contains both professors and students. so far so good!
What I am trying to do is generate a list of all courses that have in the
name the string 2013, then grab all professors for each course, and
finally get a count of all students in each course from the Enrollment
table which only has the following columns: pk1, c_pk1, u_pk1, role.
this is what I am trying to do but it obviously doesn't work because Count
does not accept sub-queries as an argument:
select c.name, u.name, count(select * from enrollments where role =
'student')
from courses c, users u, enrollments e
where u.pk1 = e.u_pk1 and c.pk1 = e.c_pk1
and c.name like '%2013%' and e.role = 'professor'
order by c.name;
Any hints on how I can make this work the way I want?

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!

Why isn't my pagination code working?

Why isn't my pagination code working?

I have this pagination code and the &pagenum=whatever is showing up
perfectly fine in my URL but it just does absolutely nothing and I really
don't know why. Here is my code:
paginate.php:
<?php
include("config.php");
if (!(isset($pagenum)))
{
$pagenum = 1;
}
$data = mysql_query("SELECT * FROM shop
WHERE MATCH (name,description,keywords) AGAINST ('$search' IN BOOLEAN
MODE)") or die(mysql_error());
$rows = mysql_num_rows($data);
$page_rows = 5;
$last = ceil($rows/$page_rows);
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
?>
search.php:
<?php
include("config.php");
$search = mysql_real_escape_string($_GET['result']);
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<div id="wrapper">
<div class="searchleft">
</div>
<div class="search">
<center>
<form method="get" action="search.php">
<input type="text" name="result" value="<?php echo $search; ?>" />
<input type="submit" />
</form>
<?php
include("paginate.php");
$data_p = mysql_query("SELECT * FROM shop
WHERE MATCH (name,description,keywords) AGAINST ('$search' IN BOOLEAN
MODE) $max") or die(mysql_error());
$num_rows = mysql_num_rows($data_p);
if ($num_rows == "1") {
echo "Returned 1 result.";
} else { echo "Returned ".$num_rows." results."; }
while ($info = mysql_fetch_assoc($data_p)) {
$name = stripslashes($info['name']);
$desc = stripslashes($info['description']);
$desc = substr($desc, 0, 150);
$price = stripslashes($info['price']);
Print "<div style=\"width:600px; height:150px; border:1px solid black;
overflow:hidden\"><div style=\"height:148px; width:25%; border:1px
solid red; float:left\"><center><img src=\"".$picture."\"
height=\"120\" width=\"120\" style=\"margin-top:15px\"
/></center></div><div style=\"height:150px; width:50%; border:1px
solid blue; float:left; text-overflow: ellipsis;
padding-top:5px\"><center><font size=\"+1\"><b><a
href=\"result.php?product=".urlencode($name)."\">".$name."</b></a></font><br><br>".$desc."...</center></div><div
style=\"height:150px; width:24%; border:1px solid green;
float:left\"><center><h1>$".$price."</h1><button>Add to
Cart</button></center></div></div>";
}
echo " --Page $pagenum of $last-- <p>";
if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?result=".$search."&pagenum=1'>
First</a> ";
$previous = $pagenum-1;
echo " <a
href='{$_SERVER['PHP_SELF']}?result=".$search."&pagenum=$previous'>Previous</a>
";
}
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a
href='{$_SERVER['PHP_SELF']}?result=".$search."&pagenum=$next'>Next</a>
";
echo " ";
echo " <a
href='{$_SERVER['PHP_SELF']}?result=".$search."&pagenum=$last'>Last</a>
";
}
?>
I'm honestly stumped.

How to disable editor

How to disable editor

I use django-tinymce to input formatted text. I need to disable whole
field in form and all editor buttons but can't find how. If anyone has
idea about how it can be done, please help.

When are global variables actually considered good/recommended practice?

When are global variables actually considered good/recommended practice?

I've been reading a lot about why global variables are bad and why they
should not be used. And yet most of the commonly used programming
languages support globals in some way.
So my question is what is the reason global variables are still needed, do
they offer some unique and irreplaceable advantage that cannot be
implemented alternatively? Are there any benefits to global addressing
compared to user specified custom indirection to retrieve an object out of
its local scope?
As far as I understand, in modern programming languages, global addressing
comes with the same performance penalty as calculating every offset from a
memory address, whether it is an offset from the beginning of the "global"
user memory or an offset from a this or any other pointer. So in terms of
performance, the user can fake globals in the narrow cases they are needed
using common pointer indirection without losing performance to real global
variables. So what else? Are global variables really needed?

Friday, 30 August 2013

How to build code on local machine while code is on tfs server

How to build code on local machine while code is on tfs server

i am trying to learn how to work with TFS(Team Foundation Server).actually
i have project on tfs and now i wanted to make changes and check whether
it is running perfectly or not.So i tried to run the build but its showing
this error..
Windows phone Emulator was not able to connect Windows Phone Operating
System. The Emulator couldn't determine the host ip address which is used
to communicate with the quest virtual machine. Some functionality may be
disabled.
i am thinking that i have to set some setting but that i don't know. any
help and suggestion is appreciated.

Thursday, 29 August 2013

Is there any easy way within Java to prefix one string onto multiple other strings?

Is there any easy way within Java to prefix one string onto multiple other
strings?

Does anybody know if there is any easy way within Java to prefix one
string onto multiple other strings?
For example, if I have the following snippet of Java code ;
String includeDir = "/usr/local/boost-1.52.0/include";
ArrayList<String> filenamesRelative = new ArrayList<String>(),
filenamesAbsolute = new ArrayList<String>();
filenamesRelative.add("/boost/aligned_storage.hpp");
filenamesRelative.add("/boost/any.hpp");
I would like to be able to prefix the value of the variable 'includeDir',
i.e. "/usr/local/boost-1.52.0/include", onto the front of each value in
the ArrayList filenamesRelative.
Ideally, I would like to be able to do something like the following ;
filenameAbsolute = filenamesRelative.prefixAll(includeDir);
I don't necessarily have to use ArrayLists in the solution; I have just
used them above for illustrative purposes.
From memory, you can do something like this rather easily in C++ using the
STL, however my current working knowledge of Java isn't all that good
unfortunately :(
Thanks in advance for any assistance.

Qt animation without Animation Framework

Qt animation without Animation Framework

I need to update QPixmap 1024x128, 30...60 times a second and i don't want
to use Animation Framework - i think is overkill for this purpose. So, any
ideas?
Should i use QTimer with 30...60 ticks per second (TPS) and call update()
in timer SLOT? But QTimer is not syncronized with actual screen updates
and QTimer is inaccurate. My QTimer rate may be too low (not smooth
picture) or too high (eat too much CPU) - how to find good one? My
experiment showed that i need different QTimer interval for my linux and
windows machines to get smooth update: linux: 30 TPS, windows: 50...60 TPS
(when i set 1000/30 msec interval for windows, i see rugged motion).

Wednesday, 28 August 2013

Arrays and input

Arrays and input

My assignment asks me to write a program that will let the user input 10
players' name, age, position, and batting average. The program should then
check and display statistics of only those players who are under 25 years
old and have a batting average of .280 or better, then display them in
order of age.
I've written my code for the input section (where it'll store them in an
array):
static int players[] = new int [10];
static String name[] = new String [10];
static double average [] = new double [10];
static int age[] = new int [10];
static String position[] = new String [10];
//method to input names of Blue Jays
public static void inputInfo() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < players.length; i++)
{
System.out.println("Enter player information.");
System.out.println("Input first and last name: ");
name [i] = br.readLine();
System.out.println("Input position: ");
position[i] = br.readLine();
System.out.println("Input batting average (e.g. .246): ");
String averageString = br.readLine();
average [i] = Double.parseDouble(averageString);
System.out.println("Input age: ");
age[i] = br.read();
System.out.println(" ");
}
}
My problem is the input. For the first player I input it shows me this (as
it should):
Input first and last name:
John Smith
Input position:
pitcher
Input batting average (e.g. .246):
.300
Input age:
27
But my second input skips the name section completely and jumps to the
position input. I can't really figure out why it's doing this! Can anyone
help me out? Thanks in advance!

How do I get geolocation to return to a variable in jquery?

How do I get geolocation to return to a variable in jquery?

below is some rough code I'm working on. All I'm trying to do, right now
is return the var geoOutput so I can store it and use it for later. In the
example it should alert the city and state. I works if I alert from within
the success but returns as undefined when outside the geolocation
function.
$(function(){
var geoOutput;
var geoGet;
function getGeoLocation(geoType,displayType){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(geoSuccess,
geoError);
}
else {
$('.your-location').remove();
}
function geoSuccess(position) {
console.log(position.coords.latitude+',
'+position.coords.longitude);
var geoCoder = new google.maps.Geocoder();
var userLocation = new
google.maps.LatLng(position.coords.latitude,position.coords.longitude);
geoCoder.geocode({'latLng':userLocation},
function(results,status){
if (status == google.maps.GeocoderStatus.OK) {
if (results) {
if(geoType == "zip") {
geoOutput =
results[2].address_components[0].long_name;
}
if(geoType == "state") {
geoOutput =
results[6].address_components[0].long_name;
}
if(geoType == "city") {
geoOutput =
results[3].address_components[0].long_name;
}
if(geoType == "cityState") {
geoOutput =
results[3].address_components[0].long_name+",
"+results[6].address_components[0].long_name;
}
if(geoType == "coords") {
geoOutput =
position.coords.latitude+","+position.coords.longitude;
}
if(geoType == "longitude") {
geoOutput = position.coords.longitude;
}
if(geoType == "latitude") {
geoOutput = position.coords.latitude;
}
if(displayType)
$('.your-location').text(geoOutput);
return geoOutput;
} else {
console.log('Google did not return any results.');
$('.your-location').remove();
}
} else {
console.log("Reverse Geocoding failed due to: " +
status);
$('.your-location').remove();
}
});
}
function geoError(err) {
if (err.code == 1) {
//console.log('The user denied the request for location
information.');
$('.your-location').text('State Not Found');
} else if (err.code == 2) {
//console.log('Your location information is unavailable.');
$('.your-location').remove();
} else if (err.code == 3) {
//console.log('The request to get your location timed out.');
$('.your-location').remove();
} else {
//console.log('An unknown error occurred while requesting
your location.');
$('.your-location').remove();
}
}
}
alert(getGeoLocation("cityState",false));
});

ASP.NET MVC 4 switch resource file via url parameter

ASP.NET MVC 4 switch resource file via url parameter

I am new at working with resource files and I haven't quite got how it
works yet. Now I need to have my application's text available in English
and in Chinese. I will receive a get parameter (e.g. lang) and from there
I will need to decide whether to use Language.zh.resx or my default
Language.resx - That's what I understood from articles that I have been
reading. Now I have my View Title for example:
@{
ViewBag.Title =
MyApplication.App_GlobalResources.Language.MyPage_Title;
}
I can't figure out where to check the parameter lang and apply it. I saw
articles where people say I should create an action filter and they add
stuff to cookies and they were confusing. In my case it might not be
necessary as it just has one request, there is no requirement for
preserving the state as once the page is loaded that's it.
If someone could also give some brief explanation of how resources work
that would be nice, thanks!

How to select dynamic image from Gallery View in JQuery

How to select dynamic image from Gallery View in JQuery

Hello all I am newbie on jQuery and i am working on one application, I
need to select an image from Galary View in JQuery. I tried doing this
code.
// I need to set image dynamically so i am taking ImageIndex as a parameter.
function OpenImageGallery(sImageIndex) {
$('#myGallery').galleryView();
$(function () {
$("#Divgallery").dialog(
{
width: 840,
height: 520,
title: 'Hotel Image Gallery'
}
).parent().appendTo(jQuery("form:first"));
});
}
but here i am facing one issue is it is showing only default image and not
dynamic whose Index i am passing to function.
Please help me friends.

Remote control a Cybershot DSC-WX300 camera via WiFi (has in PlayMemories)

Remote control a Cybershot DSC-WX300 camera via WiFi (has in PlayMemories)

I'm developing a 360 degrees photo device using a Cybershot DSC-WX300 that
has remote capabilities via wifi, has in sony's app PlayMemories, and need
information on how to remote control the camera via wifi. Protocols,
libraries or any kind of information would be helpful the electronics are
actually very simple and I've got it allready covered, now i just need to
comunicate with the camera to order the shot, control the zoom and receive
the images. Best regards, Filipe Batista

Op-Amp input question – electronics.stackexchange.com

Op-Amp input question – electronics.stackexchange.com

I'm self-taught in electronics and while I can do the digital stuff fairly
readily, analog throws me for a loop. I'm looking at an audio CODEC and
the reference schematic has this on the input to the …

Tuesday, 27 August 2013

SUPER privilege(s) for this operation

SUPER privilege(s) for this operation

I create my database and user navid in my shared server with cpanel
(databases -> mySQL@ Databases -> add new user),and then selected ALL
PRIVILEGES for user navid. I was importing mydatabase.sql when I was
confronted with this error. how do i fix the error?
Error
SQL query:
DELIMITER $$--
-- Procedures
--
CREATE DEFINER = `navid`@`%` PROCEDURE `d_answer` ( OUT `sp_out` INT( 11 )
, IN `sp_id` INT( 11 ) ) NO SQL BEGIN DELETE FROM `tblname` WHERE `a_id` =
sp_id;
SET sp_out = ROW_COUNT( ) ;
END$$
MySQL said: Documentation
#1227 - Access denied; you need (at least one of) the SUPER privilege(s)
for this operation

tSQL While looping same table on 2 fields

tSQL While looping same table on 2 fields

I am trying to add incremental counting to 2 separate columns.
I have FieldA and FieldB in the same table and need to increment as in
this example:
FieldA ID1 FieldB ID2
ABC 1 GREEN 2
ABC 1 RED 3
ABC 1 Yellow 4
XYZ 5 RED 6
DEF 7 GREEN 8
DEF 7 BLUE 9
Where no number is duplicated except for FieldA and FieldA will increment
depending on the last of FIELDB.

VS 2013 Preview allows to call free functions using curly braces

VS 2013 Preview allows to call free functions using curly braces

To my surprise VS 2013 compiled this without a error:
#include <utility>
auto main() -> int {
auto p = std::make_pair{123, 12.3f};
return 0;
}
Is this some new feature or what? Probably a bug...

How does one view the terminal (tty) output externally? (Not a new ssh session, but what is currently going on)

How does one view the terminal (tty) output externally? (Not a new ssh
session, but what is currently going on)

Basically I've set up a few Raspberry Pis running different programmes,
and I'd like to see what is being outputted on them. I can obviously
connect via SSH, but that's a new tty session. Tried googling it, but I
think my terminology is a little odd!

Detect element tag name by its class

Detect element tag name by its class

I would like to know if there is a way to get the name of a element by its
class or id.
for exemple <input class="some-class" type="text" /> returns "input"
Thanks.

Monday, 26 August 2013

make interactive text area on top of canvas

make interactive text area on top of canvas

I want to draw Interactive text area on canvas .Normaly , using id and
classes we can change div css property but with canvas how can i achieve
same functionality .
i want to write text on top of canvas which should change on change event
of some text area.i wish to use menu bar to achieve functionality like
change font-color,font-size,font-family etc .
with div id and class i can change css but on canvas how can i achieve
this?? please suggest ?

Struggling - I need to copy specific data from outlook email into excel (html)

Struggling - I need to copy specific data from outlook email into excel
(html)

First I want to apologize as I know there have been some posts on here
about getting data out of outlook and into excel; however, I have tried
for days to alter the samples I found but have not had any luck.
My goal, I think is fairly simple. I am a network engineer who receives
automated emails from our WAN carrier and need to take specific data out
of those emails and put that data into excel. The emails from the carrier
come in html format which I suspect might be one reason I am having so
much trouble. At the bottom of this post is a of an email and I need the
vbscript to read and capture the follow data listed below and then put the
data into seperate fields in excel as follows:
Any help will be greatly appreciated!
Company name: MR COMPANY Request number: 1323656 Event ID: 12345678
Maintenance location: HOLLYWOOD, STATE, UNITED STATES Maintenance window
local: Sep 8 2013 00:01 EDT - Sep 8 2013 06:00 EDT Maintenance window GMT:
Sep 8 2013 04:01 GMT - Sep 8 2013 10:00 GMT
Outage duration: 10 Minutes
Duration: 2 X 10 Minutes
Circuit ID BCBKDDRFL0003
COPY OF EMAIL
Sent: Thursday, August 22, 2013 6:54 PM Subject: Verizon Scheduled
Maintenance Notification - R-123456 / E-12345678 Location: HOLLYWOOD,
CALIFORNIA, UNITED STATES



ENGLISH



Verizon Maintenance Notification
Dear Verizon Customer,
We would like to inform you that maintenance work needs to be carried out
on the Verizon network. Company name: MR COMPANY Request number: 1323656
Event ID: 12345678 Maintenance location: HOLLYWOOD, STATE, UNITED STATES
Maintenance window local: Sep 8 2013 00:01 EDT - Sep 8 2013 06:00 EDT
Maintenance window GMT: Sep 8 2013 04:01 GMT - Sep 8 2013 10:00 GMT
Outage duration: 10 Minutes



Outage Duration greater than 50 milliseconds – Customer Affecting
Outage Duration 50 milliseconds or less – Switch Hits – Non Customer
Affecting



Description of Maintenance:
We will be performing scheduled software maintenance on the network to
provide improved network reliability.
Duration: 2 X 10 Minutes
Company Name Circuit ID A Location Billing ID Expected Outage Window



MR COMPANY BCBKDDRFL0003 HOLLYWOOD, CA 456789 7:00 GMT - 9:00 GMT 7:00 GMT
- 9:00 GMT



We appreciate your cooperation and understanding.
If you have questions regarding this maintenance event, please contact the
Verizon Global Event Notification Center,
United States and Canada Standard Time
EST Eastern Standard Time (GMT -5 hours) CST Central Standard Time (GMT -6
hours) MST Mountain Standard Time (GMT -7 hours) PST Pacific Standard Time
(GMT -8 hours)
EDT Eastern Daylight Time (GMT -4 hours) CDT Central Daylight Time (GMT -5
hours) MDT Mountain Daylight Time (GMT -6 hours) PDT Pacific Daylight Time
(GMT -7 hours)

Query All Tables For All Fields Containing Value

Query All Tables For All Fields Containing Value

So I'm trying to figure out where this value is stored in this database.
Is there a way to query across all tables in the database and return all
rows that contain a certain value where the field name that would contain
that certain value is unknown?
For example:
select * from * where unknown_field_name = 'x'

Image behind text

Image behind text

I want to display an image behind an H1 tag, I also want the image width
to stretch to the same width as the text.
My code:
<div style="display: inline;">
<img src="http://img585.imageshack.us/img585/3989/m744.png"
width="100%" height="68" />
<h1 style="position: absolute; top: 0px;">Variable length text</h1>
</div>
JSFiddle: http://jsfiddle.net/Aykng/
Current Appearance:

Desired Appearance:

The image width should either stretch or shrink to fill the div, how can I
achieve this?
I want it to be compatible with IE 7+, otherwise I would just use
background-image and background-size.

Advantages of Constructor Overloading

Advantages of Constructor Overloading

I am very new to Java and trying to learn the subject, having previous
programming exposure in only HTML/CSS. I have started with Herbert Schildt
and progressed through a few pages.
I am unable to understand the exact advantages of Constructor Overloading.
Isn't it easier to Overload Methods using single constructor for
flexibility? Moreover if I am trying to use constructor overloading to use
one object to initialize another, there are simpler ways to do it! So what
are the benefits and in which situation should I use Constructor
Overloading.

How to set position of a dynamic body in andengine?

How to set position of a dynamic body in andengine?

I'm developing a game using Box2D. I have to move ball according to
accelerometer. I have created a body n connected ballsprite to it. I'm
moving body using setLinearVelocity(). once the ball reaches the
boundaries of screen,i want to stop the movement of ball at the edge of
the screen. How do i do this?
public void onAccelerationChanged(AccelerationData arg0) {
ballBody.setLinearVelocity(arg0.getX(), 0);
}

Sunday, 25 August 2013

Working with NSDateFormatter

Working with NSDateFormatter

Currently, I am attempting to format an NSDate string.
2013-08-25 22:54:00.500 MYSCHEDULER[23153:c07] 9:00 PM
2013-08-25 22:54:00.501 MYSCHEDULER[23153:c07] 2013-08-10 04:00:00 +0000
Here's the code I use:
- (NSString *)monthFormatter:(NSDate *)date
{
static NSDateFormatter *dateFormat = nil;
if (nil == dateFormat) {
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"h:mm a"];
}
return [dateFormat stringFromDate:date];
}
What I would like to do is create a date formatter that takes out
appending 0s.
So I have a time like 9:00 PM and I would like to convert the time to 9
PM. Is there a way this can be accomplished with a NSDateFormatter?
I attempted to do this : [dateFormat setDateFormat:@"h:m a"]; but it just
made the date show up like so : 9:0 PM
Anyone have any ideas?
EDIT
Also, I understand I could write:
[dateFormat setDateFormat:@"h a"];
and that would satify this case but for the case of maybe 9:30 PM, what
would need to be done? Maybe a checker within the dateformatter method?
But I figure Apple has already implemented this case.

Find vertices in equilateral triangle mesh originating from a center vertex

Find vertices in equilateral triangle mesh originating from a center vertex

I'd like to ask whether there is code out there or if you can give me some
help in writing some (C#, but I guess the maths is the same everywhere).
I'd like to specify a center point from which an equilateral triangle mesh
is created and get the vertex points of these triangles. The center point
should not be a face center, but a vertex itself. A further input would be
the size of the triangles (i.e side length) and a radius to which triangle
vertices are generated.
The reason behind it is that I want to create a mesh which is centered
nicely on the screen/window center with as little code as possible. I just
find mesh generation code, but not a "radial outward propagation" example.
In the end, I'd like to have the subsequently farther away vertices being
displaced in a logarithmic fashion, but I guess that's just an easy
addition once the mesh code is there.
Can anybody help me with that? Thanks!

[ Comics & Animation ] Open Question : Where can one LEGALLY watch anime in India?

[ Comics & Animation ] Open Question : Where can one LEGALLY watch anime
in India?

anyone know where I can get to legally watch anime in India? even in the
from of Pay-to-Watch or Subscription sites.

Javascript click doesn't work

Javascript click doesn't work

I'm simply trying to figure out how to automatically click the login
button. Nothing I've tried works.
https://www.24option.com/
I've tried:
$("#loginButton").click()
$(".gwt-PushButton.loginButton.gwt-PushButton-up").click()
I've also tried using a few "click simulators" via javascript. Those
didn't work either.
Any ideas how to just get the button to click via JS?

how to programically check current week is first week of month

how to programically check current week is first week of month

how toget the first monday of week??? im creating an school app which
display lunch for semester which start from 1st jully 2013 which is monday
so its prsent frist week of month another menu and give second week of
month another menu so first week of month its show Monday1,
tuesday1,wednesday1,thursday1,friday1, second week of month i will lik to
check monday2,tuesday2, wednesday2,thursday2,friday2, below is my calender
how i will modify this code to detect it is frist week of month this is
secon week of month in thirdweek again values will change to m1.t1,w1,t,1
actully lunch is provide for 2 week and rechudule again so how i will
detect programiclally current week is first week of month and current week
is second week of month
public class HoyahCalendar extends Activity {
public static int mYear;
public static int currentIndex = -1;
public static int mMonth;
public static int mDay;
public static String[][] a = new String[6][7];
String January="January";
String February="February";
String March="March";
String April="April";
String May="May";
String June="June";
String Jully="Jully";
String August="August";
String September="September";
String October="October";
String November="November";
String December="December";
String Monthname;
TextView date_today;
ImageView last_month;
ImageView next_month;
ImageView last_week;
ImageView next_week;
String completedate2;
Date dt1;
Button e00;
Button e01;
Button e02;
Button e03;
Button e04;
Button e05;
Button e06;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getIntent().setAction("Already created");
date_today = (TextView) findViewById(R.id.date_today);
last_month = (ImageView) findViewById(R.id.last_month);
next_month = (ImageView) findViewById(R.id.next_month);
last_week = (ImageView) findViewById(R.id.last_week);
next_week = (ImageView) findViewById(R.id.next_week);
//
// e00 = (TextView) findViewById(R.id.e00);
// e01 = (TextView) findViewById(R.id.e01);
// e02 = (TextView) findViewById(R.id.e02);
// e03 = (TextView) findViewById(R.id.e03);
// e04 = (TextView) findViewById(R.id.e04);
// e05 = (TextView) findViewById(R.id.e05);
// e06 = (TextView) findViewById(R.id.e06);
e00 = (Button) findViewById(R.id.e00);
e01 = (Button) findViewById(R.id.e01);
e02 = (Button) findViewById(R.id.e02);
e03 = (Button) findViewById(R.id.e03);
e04 = (Button) findViewById(R.id.e04);
e05 = (Button) findViewById(R.id.e05);
e06 = (Button) findViewById(R.id.e06);
Calendar mCalendar = Calendar.getInstance();
mYear = mCalendar.get(Calendar.YEAR);
mMonth = mCalendar.get(Calendar.MONTH) + 1;
mDay = mCalendar.get(Calendar.DAY_OF_MONTH);
// / setListeners();
last_month.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 1) {
mYear -= 1;
mMonth = 12;
new ShowCalendar(mYear, mMonth, 1);
showOnScreen();
} else {
mMonth -= 1;
new ShowCalendar(mYear, mMonth, 1);
showOnScreen();
}
}
});
next_month.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 12) {
mYear += 1;
mMonth = 1;
new ShowCalendar(mYear, mMonth, 1);
showOnScreen();
} else {
mMonth += 1;
new ShowCalendar(mYear, mMonth, 1);
showOnScreen();
}
}
});
last_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 1) {
mYear -= 1;
mMonth = 12;
new ShowCalendar(mYear, mMonth, mDay, "last");
showOnScreen();
} else {
// mMonth -= 1;
new ShowCalendar(mYear, mMonth, mDay, "last");
showOnScreen();
}
}
});
next_week.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mMonth == 12) {
mYear += 1;
mMonth = 1;
new ShowCalendar(mYear, mMonth, mDay, "next");
showOnScreen();
} else {
if (HoyahCalendar.currentIndex == 4) {
HoyahCalendar.currentIndex = 4;
// mMonth += 1;
}
new ShowCalendar(mYear, mMonth, mDay, "next");
showOnScreen();
}
}
});
new ShowCalendar(mYear, mMonth);
showOnScreen();
completedate2= String.format("%02d", mDay)+ "/"+String.format("%02d",
mMonth) +"/"+mYear;
String input_date=completedate2;
SimpleDateFormat format1=new SimpleDateFormat("dd/MM/yyyy");
try {
dt1 = format1.parse(input_date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SimpleDateFormat format2=new SimpleDateFormat("EEEE");
String finalDay=format2.format(dt1);
Toast.makeText(this, "Today is is"+ finalDay,
Toast.LENGTH_SHORT).show();
}
public void showOnScreen() {
if (mMonth ==1)
{
Monthname="January";
}
else
if (mMonth ==2) {
Monthname="February";
}
else
if (mMonth ==3) { Monthname="March";}
else
if (mMonth ==4) { Monthname="April"; }
else
if (mMonth ==5) { Monthname="May";}
else
if (mMonth ==6) { Monthname="June"; }
else
if (mMonth ==7) { Monthname="July";}
else
if (mMonth ==8) { Monthname="August"; }
else
if (mMonth ==9) { Monthname="September";}
else
if (mMonth ==10) { Monthname="October"; }
if (mMonth ==11) { Monthname="November";}
else
if (mMonth ==12) { Monthname="December"; }
date_today.setText( Monthname + " " +mYear);
e00.setText("" + a[0][0]);
if(e00.getText().toString().equals(String.valueOf(mDay)))
// if(e00.getText().toString().equals(mDay))
{e00.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button1 text equals!", Toast.LENGTH_SHORT).show();
}
e01.setText("" + a[0][1]);
if(e01.getText().toString().equals(String.valueOf(mDay)))
{
e01.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button2 text equals!", Toast.LENGTH_SHORT).show();
}
e02.setText("" + a[0][2]);
if(e02.getText().toString().equals(String.valueOf(mDay)))
{e02.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button3 text equals!", Toast.LENGTH_SHORT).show();
}
e03.setText("" + a[0][3]);
if(e03.getText().toString().equals(String.valueOf(mDay)))
{e03.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button4 text equals!", Toast.LENGTH_SHORT).show();
}
e04.setText("" + a[0][4]);
if(e04.getText().toString().equals(String.valueOf(mDay)))
{e04.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button5 text equals!", Toast.LENGTH_SHORT).show();
}
e05.setText("" + a[0][5]);
if(e05.getText().toString().equals(String.valueOf(mDay)))
{e05.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button6 text equals!", Toast.LENGTH_SHORT).show();
}
e06.setText("" + a[0][6]);
if(e06.getText().toString().equals(String.valueOf(mDay)))
{e06.setTextColor(Color.parseColor("#FFBBFF"));
Toast.makeText(this, "Button7 text equals!", Toast.LENGTH_SHORT).show();
}
}
public class ShowCalendar {
int mYear;
int mMonth;
int mDay;
public ShowCalendar(int mYear, int mMonth){
this.mYear = mYear;
this.mMonth = mMonth;
calculateMonthFirstday();
}
public ShowCalendar(int mYear, int mMonth, int mDay){
this.mYear = mYear;
this.mMonth = mMonth;
HoyahCalendar.currentIndex = 0;
this.mDay = mDay;
calculateMonthFirstday();
}
public int getmDay() {
return mDay;
}
public void setmDay(int mDay) {
this.mDay = mDay;
}
public ShowCalendar(int mYear, int mMonth, int mDay, String time){
this.mYear = mYear;
this.mMonth = mMonth;
if (time == "next"){
HoyahCalendar.currentIndex++;
if (HoyahCalendar.currentIndex == 5){
HoyahCalendar.currentIndex--;
}
this.mDay = mDay + 7;
} else if (time == "last"){
HoyahCalendar.currentIndex--;
if (HoyahCalendar.currentIndex == -1){
HoyahCalendar.currentIndex++;
}
this.mDay = mDay - 7;
}
calculateMonthFirstday();
}
public void calculateMonthFirstday(){
int month, first_day=0;
if((mYear%4==0 && mYear%100!=0)||(mYear%400==0))
month=1;
else
month=0;
int y, y12, c, c12, m, d;
y = mYear%100;
y12 = (mYear-1)%100; //only for January and February
c = mYear/100;
c12 = (mYear-1)/100;
m = mMonth;
d = 1;
switch(mMonth){
case 1: {first_day = y12 + y12/4 +c12/4 - 2*c12 + 26*(13 + 1)/10 + d -
1;break;}
case 2: {first_day = y12 + y12/4 +c12/4 - 2*c12 + 26*(14 + 1)/10 + d -
1;break;}
case 3: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 4: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 5: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 6: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 7: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 8: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 9: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 10: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 11: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
case 12: {first_day = y + y/4 +c/4 - 2*c + 26*(m + 1)/10 + d - 1;break;}
}
if(first_day<0)
first_day = 7 - (Math.abs(first_day))%7;//first_dayÿÔµÚÒ»ÌìÐÇÆÚ¼¸
else
first_day = first_day%7;
switch(mMonth){
case 1: {CalculateCalendar(1,first_day,31);break;}
case 2: {CalculateCalendar(2,first_day,28+month);break;}
case 3: {CalculateCalendar(3,first_day,31);break;}
case 4: {CalculateCalendar(4,first_day,30);break;}
case 5: {CalculateCalendar(5,first_day,31);break;}
case 6: {CalculateCalendar(6,first_day,30);break;}
case 7: {CalculateCalendar(7,first_day,31);break;}
case 8: {CalculateCalendar(8,first_day,31);break;}
case 9: {CalculateCalendar(9,first_day,30);break;}
case 10:{CalculateCalendar(10,first_day,31);break;}
case 11:{CalculateCalendar(11,first_day,30);break;}
case 12:{CalculateCalendar(12,first_day,31);break;}
}
}
public void CalculateCalendar(int month_no, int week_no, int month_days){
int i, s, targetRow = 0;
int currentDay;
if (this.mDay == 0){
mDay = 1;
currentDay= HoyahCalendar.mDay;
}else {
currentDay = this.mDay;
}
//String[][] a = new String[6][7];
for (i=0;i<week_no;i++)
HoyahCalendar.a[i/7][i%7] = "";
for(i=week_no; i<week_no + month_days; i++){
s = i - week_no + 1;
HoyahCalendar.a[i/7][i%7] = String.valueOf(s);
if (s == currentDay && HoyahCalendar.currentIndex == -1){
HoyahCalendar.currentIndex = i/7;
}
}
for (i=0; i<7;i++){
if (HoyahCalendar.a[HoyahCalendar.currentIndex][i] == null){
HoyahCalendar.a[0][i] = "";
}else{
HoyahCalendar.a[0][i] =
HoyahCalendar.a[HoyahCalendar.currentIndex][i];
}
}
for(i=week_no+month_days; i<42; i++)
HoyahCalendar.a[i/7][i%7] = "";
}
}

sending emails using swiftmaier and postfix

sending emails using swiftmaier and postfix

I use postfix as my MTA on my VM runing ubuntu server and swiftmailer as
my mailer library there are two methods to set postfix as transport in
swiftmailer
$transport = Swift_SmtpTransport::newInstance('localhost', 587);
and the second
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/postfix -bs');
which one is preferred or more secure?

Saturday, 24 August 2013

The page is not redirecting properly using header in php

The page is not redirecting properly using header in php

I don't know what is problem in the header location part,but there is some
error due to which page gets infinite redirecting and stops after
sometime.Here is my code,when i select a pic so that it should redirect to
the facebook make cover or make profile page,but instead it keeps
redirecting with a loop.
<?php
include_once("inc/facebook.php"); //include facebook api library
######### edit details ##########
$appId = ''; //Facebook App ID
$appSecret = ''; // Facebook App Secret
$return_url = 'http://www.mysite.com/testing/process.php'; //return url
(url to script)
$homeurl = 'http://www.mysite.com/testing'; //return to home
$fbPermissions = 'publish_stream,user_photos'; //Required facebook
permissions
##################################
$GetPicId = $_GET["pid"]; // Picture ID from Index page
$PicLocation ='';
/*
Users do not need to know original location of image.
I think it's better to get image location from database using ID.
for demo here i'am using PHP switch.
*/
switch($GetPicId)
{
case 1:
$PicLocation = 'cover_pics/cover1.jpg';
break;
case 2:
$PicLocation = 'cover_pics/cover2.jpg';
break;
case 3:
$PicLocation = 'cover_pics/cover3.jpg';
break;
default:
header('Location: ' . $homeurl);
break;
}
//Call Facebook API
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $appSecret,
'fileUpload' => true,
'cookie' => true
));
//get user
$fbuser = $facebook->getUser();
$access_token = $facebook->getAccessToken();
//variables we are going to post to facebook
$msg_body = array(
'access_token' => $access_token,
'message' => 'I liked this pic from '. $homeurl .' it is perfect for my
cover photo.',
'source' => '@'.realpath($PicLocation)
);
if ($fbuser){ //user is logged in to facebook, post our image
try {
$uploadPhoto = $facebook->api('/me/photos', 'post', $msg_body );
} catch (FacebookApiException $e) {
echo $e->getMessage(); //output any error
}
}else{
$loginUrl =
$facebook->getLoginUrl(array('scope'=>$fbPermissions,'return_url'=>$return_url));
header('Location: ' . $loginUrl);
}
if($uploadPhoto)
{
/*
image is posted in user facebook account, but still we need to send user
to facebook
so s/he can set cover or profile picture!
*/
//Get url of the picture just uploaded in user facebook account
$jsonurl =
"https://graph.facebook.com/".$uploadPhoto["id"]."&?access_token=".$access_token;
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
/*
We can not set facebook cover or profile picture automatically yet,
So, the trick is to post picture into user facebook account first
and then redirect them to a facebook profile page where they just have to
click a button to set it.
*/
echo '<html><head><title>Update Image</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
echo '<link href="style.css" rel="stylesheet" type="text/css" />';
echo '</head><body>';
echo '<div align="center" class="fbpicwrapper">';
echo '<h1>Image is sent to your facebook account!</h1>';
echo '<div class="fbpic_desc">Click on desired button you want to do with
this image!</div>';
echo '<div class="option_img"><img src="'.$json_output->source.'" /></div>';
/*
Links (buttons) below will send user to facebook page,
where they just need to crop or correct propertion of image and hit apply
button.
*/
echo '<a class="button" target="_blank"
href="http://www.facebook.com/profile.php?preview_cover='.$uploadPhoto["id"].'">Make
Your Profile Cover</a>';
echo '<a class="button" target="_blank"
href="http://www.facebook.com/photo.php?fbid='.$uploadPhoto["id"].'&type=1&makeprofile=1&makeuserprofile=1">Make
Your Profile Picture</a>';
echo '<a class="button" href="'.$homeurl.'">Back to main Page.</a>';
echo '</div>';
echo '</body></html>';
}
?>

SQL Sort by based off of CASE - Not working

SQL Sort by based off of CASE - Not working

Not sure why this isn't working:
ORDER BY a.QuestionTitle
When by itself it works. But below, if SortBy is equal to 4...
ORDER BY
CASE WHEN (@SortBy = 1) THEN a.Date_Created
WHEN (@SortBy = 2) THEN a.Date_Created
WHEN (@SortBy = 3) THEN a.Date_Created
WHEN (@SortBy = 4) THEN a.QuestionTitle
END DESC
I get this error: Conversion failed when converting date and/or time from
character string.
Thank you very much in advance for your help.

how to do the following effect in jquery or css etc

how to do the following effect in jquery or css etc

http://www.ptc-investigation.com/default.aspx
As shown in the website how to do this effect on mouse over on recent
payment proofs images. it goes large and not disturb any thing. thanks

how to make sure that N+1 argument is present when Nth argument is equal to "--check"

how to make sure that N+1 argument is present when Nth argument is equal
to "--check"

I am trying to write code to check if any argument (on position N) is
equal to "--check" and, if its true, require that next argument (position
N+1) is present. Otherwise, exit.
How can i achieve that?
i am trying sth like this but it doesnt seem to work: i am reiterating
arguments and if "--check" is found then setting FLAG to 1 which triggers
another conditional check for nextArg:
FLAG=0
for i in "$@"; do
if [ $FLAG == 1 ] ; then
nextARG="$i"
FLAG=0
fi
if [ "$i" == "--check" ] ; then
FLAG=1
fi
done
if [ ! -e $nextARG ] ; then
echo "nextARG not found"
exit 0
fi

kali linux not working?

kali linux not working?

OK, so I installed kali linux. It asked me for a hostname, I typed Kali,
then for a domain name I typed website.com and then for password.
now when I try to login what do I type, because nothing seems to work

How to implement accessibility for ALAsset photos on iOS

How to implement accessibility for ALAsset photos on iOS

I wrote a custom image picker based on ALAssetsLibrary, everything works
fine but VoiceOver, every photo are only representing as "Button", I think
that is not good.
So I checked the Photo app that built in iOS, VoiceOver spoke following
information for each photo:
It's photo or video or screenshot etc.
It's portrait or landscape.
The creation date of it.
It's sharp or blurry.
It's bright or dark.
I think I can get the first three from ALAsset's properties, which is
ALAssetPropertyType
ALAssetPropertyOrientation
ALAssetPropertyDate
But how about sharpness and brightness? Can I get them from image Metadata
or derive them out?

jquery clone an html structure with out text content

jquery clone an html structure with out text content

every one. please help me.
how to clone an html structure ( with tables and input field ) without its
input content.
this is my html code
<div class="clone_wrapp">
<div class="clone_table">
<div class="two_column_table">
<table>
<tr><td>Name of officer-in-charge</td></tr>
<tr><td><input type="text"></td></tr>
<tr><td>Contact No</td></tr>
<tr><td><input type="text"></td></tr>
</table>
</div> <!-- two_column_table -->
<div class="two_column_table">
<table>
<tr>
<td>Address</td>
<td><textarea></textarea></td>
</tr>
</table>
</div> <!-- two_column_table -->
</div> <!-- clone_table -->
</div> <!-- cloned wrapp -->
<div class="add_more_field">ADD MORE</div>
and this is my jquery
$('.add_more_field').click(function(){
var cloned_structure= $('.clone_table').clone();
$('.clone_wrapp').append(cloned_structure);
});
the code is working but it will append along with input content
thanks

Questions About DRBD

Questions About DRBD

Backround: We are in need of a HA server in a small office environment and
are looking at DRBD to provide it. We only have about 100GB that needs to
be on the HA server and server load will be extremely low. The data will
probably increase about 10%-25% per year if we archive older office data,
and 50%-75% each year if we don't.
Point is we use a mix of consumer grade and used enterprise grade hardware
which WILL be a problem if we don't preemptively plan for it; and
pre-built quality servers DO fail, so redundant servers seems like the way
to go.
The Plan: We are thinking it would be good to find (2) of the best
bang-for-our-buck used servers and synchronize them. We simply need
SATA/SAS capable servers and space for as many drives as can be had for
the price. These servers seem like they can be had for $100-$200 (+some
parts and additional drives) if you catch a deal.
This would theoretically mean a server could fail and if we took days to
get to it, as long as we didn't have another coincidental failure, things
would still hum along until our IT department (me) could get to it. We
would use Debian as an OS.
Some Questions
(A) How does DRBD handle drive or controller failure? That is This shows
DRBD before the storage driver, so what happens when the controller fails
and writes dirty data or the drive fails but doesn't crash immediately? Is
the data mirrored to the other server or not and is there risk of data
corruption across servers in cases like these?
(B) What are the fail points for DRBD; that is theoretically as long as
one server is up and running there are no issues EVER. But we know that
there are issues so what are the fail modes using DRBD since most of them
should theoretically be software?
If we are going to have two servers for this, would it be reasonable to
run VM's on each with MYSQL and Apache for database and web server
replication? (I am assuming so)
Is DRBD reliable enough? If not, is the unreliability isolated to certain
tasks, or is it more random. Searching turned up people with various issue
but this IS the internet with seemingly more bad info than good.
If data is being synchronized over LAN, does DRBD use double the
bandwidth? That is, should we double up on NICS and do some link
aggregation and trunking? Then maybe put them on separate routers on
separate circuits and UPS's in separate rooms and now you really have some
redundancy!
Is this too crazy for an office in terms of server management? Is there a
simpler REALTIME alternative (granted DRBD seems simple in theory).
We already have a server. So it seems to me a second USED server with a
dedicated drive for DRBD could easily be had for around $150-$250 with
some smart shopping. Add a second router, more drives, more NIC's (Used),
and (2) UPS's and were talking $1,000 +/-. That is relatively cheap! And I
am hoping this would mainly buy us time during a server fault. Drive
failures seem like the easier thing to handle with RAID these days. It's
other hardware failures like controllers, memory, or power supplies that
might require downtime to diagnose and fix that are the concern.
Redundant servers for us means used hardware becomes more viable with more
up time and more flexibility for me to fix things when my schedule allows
vs having to stop everything to repair the server.
Hopefully I didn't miss that these questions have easy searchable answers.
I did a quick search and didn't find what I was looking for.

Friday, 23 August 2013

Image is not display in repeater in asp.net

Image is not display in repeater in asp.net

In my website i am saving data in xml using html editor. When i add a
picture before the content means on the top of the content and save it in
xml.Now the problem is this that when i am trying to get result from xml
to repeater control then image which is on the top of the content is
giving me blank result. Here is the code which i am using for save data in
xml
int date = DateTime.Now.Day;
int month = DateTime.Now.Month;
int year = DateTime.Now.Year;
String File = Server.MapPath("~/Data/BlogContent.xml");
int newid;
XDocument doc = XDocument.Load(File);
XElement root = doc.Root;
string id = root.Elements("post").Last().ToString();
XmlDocument pacXML = new XmlDocument();
pacXML.Load(new StringReader(id));
XmlNode xmlnode1;
xmlnode1 = pacXML.DocumentElement.ChildNodes.Item(1);
String stCode =
Convert.ToString(pacXML.DocumentElement.ChildNodes.Item(0).InnerText).Trim();
if (xmlnode1 == null)
{
newid = 1;
}
newid = Convert.ToInt32(stCode.ToString()) + 1;
XmlDocument xdoc = new XmlDocument();
xdoc.Load(File);
XmlNode xnode = xdoc.SelectSingleNode("content");
XmlNode xrnode =
xnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "post",
""));
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "id",
"")).InnerText = newid.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "title",
"")).InnerText = TextBox1.Text;
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element,
"Discription", "")).InnerText = Editor.Text;
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "dt",
"")).InnerText = date.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "mnt",
"")).InnerText = month.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element, "yr",
"")).InnerText = year.ToString();
xrnode.AppendChild(xdoc.CreateNode(XmlNodeType.Element,
"PostDate", "")).InnerText = DateTime.Now.ToString("MM/dd/yyyy");
xdoc.Save(File);
Editor.Text = string.Empty;
TextBox1.Text = string.Empty;
and it is the code of display data in repeater
PagedDataSource page = new PagedDataSource();
page.AllowCustomPaging = true;
page.AllowPaging = true;
DataTable dtv = (DataTable)ViewState["Mytable"];
DataView dv = new DataView();
dv = dtv.DefaultView;
dv.Sort = dtv.Columns["id"].ColumnName;
dv.Sort += " Desc";
dv.RowFilter = "id>=" + pageSize + " AND " + "id<=" + take;
page.DataSource = dv;
page.PageSize = psize;
Repeater1.DataSource = page;
Repeater1.DataBind();
if (!IsPostBack)
{
int rowcount = dtv.Rows.Count;
CreatePagingControl(rowcount);
}
I hope you understand what is my problem

Footnotes numbering placement and XeTeX

Footnotes numbering placement and XeTeX

Well, I meet the following problem: the horizontal spacing between the end
of a word and the footnote number is much too important – about 1.25ex.
Does any one know where this comes from, and how to address this problem ?
I use MiKTeX 2.9 and the font is Sabon Next LT Pro as well as Minion Pro
or Latin Modern.

Creating an action filter attribute that bypasses the actual execution of the action and returns a value for it

Creating an action filter attribute that bypasses the actual execution of
the action and returns a value for it

Can I create an ActionFilterAttribute that bypasses the actual execution
of the action and returns a value for it?

Type or Namespace name 'HTMLWorker' could not be found

Type or Namespace name 'HTMLWorker' could not be found

I am using iTextSharp version 4.1.6 in my application. My using includes
both itextsharp.text and itextsharp.text.pdf. I am trying to follow
guidance from stackoverflow on creating a PDF from an html page. This
requires that I use an itextsharp object called HTMLWorker. However the
intellisence shows no such class. When I manually type in "HTMLWorker
worker = new HTMLWorker(doc);" I get an error "Type or Namespace name
'HTMLWorker' could not be found. Are you missing a using directive or a
reference?" Can anyone identify which using or reference I am missing?

Hoe should I re-write this so I don't get a warning?

Hoe should I re-write this so I don't get a warning?

I have been updating my Android apps from Android 2.1 to 2.2 and now I
keep getting this error: "Use java.lang.Math#sqrt instead of
android.util.FloatMath#sqrt() since it is faster as of API 8"
here are the few lines of code:
private float spacing(MotionEvent event) {
float x = event.getX(0) - event.getX(1);
float y = event.getY(0) - event.getY(1);
return FloatMath.sqrt(x * x + y * y);
}

How to know if two images are intersect while one image moving in android?

How to know if two images are intersect while one image moving in android?

pIn my application, i am moving image around the screen by using
codeonTouchListener/code./p pI have another two images in the same view.
My problem is that, when the moving image, touches any of the other
images, i need to perform a certain action (that means if images are
intersected, then do something)./p pHow can this be achieved?.Please help
me asap/p pThanks in Advance./p

Thursday, 22 August 2013

Why does horizontal list item justification not work with dynamically added items

Why does horizontal list item justification not work with dynamically
added items

I'm creating a grid of divs, and I decided to use an unordered list as the
container, so that I can take advantage of horizontally justifying the
list items that will contain the divs. The problem is that the
justification only works with the HTML written in advance of the page
load. If I try to create and add the list items dynamically with
Javascript, the justification fails.
This fiddle demonstrates the problem with two unordered lists, where one
is populated statically (succeeds) and the other dynamically (fails).
Here's the code:
HTML
<ul>
<li><div></div></li>
<li><div></div></li>
<li><div></div></li>
</ul>
<ul id="list"></ul>
Javascript
var list = document.getElementById("list");
for (var i=0; i<3; i++) {
var li = document.createElement("li");
var div = document.createElement("div");
li.appendChild(div);
list.appendChild(li);
}
CSS
ul {
margin: 0;
padding: 0;
list-style-type: none;
text-align: justify;
}
ul:after {
content: "";
width: 100%;
display: inline-block;
}
li {
display: inline;
}
div {
display: inline-block;
width: 100px;
height: 100px;
background: #4391EE;
border: 1px solid black;
}

Rails: View javascript object's attributes in browser's console

Rails: View javascript object's attributes in browser's console

I have created a variable in CoffeeScript and can verify that it logs as
'object' in the browser's console:
# app/assets/javascripts/products.js.coffee
myvar =
name: "Test"
valid: false
jQuery ->
console.log(myvar)
console output:
Object
name: "Test"
valid: false
__proto__: Object
So browser knows about the object but how can I manually dump it's values
from the console (>) prompt. I'm using Safari at the moment but can switch
if it's not possible w/Safari.

How to submit single button at a time with two form tags

How to submit single button at a time with two form tags

I have two forms with submit buttons, each button will show xml response
over jsp page. Currently, I am getting data after last form. Can only xml
data after clicking one button at a time, another submit button will not
work?
Jsp page code:-
<h2>Customer Order Tracking Details Call</h2>
<form name="samsRequestFormForTrackingData" method ="get"
action="testSAMS.jsp" id="frmtd">
<div class="inputhelper" >
<TABLE id="inputtable">
<tr><td class="label">Enter Vin: </td><td class="val"><input
type="text" ID="vintext" name="vintext" value="" /></td><td
class="help">Vin of the Vehicle</td></tr>
<tr class="dealercode"><td class="label"><SPAN
id="appselector_label">Enter DealerCode: </SPAN></td><td
class="val"><input type="text" ID="dealertext" name="dealertext"
value="" /></td><td class="help">FSLS code of the
dealer</td></tr>
<tr class="dealercode"><td class="label"><SPAN
id="ptselector_label">Enter BodyCode: </SPAN></td><td
class="val"><input type="text" ID="bodycodetext"
name="bodycodetext" value="" /></td><td class="help">Body code
of the vehicle</td></tr>
<tr><td class="label">Enter Item Number:</td><td
class="val"><INPUT TYPE="TEXT" ID="itemnumber" NAME="itemnumber"
SIZE="5" id="itemtext"></td><td class="help">Order
Number</td></tr>
<tr><td class="label">Enter ModelYear:</td><td
class="val"><INPUT TYPE="TEXT" ID="modelyear" NAME="modelyear"
SIZE="5" id="modelyear"></td><td class="help">Year of the
vehicle</td></tr>
<tr><td colspan="3">*Note- Please provide either a VIN or the
combination of DealerCode, BodyCode, Item Number,
ModelYear</td></tr>
<tr><td><input type="submit" name="SUBMITTED" value = "Get
output xml" onclick="updateXMLForTrackinDetails()"/></td></tr>
</TABLE>
</div>
</form>
<form name="samsRequestFormForSummaryRequest" method ="get"
action="testSAMS.jsp" id="frmsr">
<h2>Customer Order Tracking Summary Call</h2>
<div class="inputhelperdiv" >
<TABLE id="inputtable">
<tr><td class="label">Enter DealerCode:</td><td
class="val"><input type="text" ID="textdealercode"
name="textdealercode" value="" /></td><td class="help">FSLS code
of the dealer</td></tr>
<tr class="dealercode"><td class="label">Enter Item
Number:</td><td class="val"><input type="text" ID="textitem"
name="textitem" value="" /></td><td class="help">Order
Number</td></tr>
<tr><td><input type="submit" name="SUBMITTED" value = "Get
output xml" onclick="updateXMLForSumary()" /></td> </tr>
</TABLE>
</div>
</form>
<SCRIPT LANGUAGE="JavaScript">
function updateXMLForTrackinDetails()
{
<%
String vin = request.getParameter("vintext");
String dealerCode = request.getParameter("dealertext");
String bodyCode = request.getParameter("bodycodetext");
String ordernumber = request.getParameter("itemnumber");
String year= request.getParameter("modelyear");
int modelYear =0;
if(year != null)
{
modelYear = Integer.parseInt(year);
}
VehicleOrderDetailResponseType vehicleOrderResponse = null;
try
{
SAMSServiceAdaptor serviceadaptor = new SAMSServiceAdaptor();
VehicleOrderDetailRequestType vehicleOrderDetailRequest =
serviceadaptor.createRequest(
vin, bodyCode, dealerCode, ordernumber, modelYear);
vehicleOrderResponse =
SAMSServiceLocator.getSAMSServicePort().retrieveVehicleOrderDetail(vehicleOrderDetailRequest);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
JAXBContext context = JAXBContext
.newInstance(VehicleOrderDetailResponseType.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
marshaller.marshal(vehicleOrderResponse, bytes);
String sb = new String(bytes.toByteArray());
String responseXML = sb.trim();
if(responseXML!=null){
out.println(responseXML.trim().substring("<?xml
version=\"1.0\" encoding=\"UTF-8\"
standalone=\"yes\"?>".length()));
}else{
out.println("Response was null, Please check input
paramters! ");
}
}
catch(Exception ex)
{
out.println(ex.toString());
}
%>
}
function updateXMLForSumary()
{
<%
String dealercode = request.getParameter("textdealercode");
String itemnumber = request.getParameter("textitem");
try
{
FSConditionStatementType fsConditionStatementType = new
FSConditionStatementType();
SAMSServiceAdaptor samsServiceAdaptor = new SAMSServiceAdaptor();
ExpressionType dealerExpression =
samsServiceAdaptor.createExpression(
FSCategoryCodeEnumType.DEALER_CODE_NOZONE,
OperatorEnumType.EQUAL, dealercode);
fsConditionStatementType.getExpression().add(dealerExpression);
ExpressionType orderNumberExpression =
samsServiceAdaptor.createExpression(
FSCategoryCodeEnumType.ITEM_NUMBER, OperatorEnumType.EQUAL,
itemnumber);
fsConditionStatementType.getExpression().add(orderNumberExpression);
SearchCriteriaType searchCriteria = new SearchCriteriaType();
searchCriteria.setFSConditionStmt(fsConditionStatementType);
ServiceContextType serviceContext = new ServiceContextType();
serviceContext.setCode(ServiceContextCodeEnumType.OIS);
searchCriteria.setServiceContext(serviceContext);
List<VehicleOrderType> vehicleOrders =
SAMSServiceLocator.getSAMSServicePort().retrieveSummaryByCriteria(
"NGPRequestor", ServiceContextCodeEnumType.OIS,
"SAMS", searchCriteria);
System.out.println("Resposnse BodyCode: " +
vehicleOrders.get(0).getBody());
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
JAXBContext context = JAXBContext
.newInstance(VehicleOrderType.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
marshaller.marshal(new VehicleOrderType(vehicleOrders), bytes);
String sb = new String(bytes.toByteArray());
String responseXML = sb.trim();
if(responseXML!=null){
out.println(responseXML.trim().substring("<?xml
version=\"1.0\" encoding=\"UTF-8\"
standalone=\"yes\"?>".length()));
}else{
out.println("Response was null, Please check input
paramters! ");
}
}
catch(Exception ex)
{
out.println(ex.toString());
}
%>
}
</SCRIPT>
</body>
</html>

The process cannot access the file

The process cannot access the file

Please have a look at the following code
void InformationWriter::writeContacts(System::String ^phone,
System::String ^email)
{
try
{
//Write the file
StreamWriter ^originalTextWriter = gcnew
StreamWriter("contacts.dat",false);
originalTextWriter->WriteLine(phone);
originalTextWriter->WriteLine(email);
originalTextWriter->Close();
//Encrypt the file
FileStream ^fileWriter = gcnew
FileStream("contacts.dat",FileMode::OpenOrCreate,FileAccess::Write);
DESCryptoServiceProvider ^crypto = gcnew DESCryptoServiceProvider();
crypto->Key = ASCIIEncoding::ASCII->GetBytes("Intru235");
crypto->IV = ASCIIEncoding::ASCII->GetBytes("Intru235");
CryptoStream ^cStream = gcnew
CryptoStream(fileWriter,crypto->CreateEncryptor(),CryptoStreamMode::Write);
//array<System::Byte>^ phoneBytes =
ASCIIEncoding::ASCII->GetBytes(phone);
FileStream ^input = gcnew
FileStream("contacts.dat",FileMode::Open); //Open the file to be
encrypted
int data = 0;
while((data=input->ReadByte()!=-1))
{
cStream->WriteByte((System::Byte)data);
}
input->Close();
cStream->Close();
fileWriter->Close();
System::Windows::Forms::MessageBox::Show("Data Saved");
}
catch (IOException ^e)
{
System::Windows::Forms::MessageBox::Show(e->Message);
}
}
When the following part get executed, I get an error
FileStream ^input = gcnew FileStream("contacts.dat",FileMode::Open);
//Open the file to be encrypted
Below is the error I get

This is the first time I am using CryptoStream and I new to C++/CLI as well.
Please help

Copy vagrant box locally

Copy vagrant box locally

I have a vagrant box running on VirtualBox, and I need to make a copy
(with all its existing config and data), so that I can make changes on it
without affecting the original.
The problem is that my original box came as a file package - the internet
connection where I'm working with is extremely slow so someone else copied
their vagrant and virtualbox folders to my machine. Thus there is no
config.vm.box_url
to use.
How can I accomplish this?

LogOff disconnected users from remote desktop

LogOff disconnected users from remote desktop

Firstly I'm new to this..Excuse me If something might asked here is not
appropriate.
I would like to find out the disconnected users and then make all of them
logOff at once from my windows app.
This is what I have found here
Can anyone say how do I use this and from where ?
Or any other alternative is the best option to do ?
As when I'm trying this way :
ExecuteCommand("TSDISCON 31 /SERVER:myservername /V")
Public Sub ExecuteCommand(ByVal Command As String)
Dim ProcessInfo As ProcessStartInfo
Dim Process As Process
ProcessInfo = New ProcessStartInfo("cmd.exe", "/K" & Command)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = True
Process = Process.Start(ProcessInfo)
End Sub
It gives me an error that session Id 31 is not found and when checked it
is showing me the session id 31 is there in the task manager as you can
see it below.
http://imageshack.us/photo/my-images/443/elhs.png/
Sorry as I'm having low rep I couldnt post images here infact proving a link.

Wednesday, 21 August 2013

Vbscript for error handling in copying zip file

Vbscript for error handling in copying zip file

Please help me out. I want a vbscript program to check whether my zip is
completely copied or not and checks whether i have unzipped the exact zip
file.Any ideas and suggestions?

Netbeans C program return value 2

Netbeans C program return value 2

I just got my Netbeans tools configured,and (finally) it worked :) (I
checked with Hello World). We were shifting so I have had like a 3 month
gap so I though I'd make a calculator rather than some other program like
a palindrome checker and bleh bleh bleh. So here's the code :
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void addition(int,int);
void subtraction(int,int);
void mutiplication(int,int);
void division(int,int);
int main() {
int x,y,choice,redo = 1;
while(redo)
{
printf("\nWelcome to the CalC :D\nPlease make a
choice\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n>");
scanf("%d",&choice);
switch(choice);
{
case '1' :
{
printf("Enter the first number\n>");
scanf("%d",&x);
printf("\nThe second number?\n>");
scanf("%d",&y);
addition(x,y);
}
case '2' :
{
printf("Enter the first number\n>");
scanf("%d",&x);
printf("\nThe number to be subtracted from %d is?\n>",x);
scanf("%d",&y);
subtraction(x,y);
}
case '3' :
{
printf("Enter the first number\n>");
scanf("%d",&x);
printf("\nThe number to be multiplied with %d is?\n>",x);
scanf("%d",&y);
multiplication(x,y);
}
case '4' :
{
printf("Enter the first number\n>");
scanf("%d",&x);
printf("\nThe number to be divided by %d is?\n>",x);
scanf("%d",&y);
division(x,y);
}
}
printf("\nWould you like to make another calculation?\n1.Yes '_'
\n2.No! :p\n>");
scanf("%d",&redo);
}
return (EXIT_SUCCESS);
}
void addition(int x,int y)
{
int sum;
sum = x + y;
printf("\nThe sum of %d and %d is %d\n(Press enter to display the
menu)",x,y,sum);
getch();
}
void subtraction(int x,int y)
{
int difference;
ce;
difference = x - y;
printf("The difference between %d and %d is %d\n(Press enter to
display the menu)",x,y,difference);
getch();
}
void multiplication(int x,int y)
{
int product;
product = x * y;
printf("The product of %d and %d is %d\n(Press enter to display the
menu)",x,y,product);
getch();
}
void division(int x,int y)
{
float quotent;
quotent = (float)x/(float)y;
printf("The quotient of %d and %d is %.2f\n(Press enter to display the
menu)",x,y,quotent);
getch();
}
And this is the error I get :
"/C/MinGW/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS=
.build-conf
make[1]: Entering directory
'C:/Users/CaptFuzzyboots/Documents/NetBeansProjects/CalC'
"c:/MinGW/bin/make.exe" -f nbproject/Makefile-Debug.mk
dist/Debug/MinGW-Windows/calc.exe
make[2]: Entering directory
'C:/Users/CaptFuzzyboots/Documents/NetBeansProjects/CalC'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
gcc -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o
build/Debug/MinGW-Windows/main.o main.c
main.c: In function 'main':
main.c:26:5: error: case label not within a switch statement
main.c:34:9: error: case label not within a switch statement
main.c:42:9: error: case label not within a switch statement
main.c:52:9: error: case label not within a switch statement
main.c: In function 'subtraction':
main.c:78:5: error: 'ce' undeclared (first use in this function)
main.c:78:5: note: each undeclared identifier is reported only once for
each function it appears in
main.c: At top level:
main.c:83:6: warning: conflicting types for 'multiplication' [enabled by
default]
main.c:48:13: note: previous implicit declaration of 'multiplication' was
here
nbproject/Makefile-Debug.mk:66: recipe for target
'build/Debug/MinGW-Windows/main.o' failed
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make[2]: Leaving directory
'C:/Users/CaptFuzzyboots/Documents/NetBeansProjects/CalC'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory
'C:/Users/CaptFuzzyboots/Documents/NetBeansProjects/CalC'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 661ms)
I'm used to code::blocks so I don't really know what's the problem here :\
please help me out,I clearly defined the switch labels as '1','2','3','4'!
Thanks guys :)

java.lang.StackOverflowError due to recursion

java.lang.StackOverflowError due to recursion

My problem is that I usually get a java.lang.StackOverflowError when I use
recursion. My question is - why does recursion cause stackoverflow so much
more than loops do, and is there any good way of using recursion to avoid
stack overflow?

Get parameter's value of a Data Annotation

Get parameter's value of a Data Annotation

The goal
Get parameter's value of a Data Annotation.
The problem
I don't know the syntax.
The scenario
There is the following controller on my application:
[PermissionsFilter(Roles = "Administrator")]
public ActionResult Index()
{
return View();
}
And there is the following method on my application:
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return true;
}
What I need seems to be simple: how do I get the Administrator string on
the AuthorizeCore method?
Knowledge spotlight
The AuthorizeCore is within of PermissionFilters class that implements
AuthorizeAttribute. In other words, I'm overriding the AuthorizeCore
method of Authorize attribute to create a new one (PermissionFilters
attribute).

WPF- filling color to polyline in for wpf toolkit

WPF- filling color to polyline in for wpf toolkit

I have created a custom LineSeries graph using a polyline. Below image has
plotted two graph ranged from 0-1 and 1.2 to 2 against the date and time.
It demo the expected graph output. I have data structure where I will get
the data from 0-1 and 1.2 to 2.
My problem is I am not able to fill the color when the point is constantly
read 1 till the next drop to 0.
Here is my style
<customSeries:StepLineSeries.Style>
<Style TargetType="customSeries:StepLineSeries">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="customSeries:StepLineSeries">
<Canvas x:Name="PlotArea" >
<Border BorderThickness="0" Background="{Binding
DataContext.SeriesForeColor,
RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type customSeries:StepLineSeries}},
Converter={StaticResource TextToBrushConverter}}">
<Polyline DataContext="{Binding Tag,
RelativeSource={RelativeSource AncestorType={x:Type
customSeries:StepLineSeries}}}"
Points="{TemplateBinding Points}" Stroke="{Binding
DataContext.SeriesForeColor}" Fill="White"/>
</Border>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</customSeries:StepLineSeries.Style>
To Do that I have used Border in the canvas I am filling the color to the
border and making Polyline fill to white always. This approach will not
work for all the case. Can anyone suggest something better than this to
fill the color other than polyline fill

Two-column table various problems

Two-column table various problems

Following the page in question: http://jsfiddle.net/EaFZF/
First problem: the image on the left creates an empty space on the right
equal to the height of the image (see the link).
Second problem: how to determine the maximum height of the table? In my
case height: 120px; is ignored. Thanks in advance.

best practice to know whether mail function send mail or not

best practice to know whether mail function send mail or not

I am using the below code snippet to send mail via php mail function.
$mailsent = mail($to_address, $subject, $message, $headers);
if ($mailsent)
return "mail send";
else
return "error";
I am checking the boolean in $mailsent variable to determine whether the
mail is send successfully or not. Is this the right practice to find the
status of mail send by php mail function. Any help will be
appreciated.Thanks

Tuesday, 20 August 2013

User define key equivalents

User define key equivalents

I would like to allow the user to create their own key equivalents. Below
is a snap of the prefs page in Google Voice as an example. I'm stumped on
how to record the shortcut in a field as shown below. I've yet to find an
example or any help on this. I would really appreciate any suggestions.
Thanks in advance.

Simple .Show function not displaying DIV on page load

Simple .Show function not displaying DIV on page load

I have a check box on my page "cbxShowNotifications." If it is checked
when the page loads, I want to SHOW "treeview."
.aspx page:
<html>
<body>
<form>
<asp:CheckBox ID="cbxShowNotifications" runat="server"/>Show
Notifications
<div id="treeview"></div>
</form>
<script src="../Scripts/jquery.min.js" type="text/javascript">
</script>
<script src="../Scripts/kendo.web.min.js" type="text/javascript">
</script>
<script src="../Scripts/NotificationsTreeView.js"
type="text/javascript"> </script>
<script type="text/javascript">
$(document).ready(function()
{
showOrHide();
});
</script>
<script type="text/javascript">
$(document).ready(function()
{
CreateNotificationTree(<%=
UserId.ToString(CultureInfo.InvariantCulture) %>);
});
</script>
</body>
</html>
JavaScript file:
function CreateNotificationTree(userId)
{
var data = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "../api/notifications/byuserid/" + userId,
contentType: "application/json"
}
},
schema: {
model: {
children: "notifications"
}
}
});
$("#treeview").kendoTreeView({
dataSource: data,
loadOnDemand: true,
dataUrlField: "LinksTo",
checkboxes: {
checkChildren: true
},
dataTextField: ["notificationType", "NotificationDesc"],
select: treeviewSelect
});
function treeviewSelect(e)
{
var node = this.dataItem(e.node);
window.open(node.NotificationLink, "_self");
}
}
$('#cbxShowNotifications').on('change', function()
{
debugger;
var tview = $('#treeview');
if ($(this).prop('checked'))
{
tview.show();
}
else
{
tview.hide();
}
});
function showOrHide()
{
debugger;
var tview = $('#treeview');
if ($(this).prop('checked'))
{
tview.show();
}
else
{
tview.hide();
}
}
The problem is, when the page loads AND the check box is checked, the
treeview is NOT visible. What am I doing wrong?
By the way, after the page is loaded, if I uncheck the checkbox, the tree
disappears and if I check it, it appears.
So this is only happening at page load which leads me to believe it's an
issue of WHEN things are being executed.

Dilogarithm integral $\int^x_0 \frac{\operatorname{Li}_2(1-t)\log(1-t)}{t}\, dt$

Dilogarithm integral $\int^x_0
\frac{\operatorname{Li}_2(1-t)\log(1-t)}{t}\, dt$

I am hoping to find a closed form for the following
$$\tag{1} \sum_{k\geq 1}\frac{H_k}{k^3} x^k $$
Using the generating function
$$\sum_{k\geq 1}H^{(n)}_k x^k = \frac{\operatorname{Li}_n(x)}{1-x}$$
I could find this by simple integration
So I am stuck at evaluating
$$\tag{2}\int^x_0 \frac{\operatorname{Li}_2(1-t)\log(1-t)}{t}\, dt$$
For $x=\pm 1$ the problem can be solved , but what about the general case ?

Android EditText exceeded it's parent viewgroup

Android EditText exceeded it's parent viewgroup


As shown in the above screenshot, the EditText exceeded it's parent, how
to prevent this from happening?
In my chat activity I use a ListView to display messages, each message is
a list item
This is the xml file:
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/form"
android:layout_below="@+id/header"
android:divider="@null"
android:dividerHeight="0dp"
android:padding="5dp" >
</ListView>
And list item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/avatarLeft"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/border"
android:contentDescription="@string/empty_string"
android:src="@drawable/icon_default_avatar"
android:visibility="gone" /> this will be adjusted
programmatically
<TextView
android:id="@+id/comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" this will be adjusted
programmatically
android:layout_margin="5dp"
android:background="@drawable/none" this will be adjusted
programmatically
android:ellipsize="none"
android:paddingLeft="10dp"
android:singleLine="false"
android:text=""
android:textColor="@android:color/primary_text_light" />
<ImageView
android:id="@+id/avatarRight"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/border"
android:contentDescription="@string/empty_string"
android:src="@drawable/icon_default_avatar"
android:visibility="gone" /> this will be adjusted
programmatically
</LinearLayout>
</LinearLayout>