Thursday, 3 October 2013

How can I retrive the top 3 rated events MySQL

How can I retrive the top 3 rated events MySQL

I have sporting events that users can rate. All data is stored in a Mysql
database.
Ratings_table:
rating_id PK
organisation float
value_for_money float
fun_factor float
facilities float
event_id int
user_id int
Event_table:
event_id PK
event_name varchar
Is there a way I can use Mysql query to join the tables and order them so
that the 3 highest rated events are retrieved?

Wednesday, 2 October 2013

Need help writing an int to roman numeral converter using only if, if else, and switch statements

Need help writing an int to roman numeral converter using only if, if
else, and switch statements

Here is the code:
public String ToRoman(int number) {
if ((number < 1 || (number > 3999)))
if (number >= 1000) return "M" + ToRoman(number - 1000);
if (number >= 900) return "CM" + ToRoman(number - 900);
if (number >= 500) return "D" + ToRoman(number - 500);
if (number >= 400) return "CD" + ToRoman(number - 400);
if (number >= 100) return "C" + ToRoman(number - 100);
if (number >= 90) return "XC" + ToRoman(number - 90);
if (number >= 50) return "L" + ToRoman(number - 50);
if (number >= 40) return "XL" + ToRoman(number - 40);
if (number >= 10) return "X" + ToRoman(number - 10);
if (number >= 9) return "IX" + ToRoman(number - 9);
if (number >= 5) return "V" + ToRoman(number - 5);
if (number >= 4) return "IV" + ToRoman(number - 4);
if (number >= 1) return "I" + ToRoman(number - 1);
Scanner myKeyboard = new Scanner (System.in);
System.out.println("Enter the integer: ");
number = myKeyboard.nextInt();
myKeyboard.close();
} }
The problem im having is that i get an error saying "The method must
return a result type string".

How to Convert a tab delimited file with commas in values to .CSV and the values with commas to be enclosed in double quotes?

How to Convert a tab delimited file with commas in values to .CSV and the
values with commas to be enclosed in double quotes?

I have a .CSV file (Lets say tab_delimited_file.csv) that I download from
a web portal of a particular vendor. When I moved the file to one of my
Linux directories, I noticed that this particular .CSV file is actually a
tab delimited file which is named as .CSV. Please find below few sample
records of the file.
"""column1""" """column2""" """column3""" """column4"""
"""column5""" """column6""" """column7"""
12 455 string with quotes, and with a comma in between 4432 6787
890 88
4432 6787 another, string with quotes, and with two comma in between
890 88 12 455
11 22 simple string 77 777 333 22
The above sample records are separated by tabs. I know the header of the
file is very weird but this is the way I received the file format to be.
I tried to use tr command to replace the tabs with commas but the file
gets messed up completely due to the extra commas in the record values. I
need the record values with commas in them to be enclosed in double
quotes. The command I used is as below.
tr '\t' ',' < tab_delimited_file.csv > comma_separated_file.csv
This converts the file into the below format.
"""column1""","""column2""","""column3""","""column4""","""column5""","""column6""","""column7"""
12,455,string with quotes, and with a comma in between,4432,6787,890,88
4432,6787,another, string with quotes, and with two comma in
between,890,88,12,455
11,22,simple string,77,777,333,22
I need help to convert the sample file into the below format.
column1,column2,column3,column4,column5,column6,column7
12,455,"string with quotes, and with a comma in between",4432,6787,890,88
4432,6787,"another, string with quotes, and with two comma in
between",890,88,12,455
11,22,"simple string",77,777,333,22
Any solution in either using sed or awk will be very useful.

Tuesday, 1 October 2013

Max Character in JSON Parsing

Max Character in JSON Parsing

What is the max char in json parsing, and how to display large text like
800 char?
{
"employees": [
{
"firstName": "John",
"desc": null
},
{
"firstName": "Anna",
"desc": null
},
{
"firstName": "Peter",
"desc": null
}
]
}
I have problem when my database has 900 char the "JSON" showed null.

Print command line output into a text file in Linux (Ubuntu)

Print command line output into a text file in Linux (Ubuntu)

I have a C++ program in Linux (Ubuntu) which prints very long output in a
command terminal.
How can i copy this output from command terminal directly to the .txt file
by Linux command?

Mod_cache is not logging or caching

This summary is not available. Please click here to view the post.

Is this an open set in $(C([0,1]), \left\|{\cdot}\right\|_p)$?

Is this an open set in $(C([0,1]), \left\|{\cdot}\right\|_p)$?

Let $A=\{g\in C([0,1]):\int_{0}^{1}|g(x)|dx<1\}$. If $p\in [0,\infty]$, is
$A$ an open set of $(C([0,1]), \left\|{\cdot}\right\|_p)$?
Is it obvious that if $p=1$ then $A$ is open in $(C([0,1]),
\left\|{\cdot}\right\|_1)$, because $A=B(0,1)$.
I think $A$ is not open if $p>1$. Any hint to show this?
Thanks.

Monday, 30 September 2013

how can I install ubuntu in windows 7 32bit machine?

how can I install ubuntu in windows 7 32bit machine?

how do I install ubuntu.iso (downloaded from ubuntu.com[more than 700mb])
in my windows 7 ultimate 32bit. please explain step by step.. thanks

Why are my new Azure end points not working?

Why are my new Azure end points not working?

I have two virtual machines (running Ubuntu Linux) hosted on Azure, and
I'm trying to set up new endpoints for one of them. I've successfully
created the end points but the connections won't go through. I've used
tcpdump to verify that the SYN packets are not even reaching the VM. I
don't have a firewall configured on the VM either. All my existing end
points work fine, and if I delete one of them, it stops receiving
connections. I just can't add any new, working endpoints.
So I tried the same with my second VM and everything works as expected
there. The only difference between them is that VM #2 has end points 22,
80, 19000, 19001 while the problematic VM #1 has 80, 443, 19000 and 19001.
What could I be possibly doing wrong? How can I fix this?

How can I catch exception on bash file exit unnormally?

How can I catch exception on bash file exit unnormally?

Here I get a bash file b.sh:
#!/bin/sh
if [ ! -f somefile.txt ]; then
..................
fi
in the bash file ,I try to check whether somefile called "somefile.txt"
exist, if not, I would consider it as an error and exit.
And I run this bash file in c++:
::system("sh b.sh")
What should I fill in the "..............." in that bash file and what
should I do in c++ code to catch exception when the "somefile.txt" is not
found.

drupal 6 installation: redirect loop

drupal 6 installation: redirect loop

