Thursday, 3 October 2013

How go to authorize method ASP.NET

How go to authorize method ASP.NET

I'm testing Basic Http Authentication. I try go to a page, But when I go
to "books/get", I see nothing. Why? What I should add?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Net.Http.Headers;
using System.Security.Principal;
using System.Text;
using System.Threading;
namespace WebApiTest.Controllers
{
public class BooksController : Controller
{
[Authorize]
public String Get()
{
String res = "Hello";
return res;
}
public ActionResult Index()
{
return View();
}
}
}

Wednesday, 2 October 2013

how to increment value of a column up to specific range for values in other column?

how to increment value of a column up to specific range for values in
other column?

The existing table is like:
tmc speed
ABC 55
DEF 55
I want to create a table like the following one using the existing table
in SQL Server 2008:
tmc speed
ABC 55
ABC 56
ABC 57
ABC 58
ABC 59
ABC 60
DEF 55
DEF 56
DEF 57
DEF 58
DEF 59
DEF 60
The code I developed is not showing me the exact result I want. Any help
will be highly appreciated.

Objective C adding C++

Objective C adding C++

I have been given some C++ classes to incorporate into my Objective C
project. I've never done this before, so I have to ask:
Is there something special I need to do or can I just rename the .cpp to .mm?
What about importing (or including) the .h file? Anything special I need
to do there?
Just baby steps here. Thank you.

PHP if statements with multiple values

PHP if statements with multiple values

Is there a shorter way of writing this?
<?
if($_GET['id']==1 ||
$_GET['id']==3 ||
$_GET['id']==4 ||
$_GET['id']==5)
{echo 'does it really have to be this explicit?'};
?>
Something like this perhaps?
<?
if($_GET['id']==1 || 3 || 4 || 5){echo 'this is much shorter'};
?>

Pointers in B Tree

Pointers in B Tree

I read about B trees and understand their input, delete methods. I read
with an introduction like this:
When we build structures on disk, we must deal with certain realities of
access and transfer time:
Random access to disk typically requires on the order of 10-20 ms access
time to position the head and wait for data to come up under it.
Once the head position is right, data can be transferred at rates in
excess of 1 million bytes/sec.
Observe, then, how total transfer times behave for different size blocks
(assuming a fairly fast 10 ms access time, and 1 megabyte/sec transfer
rate)
So, B Tree Data Structure is made for serving from disk ( which is what
makes them great for Databases ). But when I tried to implement it, I hit
this problem.
Normal B Tree diagrams shows pointers to child nodes which then descend
down to leaves.
But how do I make pointers on the disk? Is it like a file name ?

Tuesday, 1 October 2013

Access igraph R objects from Python

Access igraph R objects from Python

I have a graph object created with the igraph R package. If I understand
the architecture of the igraph software package correctly the igraph R
package is an interface to use igraph from R. Then since there is also a
igraph Python interface I wonder if it is possible to access my igraph
object created with R via Python directly. Or if the only way to access
and igraph R object from Python is to export the igraph R object with
write.graph() in R and then import it with the igraph R package.

Custom URL in PHP

Custom URL in PHP

I am trying to create custom profile URLs using PHP.
I currently have the following URL:
http://mysite.com/profile.php?user=1
where user_id 1 is Kyle Hagler in the database.
I would like to allow access to this same page through the following url:
http://mysite.com/kylehagler

Cont'd Decimal Expansion, rational or not?

Cont'd Decimal Expansion, rational or not?

This is a follow up from this question.
Since it's proven by Calvin Lin that $0.11235813213455...$ (Fibonacci
Sequence), I'm not wondering if the sequence
$$0.123456789101112131415...$$
(which is just natural numbers) is rational or not. Thanks for the help in
advanced!

which shell will sudo use to execute a shell script without the shebang line – unix.stackexchange.com

which shell will sudo use to execute a shell script without the shebang
line – unix.stackexchange.com

My environment is Ubuntu 12.04 LTS, and the sudo version is 1.8.3p1. First
I login as a normal user: $ whoami fin $ cat /etc/passwd | grep -i
"root\|fin" root:x:0:0:root:/root:/bin/bash ...

Monday, 30 September 2013

Run CRON task directly on router to automate jobs

Run CRON task directly on router to automate jobs

I want to setup CRON job directly on D'LINK DIR-655 router. I need to run
there PING job to monitor my network response times, and log all the
errors with Internet connection directly on router.
D'LINK router firmware have built in some PING tool, but D'LINK prepared
it only to manual tests. I need to automate it with CRON job to monitor
connection 24h/day with interval 3 seconds.
Is it possible?

Is “on one hand...on the other hand” a cliché to be avoided=?iso-8859-1?Q?=3F_=96_english.stackexchange.com?=

Is "on one hand...on the other hand" a cliché to be avoided? –
english.stackexchange.com

We should find a way of long peace instead of living just for today. On
one hand, we have to prevent the community from coming apart and suffering
the disasters caused by it; on the other hand, to …

How to show a location with respect to my current location?

How to show a location with respect to my current location?

I have a lat and longitude of my friend's location also my current
location. I want to show the position of my friend with respect to my
location, just like a compass - in an iPhone app. I know the function
didUpdateHeading -
-(void)locationManager:(CLLocationManager *)manager
didUpdateHeading:(CLHeading *)newHeading
{
NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);
NSLog(@"New true heading: %f", newHeading.trueHeading);
}
I am not getting an idea about how to do this, Please help me.

How to organize js files for a multi page mvc applicaiton

How to organize js files for a multi page mvc applicaiton

We have a project implemented using ASP.NET MVC 4. it is a multi page
application.
We use jQuery for handling client side interactions. Now the js file has a
lot of callback functions.
What is the best way to organize the code in the javascript file?

Sunday, 29 September 2013

Function that checks width of an image loaded by user randomly returns 0

Function that checks width of an image loaded by user randomly returns 0

I was trying to write a function that would check if the image I chose via
input[type=file] is exactly 700 px wide and if not - reject this image. I
succeeded, however, sometimes this function randomly returns 0 and I need
to load the same image a couple of times until it reads its width
correctly. Any ideas on how to improve this code? Thanks in advance!
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
var img = new Image;
img.src = e.target.result;
if(img.width == 700) {
DoSomeStuff();
} else {
alert("This image has to be 700 px wide, but is " +
img.width + " px wide. Try again!");
input.value = "";
}
};
reader.readAsDataURL(input.files[0]);
}

Get list from list values in a python dictionary

Get list from list values in a python dictionary

I have a python dictionary with the following entries:
professions = {Peasant : ["Peasant", 10000], Merchant : ["Merchant",
15000], ...}
Is there a clever way to get a list of all profession names? I'd like a
function that returns
["Peasant", "Merchant", ...]
thanks for suggestions

In SAO architecture should single API do everything or API should be spilt as multiple action

In SAO architecture should single API do everything or API should be spilt
as multiple action

We have an app which is exposing api(RESTful) to UI for purchasing a item.
I have a question regardinng API design. Lets say the following action
should be taken in order
Item to be chosen for purchase
Next give the address to be delivered to
My question is should we design a single api which gets both data perform
both? Or should we desgin two api calls one that creates a purchase record
and second that update the address to be delivered to?

How to add space between menu and dropdown submenu

How to add space between menu and dropdown submenu