I am trying to install drupal6 on my localhost and the installation does
not complete. it gets stuck in after creating the database tables.
It redirects to
[http://localhost/sie/install.php?locale=en&profile=default&op=start&id=105]
and gives the below error.
In Firefox
Firefox has detected that the server is redirecting the request for this
address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept
cookies.
In Chrome
This webpage has a redirect loop
I have tried enabling the cookies/adding localhost as an exception. please
help me with this.
Thanks

Sunday, 29 September 2013

Weird values for struct member

Weird values for struct member

Fixed, thank you! Deleting so code cannot be plagiarized

Parsing XML data with same tags at different depths

Parsing XML data with same tags at different depths

for a OSX-Application i need to parse XML-Data. My problem is that there
are used the same tags in different depths and all of them contain
different data.
The XML I need to parse is taken from the API of EVE Online:
<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2010-12-21 14:33:30</currentTime>
<result>
<rowset columns="groupName,groupID" key="groupID" name="skillGroups">
<row groupID="266" groupName="Corporation Management">
<rowset columns="typeName,groupID,typeID,published" key="typeID"
name="skills">
<row groupID="266" published="1" typeID="11584"
typeName="Anchoring">
<description>...</description>
<rank>3</rank>
<rowset columns="typeID,skillLevel" key="typeID"
name="requiredSkills"/>
<requiredAttributes>
<secondaryAttribute>...</secondaryAttribute>
<primaryAttribute>...</primaryAttribute>
</requiredAttributes>
<rowset columns="bonusType,bonusValue" key="bonusType"
name="skillBonusCollection">
<row bonusType="canNotBeTrainedOnTrial" bonusValue="1"/>
</rowset>
</row>
<row groupID="266" published="0" typeID="3369" typeName="CFO
Training">
<description>...</description>
<rank>3</rank>
<rowset columns="typeID,skillLevel" key="typeID"
name="requiredSkills">
<row skillLevel="2" typeID="3363"/>
<row skillLevel="3" typeID="3444"/>
</rowset>
<requiredAttributes>
<secondaryAttribute>...</secondaryAttribute>
<primaryAttribute>...</primaryAttribute>
</requiredAttributes>
<rowset columns="bonusType,bonusValue" key="bonusType"
name="skillBonusCollection"/>
</row>
</rowset>
</row>
</rowset>
</result>
<cachedUntil>2007-12-23 21:51:40</cachedUntil>
</eveapi>
I want to create a new GroupItem with the contents of the line:
<row groupID="266" groupName="Corporation Management">
In this group I want to add as many SkillItems as rows are listed in the
second rowset:
<rowset columns="typeName,groupID,typeID,published" key="typeID"
name="skills">
Here I have (in this example) two Skills listed, which themselves contain
various data, which are partly again stored in a rowset.
My problems are:
How do I differentiate the multiple rowsets, which contain different data
I need to add to different objects?
How do I recognize the end of a skill-row, group-row and the other rowsets
including rows as the tags are used for multiple, different objects?
The problem is not to extract the single attributes and contents of the
objects!
I am using NSXMLParser at the moment. For smaller and less complex
XML-Data I managed to seperate the rows correctly. However, here, I don't
know how to solve this, because of the repetitive use of the same tags in
the data.
As there is no written code yet (due to lack of ideas how to solve this),
I can't add any attempted implementation...
For my working attempt of the small XML (which only contains one rowset
with one row) I used only the following code:
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString
*)elementName namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"row"] && [[attributeDict allKeys]
containsObject:@"characterID"]) {
//Code to extract needed attributes
}
}
How can get I rid of this problem?

Read modified and yet uncommitted data

Read modified and yet uncommitted data

select .. WITH UR ignores locks and gives only currently committed data
how to read data that are not committed ?
as in Oracle :
update table set ..
select .. gives modified and yet uncommitted data

Saturday, 28 September 2013

Failed to run maven install?

Failed to run maven install?

Hi a query I have configured my pom.xml, was downloaded all libraries
except the library jdbc6 Oracle 11.2.0, so for now I've had to say, I do
not understand why not download this library. My pom.xml is this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bbva.sca</groupId>
<artifactId>adm</artifactId>
<name>AdmSCA</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.0.5.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<repositories>
<repository>
<id>spring-release</id>
<name>Spring Release Repository</name>
<url>http://maven.springframework.org/release</url>
</repository>
<repository>
<id>jboss</id>
<name>jboss Repository</name>
<url>http://repository.jboss.org/maven2</url>
</repository>
<repository>
<id>ibilio maven-2</id>
<name>ibilio Repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External
Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>primefaces-repo</id>
<name>Primefaces Repository</name>
<url>http://repository.primefaces.org/</url>
</repository>
<repository>
<id>oracle</id>
<name>SpringSource Enterprise Bundle Repository - External
Bundle Releases</name>
<url>http://www.mvnsearch.org/maven2/</url>
</repository>
<repository>
<id>ibilio maven-1</id>
<name>ibilio Repository</name>
<url>http://download.java.net/maven/1</url>
</repository>
</repositories>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Spring Hibernate -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.4.Final</version>
</dependency>
<!-- <dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency> -->
<!-- JSF -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>1.0.9</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.0</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
While cleaning out my maven satisfactory, but when installing I get this
error:
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building AdmSCA 1.0.0-BUILD-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ adm ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ adm ---
[WARNING] File encoding has not been set, using platform encoding Cp1252,
i.e. build is platform dependent!
[INFO] Compiling 62 source files to
C:\Users\PC\Documents\BBVA\Versiones\AdmSCA\target\classes
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 1.044s
[INFO] Finished at: Sat Sep 28 22:08:13 COT 2013
[INFO] Final Memory: 5M/122M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
(default-compile) on project adm: Fatal error compiling: tools.jar not
found: C:\Program Files\Java\jre1.6.0_34\..\lib\tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the
-e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

update field that could be null in stored procedure

update field that could be null in stored procedure

I have a table that contains two columns which could be null.
I want to build a stored procedure to edit that table. in the stored
procedure I did this:
@ID INT,
@newBuildingName NVARCHAR(250),
@newLocation NVARCHAR(3000),
@newImage VARBINARY(MAX) = NULL,
@newNote NVARCHAR(3000) = NULL,
@result BIT OUTPUT
Not I can't decide in this point if the user has entered values for
newImage or newNote fields, so I can't say
UPDATE myTable SET image = @newImage, note = @newNote
because these two fields might already have values and in this way I would
be deleting those vaules,
what should I do?
What I thing is make an if-else statement and try if the first field is
null so make my update without it and then if my second field is null then
make my update statement without it and if neither of them is null then
make a full update statement but I thing that this is a very teduis
process.
Is there any other solution plesae ?
Thanks in advance

Block IE but keep some reserved links

Block IE but keep some reserved links

I blocked Internet Explorer (IE 6~9) via Apache .htaccess, so all links
will be blocked if the agent equivalent to Internet Explorer, Now I want
to ask that is it possible to ignore some reserved links?
here is my current .htaccess:
RewriteCond %{HTTP_USER_AGENT} "MSIE [6-9]" [NC]
RewriteCond %{REQUEST_FILENAME} !ie
RewriteRule .* /ie [L]

Type Inheritance in oracle 10g

Type Inheritance in oracle 10g

I am trying to implement type inheritance in oracle 10g
HERE is my code
create type stud_detail as object (stud_id number(5), stud_name
varchar(8)); /
create type stud_result under stud_detail as (status(P/F)? char(1)); /
I get this error
ERROR at line 1: PLS-00103: Encountered the symbol "AS" when expecting one
of the following:
. ( not external JAVA_ BOUND_ 1. create type stud_result under stud_detail
as object 2. (status(P/F)? char(1));

Friday, 27 September 2013

Python: Dividing integers in a list by another list UNTIL the result is zero

Python: Dividing integers in a list by another list UNTIL the result is zero

I have seen similar questions, but nothing to help me with this problem.
I have two lists, call them a and b. I want to take the first number in a,
and divide that by numbers in b. But upon reaching the first integer in b
where a % b == 0 (no remainder), I want the process to stop and then move
onto the next integer in a, and repeat the process. I can get the ultimate
result I need with a process that just divides each number in a by ALL
numbers in b and then gives the result, but that seems wasteful. The
operation should cut off as soon as a / (any b) gives a remainder of 0,
and then move onto the next a.
NB: I've tried using the any() function (e.g. a % any(b) == 0) but to no
avail.
Thanks for any help!

copying remote master to local branch -git

copying remote master to local branch -git

Hey I am working on a local branch on an Android Project.I want to replace
all code on my local branch with all the code on the remote master.When I
try to do git pull origin master,it tries to merge and pulls up conflicts
to resolve,which is undesirable since I just want to simply replace
everything.

#EANF#

#EANF#

I know how to add Shortcut for my application in setup and deployment
project, but the question is how to edit properties of that shortcut,
especially HotKey(short cut key)(I cant find it in Visual Studio).
I googled for information but didn't got any information, ofcourse i now
how to create shortcuts using C#(Windows Script or,VB), is there any way
we can do it in Setup and deployment project?
Thanks in advance.

Model is null after post

Model is null after post

Here is my model:
public class Items
{
public string ItemName { get; set; }
public string Type { get; set; }
public bool Picked { get; set; }
}
This is my controller:
public class InvoiceController : Controller
{
[HttpGet]
public ActionResult Index()
{
using (TPGEntities context = new TPGEntities())
{
List<Items> result = (from a in context.IV00101
select new Items { ItemName =
a.ITEMDESC, Type = a.ITEMNMBR,
Picked = false }).Take(10).ToList();
return View(result);
}
}
[HttpPost]
public ActionResult Index(string searchTerm, IList<Items> model)
{
return View();
}
}
And my view:
@using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "POST",
InsertionMode = InsertionMode.Replace, UpdateTargetId = "partsList" }))
{
<input type="search" name="searchTerm" />
<input type="submit" value="OK" />
<div id="partsList">
@foreach (var item in Model)
{
<h1>@item.ItemName</h1>
<div>@item.Type</div>
<div>
@if (@item.Picked)
{
<img src="~/Images/checkbox.png" />
}
</div>
}
</div>
}
When I click the submit button, and it reaches this method:
[HttpPost]
public ActionResult Index(string searchTerm, IList<Items> model)
{
return View();
}
The model is null. I need to be able to update the properties in the
model, and then send the edited model back to the view. What am I doing
wrong?