I'm working on a CSS3 full width dropdown menu, but some details i can't
get right. :-(
What i try to achieve is this:
http://i.stack.imgur.com/Egk0P.png
You can see there is a little 20px space between the mainmenu and the
submenu. In this example i used a top-margin:20px for the ul submenu. But
that doesn't really work, because you will leave the hover-area with your
cursor and the submenu wil dissapear. The dropdown only works if the
ul-container of the submenu "touches" the hover-area.
It did tried using the ul:before trick to add an empty block before the
submenu ul, but somehow that doesn't work. :( It doens't take space like a
block should do. It's just adding the content right over the ul element.
What do i overlook or doing wrong here? :( Is there a better way to add a
little bit of empty "hoverspace" above the submenu?
Your help would be very helpfull :-).
Live demo: http://jsfiddle.net/JeroenGerth/hDmxd/
The HTML:
<nav>
<ul id="menu">
<li><a href="#">Home</a></li>
<li><a href="#">Tutorials &gt;</a>
<ul class="submenu">
<li><a href="#">Photoshop 1</a></li>
<li><a href="#">Dreamweaver 2</a></li>
<li><a href="#">Photoshop 3</a></li>
<li><a href="#">InDesign 4</a></li>
<li><a href="#">Bridge 5</a></li>
<li><a href="#">Lightroom 6</a></li>
<li><a href="#">After Effects 7</a></li>
<li><a href="#">Premiere 8</a></li>
<li><a href="#">Motion 9</a></li>
<li><a href="#">Aperture 10</a></li>
<li><a href="#">iPhoto 11</a></li>
</ul>
</li>
<li><a href="#">Downloads &gt;</a>
<ul class="submenu">
<li><a href="#">Wallpapers 1</a></li>
<li><a href="#">PSD files 2</a></li>
<li><a href="#">Video's 3</a></li>
<li><a href="#">Soundeffects 4</a></li>
<li><a href="#">Icons 5</a></li>
<li><a href="#">Maps 6</a></li>
</ul>
</li>
<li><a href="#">About me</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
The CSS:
body {background-color: #E9E9E9;}
nav ul { /*Main menu container*/
margin: 0px;
padding: 0px 20px;
background-color:#444;
color: #fff;
list-style: none;
position:relative;
display:inline-table;
border-radius: 5px;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li { /*Main menu-items*/ float:left;}
nav ul li a {
padding: 10px 20px;
color: #fff;
font-family: Calibri, Verdana, sans-serif;
text-decoration:none;
display: block;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
nav ul li a:hover {color: #66D1D3;}
nav ul ul { /*Submenu container*/
display:block;
border-radius:0px;
padding: 0px;
position: absolute;
background-color:#fff;
color: #000;
visibility:hidden;
opacity:0;
transition:all ease-in-out 0.4s;
left: 0px;
top: 100%;
width: 100%;
columns:100px 3;
-webkit-columns:100px 3; /* Safari and Chrome */
-moz-columns:100px 3; /* Firefox */
}
nav ul li:hover > ul { /*Show submenu*/
visibility:visible;
opacity:1;
transition-delay:0s;
}
nav ul ul:before { /*Why doesn't this work :( */
content: "";
display: block;
height: 20px;
position: absolute;
width: 100%;}
nav ul ul li { /*Submenu items*/
float: none;
border-bottom: 1px #CCCCCC dotted;
position:relative;
}
nav ul ul li a {
color: #000;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
nav ul ul li a:hover {
color: #66D1D3;
background-color: #444;
}

Saturday, 28 September 2013

How to end with one result with an if statement on java?

How to end with one result with an if statement on java?

if (number1 + 8 == number2 || number1 - 8 == number2){
if (name1.equals(name2)){
if (cod1 == cod2){
if (some1.equals(some2)){
System.out.println("They're in the same group");
}
System.out.println("They are in the same column");;
}
System.out.println("They are in the same section");
}
System.out.println("They are in the same subgroup");
}
else{
System.out.println("They are different");
}
}
}
How could I change this so that I only get one message at the end? Right
now it gives all the messages or just the They are different. I know I
can't put an actual break since this isn't a loop, but what action could I
take in this problem? Would I have to rewrite it? Thank You for the help.

Python - PyCharm - PowerShell terminal - run as administrator

Python - PyCharm - PowerShell terminal - run as administrator

In PyCharm I set my terminal to be the Windows PowerShell, but when I try
to use virtualenv in that terminal:
Import-Module virtualenvwrapper
(I have this command in a startup script, but just included the command
alone for simplicity)
I get the following error:
Import-Module : File
C:\Users\Sean\Documents\WindowsPowerShell\Modules\virtualenvwrapper\support.psm1
cannot be loaded because the execution of scripts is disabled on this
system. Please see "get-help about_signing" for more details. At line:1
char:14 + Import-Module <<<< virtualenvwrapper + CategoryInfo :
NotSpecified: (:) [Import-Module], PSSecurityException +
FullyQualifiedErrorId :
RuntimeException,Microsoft.PowerShell.Commands.ImportModuleCommand
So I try to enable script execution (as I did for PowerShell outside of
PyCharm):
Set-ExecutionPolicy RemoteSigned
but get the following error (I avoided this error outside of PyCharm by
running PowerShell as administrator):
Set-ExecutionPolicy : Access to the registry key
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell'
is denied. At line:1 char:20 + Set-ExecutionPolicy <<<< RemoteSigned +
CategoryInfo : NotSpecified: (:) [Set-ExecutionPolicy],
UnauthorizedAccessException + FullyQualifiedErrorId :
System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
So what can I do to be able to use virtualenv from the PyCharm terminal?
Windows 7
Python 2.7
PyCharm Community Edition 3.0

Trouble inserting PHP variables into Mysqli

Trouble inserting PHP variables into Mysqli

I am trying to insert data from a form I have made into my MYsql table
using mysqli but whenever I submit my form it just displays the
successfully connected to db server. Any ideas? It should show my errors
for the insert shouldn't it?
<?php
if ($_POST['submit']) {
$errormsg = "";
$name = $_POST['name'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$connection = @mysqli_connect("$hostname","$username", "$password",
"$database");
if(!$connection){
die("<p>The database server is not available.</p>".mysqli_error());
}
echo "<p>Sucessfully connected to the database server.</p>";
if((!$name)||(!$password)||(!$password2)||(!$email)||(!$phone)){ /*
Checks if all inputs are filled*/
$errormsg = "Please insert the required fields below<br />";
if ($name == "")
{
$errormsg = $errormsg . "Enter a name.<br />";
}
if ($password == "")
{
$errormsg = $errormsg . "Please enter a password.<br />";
}
if ($password2 =="")
{
$errormsg = $errormsg . "Please re-enter your password.<br
/>";
}
if ($email =="")
{
$errormsg = $errormsg . "Please enter an email address.<br
/>";
}
if ($phone =="")
{
$errormsg = $errormsg . "Please enter a phone number.<br />";
}
if($errormsg){
echo "$errormsg";
}
}
if($password != $password2) {
$errormsg = $errormsg. "Your passwords must match!<br/>";
}
function checkEmail($email){ //begin email check function
$sql = "SELECT count(email) FROM CUSTOMER WHERE email='$email'";
$result = mysqli_result(mysqli_query($sql),0);
if( $result > 0 ){
$errormsg = $errormsg. "There is already a user with that
email!";
}//end email check function
if(!$errormsg)
{
$insertquery = "INSERT INTO CUSTOMER (customer_no, name, password,
email, phone)
VALUES(NULL, '$name', '$password', '$email',
'$phone')";
$queryresult = mysqli_query($insertquery);
if($queryresult)
{
echo("<br>Registration sucessful");
}
else
{
echo("<br>registration was not sucessful");
}
}
}
} ?>

Play 2.2.0 - How to create a war file

Play 2.2.0 - How to create a war file

I am using play 2.2.0 for my application so inorder to host the
application i need to create a war file so i can host in my Tomcat7
server. So is there any method to
Clean and Build as we have options in netbeans with console.
Create war file so i can host.
The method to create a war file as in normal jsp hosting i paste all my
class files in WEB_INF folder but here how can i do please tell the
procedure. I just gave few try this i have mentioned below i know i am
wrong please show me the right way.
F:\Play_workspace\ThemePractice>play war [info] Loading project definition
from F:\Play_workspace\ThemePractice\project [info] Set current project to
ThemePractice (in build file:/F:/Play_workspace/Th emePractice/) [error]
Not a valid command: war (similar: start) [error] Not a valid project ID:
war [error] Expected ':' (if selecting a configuration) [error] Not a
valid key: war (similar: watch, run, apiUrl) [error] war [error] ^

Friday, 27 September 2013

SQL statement exception when MDB table name contains #32

SQL statement exception when MDB table name contains #32

I am using Delphi 7 and am trying to build a SQL query statement which
will be used with a Microsoft Access MDB file. The code is below:
dm.tblUserTableQ.Close;
dm.tblUserTableQ.sql.Clear;
dm.tblUserTableQ.sql.Add('select count(*) as QTY from '+
Tables.items[Tables.itemindex]);
The above code works fine as long as the MDB table name chosen has no #32
space characters in it. IOW, if the table name is named "ZIPCODES", the
query works fine. However, if the table name is named "ZIP CODES", the
sql.Add statement triggers an exception: Syntax error in query. Incomplete
query clause.
I have tried enclosing the table name within #39 characters, but that
doesn't help. IOW:
'select count(*) as QTY from '+ #39 + Tables.items[Tables.itemindex] + #39
I've tried #34, but that doesn't help either.
Other than renaming the table, is there any solution?

Allow Java to recognize input not equal to a wanted value

Allow Java to recognize input not equal to a wanted value

I am new to both Java and this site so please have mercy on any mistake I
may make, I am at my wits end!
I am trying to make a program that calculates the speed of sound through
different mediums. As of now the program will ask the user for input on
the distance and allow input, same for the medium. I created several cases
that will calculate the the answer of the given medium which work
properly.
The issue is when I try to create a loop that recognizes if the medium
input is not one of the 4 options available. I was able to successfully
create a loop that recognizes if the distance input is not a numeric value
and tried using similar principles for the medium input but either keep
getting stuck in infinite loops or getting the message I created for a
wrong entry when I entered the right option. I have tried the basic loops
that I have been taught: for, do-while, etc., but am stuck. Any and all
suggestions are appreciated, thank you so much!
public static void main(String[] args) {
//prompt the user about the purpose of this program
System.out.println(" The purpose of this program is to calculate the
speed of sound through several mediums.\n The program user will input
a distance in feet followed by a mediums and the program will output
the speed in feet per second and miles per hour\n");
//declare variables
Scanner keyboard = new Scanner(System.in);
final double Air = 1126.1;
final double Water = 4603.2;
final double Steel = 20013.3;
final double Earth = 22967.4;
double OneFootPerSecond = .68181818182;
double Distance;
double AirSpeed;
double WaterSpeed;
double SteelSpeed;
double EarthSpeed;
System.out.print(" What is the distance in feet:" );
//ask the user to input variables
while (!keyboard.hasNextDouble()){
System.out.println("Please enter a valid numeric value, try again:
");
keyboard.next();
}
Distance =keyboard.nextDouble();
{
System.out.print("Input the media: Air, Water, Steel, or Earth: ");
String Input = keyboard.next();
Input.toLowerCase();
switch (Input)
{
case "air":
AirSpeed = Distance/Air;
System.out.print("\n \nThe time to for sound to travel ");
System.out.print(Distance);
System.out.print(" feet through AIR" +"\n");
System.out.printf("%.6f", AirSpeed);
System.out.print(" seconds or ");
System.out.printf("%.1f", OneFootPerSecond*Air);
System.out.print(" miles per hour.");
System.out.print("\n \nEnter Yes for another calculation, else
No: ");
String Another = keyboard.next();
Another.toLowerCase();
break;
case "water":
WaterSpeed = Distance/Water;
System.out.print("\nThe time to for sound to travel ");
System.out.print(Distance);
System.out.print(" feet through WATER" +"\n");
System.out.printf("%.6f",WaterSpeed);
System.out.print(" seconds or ");
System.out.printf("%.1f", OneFootPerSecond*Water);
System.out.print(" miles per hour.");
break;
case "steel":
SteelSpeed = Distance/Steel;
System.out.print("\nThe time to for sound to travel ");
System.out.print(Distance);
System.out.print(" feet through STEEL" +"\n");
System.out.printf("%.6f",SteelSpeed);
System.out.print(" seconds or ");
System.out.printf("%.1f", OneFootPerSecond*Steel);
System.out.print(" miles per hour.");
break;
case "earth":
EarthSpeed = Distance/Water;
System.out.print("\nThe time to for sound to travel ");
System.out.print(Distance);
System.out.print(" feet through EARTH" +"\n");
System.out.printf("%.6f",EarthSpeed);
System.out.print(" seconds or ");
System.out.printf("%.1f", OneFootPerSecond*Earth);
System.out.print(" miles per hour.");
break;

Connection string is not intialized

Connection string is not intialized

When I'm trying to develop the infinite scrolling I'm facing the problem
called connection string is not initialized, but my other pages are
working fine with the same connection string.
I'll share my page so that someone could help me telling me what is wrong
in it. I think it is easy to get my problem solved for someone with
experience.
my DataClass.cs which is in App.data folder:
public class DataClass
{
public DataClass()
{
}
/// <summary>
/// return rows depend on position
/// if you need 10th to 20th you need to pass start=10 and end=20
/// </summary>
/// <param name="start">database start position of one row</param>
/// <param name="next">database end position of one row</param>
/// <returns></returns>
public string GetAjaxContent(int start, int end)
{
string result = string.Empty;
//adding sp params with values in Dictionary entry.
Dictionary<string, object> keyValPair = new Dictionary<string, object>();
keyValPair.Add("@start", start);
keyValPair.Add("@next", end);
DBHelper DBHelper = new DBHelper();
//passing the Stored Procedure name and keyvalue pair
DataTable dataTable = DBHelper.GetTable("spuserdata", keyValPair);
if (dataTable.Rows.Count > 0)
{
for (int i = 0; i < dataTable.Rows.Count; i++)
{
result += string.Format(@"<tr>
<td>
<table>
<tr>
<td
style='width:50px;'>{0}</td><td
style='width:400px;'>{1}</td><td
style='width:150px;'>{2}</td>
</tr>
</table>
</td>
</tr>",
dataTable.Rows[i][0].ToString(),
dataTable.Rows[i][1].ToString(),
dataTable.Rows[i][2].ToString());
}
}
//this string is going to append on Datalist on client.
return result;
}
/// <summary>
/// function to bind data on page load
/// </summary>
/// <returns></returns>
public DataTable FirstTenRecords()
{
Dictionary<string, object> keyValPair = new Dictionary<string, object>();
keyValPair.Add("@start", 0);
keyValPair.Add("@next", 10);
DBHelper DBHelper = new DBHelper();
DataTable dataTable = DBHelper.GetTable("spuserdata", keyValPair);
return dataTable;
}
}
public class Provider
{
public static SqlConnection GetConnection()
{
return new SqlConnection(ConfigurationManager.AppSettings["conn"]);
}
}
public class DBHelper
{
public DBHelper()
{
}
public DataTable GetTable(string SPName, Dictionary<string, object>
SPParamWithValues)
{
SqlConnection conn;
SqlCommand cmd;
SqlDataAdapter adapter;
DataTable dataTable = new DataTable();
conn = Provider.GetConnection();
//open DB connection
conn.Open();
cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
cmd.CommandText = SPName;
foreach (KeyValuePair<string, object> paramValue in
SPParamWithValues)
{
cmd.Parameters.AddWithValue(paramValue.Key, paramValue.Value);
}
adapter = new SqlDataAdapter(cmd);
adapter.Fill(dataTable);
return dataTable;
}
}
and my handlerr.aspx is
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
string startQstring = context.Request.QueryString["start"];
string nextQstring = context.Request.QueryString["next"];
//null check
if ((!string.IsNullOrWhiteSpace(startQstring)) &&
(!string.IsNullOrWhiteSpace(nextQstring)))
{
//convert string to int
int start = Convert.ToInt32(startQstring);
int next = Convert.ToInt32(nextQstring);
//setting content type
context.Response.ContentType = "text/plain";
DataClass data = new DataClass();
//writing response
context.Response.Write(data.GetAjaxContent(start, next));
}
}
public bool IsReusable {
get {
return false;
}
}
}

WAN Access Issues on LAMP Server

WAN Access Issues on LAMP Server

I am running a LAMP server and having trouble connecting over the internet.
I confirmed everything is working fine locally. All other PC's on my
network can access the server over the LAN.
The server is wired directly to one of the gigabit ports on my modem and
ports have been forwarded accordingly.
I recently moved and switched from FIOS to Comcast. This configuration
worked fine on FIOS, but not so much here on Comcast. I have a Docsis 3
modem and am on the Extreme 105 package if that is relevant to anyone.
A ShieldsUp port scan showed all ports in stealth mode.
When attempting to connect from the WAN ip, it simply fails to connect.
Also may be worth mentioning that neither FTP, or SSH are working either,
despite having the ports forwarded properly. (I say properly in that the
same configuration worked on my FIOS connection before I moved)
Has anyone else seen this issue with Comcast?

Changing msvcrt.dll on Windows System

Changing msvcrt.dll on Windows System

I'm using MinGW 4.8.0 (posix, dwarf-2) for building c++ code. Looking with
dumpbin I noticed the MinGW links to msvcrt.dll that on my on Windows 7 is
at the version 7.0.7601.17744 and on Windows Xp SP3 is at version
7.0.2600.5512.
Well I want that MinGW links to a newer version to Microsoft C Runtime
library so I've two choice: use a precompiled version of MinGW that
arleady links to newr C Runtime or rename for example msvcrt110.dll to
msvcrt.dll and deply the application with that library.
What do you think?

getting NullPointerException on Facebook Request.Callback Response

getting NullPointerException on Facebook Request.Callback Response

I am trying to execute FQL but when I try to display the response I got
NullPointerException. I followed as what written here
https://developers.facebook.com/docs/android/run-fql-queries/
below is my code.
String fql = "SELECT name,uid FROM user WHERE online_presence IN
('active', 'idle') AND uid IN ( SELECT uid2 FROM friend WHERE uid1 =
me())";
Session session = Session.getActiveSession();
if(session.isOpened()){
Bundle bundle = new Bundle();
bundle.putString("q", fql);
Request request = new Request(Session.getActiveSession(), "/fql",
bundle, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
Log.d("Result", response.toString());
}
});
Request.executeBatchAsync(request);
whole NullPointerException
09-27 19:11:09.046: E/AndroidRuntime(5134): FATAL EXCEPTION: main
09-27 19:11:09.046: E/AndroidRuntime(5134):
java.lang.NullPointerException
09-27 19:11:09.046: E/AndroidRuntime(5134): at
libcore.net.http.HttpEngine.writeRequestHeaders(HttpEngine.java:647)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
libcore.net.http.HttpEngine.readResponse(HttpEngine.java:801)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:293)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:505)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
com.facebook.Response.toString(Response.java:232)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
com.mier.android.fbtalksms.FBFriendsListActivity$1.onCompleted(FBFriendsListActivity.java:111)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
com.facebook.Request$4.run(Request.java:1634)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
android.os.Handler.handleCallback(Handler.java:615)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
android.os.Looper.loop(Looper.java:153)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
android.app.ActivityThread.main(ActivityThread.java:5006)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
java.lang.reflect.Method.invokeNative(Native Method)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
java.lang.reflect.Method.invoke(Method.java:511)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
09-27 19:11:09.046: E/AndroidRuntime(5134): at
dalvik.system.NativeStart.main(Native Method)
still can't find the reason why response returns null
NullPointerException occurs on Log.d("Result",response.toString());
any help would be appreciated.
Thank you.

Coin Toss game in R

Coin Toss game in R

So trying to make a simulation of a coin toss game where you double your
money if you get heads and half it if you have tales. And want to see what
you get after n throws if you start with x money
However I'm not sure how to tackle this problem in a nice clean way,
without just doing a forloop to n.
Is there some clean way to do this?

Thursday, 26 September 2013

Unable to fetch tab id from sub tab in Jquery

Unable to fetch tab id from sub tab in Jquery

I am using a tab structure as below:
<div id="tabs">
<ul>
<li><a href="#dia_details">Details</a></li>
<li><a href="#tab_raise_req">Raise Req</a></li>
</ul>
<div id="dia_details">
<div id="sub_tabs">
<ul>
<li><a href="#DIA_details">DIA Details</a></li>
<li><a href="#allocate_ba">Allocate BA</a></li>
</ul>
<div id="DIA_details>
<form>
--Code--
</form>
</div>
<div id="allocate_ba">
<form>
--Code--
</form>
</div>
</div>
</div>
<div id="tab_raise_req">
<form>
--Code--
</form>
</div>
When I am in a sub tab and want to save the particular tab for which I
have defined a button, I wanted to obtain the tab id of the currently
active tab.....which is one of the sub tabs.
For this I was using the below function in Jquery:
// Save Changes button click
$("#save_changes_id").click(function() {
// To retrieve the current TAB and assign it to a variable ...
var curTab = $('.ui-tabs-active');
var curTabPanelId = curTab.find("a").attr("href");
responseData = doAjaxCall($(curTabPanelId + " form"));
if(responseData == 1)
showMessage('status_msg', 'Project details updated successfully',
'green');
else
showMessage('status_msg', 'Error: Please check all the fields',
'red');
});
Here the function is returning the id of the parent tab instead of the sub
tab. I tried using addClass and removeClass but of no use.
Please suggest a solution for this. Thanking you in advance.

Wednesday, 25 September 2013

Image and textview above gridview layout

Image and textview above gridview layout

Am trying to place 4 image views and one textview above gridview and my
layout should me like this(blue-textview, orange- imageview and next
gridview) and inbetween the gap is also essential.I searched but couldn't
achieve my view. I referred here for my gridview layout. Help me in
achieving this. Thanks in advance.

Thursday, 19 September 2013

Visual Studio shortcut to get back to coding pane after terminating the run using Shift+F5

Visual Studio shortcut to get back to coding pane after terminating the
run using Shift+F5

This was very tricky to Google ,however, a very simple question in mind.
Instead of wasting lots of time filtering the Google search results I
prefer to ask my Stack fellow developers.
Scenario
Program is running
I terminate it using Shift + F5
I want to continue making change to the code BUT the focus is on some
random Find Usage pane (from resharper) instead of the code itself.
I simply don't want to keep pressing the Tab key until I'm lucky.
Any shortcut available?
Thanks

Null Pointer Exception Android

Null Pointer Exception Android

I am trying to make a button, count clicks and display them in a text
view. Here is my code:
public class Main extends Activity{
int c=0;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
if (container == null) {
return null;
}
ScrollView GPU_LAYOUT = (ScrollView)inflater.inflate(R.layout.gpu,
container, false);
TextView text =(TextView) GPU_LAY.findViewById(R.id.text1);
Button plus =(Button) GPU_LAY.findViewById(R.id.butt1);
plus.setOnClickListener(new OnClickListener() {//null pointer this
line, but it's from .setText i think
public void onClick(View v) {
c++;
text.setText(c);
}
});
}
return GPU_LAY;
}

Trying to implement Jekyll Slideshow but unsure of syntax

Trying to implement Jekyll Slideshow but unsure of syntax

I am trying to implement https://github.com/matthewowen/jekyll-slideshow,
however I am unsure of what Matt means in the documention when he says:
For any content that you'd like the slideshow process to work on, use the
filter 'slideshows' in your template, like so:
{{ content | slideshows }}
I am using HTML rather than markdown. My html looks like...
<ul>
<li><img src="assets/images/77_xs650.JPG" alt="Example image" title=""
/></li>
<li><img src="assets/images/650_chop.JPG" alt="Example image" title=""
/></li>
<li><img src="assets/images/sr500.JPG" alt="Example image" title="" /></li>
<li><img src="assets/images/triumph.jpg" alt="Example image" title="" /></li>
</ul>
How do I use the filter 'slideshows' on this data?

Equivalent of "svn checkout" for git?

Equivalent of "svn checkout" for git?

I'm used to svn but not git. I have a repository on the server and a
branch in my laptop. I would like to make a "checkout" in my VM to get a
copy of my source in my VM too. But I'm a lit bit confused about what
command I need to run in git. I mean, can I just make:
git checkout
Many thanks!

SqlProj for one database developed multiple teams

SqlProj for one database developed multiple teams

If you have multiple teams of people working on a large product with one
database, what is the best way organize the .sqlproj(s) when the teams are
going to have their own SQL objects (Stored procedures, Tables, etc) and
access other teams' object for read-only access?

subquery is not working in mysql

subquery is not working in mysql

This is my mysql query
SELECT tm.MAGAZINE_ID,
tm.MAGAZINE_NAME,tm.MAGAZINE_DESCRIPTION,pub.publisher_name,
tmi.COVER_PAGE_THUMB AS COVER_PAGE_VERTICAL,tmi.FROM_DATE
AS ISSUE_DATE,
tm.html_flag AS
HTML_EXIST,tm.CATEGORY_ID,tm.language_id,tm.is_free,tma.AppUrl,
(SELECT issue_id from tbl_magazine_issue WHERE magazine_id
= 141
ORDER BY FROM_DATE DESC LIMIT 1) as temp_issue_id
FROM tbl_magazine_apps as tma
LEFT OUTER JOIN tbl_magazine_code as tmc ON tmc.Code =
tma.AppsCode
LEFT OUTER JOIN `tbl_magazine` AS tm ON tmc.magazine_Id =
tm.MAGAZINE_ID
JOIN `tbl_magazine_issue` AS tmi ON temp_issue_id =
tmi.issue_id
LEFT OUTER JOIN mst_publisher AS pub ON
tm.publisher_id=pub.publisher_id
WHERE
tmi.PUBLISH_STATUS IN(1,3)
AND tmi.`OS_SELECT` = '".$osType."'
AND tma.id IN (".$appIds.")
GROUP BY tm.MAGAZINE_ID
ORDER BY tmi.ISSUE_DATE DESC
but i got an error that
#1054 - Unknown column 'temp_issue_id' in 'on clause'
if any one know about this please help me. i am new to this

Convert String elements to Array

Convert String elements to Array

I have a String :
str="[a],[b],[c]";
How can I convert str to array in Java (Android):
array[0] -> a
array[1] -> b
array[2] -> c

Wednesday, 18 September 2013

Formatting JSON.stringify code

Formatting JSON.stringify code

I have made my callback and now have my hotel list outputted into my
browser using JSON.stringify and removed the ugly quotes.
How do I now take only the values I need such as address, hotel name and
style these using css?
I can only manage to output the whole callback without any styling
$.ajax({ url:
"http://api.eancdn.com/ean-services/rs/hotel/v3/list?cid=55505&minorRev=20&apiKey=cbrzfta369qwyrm9t5b8y8kf&locale=en_AU&city=Sydney&stateProvinceCode=NW&countryCode=AU&numberOfResults=2&type=json",
dataType: "jsonp", jsonpCallback:"myCallback",
success: function(data) {
var StrHotelListResponse = data.HotelListResponse.HotelList.HotelSummary;
$.each(StrHotelListResponse, function(index, value) {
var StrHotelListResponse = JSON.stringify(data);
$('#target').append(StrHotelListResponse.replace(/\"/g, ""));
$('#target').console.log(JSON.stringify(StrHotelListResponse));
});
},
error: function(e) {
console.log(e.message);
//alert('no');
}
}); });

ItemFileWriteStore vs dojo.store.Memory?

ItemFileWriteStore vs dojo.store.Memory?

I'm using dojo 1.6 and I wanna create a store to connect to a grid;
however, in dojo 1.6 only exists two ways with ItemFileWriteStore and
store Memory which of these two is the best ?
I'm working with spring 2.5 for the controller.

Zip File Entry has custom file extension. C# claims it cannot open

Zip File Entry has custom file extension. C# claims it cannot open

I have a zip file given to us by a 3rd party. In this zip files are custom
files. These are just text files with a different extension, which I
assume is just to frustrate me.
I'm trying to open this files in my C# application, but it keeps throwing
the error that the format is not supported.
Since these are just text files, I feel there must be some way for this to
happen.
If anyone has any ideas, please let me know.
Code:
using (ZipArchive archive = ZipFile.OpenRead(_trailerName))
{
ZipArchiveEntry entry = archive.GetEntry(tableChanged + ".trl");
Stream ms = entry.Open(); //Here is what's causing the issue.
StreamReader reader = new StreamReader(ms);
string allLinesRead = reader.ReadToEnd();
string[] everyCell = allLinesRead.Split('|');
int numRecords = Convert.ToInt32(everyCell[1]);
int numChanged = getRecordNum(tableChanged);
Console.Write(numRecords + "/" + numChanged + " - " + tableChanged);
if (numChanged != numRecords)
{
_errorMessage += "Records updated do not match trailer. (" +
numRecords + "/" + numChanged + ") Please check database. Table
affected: " + tableChanged + Environment.NewLine;
}
}
Error:
The given path's format is not supported.
I know this is specific, but I need advice on what steps I can take to
resolve this.
Thanks.

How to apply a loop on a script for multiple/various sheet names in Google spreadsheet?

How to apply a loop on a script for multiple/various sheet names in Google
spreadsheet?

I'm still learning GoogleApp scripting. Can anyone guide me in the right
direction how to apply the same codes on a Google spreadsheet with
multiple sheets with different sheet names? Maybe I need a script for a
loop?
Thank you for your help in advance!
This is the script I have so far:
function MakeRowGray() {
var sheet =
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var columnD = sheet.getRange(2, 2, sheet.getLastRow()-1, 1); // Row B
var dValues = columnD.getValues();
var columnE = sheet.getRange(2, 3, sheet.getLastRow()-1, 1); // Row C
var eValues = columnE.getValues();
for (var i = 2; i < dValues.length + 2; i++) {
if (dValues[i-2][0].toUpperCase() == 'Y' &&
eValues[i-2][0].toUpperCase() == 'Y') { // Checks for 'Y' in both D
and E columns (Participated & Received)
// If they're both yes, make them gray...
sheet.getRange(i, 1, 1, 7).setBackgroundColor("#CCCCCC"); // Make
A through H gray
}
else if (dValues[i-2][0].toUpperCase() == 'Y' &&
eValues[i-2][0].toUpperCase() != 'Y' &&
eValues[i-2][0].toUpperCase() != 'W' &&
eValues[i-2][0].toUpperCase() != 'W?') // IN PROGRESS CODE --
MAKE ROW BLUE??
{
sheet.getRange(i, 1, 1, 7).setBackgroundColor("#AAAAFF"); // Make A
through H blue
}
else if (dValues[i-2][0].toUpperCase() == 'Y' &&
eValues[i-2][0].toUpperCase() == 'W?') // Not sure if Waiting or not
(W?)
{
sheet.getRange(i, 1, 1, 7).setBackgroundColor("#FFBB00"); // Make A
through H slightly orange
}
else if (dValues[i-2][0].toUpperCase() == 'X' &&
eValues[i-2][0].toUpperCase() == 'X') {
sheet.getRange(i, 1, 1, 7).setBackgroundColor("#FF0000"); //
Red
}
else if (dValues[i-2][0].toUpperCase() == 'Y' &&
eValues[i-2][0].toUpperCase() == 'W') {
sheet.getRange(i, 1, 1, 7).setBackgroundColor("#FFFF00"); //
Yellow
}
else
{ // Reset...
sheet.getRange(i, 1, 1, 7).setBackgroundColor("#FFFFFF");
}
}
};

How to switch back to a view controller without losing data

How to switch back to a view controller without losing data

I have an iCarousel view, which for those of you who don't know what it
is, works a lot like UITableView or UICollectionView. If you'd like, we
can pretend that I'm using one of those.
Anyways, my iCarousel has a bunch of items in it already. They're defined
in a global NSMutableArray by the name of "items". My problem is when I
switch views for a minute away from the carousel, when i switch back, the
items are gone. I believe this is because when i switch views, the
carousel is deallocated or the reference is lost. When i try to reload it,
i use this code:
self.carousel = [[iCarouselExampleViewController alloc]
initWithNibName:@"iCarouselExampleViewController" bundle:nil];
[self presentViewController:self.carousel animated:YES completion:nil];
[self.carousel.carousel reloadData];
This code brings me to an empty carousel. I assume this is because, as
aforementioned, i lost the reference to the view and i had to reallocate
it with the initWithNibName call. Anyways, how do i get around that? I
dont want to lose the data that was in the class. any suggestions? And how
would i go about switching back to a UITableView from a different view
controller in the first place?

Removing values from a TextBox based on a checkbox

Removing values from a TextBox based on a checkbox

i populate a textbox when checkboxes are clicked, with their values (comma
separated) Now i want to remove that value from the textbox when the
checkbox is unchecked.
here is where i am now:
$(document).ready(function () {
$('.checkboxes').change(function () {
if ($(this).is(':checked')) {
if ($('.DISTRIBUTION').val().length == 0) {
var current = $('.DISTRIBUTION').val() + $(this).val()
+ ",";
}
else {
var current = $('.DISTRIBUTION').val() + "," +
$(this).val();
}
}
else if ($(this).not(':checked')) {
var current =
$('.DISTRIBUTION').val().replace(","+$(this).val(), "");
}
$('.DISTRIBUTION').val(current);
});
});
it works great! except for the first value, which does not have a comma in
front of it. how do i handle that situation? How do i find out of the
value to be removed, is actually the first item in the textbox?
here's an example:
apple,pear,peach,banana
when i remove ",pear" and ",banana" it works fine, but when i get to
",apple" it does not work as apple is first and there is no comma.
Thanks!

Cannot remove DOM Element (JavaScript, CreateJS)

Cannot remove DOM Element (JavaScript, CreateJS)

I have a problem removing a DOMElement from the stage. This is how I
created my domElement with createjs Framework.
this.domElement = new
createjs.DOMElement(document.getElementById('nickname'));
this.domElement.x = 580;
this.domElement.y = 200;
this.stage.addChild(this.domElement);
My HTMl code looks like this:
<form id="myForm" style="visibility: hidden">
<input id="nickname" value="" size="10">
Everything works fine till I want to remove "domElement" from the stage.
Here is how I attempted it:
this.stage.removeChild(this.domElement);
I also tried other solutions like :
this.stage.parentNode.removeChild(this.domElement);
Do you have an ideea why I am not able to remove this DOM Element?
Thank you in advance for your help

xcode Interface Builder is resizing back to a wrong size a UITableViewCell

xcode Interface Builder is resizing back to a wrong size a UITableViewCell

I have a UITableView with 2 different xib files, the first one for iPhone,
the second one for iPad, then I have for both a xib for the custom Cell,
the iPhone version works well, the iPad version (which is bigger) is
automatically resize itself to 320 width, Inside I have a UILabel that
needs to show text in 2 lines, when I set the 2 lines on Interface Builder
even if I had the cell size to 600 for example, it is automatically
resized back to 320
I've setted the class and the names are correct, I don't understand which
relationship there's between the first xib (the iPhone custom cell) and
the second (the iPad custom cell which is resized back to 320)
any advice?

Tuesday, 17 September 2013

.Net Immutable Collections with WPF DataGrid

.Net Immutable Collections with WPF DataGrid

Has anybody found a nice pattern for binding ImmutableCollections ( from
the MS BCL ) to a WPF DataGrid? To represent mutablility of an immutable
structure I would wrap it with ISubject to track changes and provide new
versions to the datagrid.
ISubject<ImmutableList<T>> <--(binding)--> DataGrid
Has anybody tried something like this before? Any suggestions on how to
model this. The DataGrid obviously needs a mutable collection such as
ObservableCollection directly under it so perhaps the problem can be
reduced to
ISubject<ImmutableList<T>> <-----> ObservableCollection<T>
Any suggestions?
ObservableCollection

Is Google's Webspeech server request-limiting me, and is there a fix?

Is Google's Webspeech server request-limiting me, and is there a fix?

I've been writing an extension that allows the user to issue voice
commands to control their browser, and things were going great until I hit
a catastrophic problem. It goes like this:
The speech recognition object is in continuous mode, and whenever the
onerror: 'no-speech' or onend events fire, it restarts. This way, the
extension is constantly waiting to accept input and reacts whenever a
command is issued, even after 5 minutes of silence.
After a few days of of development, today I reached the point where I was
testing it in practical use, and I found that after a little while (and
with no change to anything on my part), my onend event started firing
constantly. As in, looking at the console, I would see 18,000 requests
being made in the space of three seconds, all being instantly denied, thus
triggering onend and restarting the request.
I'm aware that it would be optimal to wait for sound before sending a
request, or to have local speech recognition capabilities without the need
for a remote server, but the present API does not allow that.
Are my suspicions correct? Am I getting request limited?

Altering database to include FileTable gives me syntax error

Altering database to include FileTable gives me syntax error

I have an existing database and I'd like to take advantage of the
FileTable feature in SQL Server 2012. Looking online, this is how I update
the database:
ALTER DATABASE MyDB
ADD FILEGROUP MyDBFiles CONTAINS FILESTREAM
(
NAME = SomeCoolName,
FILENAME= 'C:\FileTable\Data'
)
GO
However, I get Incorrect syntax near 'NAME' error.
What am I doing wrong?

Want the width to be padding + text itself only

Want the width to be padding + text itself only

I have this http://jsfiddle.net/d4Ajj/1/
I Want the width to be the text itself + the padding 20px (x 2).
In the fiddle I put width to be 400px otherwise there is no result. Is
there a way to do this?

PHP use variable to pass multiple arguments to function

PHP use variable to pass multiple arguments to function

I have a function that expects 9 arguments to be passed to it. The first
argument it expects is a string, the rest are ints.
Here is the function:
getProductPrice('red', 8, 1.6, 2.15, 0, 0, 0, 17.6, 0);
When that gets run, it works fine. However, when I run it like this:
getProductPrice("'red'".','.$arguments);
It does not work.
"'red'".','.$arguments
outputs: 'red', 8, 1.6, 2.15, 0, 0, 0, 17.6, 0
If anyone could tell me how to use the $arguments variable in place of all
the arguments?
What I ended up suspecting was making it not work, is that what $arguments
is outputting is a string, so I looked into how to convert a comma
separated string of numbers into a php function's arguments.
I came across this:
$params = explode(',', $str);
call_user_func_array("func", $params);
I can't figure out how to use this solution for two reasons:
1. I need to pass a string along with the numbers.
2. simply putting my function name where it says "func" in that example
won't work, because it's a cakephp function, which requires me to put
$this->ModelName->functionname, which breaks the first argument in the
call_user_func_array function()
Any ideas how to help me guys?
I could just put the variables that make $arguments output what it does,
but it's a ton of complicated logic and math to get each of those numbers,
so my function calls would look ridiculous.
Thanks again.

Sunday, 15 September 2013

Java semaphore + No synchronization lock is held when acquire() is called

Java semaphore + No synchronization lock is held when acquire() is called

I am not able to understand the meaning of below line which is provided on
link JavaWorld
No synchronization lock is held when acquire() is called because that
would prevent an item from being returned to the pool

Lilypond: controlling clef and key signature visibility, aligning markup

Lilypond: controlling clef and key signature visibility, aligning markup

My effort to create a document with six incipits from different pieces is
running into a couple of problems. Can anyone help? I am pasting my code
below (I've reduced the example somewhat for the purposes of asking the
question).
Problem 1: How can I hide the clefs and key signatures from the ends of
the lines? The commands in \score are not behaving as I thought they would
based on the documentation.
Problem 2: How can I align the text markup to the start of the lines? I
want "No. 1" etc. left-aligned to the very start of the staff.
Extra query: Does anyone know why using \partial breaks the beaming in the
measure preceding the partial measure? Is there a general fix for this?
(Short of hard-coding the proper beaming with [ ].)
Any assistance gratefully received!
=========================
\version "2.16.2"
notes = {
\bar""\mark\markup\normalsize{No. 1}
\clef bass
\time 6/8
\key g \major
\partial 8 \once \stemUp d=8 |
g( d e) e( c d) |
\partial 8*5 d g d b g
\bar""
\break
\mark\markup\normalsize{No. 2}
\clef bass
\time 3/8
\key d \minor
\partial 8 a=8 |
d,4 bes'8 |
\partial 4 cis,4
\bar""
\break
\mark\markup\normalsize{No. 3}
\clef bass
\time 3/8
\key c \major
\partial 8 g=8 |
c8 c,16( d e f) |
\partial 4 g8( a)
\bar""
\break
\mark\markup\normalsize{No. 4}
\clef bass
\time 12/8
\key es \major
\partial 8 es8 |
es( d es) bes( c d) es( d es) g( f g) |
\break
\mark\markup\normalsize{No. 5}
\clef bass
\time 3/8
%\key c \minor
\partial 8 g=8 |
es8. f16 d8 |
\partial 16*3 es8.
\bar""
\break
\mark\markup\normalsize{No. 6}
\clef alto
\time 6/8
\key d \major
\partial 8 a='8 |
<< { d,4. e8 fis g |\noBreak
fis d a' \stemDown a16( g fis g) a8 \stemUp |\noBreak
d, a d e fis g |\noBreak } \\
{ fis,4. a8 s s |
d, s8*5 |
fis8 s s a s s | } \\
{ s2. |
a8 s8*5 |
s2. | } >>
fis'8 d a d,4
}
\score {
\relative c <<
\new Staff \notes
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
\override Staff.Clef #'break-visibility = #begin-of-line-visible
\override Staff.Clef #'explicitClefVisibility = #begin-of-line-visible
\override Staff.TimeSignature #'break-visibility = #begin-of-line-
visible
\override Staff.KeySignature #'break-visibility = #begin-of-line-visible
\override Staff.KeySignature #'explicitKeySignatureVisibility = #begin-
of-line-visible
\override Staff.KeyCancellation #'break-visibility = #all-invisible
\override Staff.KeyCancellation #'explicitKeySignatureVisibility = #all-
invisible
>>
\layout {
}
}
\paper {
paper-height = 250\pt%7in=504pt max.
line-width = 432\pt
paper-width = 432\pt
left-margin = 0\pt
top-margin = 0\pt
bottom-margin = 0\pt
indent = 0
head-separation = 0\pt
page-top-space = 0\pt
after-title-space = 0\pt
before-title-space = 0\pt
between-system-padding = 0\pt
between-system-space = 0\pt
between-title-space = 0\pt
foot-separation = 0\pt
ragged-bottom = ##f
ragged-right = ##t
}
\book {
#(set-global-staff-size 13)
}
\header {
tagline = ""%removed
title = ""
}

Chrome iOS - Loading indicator when applying class with jQuery

Chrome iOS - Loading indicator when applying class with jQuery

For some reason, my page displays the loading indicator on Chrome, when
applying a class to a section with css transition. I think this is causing
the address bar to be 'active', and won't slide up again. And thus
covering my navigation bar. I'm using iPhone 4, iOS5.
I've tried to pin-point what might be causing this, because it's not there
on desktop Chrome, or on Safari on the iphone. The page has a google map,
and I'm collecting data from an XML document using $.ajax. This is however
not causing the problem, cause I've tried disabling everything in the
js-file, except the click handler that applies the class.
Here's the CSS:
#main_bottom {
position: absolute;
bottom: -297px;
width: 300%;
height: 384px;
background-color: #ececec;
-webkit-transition-property: bottom, left;
-webkit-transition-duration: 0.2s;
}
#main_bottom.active {
bottom: 36px;
}
I'm using this to apply the class:
$(document).on('click', '#main_bottom > section:not(#gps) > a', function (e){
e.preventDefault();
$($main_bottom).toggleClass('active');
});
What could be causing this? It seems to be related to the animation
somehow, not sure why. Could it be the absolute positioning, along with
the css transition? If I'm allowed to link to the current live site, I'd
be happy to do that :)

Objective-C setTitle forState method

Objective-C setTitle forState method

I'm developing an application which has a view of only one card and
everytime this card is clicked the card shows a random card from the deck.
I already implemented a deck class which has drawRandomCard method which
draws a random card
@interface Deck()
@property (strong,nonatomic) NSMutableArray *cards; //of Card
@end
@implementation Deck
- (NSMutableArray *)cards
{
if(!_cards){
_cards= [[NSMutableArray alloc]init];
}
return _cards;
}
- (void)addCard:(Card *)card atTop:(BOOL)atTop{
if(atTop)
{
[self.cards insertObject:card atIndex:0];
}
else
{
[self.cards addObject:card];
}
}
- (Card *)drawRandomCard
{
Card *randomCard = nil;
if(self.cards.count)
{
unsigned index = arc4random() % self.cards.count;
randomCard = self.cards[index];
[self.cards removeObjectAtIndex:index];
}
return randomCard;
}
@end
how can i use the drawRandomCard method in my ViewController and the
setTitle forState method to be able to change the title of the card
according to the card drawn randomly from the drawRandomCard method ?

Are cookies secure from local access on the user's computer?

Are cookies secure from local access on the user's computer?

The book says "When a user visits a website, the browser locates and
cookies written by that website and sends them to the server. Cookies may
be accessed only by web server and scripts of the website from which the
cookies originated (i.e a cookie set by a script on amazon.com can be read
only by amazon.com servers and scripts) The browser sends these cookies
with every request to the server."
Is this really true. I mean cookies is just text files without any type of
sequrity so anyone can read the cookie as long as they know the name ov
the cookie.
//Tony

How to Make Magento Module Domain specific

How to Make Magento Module Domain specific

How we can make our module domain specific?
e.g suppose user buys module for www.example.com and if it used by another
domain it will not work.

how to split a C++ string to get whole string individually and some parts/characters of it

how to split a C++ string to get whole string individually and some
parts/characters of it

My question is, how can I split a string in C++? For example, I have `
string str = "[ (a*b) + {(c-d)/f} ]"
It need to get the whole expression individually like [,(,a,*,b,......
And I want to get the brackets only like [,(,),{,(,),},] on their proper
position
How can I do these with some easy ways

Saturday, 14 September 2013

REMOVE JAVASCRIPT CODES Prevention TO OPEN A LINK [on hold]

REMOVE JAVASCRIPT CODES Prevention TO OPEN A LINK [on hold]

I Have a Html theme names"Elliot"
You Can Download it:
I Need Change This Theme : In this case, when you click on the
news(picture1) or on the images will open a new page and go to a url(for
exp:go to stackoverflow.com)
tnx plz help me

How can i stop html5 audio from auto download

How can i stop html5 audio from auto download

I am using this
<audio src="audio.mp3" />
Now that file is big and system automatically downloads it when someone
loads the page.
is there any way that when someone press play , only then system
downlaods. Because that player is in my every page and it wastes the BW

why does if(number

why does if(number

var way = 'up';
var m25 = {
'n': 10
};
for (var somelongnumber = 0; i < 10000; i++) {
if (way === 'up') {
m25.n = m25.n + 5;
if (m25.n >= 90) {
way = 'down';
}
} else {
m25.n = m25.n - 5;
if (m25.n <= 10) {
way = 'down';
}
}
console.log(way + m25.n);
}
this console.logs:
up15
up20
up25
up30
up35
up40
up45
up50
up55
up60
up65
up70
up75
up80
up85
down90
down85
down80
down75
down70
down65
down60
down55
down50
down45
down40
down35
down30
down25
down20
down15
down10
down5
down0
down-5
down-10
down-15
down-20
down-25
down-30
down-35
down-40
down-45
down-50
down-55
why does it go past zero? I am very confused!

Name 'now' is not defined?

Name 'now' is not defined?

When I typed in the following code it said that name 'now' is not defined.
However, I did import datetime?
from datetime import datetime
print str(now.month) + "/" + str(now.day) + "/" + str(now.year)
(I have already searched on the web for this but it did not come up with
anything related to this)

iOS- Cannot get expected json results back

iOS- Cannot get expected json results back

I am trying to use google currency rest api to get USD->GBP convert
result. something like this->
http://www.google.com/ig/calculator?hl=en&q=100USD=?GBP
the json is response is :
{lhs: "100 U.S. dollars",rhs: "62.9802242 British pounds",error: "",icc:
true}
so i m trying to get the values from "lhs" "rhs" stored into 2 strings
here is my method for fetching converted result data :
@implementation ConvertorBrain
-(id)initWithFromCurrency:(NSString *)fromCurrency
toCurrency:(NSString *)toCurrency
withAmount:(int)amount
{
if (self=[super init]) {
self.fromCurrency = fromCurrency;
self.toCurrency = toCurrency;
self.amount = amount;
}
return self;
}
-(void)getConvertResult
{
NSString *encodeFromCurrencyTerm = [self.fromCurrency
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *encodeToCurrencyTerm = [self.toCurrency
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *searchLocation = [NSString
stringWithFormat:@"http://www.google.com/ig/calculator?hl=en&q=%d%@=?%@",
self.amount, encodeFromCurrencyTerm, encodeToCurrencyTerm];
NSURL *convertedResults = [NSURL URLWithString:searchLocation];
NSData *JSONData = [[NSData alloc]
initWithContentsOfURL:convertedResults];
if ([JSONData length] > 0) {
NSError *error = nil;
NSDictionary *dictoionary = [NSJSONSerialization
JSONObjectWithData:JSONData options:0 error:&error];
if (!dictoionary) {
NSLog(@"Json parsing failed: %@", error);
}
self.lhs = [dictoionary valueForKey:@"lhs"];
self.rhs = [dictoionary valueForKey:@"rhs"];
} else {
[[[UIAlertView alloc] initWithTitle:@"Service Error"
message:@"Cannot complete your request at this time, please try
later" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]
show];
}
}
then i called method in some other place like this :
self.brain = [[ConvertorBrain alloc] initWithFromCurrency:@"USD"
toCurrency:@"GBP" withAmount:100];
[self.brain getConvertResult];
then my expected lhs and rhs results should be lhs= "100 U.S. dollars" rhs
="62.9802242 British pounds"
however, if i run the code, it throw me back these errors: Error
Domain=NSCocoaErrorDomain Code=3840 "The operation couldn't be completed.
(Cocoa error 3840.)" (No string key for value in object around character
1.) UserInfo=0x7172860 {NSDebugDescription=No string key for value in
object around character 1.}
i cannot figure out what has went wrong..need help, also, i tried to debug
it a bit. it seems is this line went wrong, dosent get any data somehow ->
NSData *JSONData = [[NSData alloc]
initWithContentsOfURL:convertedResults];

Dllhost.exe - How to know programmatically to which COM+ application it belongs

Dllhost.exe - How to know programmatically to which COM+ application it
belongs

I'd like to find out programmatically which COM+ applications are running
when I have some dllhost.exe processes running in my task manager under
Windows.
Process Explorer from Sysinternal can retrieve the info by retrieving the
CLSID in the command line (see the image). How can I do that by code or
with a command ?

I've tried :
WMIC PROCESS get Caption, Commandline, Processid
with no success. Unable to retrieve the command line used to run dllhost.exe

Link and button positioning

Link and button positioning

I need to make buttons and links of specific class to look and to be
positioned the same way. I tried this (simplified):
<html>
<head>
<title>My site</title>
<style>
.my-class {
display: inline-block;
background-color: #cccccc;
width: 18px;
height: 18px;
cursor:pointer;
box-sizing: border-box;
border: 1px solid #888888;
}
</style>
</head>
<body>
<a href="#" class="my-class" title="My link"></a>
<button class="my-class" type="submit" title="My button"></button>
</body>
</html>
But the link is positioned a bit higher than the button:

Is there a cross-browser css-only solution (no javascript) that allows to
position them on the same level?

Friday, 13 September 2013

Populating user data with facebook AFTER the user signed up with their email address

Populating user data with facebook AFTER the user signed up with their
email address

I'm sure there is a feasible solution to this problem but I couldn't find
it so far. In my application,I only want to let users with the certain
email account(such as gmail etc.) for now. Once the user verified their
email, I want to create a populate with Facebook button at the bottom of
my view that will only used once, and it will disappear once the person
populates information from it. I am planning to place this button at the
button of the profile view view controller here. I have a login/sign up
implementation using parse.com as backend and after sign in, user directly
goes to this view. If anyone knows the solution to this, I would
appreciate the help. Thank you!

Saving HTTP_REFERER in django

Saving HTTP_REFERER in django

I have the following code in Django:
def signup(request)
http_referer = request.META.get('HTTP_REFERER','/')
if request.user.is_authenticated():
return HttpResponseRedirect(reverse('index'))
else:
if request.method == 'GET':
# return HttpResponse(http_referer) Here it returns the right
value
args={}
return render(request,'signup.html',args)
elif request.method =='POST':
# return HttpResponse(http_referer) Here it breaks and returns
current url
... actual code goes here, but this should be enough
I want to save the HTTP_REFERER for later use, because it is being
changed. I have tried storing it in variable, but somehow variable still
automaticlly changes. I guess i could try storing it temporarily in
database (it probably won't change there), but since I only need it in
that function and never again, that seems like a bad solution. Is there a
better way of doing this?

Get List of Active Directory Print Servers and Printers

Get List of Active Directory Print Servers and Printers

For a mvc 4 intranet site on an enterprise IIS, what's the correct or best
approach for getting print server and related printer properties within
active directory? I realize there's a credential issue, but isn't there
also a similar issue with connections to a MSSQL database?
Any help is greatly appreciated. Thank you.

execute mysql query and display results while reading

execute mysql query and display results while reading

I have a mysql database and i want to execute a query and while this query
is being executed the data should be displayed in page.
so for example if i have 1,000 result row from the query result i want to
display each row while the query is being executed instead of waiting till
the query finishes executing then displaying them at once.
here is my php code:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// Database Name
mysql_select_db("dbname", $con);
$test_query = mysql_query("SELECT * FROM V_Posts where _PID > 100 and _PID
< 10000");
while($CHECK_PCID_R = mysql_fetch_array($test_query))
{
echo $CHECK_PCID_R['_PID'] . "<br />";
}
?>
I tried
echo $CHECK_PCID_R['_PID'] . "<br />";
flush();
But it didn't work :(

Java applet functions aren't being accessed by Javascript

Java applet functions aren't being accessed by Javascript

I am trying to create a very simple java Applet to try out using Java
functions in a web browser. problem is, is that I can't get any sort of
functionality from my applet. I've tried dozens of tutorials and answers
from within this site, but nothing produces any different result, The
browser always says AppName.FunctionName is not a function.
Here is my html...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4 /strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Test Applet</title>
</head>
<body onload="test()">
<applet code="TestApplet.class" name="AppTest"
height="350" width="100"></applet>
<script language="Javascript">
function test(){
alert("Attempt 1");
var elem= document.getElementById('AppTest');
alert(elem);
elem.test();
alert("Attempt 2");
document.AppTest.test();
}
</script><br>
</body>
</html>
and here is my Java code...
import javax.swing.JApplet;
public class TestApplet extends JApplet {
public String sayHi(){
return "hello";
}
public void test(){
System.out.println("You did it bro");
}
}
Any ideas why this seems to do nothing? Note: I am testing it using FireFox

finding which div was clicked when click event is on class

finding which div was clicked when click event is on class

I have multiple divs under class subcat. And I have a click event on the
class. I want to get the div which was clicked.
<div class="subcat"><a href="#">abc</div>
<div class="subcat"><a href="#">def</div>
<div class="subcat"><a href="#">ghi</div>
<div class="subcat"><a href="#">jkl</div>
My jquery function is like
$('.subcat').click(function(element) {
element.preventDefault();
getsubcat(element);
});
But the element shows null. I tried using this instead of element but that
didn't work either.
$('.subcat').click(function(element) {
this.preventDefault();
getsubcat(this);
});
I had earlier written it as below and it was working perfectly well.
<div class="subcat"><a href="#" onclick="getsubcat(this)">abc</div>
<div class="subcat"><a href="#" onclick="getsubcat(this)">def</div>
<div class="subcat"><a href="#" onclick="getsubcat(this)">ghi</div>
<div class="subcat"><a href="#" onclick="getsubcat(this)">jkl</div>

Thursday, 12 September 2013

Inscribing Square within Circle

Inscribing Square within Circle

This is my second programming homework assignment this semester and I am
totally new to the concept of java programming. I was looking to see if
anyone could give me some advice on my code because I'm really confused
right now. Here's what I have so far:
I can get it to work a little, but the given values have to be around 500
and the inscribed circle that is drawn isn't in the right location. If
anyone could help I would really appreciate it. My main question is
regarding the fact that I'm able to print my circle inside my square with
no problems but when I try to print the inscribed circle using the offset
as my graphical coordinates the drawing comes out skewed to the right. If
anyone could review code and offer me some advice that would be highly
appreciated.
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
/**
HW2.java
@author Xavier D Martin <martinx@email.sc.edu>
@version 1.1
Created on Sep 11, 2013
*/
public class HW2 extends JFrame{
public static double diameter ;
public static double insideSqside;
public static int boarder = 30;
public static int offset;
public void paint(Graphics canvas)
{
canvas.drawRect(boarder, boarder, (int)diameter, (int)diameter);
canvas.setColor(Color.blue);
canvas.fillRect(boarder, boarder, (int)diameter, (int)diameter);
canvas.drawOval(boarder, boarder, (int)diameter, (int)diameter);
canvas.setColor(Color.RED);
canvas.fillOval(boarder, boarder, (int)diameter,(int) diameter);
/**I use the offset variable here to get graphical coordinates of
my inscribed
rectangle comes out skewed to the right I'm trying to get
it centered in the JFrame
*/
canvas.drawRect(offset,offset, (int)insideSqside,(int)insideSqside);
canvas.setColor(Color.yellow);
canvas.fillRect(offset, offset,(int)insideSqside ,(int)insideSqside);
}
public HW2(int x, int y)
{
super("Draw Circle Square");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(x,y);
this.setVisible(true);
}
public static void main(String[] args) {
double circumference, radius, circleArea,outsideSqarea,largeSqside,
insideSqarea;
String diameterInput;
diameterInput = JOptionPane.showInputDialog("Enter the diameter of
the
cirlce: ");
diameter = Double.parseDouble(diameterInput);
HW2 hw = new HW2((int)diameter+100,(int)diameter+100);
radius = diameter/ 2;
circleArea = Math.pow(radius,2) * Math.PI;//circle area
circumference = 2 * Math.PI * radius;//circumference
outsideSqarea = Math.pow(diameter, 2);//area of outside square
largeSqside = diameter;//sides of outside square
insideSqside = (Math.sqrt(Math.pow(radius, 2) + Math.pow(radius,
2)));//side of inside square
offset = (int)diameter - (int)insideSqside;//difference between
diameter of
circle and and inside square to get graphical coordinates of
rectangle
insideSqarea = Math.pow((double)insideSqside,2);//area of inside
square
//prints out
JOptionPane.showMessageDialog(null, "Your circle's diameter is" + " " +
diameter);
JOptionPane.showMessageDialog(null, "Your circle's radius is" + " " +
radius);
JOptionPane.showMessageDialog(null, "Your cirlce's area is" + " " +
circleArea);
JOptionPane.showMessageDialog(null, "Your circle's circumference" + " " +
circumference);
JOptionPane.showMessageDialog(null,"The area of the smallest square
containing the circle is" + " "+ outsideSqarea);
JOptionPane.showMessageDialog(null,"The area of the largest square
contained in the circle is" +" "+ insideSqarea);
}
}

Simple way to run two while loops at the same time using threading?

Simple way to run two while loops at the same time using threading?

I have looked through all the previous answers, and they are all too
complicated for a beginner like me. I want to run too while loops at the
same time. For example, I want to run these two at the same time:
def firstFunction():
do things
def secondFunction():
do some other things
As I said, the other answers are too complex for me to understand.

Select Where In Join

Select Where In Join

I want to get results from ids i already know. This is my attempt(pseudo):
SELECT * FROM main LEFT JOIN child WHERE main.id IN("1,2,3,4") ON main.id
= child.main_id
How to get the childs from main by known ids from WHERE IN?
thx for help

split JSON data from PHP to three arrays in JavaScript

split JSON data from PHP to three arrays in JavaScript

I am passing values from PHP Script to JS using JSON encode.
$arr=array('X'=>$X,'Y'=>$Y,'par'=>$par);
echo json_encode($arr);
Which produces
{"X":
["-0.9537121038646844","-0.9537121038646844","-0.9537121038646844","0.9537121038646843",""],
"Y":
["-0.9537121038646844","-0.7799936811949519","-0.5533396521383813","-0.37962122946864896",null],
"par":
["0.009811016749950838","0.005007306592216437","5.058030686503405E-4","9.451402320405391E-4",null]}
In the javascript, I used the following command
{
$.post("plot.php",param,function(data){dataType:"json";console.log(data);Var
X1=data.X;});
}
But I am not able to obtain the values of X alone. I tried few suggestions
from similar threads, but none of them did the trick.I need the three
arrays, X,Y and Par to be used in JS.

Index Not working well in mysql

Index Not working well in mysql

I have a a query like this :
SELECT SQL_NO_CACHE u.userid AS userid ,
u.userrname , pmdate , pmid , pmmessage , imagelink
FROM `privatemessagereceiver` JOIN privatemessage
ON pmrtouserid = '1' AND pmrpmid = pmid
JOIN user u ON u.userid = pmuserid
JOIN image i ON i.imageid = u.userprofileimageid
ORDER BY pmr_date DESC
explain :
SIMPLE privatemessagereceiver ref pmrpmid,pmrtouserid pmrtouserid 4
**const** 3116 Using where; Using filesort
IT workes well on index and it takes only 0.0006 sec to execute
but when I use that query like this :
SELECT SQL_NO_CACHE result.*
FROM (
SELECT u.userid AS userid ,
u.userrname , pmdate , pmid , pmmessage , imagelink
FROM `privatemessagereceiver` JOIN privatemessage
ON pmrtouserid = '1' AND pmrpmid = pmid
JOIN user u ON u.userid = pmuserid
JOIN image i ON i.imageid = u.userprofileimageid
ORDER BY pmr_date DESC
) as result
explain :
PRIMARY <derived2> ALL NULL NULL NULL NULL 3117
2 DERIVED privatemessagereceiver ALL pmrtouserid pmrtouserid 4
7054 Using where; Using filesort
it takes 1.1 sec to execute !
============================================================== It seem
that the 2nd query do not user index and as you can see const is not
defined . Also I used Use Index And Force Index , but not working ...
where is the problem and how can I solve ?

Thread-safety in C#

Thread-safety in C#

I have currently been assigned a project that was implemented couple of
years ago in C#. It consists of frames and some excel-files extraction,
but the problem is that this project is extremly broken/outdated and I
have to change some functionalities and add some new feature.
There are some libraries that are supported only after .NET framework 3.0
that I need to use in the new features,and the framework that the current
project was built on is 2.0 or less,so changing the framework raised some
thread safety problems.
Between two partial classes for example which are the design file code and
the backend code trying to change one label's value raises an error saying
that I can not edit something that is being used at the moment... I used
delegates for one of the labels, and it worked fine..then the other
textbox raised another error.. So is there an option to encapsulate the
whole thing and apply thread safety to the whole code without having to
follow each line where the error happens?
Regards

Wednesday, 11 September 2013

How to move CSS navbar elements to the right?

How to move CSS navbar elements to the right?

for an online course I was taking I created a web app through heroku
here is the site
http://is.gd/fMJN8f
In the top I have a navigation bar with elements for home, about, faq,
contact, login and register
I would like to move the login and register elements to the right of the
navigation bar so the login drop-down menu looks nicer
here is the code I tried
<div class = "navbar navbar-inverse navbar-fixed-top">
<div class = "navbar-inner">
<div class = "container">
<button type = "button" class = "btn btn-navbar" data-toggle =
"collapse" data-target = ".nav-collapse">
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
</button>
<a class = "brand" href = "#"><span class =
"SportMem-sport">Sport</span><span class =
"SportMem-mem">Mem</span></a>
<div class = "nav-collapse collapse">
<ul class = "nav">
<li class = "active"><a href = "#">Home</a></li>
<li><a href = "/about">About</a></li>
<li><a href = "/faq">FAQs</a></li>
<li><a href = "/contact">Contact</a></li>
<li class = "login">
<a id = "login-start" href = "#">
Login<span></span>
</a>
<div id = "login-form">
<form>
<fieldset id = "inputs">
<input id = "username" type = "email" name = "Email"
placeholder = "Email Address" required>
<input id = "password" type = "password" name = "Password"
placeholder = "Password" required>
</fieldset>
<fieldset id = "actions">
<input type = "submit" id = "submit" value = "Log-in">
<label><input type = "checkbox" checked = "checked"> Keep me
logged-on</label>
</fieldset>
</form>
</div>
</li>
<li class = "register.html"><a href = "#register">Register</a></li>
</ul>
</div>
</div>
</div>
i tried floating the elements to the right among others but nothing I've
tried worked
Could someone please find me a solution?
Help is greatly appreciated

Validation of a geometry in WKT format

Validation of a geometry in WKT format

I am new to GIS area and I need to validate a geometry in WKT format in
java, to check whether a simple polygon is a closed loop, i.e the start
and end points of the vertices should be the same. I am currently using
jGeometry class of oracle spatial(com.oracle.sdoapi), get the first and
last vertices and comparing them. also, i am using getType() method to
check whether it is a simple polygon or not. The following is the piece of
code that am using:
WKT wkt = new WKT();
JGeometry geometry = wkt.toJGeometry(wkt.getBytes());
double[] d1 = geometry.getFirstPoint();
double[] d2 = geometry.getLastPoint();
if(!jGeometry.getType() == jGeometry.GTYPE_POLYGON){
//error message for other geometries
}
Is there any simple way of doing this or is there any API available? I
dont want to reinvent the wheel, if it is already done and simple to use.
Thanks!

What more does the code need to delete a node from a linked list successfully?

What more does the code need to delete a node from a linked list
successfully?

I want to delete a given node from a linked list by the node's index
number (serial number). So what I tried to do in my function is that,
first I have taken the user input of the index number. Then I used two
node type pointers temp and current. I started traversing the list with
current and when the index number of the node matches with the user input,
I tried to delete the node. So far it is correct. I am facing problem with
the deletion logic. Here is the code I tried:
void delete_node(struct node **start,int index_no)
{
int counter=0;
struct node *temp, *current;
temp=(struct node *)malloc(sizeof(struct node));
current=(struct node *)malloc(sizeof(struct node));
current=*start;
while(current->next!=NULL)
{
counter++;
if(counter==index_no)
{
temp= current->next;
free(current);
/*I guess some code is missing here. Help me finding the logic.*/
}
else
{
printf("\n The index number is invalid!!");
}
}
}
The commented portion lacks the deletion logic. Also, I have a feeling
that this code is not space and time-efficient. If it is so, please
suggest to a way to make it more compact.

javascript countdown drift

javascript countdown drift

I have been coding a penny auction site and running into a problem with
the countdowns. The starting time seems to be a little different on
different machines (usually a discrepancy of about a second, but sometimes
2 or 3), which obviously is a big issue for bidders. I'm thinking a big
part of the answer is simply network lag, but (a) are there other factors
involved? and (b) is there a way to correct for network lag somehow?
I've tried hitting the server via an Ajax call every second, and that
works well enough (though there's always a bit of lag) but I'd rather not
have to do that because it'll be hard on the server.
JavaScript development is not my forte, so I'd appreciate any tips and
feedback!
Here's my code, as generated on the server
jQuery(document).ready(function() {
var aid = " . $aid . ";
var loadTime = Math.floor(jQuery.now()/1000);
//alert(loadTime);
serverTime = " . time() . ";
var clockDiff = loadTime - serverTime;
var diff;
auctionExpirationValue" . $aid . " = " . $expiry . ";
var newServerTime = setInterval(function() {
diff = window['auctionExpirationValue' + aid] -
Math.floor((jQuery.now())/1000) + clockDiff;
diff_string = parse_countdown(diff);
jQuery('#auction-expiry').html(diff_string);
},1000);
});
the clockDiff variable is to account for any clock differences between the
user's machine and the server. Obviously, if one machine is ahead or
behind the user would see different values in the countdown.
As you can see, the code loops every second (or, more or less every
second, I understand it's not exact), calculates the difference between
now and the auction expiry (compensating with clockDiff), formats it and
displays it. Pretty simple. The auctionExpirationValue*** global variable
is used to store the auction expiry time locally as a timestamp.
My client has also informed me that on his iPad, the countdown would
sometimes drift a little, in addition to the original discrepancy. What's
the explanation there?