Anyone noticed a bug with javascript not loading in Safari on iOS 7?

Anyone noticed a bug with javascript not loading in Safari on iOS 7?

Javascript is not working in Safari/iOS 7 on this website:
https://www.freezeproshop.com/
For some reason, certain scripts are not loading, while others are. The
safari web inspector is showing a network timeout for some scripts (while
some other scripts which are stored in the same folder are loading fine!)
There is no issue with the site in any other browser, including Safari/iOS
6 and Safari/OS X.
Has anyone experienced similar issues? Any suggestions would be appreciated!

Autofac begin lifetimescope per activated instance

Autofac begin lifetimescope per activated instance

Given following code:
interface IMain {}
interface ISub {}
interface IDep {}
class Dep : IDep
{
public Dep(ISub sub) { ... }
}
class Main : IMain
{
public Main() {}
public IEnumerable<IDep> Dependencies {get;set}
}
How can i configure the container to have one single instance of ISub per
IMain instance. So if I resolve an IMain instance from the container, a
'single instance' of ISub is created for that IMain object.

Thursday, 26 September 2013

How to run algorithms in ns2 nodes?

How to run algorithms in ns2 nodes?

I am working with ns-2, and i would like to know whether it is possible to
run an algorithm within a node to select the next node. If it is possible
kindly guide me through the steps for doing so. If this is not possible
please tell me a simulator where i can do this. Thanks!

Wednesday, 25 September 2013

structure type country[i].gold ;

structure type country[i].gold ;

For the line of code: {country[i].gold++;} where country is an array
variable of a certain structure type and is gold is a field declared as an
integer in the same structure type, why cant country[i].gold be treated as
an integer and incremented in this manner?

Thursday, 19 September 2013

Smooth javascript navigation stops working after first click

Smooth javascript navigation stops working after first click

This webpage http://www.eboxlab.net/ has a menu on the left side. What I
need to achieve is to be able to go to a page section when the respective
menu option is pressed. Here is my code (pretty sure it's quite bad, but I
will clean it up later, after I make it work):
navigateMe();
navInit = 1;
navNext = 2;
function navigateMe() {
step = jQuery('ul#navigation li').size();
looper = setInterval(function(){
if(navNext > step + 1) {
navInit = 1;
navNext = 1;
}
var refLink = jQuery('ul#navigation li:nth-child(' + navInit + ')
a').attr('href').replace('#', '');
var divLink = jQuery("div[id='" + refLink + "']").offset().top;
jQuery('ul#navigation li:nth-child(' + navInit + ') a').on('click',
function() {
jQuery('html, body').animate({
scrollTop: divLink
}, 500);
});
navInit = navNext;
navNext = navNext + 1;
}, 0);
}
However the problem is that it only works once. After you click menu once,
it doesn't slide up or down anymore. Please tell me what's wrong with it.
Many thanks in advance.

How do I crop an excel text cell to 250 character

How do I crop an excel text cell to 250 character

I have text stored in microsoft excel 2010 text cells which I need to crop
to 250 characters rounded up or down to the nearest full word.
So for example the text
A lot of text ........ which ends like this
lets say the 250th character is the "i" in "like" I'd want the cell to
convert to
A lot of text ........ which ends like
I hope I've made my self clear.
Many Thanks
Nigel

Set up serial on start up Raspberry Pi

Set up serial on start up Raspberry Pi

I'm trying to set up so that I don't have to type in these two commands
after boot up (PI as user):
1) sudo CHMOD 777 /dev/ttyAMA0
2) sudo stty -F /dev/ttyAMA0 cs8 9600 -brkint -imaxbel -opost -onlcr -isig
-icanon -iexten -echo -echoe -echoctl -echoke noflsh -ixon -crtscts
Thanks

flash player embeded websites : mouse position if zoom page qt 4.8 & 5.1 windows

flash player embeded websites : mouse position if zoom page qt 4.8 & 5.1
windows

I am creating a web browser using qt, and we have an issue. our browser
has a zoom you can decide for all your pages (default zoom variable) and
when playing an embeded flash video on several websites (ie facebook) the
mouse position is wrong. Works perfect if zoom is 100%. If anyone has an
idea? It seems flashplayer doesn't receive the good variables.

Rugged error on Windows

Rugged error on Windows

When I ran the following:
r = Rugged::Repository.new('<myrepopath>')
I got the following error:
Rugged::OSError: The global/xdg file 'config' doesn't exist: The system
cannot find the path specified.
How should I resolve it?
I'm using rugged 0.19.0 on Windows 7 and ruby -v outputs ruby 2.0.0p247
(2013-06-27) [x64-mingw32] on my machine.

Force word wrap through CSS

Force word wrap through CSS

At the moment TEST TEST appear side by side. How can I push one down onto
a second line? Only through CSS.
<div id="box">TEST TEST</div>
#box{
height: 50px;
text-align: center;
position: relative;
margin: 0 auto;
background-color: red;
color: white;
display: inline-block;
padding-left: 5px;
padding-right: 5px;
}

Getting error in setting Transdirect Shipping sender APi code

Getting error in setting Transdirect Shipping sender APi code

I am trying to implement transdirect.com shipping set sender API to my
website but i am getting error i don't know what is the main cause of it.
here is the snippet::
$params = array(
'session' => $session,
'postcode' => '2164',
'name' => 'abc',
'company'=>'abc',
'email' => $email ,
'phone' => '4561237',
'streetName' => 'abcStreet',
'streetNumber' => '28',
'streetType' => 'St',
'suburb' => 'JHONFEILD',
'state' => 'NSW',
'pickupDate' => date( 'Y-m-d' ),
'pickupTime' => '1-4pm',
'hydraulicGate' =>'false'
);
$query = http_build_query($params);
$query = 'http://transdirect.com.au/api/v2/booking/sender?'.$query;
$result = json_decode( curl_sender( $query, $session, $email, $arg =
'sender') );
// curl_sender method::
function curl_sender( $url, $session, $email, $arg ) {
if ( $arg == 'sender' ) {
$datastring = "postcode=2164&name=Tara
Trampolines&company=abc&email=".$email."&phone=0280049375&streetName=Unit
4/28 Victoria
St&streetNumber=28&streetType=St&suburb=SMITHFIELD&state=NSW&pickupDate".
date( 'Y-m-d' )."&pickupTime=1-4pm&hydraulicGate=false";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datastring);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1 = curl_exec( $ch );
curl_close( $ch );
return $data1;
}
I am getting:
stdClass Object (
[message] => Must be authenticated-please create a session first.
[code] => 403
)
Here is the link from we have implemented the api::
http://transdirect.com.au/api/v2/documentation
please specify how we can authenticate each method. Any help will be
appreciable, Thanks in advance.

Wednesday, 18 September 2013

Blackberry pressing buttonfield for n seconds

Blackberry pressing buttonfield for n seconds

I am developing a blackberry app. I want to fire any operation in the same
screen when user will press one button and hold it for 2 seconds.
any way
Thanks

jquery moving rows dynamically with .on

jquery moving rows dynamically with .on

I'm attempting to move rows between two tables, but I cannot get it to
keep the click event bound to it. I'm confused on the selector part on the
.on event I'm not sure what I'm supposed to be targeting with that.
Basically I can get it to move to one table, and back but then it losses
the click property. Not sure why.
I've attached a fiddle(http://jsfiddle.net/Yjqkn/216/) to make the problem
clearer. The approve button moves it down, and the waitlist button moves
it back, but then it loses all event listeners do I need to rebind them
with .bind What is the best way to solve this.
I tried : .on("click","button.remove-participant",function() didn't work
Javascript
$( ":button" ).on("click",function(){
if($(this).hasClass('remove-participant')) {
$(this).removeClass('remove-participant').addClass('add-participant');
$(this).html('Approve');
var current_row = $(this).closest('tr').html();
$('.table_2 > tbody:last').append('<tr>'+current_row+'</tr>');
$(this).closest('tr').remove();
$( ".table_2 .add-participant" ).bind( "click", function() {
$(this).removeClass('add-participant').addClass('remove-participant');
var current_row = $(this).closest('tr').html();
$(this).html('Waitlist');
$('.table_1 > tbody:last').append('<tr>'+current_row+'</tr>');
$(this).closest('tr').remove();
});
}
});
HTML
<table class="table_1">
<tr>
<th>Info Header 1</th><th>Info Header 2</th>
</tr>
<tbody>
<tr><td>Don</td>
<td><button class="remove-participant" name="">Remove</button></td>
</tr>
</tbody>
</table>
<table class="table_2">
<tr>
<th>Info Header 1</th><th>Info Header 2</th>
</tr>
<tbody>
<tr></tr>
</tbody>
</table>

Interruption for Button and Button Press for Longer then 3 Secs

Interruption for Button and Button Press for Longer then 3 Secs

In my project, I have three buttons where each triggers a function.
This function have to do two things, one action when the button is pressed
(actually working), but I want to add a second functionality, in which if
the button is pressed for more then 3 seconds, it do something, like
calling a function.
So far, i'm initializing the interruption:
attachInterrupt(0, footOne, Falling);
and the function is:
void footOne(){
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// Debounce
if (interrupt_time - last_interrupt_time > 200){
//Do things
if(debug==1){Serial.println("Button 1 pressed!");}
}
last_interrupt_time = interrupt_time;
}
Now I want to know how I can change the function to add the possibility if
the button is pressed for longer then 3 seconds...
Remembering that this function is called from the interrupts.
Thank you!

Is it possible to increase the speed of the .css method on the .scroll event?

Is it possible to increase the speed of the .css method on the .scroll event?

This is my code:
$( window ).scroll( function () {
scrollBG( '#about' );
}
function scrollBG( e ) {
bg_position = $( document ).scrollTop() / 2;
$( e ).css( 'background-position-y', bg_position );
}
What it does is scroll the background of an element as the user scrolls.
This works fine, the only issue is when using the mousewheel to scroll,
the css take a few milliseconds to catch up (since the mousewheel will
move like 100px at a time).
Is there way to make the css change happen instantaneously? Perhaps native
JavaScript is faster?
I've noticed this plugin does not have the issue I'm facing, but I don't
want to use it as it seems overkill for my needs:
http://johnpolacek.github.io/superscrollorama/

Ran across this homebrew encryption challenge

Ran across this homebrew encryption challenge

While reading other articles on his site, I came across a post [
http://blog.ram.rachum.com/post/56061414423/the-interactive-homebrew-encryption-challenge
] which provides a cypertext, based on the bad practice of writing your
own encryption algorithm.
His challenge is to attempt to break it.
Since I wonder how much visibility his post had before, I open up the
floor to you, the SO crowd.
In addition to his cypertext (copied below), he also provides a page to
generate cypertext from your own inputs: http://homebrew.herokuapp.com/
Here is his cypertext (plus some basic line numbering that I added:
Char Num
0 1 2 3 4 5
12345678901234567890123456789012345678901234567890
==================================================
1 - 50 7F1CA699D902CD5EB179E3674958DB0836A7EFC7031075F559
51- 100 385F61C1C70EBF9F1E3A1EDD784541423D5C1F06B6A7CB4AD7
101- 150 B6E52567F26095511EEEBE6AB241BE683B0F7A4D000EE7AF51
151- 200 914B73028EBFA20CA64F539B399456FD71B71456F62A7D5D5C
201- 250 D4FB2D41F0C8B800B028330CDA79EB3A1136D267C97EA55278
251- 300 63AA057E72D10F5BD374B1D280C741A1E5A0C58847FAE73F11
E64A0530322B095803ABEAA9395E7334B78F828A5804A48B50
351- 400 73F726C038B338CAAE09FF3843A65110204F9F2848E1860567
2CB001A07A8DEC74FF8C4F12C5675FC5F6A9A6A253E996DF40
451- 500 DF23E7936B0508DB9570F45FD9ECB4F7E288BFBCCFD56453E0
8B3F78C190CF9DCC91431031B21CA6F04B3E594244D8B375AF
551- 600 F4C6E6A98689CE42EC3CAA92092A8509653E842B2BA68C4775
9FD01B85004568F41E1D3B68DBBD94DF0EE2CFF0DD35D527FB
651- 700 E6BE2C14064CAD72EEADF41769E84A64C39A915E4156EA9F20
B213D6C85BD713F48614000E484FB3410BBC8BECD509F0F51D
751- 800 E5E644D4B1A61C8AA851228046EDF0ABD9A68B593E5555FF2D
348C5B54977B8293F2C9EA40D351D69F862496A664B589E6EC
851- 900 995733248C4EEDFE94B34521F5D20D5C8A083209128B3CD015
82EDAC1FC7CF3FC5A5BA5FF03EBD94A754AD71255F06E84302
951-1000 06E10BB32EF7DF17DCDA1AA58D315797AC25F6B1E666D6198F
15A257A3094565860448D2E2657F360F3AECBA2AC93EE74762
1051-1100 6A8391FBA928C23261B83AB46043551F4C45CE4B334D79E7F7
AC8CC6C71A0496D425282BDBDC4BE188A89ADC72B610553741
1151-1200 2E458894C661D5BE88749A56E2796B585B8B1C50249A1862FA
4F823B56597BDB1B7325A6B3FD753AB5075656F1E6F34C51BF
1251-1300 16AEF334BFF1C92707114111D72273CE745337D64C5A9D37BD
48E3A4F1360CD023E0665B5B727F42EED30929F51DA5E56883
1351-1400 EDCB6B9F753D7694A0DC232AFF917A3F558E4A06A4303A5A78
599AA6F797800E1BD6C83A0C46F611B21F3DA97914F07A0013
1451-1500 993225AE350B61EF0321EBD141DC25D56C46F7628D92411A89
33AA4E650FBA3011FACA44C20CF9B8D2C3C4D2308B97B928C8
1551-1600 53E9A5398663D8DB12980BC15D536F00BFE8EA53920F8467AE
8962D1D52271F300D3C4E87EFFECBFAAE0CAC64D1B7FEDCF80
1651-1700 9DFF89E85FB0E326442B3BB2332C8A91C300E07A188A83DE1A
1B4B077B6787FBED987B8D0C12A1A2F868A8C84D6570CAE519
1751-1800 F60429E2AD6BEC6ADF39B8C390804B7D5B4CACE48851E694C3
F798FE34286A9E7DD5BF65EBCE3CC28287770A96FA356C37F7
1851-1900 02FCEFE617E7AB088B7E9A27445EAAC77C32D1E8C684DACCDA
386AD6C3CFFE148C98320910433C98BAFD3218A0F74CF0537B
1951-2000 AE6D9A36E434116B8B087930F2B42A11575C587163D2944D1C
BE4C61DD3691417D8A07C3CB51EC2126AABB1B97F78AFCA96B
2051-2100 3C76
As commented in his site, the encryption algorithm:
character count is 40 + ( 2 * length(plaintext) )
does not handle unicode correctly
I have also run the following (plaintext) inputs, looking for anything
really obvious
0 1 2 3 4 5
12345678901234567890123456789012345678901234567890
==================================================
0 4D3012792C0AAD11E0F8AD4617234E67EF6F6FC4FE
1 F429EA4A052E3E242944439E580C2BE8F6383B3287
2 9C281A9F36109B340B2ED2DECC03F052AD64ED4BD2
22 DAB2C9428FC83961964C1408D060BEA79D70265D0C2F
a E9214FF1D4A659935FDEAD7BDD050234EDC630EBC9
aa 8A1D0D3541A023492FD902C94B371FB71745B3474329
aaa B370B85964FE648090E980A9C9650AC096F0D8256D0B42
aaaaaa 8310858F81A6579A31466B6437BAF19B5665FA1BBBBDC5D3AFE1

How to set default register in a database table with EntityFramework Code First?

How to set default register in a database table with EntityFramework Code
First?

I'm trying create a system using EntityFramework code first for connect my
database, I'm using code first, because I want it create database and
tables automatic if not exist.
So, I want when my Logins table is created, it insert a first register,
user Admin and password Admin
How to I do this?
My code:
public class Login
{
public int Id { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
public class MySystemContext : DbContext
{
DbSet<Login> Logins { get; set; }
}

how to reject dropable element in container with the help[ of j query?

how to reject dropable element in container with the help[ of j query?

My jsfiddle is http://jsfiddle.net/aNreg/44/
now i am drag and drop some elements. but i want to reject one element
from container. so please refer my jsfiddle and give me appropriate reply.
and if some people has good ideas then it will be appreciated.

What are some popular Django webmail applications?

What are some popular Django webmail applications?

I'm looking for a squirrelmail-like application for django (free or payed,
but with no monthly fee), as I had a look at
https://www.djangopackages.com/grids/g/email/ it didn't look promising due
to either price or lack of Python3 support. Could you suggest me some
popular choices, please?

Tuesday, 17 September 2013

Create css file based on dropdown selection

Create css file based on dropdown selection

I Use below website for my reference.
http://www.css3maker.com/
I want to create css file based on dropdown selection change in asp.net.
select Html tag from dropdown, then it is display output and based on that
create css file.

Unix Recursively delete files and folders

Unix Recursively delete files and folders

So I am working on a program that delete files and folders recursively.
For some reason I am stucked in endless loop. Please point out where I am
wrong.
for file in $1
do
if [ -f $file ] #If it is a file just delete it
then
echo "delete $file"
elif [ -d $file ] #if it is a folder
then
#look inside and see if it is empty or not
if [ "$(ls -A $file)" ]
then
recursive $file #recursively call
else
#if the folder is empty just delete it
echo "delete $file"
fi
fi
done

Regex(taking a specific part of one line)

Regex(taking a specific part of one line)

I wanna take a specific part of one line, like this one below:
disk = ['C:/ParticionOne/lalala/bebebeb/disk.img], w']
I wanna take text between the quotes and before the first brackets, like
that:
C:/ParticionOne/lalala/bebebeb/disk.img
How can i do that? Give me clues of how do that, thanks :D

server/client chat socket in java

server/client chat socket in java

Hello, i have a server/client socket connection, each side can send a
message to the other. The client who must begin the chat. I want to close
the connection when one of the both sides (server and client) sends "quit"
message. here is my code :
import java.io.*;
import java.net.*;
class TCPClient {
public static void main(String argv[]) throws Exception
{
String sentence;
String modifiedSentence;
while(true){
BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
Socket clientSocket = new Socket("localhost", 6789);
DataOutputStream outToServer =
new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer =
new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
sentence = inFromUser.readLine();
outToServer.writeBytes(sentence + '\n');
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
if(modifiedSentence.equals("quit\n")) clientSocket.close();
}
}
}
import java.io.*;
import java.net.*;
class TCPServer {
public static void main(String argv[]) throws Exception
{
String clientSentence;
String sentence;
BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
ServerSocket welcomeSocket = new ServerSocket(6789);
while(true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient =
new BufferedReader(new
InputStreamReader(connectionSocket.getInputStream()));
DataOutputStream outToClient =
new DataOutputStream(connectionSocket.getOutputStream());
clientSentence = inFromClient.readLine();
System.out.println("FROM CLIENT: " + clientSentence);
//capitalizedSentence = clientSentence.toUpperCase() + '\n';
sentence = inFromUser.readLine();
outToClient.writeBytes(sentence);
}
}
}
any help ? :)

error trying to build program using openssl library

error trying to build program using openssl library

I'm trying to compile a simple openssl based helloworld application: link
I'm using eclipse CDT, when I hit rebuild, I get the following output:
20:13:42 **** Rebuild of configuration Debug for project MyC ****
Info: Internal Builder is used for build
gcc "-IC:\\dev\\MinGW\\msys\\1.0\\opt\\cs\\include" -O0 -g3 -Wall -c
-fmessage-length=0 -o "src\\MyC.o" "..\\src\\MyC.c"
gcc "-LC:\\dev\\MinGW\\msys\\1.0\\opt\\cs\\lib" -o MyC.exe "src\\MyC.o"
-lssl -lcrypto
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld:
skipping incompatible C:\dev\MinGW\msys\1.0\opt\cs\lib/libssl.a when
searching for -lssl
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld:
skipping incompatible C:\dev\MinGW\msys\1.0\opt\cs\lib/libssl.a when
searching for -lssl
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld:
skipping incompatible C:\dev\MinGW\msys\1.0\opt\cs\lib/libcrypto.a when
searching for -lcrypto
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld:
skipping incompatible C:\dev\MinGW\msys\1.0\opt\cs\lib/libcrypto.a when
searching for -lcrypto
20:13:43 Build Finished (took 1s.33ms)
I've built openssl-1.0.1e using MinGW on Windows:
$ cd /c/dev/openssl-1.0.1e
$ ./config
$ make
$ make install
My MinGW environment:
$ uname -a
MINGW32_NT-6.1 myhostname 1.0.18(0.48/3/2) 2012-11-21 22:34 i686 Msys
Any hints will be appreciated.

Select a value in a first table according to another value of a second table (sql)

Select a value in a first table according to another value of a second
table (sql)

let me explain my situation, it really clearer than the title! I have two
tables. Let give a look here and than I will you explain what I would like
to do.
First table (lesson table)
+------------------+----------------+
| LessonCode | SubjectCode |
+------------------+----------------+
| 1 | 10 |
| 2 | 11 |
| 3 | 12 |
+------------------+----------------+
Second table (subject table)
+------------------+----------------+------------+
| subjectCode | SubjectName | teacherCode|
+------------------+----------------+------------+
| 10 | Maths | 15 |
| 11 | English | 20 |
| 12 | Greek | 30 |
+------------------+----------------+------------+
I would select from table lesson the subject that has teacherCode=20. It
is possible in one query?

Sunday, 15 September 2013

Qualify clause in Oracle

Qualify clause in Oracle

I'm working in Teradata to Oracle migration project. How can i modify the
below query which is using QUALIFY in Teradata.
//QUERY 1
SELECT S.ID as Id,S.MP_CD as Code,S.GM_CD as GmCode,S.GM_MSR_NBR as
Mea_Year,
S.STTS_CD as YearCode,S.TRMNTN_DTM as TerminationDate FROM PD.RVY S,
LOAD_LOG TLL
WHERE S.UPDTD_LOAD = TLL.LOG_KEY AND TLL.BLSH_CD = 'Y' AND S.STTS_CD IN
( 'C', 'P' )
QUALIFY ROW_NUMBER () OVER (PARTITION BY S.GM_CD ,S.MP_CD ,S.GM_MSR_NBR
,S.STTS_CD ORDER BY S.SO_DTM DESC ) = 1;
//Query 2
SELECT
SP.ID,SP.SO_DTM,SP.TAX_ID,SP.USER_ID,SP.FRST_NM,SP.LAST_NM,SP.PHONE_NBR,
QSRP.TAX_ID,QSRP.ROW_ID,MAX(SP.SO_DTM) OVER (PARTITION BY SP.ID,
SP.TAX_ID) MAX_SO_DTM
FROM VOPR_RMSY SP,VOPR_RMSY_SPNS QSRP
WHERE SP.ID =:URVYID AND QSRP.TAX_ID =:RPAXID
AND SP.ID = QSRP.ID AND SP.TAX_ID = QSRP.TAX_ID AND SP.SO_DTM = QSRP.SO_DTM
QUALIFY ( SP.SO_DTM=MAX_SO_DTM AND QSRP.SO_DTM = MAX_SO_DTM)
GROUP BY
SP.ID,SP.SO_DTM,SP.TAX_ID,SP.USER_ID,SP.FRST_NM,SP.LAST_NM,SP.PHONE_NBR,
QSRP.TAX_ID,QSRP.ROW_ID;
For this tried with HAVING instead of qualify but got an Error: ORA-00904:
"MAX_SO_DTM": invalid identifier 00904. 00000 - "%s: invalid identifier"
seems like alias used for MAX is not working here....
Any of your help is really appreciated!

Poker game: Swap method in C++

Poker game: Swap method in C++

I'm learning C++ and I'm trying to figure out a method that involves
switching out a card in the list below.
for example:
ace of spades
king of hearts
four of clubs
two of hearts
two of clubs
How would I go about exchanging 2, 3, and 5 each for a new card.
Ok so here is my code, i have other header files that it also uses but I
think that you guys should be able to understand stand where I going with
it.
#ifndef POKERGAME_H
#define POKERGAME_H//guard code
#include <iostream>
#include <iomanip>
//don't need to add .cpp files
#include "Card.h"
#include "Deck.h"
#include "Hand.h"
class PokerGame
{
public:
void playGame()
{
PokerGame play;
Deck myCard;
Hand hand;
Hand list;
cout << "***Simple 5-card Poker***" << endl;
//get a brand new card and places it in position
hand.setCard(0, myCard.getNextCard());
hand.setCard(1, myCard.getNextCard());
hand.setCard(2, myCard.getNextCard());
hand.setCard(3, myCard.getNextCard());
hand.setCard(4, myCard.getNextCard());
cout << "The cards have been shuffled and you are dealt " << endl
<<"1."<< hand.getCard(0).printName() << endl//then i ask what is the
name of the card in that position
<<"2."<< hand.getCard(1).printName() << endl
<<"3."<< hand.getCard(2).printName() << endl
<<"4."<< hand.getCard(3).printName() << endl
<<"5."<< hand.getCard(4).printName() << endl;
//ask for users input and store them in an array
int stop = 0;
int user_input[6];
int counter = 0;
while((stop != -1) && counter < 6 )
{
cout << "Indicate the cards that you would like to exchange (-1 to
end): ";
cin >> user_input[counter];
if(user_input[counter] > 5 || user_input[counter] < 0 ||
user_input[counter - 1] == user_input[counter])
{
cout << "Invalid input" << endl;
if(user_input[counter] == -1)
{
stop = -1;
cout << "...Oh nevermind...ended" << endl;
}
}
counter++;
}
This is where I'm having trouble, I'm only getting #1 on the list to
change. When only the user inputs numbers should be changed. How do I
change the code to make this happen?
//now remove the desired card from the player's hand
for(int i = 0; i < sizeof(user_input); i++ )
{
if(user_input[i] = 1)
{
hand.setCard(0, myCard.getNextCard());//change #1 on the list
}else if(user_input[i] = 2)
{
hand.setCard(1, myCard.getNextCard());//#2
}
else if(user_input[i] = 3)
{
hand.setCard(2, myCard.getNextCard());//#3
}
else if(user_input[i] = 4)
{
hand.setCard(3, myCard.getNextCard());//#4
}
else if(user_input[i] = 5)
{
hand.setCard(4, myCard.getNextCard());//#5
}
}
cout << "You new hand is: " << endl
<<"1."<< hand.getCard(0).printName() << endl//then i ask what is
the name of //the card in that position
<<"2."<< hand.getCard(1).printName() << endl
<<"3."<< hand.getCard(2).printName() << endl
<<"4."<< hand.getCard(3).printName() << endl
<<"5."<< hand.getCard(4).printName() << endl;

Access return value in my class

Access return value in my class

I have a class located in my app_code folder named
myClass.cs
cmd.Parameters.AddWithValue("@USER", HttpContext.Current.Session["MYUSER"]);
cmd.Parameters.Add(new SqlParameter("@STATUS", SqlDbType.Int));
cmd.Parameters["@STATUS"].Direction = ParameterDirection.Output;
try
{
con.Open();
cmd.ExecuteNonQuery();
int status =
Convert.ToInt32(cmd.Parameters["@STATUS"].Value);
return
Convert.ToInt32(HttpContext.Current.Session["userStatus"]
= status);
I am adding the result to a session variable here but not sure if this is
the most efficient way to approach this. Is there a way I could access the
return value on the client side code without creating a session?

Need help to understand one-line c code output

Need help to understand one-line c code output

Please consider the following code
#include<stdio.h>
int main()
{
int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2},
{2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} };
printf("%u, %u, %u, %u\n", a, *a, **a, ***a);
return 0;
}
If I am not wrong a points to the position where array begins.So why a ,*a
,**a all three give same location?

Network days applied to different countries

Network days applied to different countries

I have a formula for counting days in between dates.
=MAX(0,NETWORKDAYS(C4+1,D4)) I was wondering if it is possible somehow in
excel to change non-business dates (holidays) for different countries. In
the US, the formula would skip over Labor day, but it would not skip over
a holiday from another country. Is there a way to change this in Excel?
Thank you.

CSS animation with time interval

CSS animation with time interval

I want to rotate a graphic element infinitely but with some time interval
by step.
For example, rotate 90 degree (smooth animation) then after 5 secs rotate
another 90 degree and repeat the same infinitely.
Can this be done using only css?
Here is my JS BIN

When I block a sender in outlook, emails from that sender does not go into junk folder

When I block a sender in outlook, emails from that sender does not go into
junk folder

In outlook, I can right click an item in my inbox and block the sender.
What I expect then is that all emails from that sender should immediately
go into the junk folder.
I have junk email alternatives setup as: No automatic filtering: email
from blocked senders are still moved to the junk folder.
This statements fails to be true, when I block a sender, none of my
emails, present or in the future are moved to the junk folder.
What did I misunderstand?

Saturday, 14 September 2013

how does cucumber/selenium/capybara work?

how does cucumber/selenium/capybara work?

What happens behind the scene when i run
bundle exec cucumber
in my feature files. How does exactly server starts and run my tests in
head or headless mode.? I want to know the complete functionality behind
the scene. Please share if you have any links from where i can get
information.

Closing an Angular UI Modal on a SocketIO Event

Closing an Angular UI Modal on a SocketIO Event

I've been stuck for a while on this and I'm really not sure what else to
do. Basically I have a program that needs to create an Angular UI Modal
when there is only one person in a SocketIO 'Room', and once another
person comes into that room, the Modal needs to close. The SocketIO events
(modalStart) and (modalEnd) are correct, but I'm not sure how to close out
of that first modal. Any help would be greatly appreciated.
angular.module('CoderCombatApp.controllers', [])
.controller('mainCntrl', ['$scope', 'socket', '$modal', function
($scope, socket, $modal) {
socket.on('join', function (room) {
socket.emit('init', room);
});
socket.on('modalStart', function(){
$modal({
template: '../../views/pairing-modal.html',
show: true,
keyboard: false,
scope: $scope
});
});
socket.on('modalEnd', function(){
//END THAT MODAL ABOVE
})
}]);
Thank you so much!

In Java, how would i be able to change an int value?

In Java, how would i be able to change an int value?

I am writing a small program where the user has to guess a number. I want
them to type in the number that they are guessing and then it would change
the value of an int. How would I change the value of X to what the user
types in? This is what I have so far:
public static void main(String[] args) {
Scanner textIn = new Scanner(System.in);
System.out.println("Try to guess what number I am thinking of.");
//X is the int I want to change
int x = 100;
//Z is the one I am comparing x to
int z = 10;
String zGuess = textIn.nextLine();
boolean xTest = true;
{
if (x == z);
System.out.println("You guessed right!");
}
//XTEST PART ONE
while (x < z) {
System.out.println("X < Z");
break;
}
//XTEST PART TWO
while (x > z) {
System.out.println("X > Z");
break;
}
}

Error with template class constructor taking arguments

Error with template class constructor taking arguments

I've been looking around the internet for a solution to my problem, but
haven't found an example question quite like mine (that I recognize).
I'm trying to create a simple constructor for my template class, but there
must be something wrong with my syntax or my implementation because I keep
getting the same compilation error when I test it out. It seems to have
something to do with the way I am passing arguments because if I create an
object with no arguments it compiles fine (which seems odd because I have
no constructor that does not take arguments).
vecxd.hpp:
#ifndef JF_VecXd
#define JF_VecXd
template <class T>
class VecXd : public VecXd<T>{
public:
VecXd(T a, T b, T c);
private:
T x, y, z;
};
template <class T>
VecXd<T>::VecXd(T a, T b, T c){
x = a;
y = b;
z = c;
}

Correctly send packed structure through network

Correctly send packed structure through network

I've a problem I can't solve so I hope someone can help me here.
The original error is here :
https://gist.github.com/Tuxity/9649ed1c2142f78bd076 a simple segmentation
fault. But why ? because the server try to handle a packet it wasn't
suppose to receive : SMSG_WHO_IS_HERE.
The thing is I never send this opcode with my test client so I guess it's
a rest of the previous packet I send to the server : CMSG_ME.
So I think my problem is around my packet structure and the way I
send/receive it, bad packing (I heard about #pragma pack()) or whatever.
You can find all my code here :
https://github.com/pixl-project/RetroArch/tree/master/smart-server
The main part of the server is in netServer.c, the packet structure in
netPackets.h, the client I use for test in test/client.c
Thx in advance for any advice, help, idea you can give me.

How can i change the app icon while building in Rhomobile

How can i change the app icon while building in Rhomobile

I followed the docs for creating the ios application using Rhomobile.
I have all the icon images placed inside icon folder. But after opening
the application in xcode, it shows the rhomobile default icon.
How and where can i change the icon ?

Xbee connected to Android Phone

Xbee connected to Android Phone

i'm trying to write a code to connect my android phone with an Xbee pro
any one can help me please, here's my code:
XBee xbee = new XBee();
try {
xbee.open("COM22", 115200);

Friday, 13 September 2013

JavaScript Browser Version changes with hostname / localhost

JavaScript Browser Version changes with hostname / localhost

Hi I have a requirement to detect the browser version via JavaScript. From
here i am able to get what i expected. However, the version that returned
is different when i access the page via localhost and via hostname.
Create a simple HTML page (BrowserVersion.html) with below source.
<html>
<script>
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown
browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return
parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.init();
</script>
<script type="text/javascript">
navigator.sayswho= (function(){
var N= navigator.appName, ua= navigator.userAgent, tem;
var M=
ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
return M;
})();
alert(navigator.sayswho);
</script>
<html>
Now when I access above page with below URL I am getting the value as,
MSIE,8.0
http://localhost:8080/docs/BrowserVersion.html,
But when I access the same page with below URL I am getting the value as
MSIE,7.0.
http://mylocalhost:8080/docs/BrowserVersion.html
Why the browser version is changing between two version of URLs.
Note: My host file has below entries
127.0.0.1 localhost
127.0.0.1 mylocalhost
Any thoughts?

What's the difference among '0', '\0' and 0 with sizeof() and strlen()?

What's the difference among '0', '\0' and 0 with sizeof() and strlen()?

#include <iostream>
int main(int argc, char* argv[])
{
int pt[4] = {'0','\0',0};
std::cout<<"size of pt: "<<sizeof(pt)<<std::endl;
std::cout<<"strlen of pt: "<<strlen((char*)pt)<<std::endl;
}
the result is:
size of pt: 16
strlen of pt: 1
and when I change int pt[4] = {'0','\0',0}; to int pt[4] = {'\0','0',0};
the result is
size of pt: 16
strlen of pt: 0
Why?

Clobbering Automatic Implicit Classes

Clobbering Automatic Implicit Classes

Let's assume the following scenario. I have an implicitly shared class as
defined below:
class MyClass
{
public:
MyClass (void) {
data = new Data();
data->refs = 1;
data->dummy = 32;
}
~MyClass (void) {
if (--data->refs == 0)
delete data;
}
MyClass (const MyClass& c) {
++(data = c.data)->refs;
}
MyClass& operator = (const MyClass& c) {
++(data = c.data)->refs;
return *this;
}
private:
struct Data {
int refs;
int dummy;
} *data;
};
The idea is that when this class gets copied, the internal pointer to the
data gets copied and the number of references to that data is incremented.
However, consider the following:
int main (void)
{
MyClass c1;
c1 = MyClass();
c1 = MyClass();
return 0;
}
My understanding is that there are three instances of MyClass and only the
last instance gets deallocated. If this is the case, what can I do to
avoid these scenarios and ensure that every instance of MyClass gets
cleaned up?

Jquery animate loop only last element

Jquery animate loop only last element

I use jquery $("#" + theidoftheelement).animate(...) in a foreach loop in
order to animate one element after the other but only the last animation
works... Plase help!

Hide hidden files for specific folder

Hide hidden files for specific folder

I like keeping show hidden files on. However, on some particular folders I
would like this option to be off. Is there a way to make this happen? That
is keep general show hidden files on but turn it off for a folder?
I was thinking of desktop.ini file could keep this info but I couldn't
find anything related.

Air file convert to apps

Air file convert to apps

I convert air application to Air apps using ios certificate[.pk12]
format,but this show error message -not a code signing certificate.how i
solved this issue anyone give me a solution for this type of
message.[Note-ios certificate is valid upto 2014].here i attach the image,
Saravanan

Thursday, 12 September 2013

Web link validator version 5 build number 505 miss to find some broken link

Web link validator version 5 build number 505 miss to find some broken link

I use Web link validator tool for find broken links in our site. This tool
missed to find some broken links. I checked the directory root report for
broken links. In that report, this tool searched only some list of
directories to take a broken link list, missed some directories. I want
reason for, "Why this tool miss some broken link". Also, This tool find
"what type broken link" like syntex error, 404 error, custom error ,
script and html or only 404 error.

Cannot perform operation because childrenKeyPath is nil

Cannot perform operation because childrenKeyPath is nil

Why do I get this crash error when I try to insert a child into my
NSTreeController?
NSTreeController *tree = [NSTreeController new];
NSTreeNode *node1 = [NSTreeNode treeNodeWithRepresentedObject:@{ @"type":
@"shirt" }];
// The below method causes mysterious crash
[tree insertObject:node1 atArrangedObjectIndexPath:[NSIndexPath
indexPathWithIndex:0]];
and Xcode says:
*** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: '<NSTreeController:
0x1005c4620>[object class: NSMutableDictionary] Cannot perform operation
because childrenKeyPath is nil'
***
Why is causing this error? What is childrenKeyPath and why do I need it
(I'm not using interface builder)?

Rake Routes and Rails Server both fail to routing issue

Rake Routes and Rails Server both fail to routing issue

Here is what I get when I run rake routes:
rake aborted!
missing :controller
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:229:in
`default_controller_and_action'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:116:in
`normalize_options!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:64:in
`initialize'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1438:in
`new'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1438:in
`add_route'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1417:in
`decomposed_match'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1398:in
`block in match'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1389:in
`each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1389:in
`match'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:596:in
`map_method'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:557:in
`get'
/Users/mlegacy/Documents/RubyProjects/relaunchradio/config/routes.rb:5:in
`block in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:in
`instance_exec'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:in
`eval_block'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:294:in
`draw'
/Users/mlegacy/Documents/RubyProjects/relaunchradio/config/routes.rb:1:in
`<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in
`load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in
`block in load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in
`load_dependency'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in
`load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in
`block in load_paths'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in
`each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in
`load_paths'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:16:in
`reload!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:26:in
`block in updater'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/file_update_checker.rb:75:in
`call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/file_update_checker.rb:75:in
`execute'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:27:in
`updater'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in
`execute_if_updated'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in
`block in <module:Finisher>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:30:in
`instance_exec'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:30:in
`run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:55:in
`block in run_initializers'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:54:in
`run_initializers'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application.rb:215:in
`initialize!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in
`method_missing'
/Users/mlegacy/Documents/RubyProjects/relaunchradio/config/environment.rb:5:in
`<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in
`require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in
`block in require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in
`load_dependency'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in
`require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application.rb:189:in
`require_environment!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application.rb:249:in
`block in run_tasks_blocks'
Tasks: TOP => routes => environment
(See full trace by running task with --trace)
Here is my routes file:
Blog::Application.routes.draw do
root to: 'home#index2'
get "sessions#new"
resources :users
get "pitchme", to: "pitchme#index", as: "pitchme"
get "gregg", to: "gregg#index", as: "gregg"
get "webleads", to: "webleads#index", as: "webleads"
get "connect", to: "connect#index", as: "connect"
get "home", to: "home#index", as: "home"
mount Ckeditor::Engine => '/ckeditor'
get "posts#new"
resources :posts
get 'signup', to: 'users#new', as: 'signup'
get 'login', to: 'sessions#new', as: 'login'
get 'logout', to: 'sessions#destroy', as: 'logout'
resources :users
resources :sessions
end
I can't find an error in my routes...I really have no idea what's going one.
I generated a controller with actions that had dashes in their names, and
i found out that is a problem, but I deleted those pages and controller
and it's still screwed up. This is so frustrating.

Haskell Function To Add First Two Numbers Of List

Haskell Function To Add First Two Numbers Of List

I am attempting to write a function so that it can find the first two
elements of a list, add them, and then place them at the head of the list.
However I am running into unexpected errors when I try to do so.
Code:
command :: Operation -> [Int] -> [Int]
command Plus [x] = error "Not enough to conduct a plus operation"
command Plus (x:xs) = x + head(xs) : [xs]
The first function for the single element list works just fine, however
the second one where the actual operation should occur does not. I thought
it would take that the x off the list, then take the following element
using head(xs), thus the first two off the list are available, add them
and then put them in the front of the list as I wanted.
When I run it over command Plus [4,5,6] I should get [9,6] However I get
this error:
Couldn't match expected type `Int' with actual type `[Int]'
In the expression: xs
In the second argument of `(:)', namely `[xs]'
In the expression: (x + head (xs)) : [xs]
Failed, modules loaded: none.
If anyone can give me some insight, I'd really appreciate it!

How to dynamically use css with a sprite

How to dynamically use css with a sprite

I am sorry if i am asking a silly question but I really need help with
this. I have a sprite i created dynamically. I understand to show this as
animation i need to change the offsets for the position of this image. I
read you put this into a CSS file. How do i dynamically create this CSS
and use it dynamically using asp.net and c#?
So far i change these offsets using AJAX, a timer and response.write the
DIV. But the image appears to flicker. So, I am hoping that by using CSS
it will eliminate this flickering.
Thanks in hope...

ASP (.NET 4) Literal control not retaining changes to HTML contents on PostBack

ASP (.NET 4) Literal control not retaining changes to HTML contents on
PostBack

I am populating a ListView with HTML from a database using a Literal with
Text='<%#Eval("Data")'%>. When I trigger a PostBack, changes to the loaded
HTML are not being reflected in litRowData.Text.
ViewState is enabled for the page, the ListView, and the Literal in the
ItemTemplate, and I am making sure to only populate the ListView with
initial values from the database when if(!IsPostBack) is true in
Page_Load.
<asp:ListView ID="lvIntermediateSanctions" runat="server"
DataKeyNames="RowID" ItemPlaceholderID="phRow"
EnableViewState="true">
<LayoutTemplate>
<asp:PlaceHolder ID="phRow" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<asp:Literal ID="litRowData" runat="server" Text='<%#Eval("Data")%>'
EnableViewState="true"></asp:Literal>
</ItemTemplate>
</asp:ListView>
I need to be able to capture changes to the contents of the loaded HTML
controls. Since this HTML comes from a database table, I can't just use
ASP controls inside the ItemTemplate. Can anyone see something I'm
missing, or suggest an alternative way to do this?

Display of highest value of data using two tables

Display of highest value of data using two tables

i have two tables employee and department with the following data
emplyee table
empid Ename deptid
1 Ajay 1
2 Vijay 1
3 sanjay 2
4 rajiv 1
5 rohit 2
6 sohit 3
department table
deptid deptname
1 HR
2 IT
3 A/C
my question is to how to display the dept name which has highest(2nd
highest or nth highest) employees in it. Please help i m beginner in SQl.

structuremap register a concrete or generic type

structuremap register a concrete or generic type

Interface of viewmodels is
IWorkSpaceViewModel<TModel>
and generic base class for viewmodels is
WorkSpaceViewModelBase<TModel>
How can i tell to structuremap if there is any driven class for given
model register it otherwise register the generic base class for given
model!
for example
class CityViewModel : WorkSpaceViewModelBase<City> { }
CityViewModel should register for IWorkSpaceViewModel, but
WorkSpaceViewModel should register for request type IWorkSpaceViewModel

undefined reference to `main' using Autotools

undefined reference to `main' using Autotools

I have a little program, when I run make this error appears:
$ make
make all-recursive
make[1]: se ingresa al directorio «/home/foo/boolham»
Making all in src
make[2]: se ingresa al directorio «/home/foo/boolham/src»
/bin/bash ../libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -o
set set.o
libtool: link: gcc -std=gnu99 -g -O2 -o set set.o
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make[2]: *** [set] Error 1
make[2]: se sale del directorio «/home/foo/boolham/src»
make[1]: *** [all-recursive] Error 1
make[1]: se sale del directorio «/home/foo/boolham»
make: *** [all] Error 2
My Makefile.am has:
lib_LTLIBRARIES = libfsequence.la
libfsequence_la_SOURCES = fsequence.c fsequence.h
bin_PROGRAMS = set main
main_SOURCES = main.c main.h
set_SOURCES = set.c set.h
main_LDADD = libfsequence.la
What's wrong with my code?

Wednesday, 11 September 2013

Making MAX IF AS work with multiple inputs

Making MAX IF AS work with multiple inputs

From a MySQL database I am seeking to create a column from a field that
meets conditions.
This works:
`DROP TABLE IF EXISTS report4;
create TABLE report4 as ( select
orders_products.orders_id,
MAX( IF(products_id = 1, final_price, "-") ) AS Membership,
MAX( IF(products_id = 12, final_price, "-" ) ) AS Donation,
MAX( IF( products_id = 16, final_price, "-" ) ) AS AHCD
from orders_products
Group by orders_id M);
select * from report4;`
But I also have other product_id that I wish to inject into the new
columns of Membership and Donation.
Product with IDs 2,3,4,5,6,7,8,9,10,11 are to go into Membership. Product
with IDs 13,14,15,17,18 are to go into Donation.
It is this secondary part I cannot make work. Thoughts on what I need to do.

Count number of strings in python

Count number of strings in python

First of all, I do realize that this is a really simple question and
please bear with me on this.
How, in python, can I get the numbers of strings? I am trying to do
something like this:
def func(input_strings):
# Make the input_strings iterable
if len(input_strings) == 1:
input_strings = (input_strings, )
# Do something
for input_string in input_strings:
analyze_string(input_string)
return
However, the len(str) returns the number of characters in the string and
wouldn't give me a "1".
I'd really appreciate your help!

Ruby dynamic constant name access

Ruby dynamic constant name access

I have a class API that pulls objects from a third party API and builds
them into objects that are subclasses of type APIObject. APIObject
subclasses match the object names from the API that I'm pulling from:
User < APIObject
Account < APIObject
I would like to define a class method in APIObject that allows me to pull
objects using standard Rails accessors:
user = User.find id
I would like the method to translate this call into an API call like this:
API::User::findById id
I would like to access the name of the APIObject subclass (User) using
self.class.name and use that to call the constant (API::User), but I know
API::self.class.name won't work. I could rewrite this method over and over
again for every subclass, but it seems like this should be possible
without doing that. Suggestions?