Saturday, 31 August 2013

CSS header with div to left which fills screen

CSS header with div to left which fills screen

Ok so I am trying to make a header div that is centered on the based that
the site
content div is 980px; width
But what I want is that if the screen is bigger on the left there is a Div
that is linked to the header that take the background color of the header
and pulls it to the left side of the users screen while keeping the header
in the center of the page.
my code
html,body{
margin:0;
padding:0;
}
#content,.content{
margin:0 auto;
width: 980 !important;
}
#header-nav{
width:100% !important;
height:60px !important;
padding:0;
margin:20px 0;
}
.nav-left{
height: 55px;
position: absolute;
top: 30px;
z-index: 6;
margin: 0;
padding: 0;
right: 60%;
width: 5000px;
background: #cb0f32;
border: none;
-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
filter: none;
}
.content{
position:absolute;
top:30px;
left:25%;
z-index: 7;
margin:0 auto;
width:980px !important;
background:#000;
}
HTML Code
<body>
<div id="header-nav">
<div class="nav-left">
</div>
<div id="content" class="content">
<div id="nav-bar">
<p>My Site Title</p>
</div>
</div>
</div>
I know this should be easy but I can't get it to work could anyone please
point me in the right direction
demo of code http://russellharrower.com/home?preview=1

Read from word document line by line

Read from word document line by line


I'm trying to read a word document using C#. I am able to get all text but
I want to be able to read line by line and s*tore in a list and bind to a
gridview*. Currently my code returns a list of one item only with all text
(not line by line as desired). I'm using the Microsoft.Office.Interop.Word
library to read the file. Below is my code till now:
Application word = new Application();
Document doc = new Document();
object fileName = path;
// Define an object to pass to the API for missing parameters
object missing = System.Type.Missing;
doc = word.Documents.Open(ref fileName,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
String read = string.Empty;
List<string> data = new List<string>();
foreach (Range tmpRange in doc.StoryRanges)
{
//read += tmpRange.Text + "<br>";
data.Add(tmpRange.Text);
}
((_Document)doc).Close();
((_Application)word).Quit();
GridView1.DataSource = data;
GridView1.DataBind();
Any help would be highly appreciated. Thanks.

Mongo find - replace ObjectId with attribute of object when find

Mongo find - replace ObjectId with attribute of object when find

Let say I obtain a find result as follows:
{ "_id" : ObjectId("5221517ad1b328371c000003"), "user_id" :
ObjectId("5221517ad1b328371c000001"), "item_id" :
ObjectId("5221517ad1b328371c000002"), "preference" : 22 }
The ObjectId is not quite meaningful. Is there a way to replace the
ObjectId with an object's attribute? eg. for user_id -> change to
username?

Can't Figure out the Null Reference

Can't Figure out the Null Reference

Here is my code (places the form on top of ALL aplications:
Imports System.Runtime.InteropServices _ Private Shared Function
SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal
X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As
Integer, ByVal uFlags As Integer) As Boolean End Function
Private Const SWP_NOSIZE As Integer = &H1
Private Const SWP_NOMOVE As Integer = &H2
Private Shared ReadOnly HWND_TOPMOST As New IntPtr(-1)
Private Shared ReadOnly HWND_NOTOPMOST As New IntPtr(-2)
Public Function MakeTopMost()
If SetWindowPos(Me.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE).Equals(True) Then
SetWindowPos(Me.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE)
End If
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
MakeTopMost()
End Sub
VS 2010 says "Function... doesn't return a value on all code paths. A null
reference exception could occur at run time when the result is used.
I have been at this for hours but annot figgure it out. Does anyone know?

how to display elements of json array returned from php within a loop in ajax(jquery)

how to display elements of json array returned from php within a loop in
ajax(jquery)

Below ajax code is receiving a json array from php. Rest details i have
written as comments:
$.ajax({
type: "POST",
url: "dbtryout2_2.php",
data:datastr,
cache: false,
//dataType: 'json',
success: function(arrayphp)
{
//"arrayphp" is receiving the json array from
php.
//below code is working where iam displaying
the array directly
//This code displays the array in raw format.
$(".searchby .searchlist").append(arrayphp);
}
});
But when iam trying to display the elements of the array seperately using
below code ,then it is not working:
$.ajax({
type: "POST",
url: "dbtryout2_2.php",
data:datastr,
dataType: "json",
cache: false,
contentType: "application/json",
success: function(arrayphp)
{
//nothing is getting displayed with this code
$.each(arrayphp,function(i,v){
alert(i+"--"+v);
});
}
});
WOULD ANYBODY FIGURE OUT WAT THE PROBLEM IS WITH MY CODE?

How not to inherit some function in the interface in C#

How not to inherit some function in the interface in C#

I am having one interface which contains suppose 10-methods and it is
inheriting to the class say class1.My requirement is i do not want to
inherit 2-method into class1 .so how it is possible in c#.net

Parsing a Zipped JSON file in PHP without Extracting

Parsing a Zipped JSON file in PHP without Extracting

With help from the guys on Stackoverflow I can now Parse JSON code from a
file and save a 'Value' into a database
However the real file I intend to read from is actually a massive 2GB
file. My web server will not hold this file. However it will hold a ZIPPED
version of it - ie 80MB.
I believe there is a way to PARSE JSON from a ZIPPED file without actually
having to save the 2GB version of the file on my web server only having to
save the ZIPPED 80MB version instead............Can anybody help?
I have found the below function which I believe will do this (I think) but
I don't know how to link it to my code
private function uncompressFile($srcName, $dstName) {
$sfp = gzopen($srcName, "rb");
$fp = fopen($dstName, "w");
while ($string = gzread($sfp, 4096)) {
fwrite($fp, $string, strlen($string));
}
gzclose($sfp);
fclose($fp);
}
My current PHP code is below and works. It reads a basic small file, JSON
decodes it (The JSON is in a series of separate lines hence the need for
FILE_IGNORE_NEW_LINES) and then takes a value and saves to MySQL database.
However I believe I need to somehow combine these two bits of code so I
can read a ZIPPED file without exceeding my 100MB storage on my webserver
$file="CIF_ALL_UPDATE_DAILY_toc-update-sun";
$trains = file($json_filename, FILE_IGNORE_NEW_LINES |
FILE_SKIP_EMPTY_LINES);
foreach ($trains as $train) {
$json=json_decode($train,true);
foreach ($json as $key => $value) {
$input=$value['main_train_uid'];
$q="INSERT INTO railstptest (main_train_uid) VALUES ('$input')";
$r=mysqli_query($mysql_link,$q);
}
}
}
if (is_null($json)) {
die("Json decoding failed with error: ". json_last_error());
}
mysqli_close($mysql_link);
Many Thanks

Display Sorted content from strings VBS

Display Sorted content from strings VBS

I need a command to display particular from the result of the execution of
cmd argument in vbs. I've the code as
<script language="VBScript" type="text/vbscript">
set objShell = CreateObject("WScript.Shell")
strOut=""
sub start
cmdarg="%comspec% /c netsh wlan show hosted "
set objExCmd = objShell.Exec(cmdarg)
strOut=objExCmd.StdOut.ReadAll
Set regEx = New RegExp
regEx.Pattern = "[\f\n\r\v]+"
regEx.Global = True
regEx.Multiline = True
strOut = regEx.Replace(strOut, "<br>")
TraceOut.innerHTML= strOut
end sub
</script>
This list all output after execution as below:
Hosted network settings
Mode : Allowed
SSID name : "MyWiFi"
Max number of clients : 10
Authentication : WPA2-Personal
Cipher : CCMP
Hosted network status
Status : Not started
I need to display only SSID name. Ie, "MyWiFi" It changes whenever i
change ssid name. So it is not always "MyWiFi"

Friday, 30 August 2013

JSON.stringify and JSON.parse wont work in IE9

JSON.stringify and JSON.parse wont work in IE9

Hi Guys I hope you can help as this is driving me up the wall !!
I am running local Vb.net web site and calling a javascript function to
try to post JSON data to a php website on a web based server. My browser
is IE9 and im using visual studio 2010
I started off trying to call JSON.stringify or JSON.parse and neither
would work. I added into my .aspx page the line and it still didnt work I
downloaded a json file and referenced it locally from JSON.ORG and it
still doesnt work.
When it gets to the line JSON.stringify - it returns a microsoft
javascript error that JSON is not defined
I have spent two days trying to get this to run and could do with your
help. Any thoughts ??
function jsonSend() {
var JSONJSON = {};
var json =
document.getElementById("ctl00_ContentPlaceHolder1_JsonTfr").value;
JSONJSON['insc_users'] = json;
var jsonStr = JSON.stringify(JSONJSON); //**this is where it fails**
$.ajax({
type: 'POST',
url: 'http://www.thiswebsite.co.uk/receive.php',
dataType: 'json',
data: jsonStr,
success: function (data) {
// handleLoginLocally(u, p);
console.log('LOG.LOGIN: trying login using local storage');
},
error: function () {
console.log('LOG.LOGIN: login remote server failed');
// handleLoginLocally(u, p);
console.log('LOG.LOGIN: trying login using local storage');
}
});

Thursday, 29 August 2013

Loading different HTML code into one single page on different link clicks

Loading different HTML code into one single page on different link clicks

So, my boss has this crazy idea - the whole website working on one single
page. So far - still ok, but here's the thing: - the different pages have
different divs with content (like usual), and when some div is clicked (or
link in it) some of the divs expand/collapse, working in the way of
revealing different content. That's fine, but...
he doesn't want to use JavaScript or anything for dynamic view of the
website ('cuz I am leaving in 2 weeks and him and the other employee are
not capable of JS, thus cannot improve/maintain if needed)
his idea is to have the HTML code, for all the pages variations of the
website, stored in the database, and upon clicking some link - reloading
the page with the certain HTML. So not different .html files for every
page, but only one for all of them.
The problem is that it works for the first page that I load, initially,
but then when I call another page, it gets twisted, since I call the
function, that retrieves the HTML, but the other call of the previously
loaded page is still there, so it calls again. Here's sample, so you
understand:
<script runat="server" type="text/C#">
public string getPage(string name)
{
string page = "null";
switch (name)
{
case "media":
page = getMediaPage(); <!-- just function from the
code-behind that retrieves the html code from the DB and
passes it to the page -->
break;
case "home":
page = getHomePage(); <!-- just function from the
code-behind that retrieves the html code from the DB and
passes it to the page -->
break;
}
return page;
}
</script>
</head>
<body onload="addEvents();">
<form id="form1" runat="server">
<div id="parent">
<div id="presentation">
SomeCompany
ApS&nbsp;&nbsp;&nbsp;Street3&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;CITY&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;INFO@Comapny.com&nbsp;&nbsp;&nbsp;TLF:
999999
</div>
<%=getPage("home") %>
</div>
</form>
So that's how the initial page will be and then just in the parent div I
will call the HTML for the other pages. One example of HTML, stored in the
DB:
<div id="mainmenu">
<b>HOME</b>
<br />
PRODUCTS
<br />
<a href="<%=getPage("media")%>">SUPPORT</a>
<br />
CONTACT
<br />
ABOUT
<br />
</div>
<div id="logo">
</div>
So I call this chunk of code slam it in the page. The twist happens as I
have <a href="<%=getPage("media")%>"> clicked, so it loads the page
normally, but there is <%=getPage("home") %> standing statically in the
page, ALL THE TIME, as I need to start from somewhere, and it attempts to
load the previous page again, and... server error.
I know it's kinda stupid idea, but I can't argue with him anymore.
So my question is - is there way of handling all this with some kind of
OnClick(Event e) or some other way out, with calling different functions
(as I already started). Or I should just tell the boss that it's not gonna
work this way...

android, php, parsing JSON in php file sent from android

android, php, parsing JSON in php file sent from android

i have this JSON
{
"count":"3",
"num":"1",
"array":[
{
"id":"a_a",
"amount":56,
"duration":"0:12",
"time":1234566,
"type":0
},
{
"id":"a_a",
"amount":56,
"duration":"0:12",
"time":1234566,
"type":1
}
]
}
created it in android and send it by **HttpPost**
, i've tried a lot of ways to get the data in the php, my php file is this:
<?php
$response = array();
//$json_data = json_encode(stripslashes($_POST['jsonarray']))
$josn = file_get_contents("php://input");
$json_data = json_decode($josn,true);
$count = $json_data->{'count'};
$num = $json_data["num"];
$response["data"]=$count;
$response["data2"]=$num;
// echoing JSON response
echo json_encode($response);
?>
but $count and $num always returns null, any help please, and thanks.

Wednesday, 28 August 2013

Why is 'name' nil for getinfo(1)

Why is 'name' nil for getinfo(1)

I'm trying to put together a lua testing framework that lets you know the
function that had the problem, but when I switched from loadstring to _G,
(I switched so my test harness could see the results of the function call)
my functions started using 'nil' for the function name
Why can _G not detect the name of the current function in the following code?
function blah()
print(debug.getinfo(1).name)
end
local name = 'blah'
local status, result = pcall(_G[name]) -- Outputs 'nil'
local status, result = pcall(loadstring(name..'()')) -- Outputs 'blah'

Linker Error when using TARGET_IPHONE_SIMULATOR in C++

Linker Error when using TARGET_IPHONE_SIMULATOR in C++

The TARGET_IPHONE_SIMULATOR macro does not work in the C++ source I added
to the project. Though it should be noted that the code runs if I simply
change out the macro with a 1 or a 0.
So here's the setup. I've been converting the files from :
https://code.google.com/p/ld48jovoc/source/browse/util/tweakval/?r=13 to
work with the iOS application I'm making in XCode.
Everything is pretty much the same except for the header.
#ifndef TWEAKVAL_H
#define TWEAKVAL_H
#ifdef __cplusplus
extern "C" {

jQuery .on() Method Not Detecting Future Elements

jQuery .on() Method Not Detecting Future Elements

I'm trying to use jQuery in order to populate one dropdown based on the
selection of the dropdown before it, like so:

This works fine for the first row, however I'm using WordPress' Gravity
Forms plugin to let me add subsequent rows. My jQuery script seems to get
completely ignored by any dropdowns that are added after the page is
loaded.
Here is how I'm using the method:
$('#form-register .gfield_list tr td:first select').on('change', function() {
var fieldBrand = $(this).parent().next().find('select');
alert('1');
The '1' is only alerted in the select field in the first row, no others.
You can see the web page (with the full jQuery script) here: -
http://www.mattpealing-server.co.uk/~devappli/register/
Can anyone see what I'm doing wrong? I see no errors in Firefox's Error
Console.
Also I'm having the same problem with the tooltips I've applied to the +/-
icons, these aren't as important but I imagine the cause of the problem is
the same.

How to get QMake to copy large data files only if they are updated

How to get QMake to copy large data files only if they are updated

I have some large data files that need to be copied from source folders to
build folders during our Qmake/QtCreator build. Since they are large, I
only want the copy to happen for new/changed files. And I'd really like to
avoid listing them all specifically in the project file. Here's what I've
tried:
This attempt at copying data files fails because the DemoData folder is
the target. Therefore the copy is not performed if files within the folder
are added or changed. Only if the folder does not exist.
DemoData.commands = $$COPY_CMD $${SRC_DATA_DIR}DemoData
$${BLD_DATA_DIR}DemoData
DemoData.target += $${BLD_DATA_DIR}DemoData
PRE_TARGETDEPS += $${BLD_DATA_DIR}DemoData
QMAKE_EXTRA_TARGETS += DemoData
This approach fails because the DemoData.target item is not expected to
have a list of multiple items. QMake puts the list in quotes in the
generated makefile so it becomes one target.
DemoData.commands = $$COPY_CMD $${SRC_DATA_DIR}DemoData
$${BLD_DATA_DIR}DemoData
DEMO_DATA_FILES = $$files($${SRC_DATA_DIR}DemoData/*)
for(FILE, DEMO_DATA_FILES){
DemoData.target += $${BLD_DATA_DIR}DemoData\\$$basename(FILE)
PRE_TARGETDEPS += $${BLD_DATA_DIR}DemoData\\$$basename(FILE)
}
QMAKE_EXTRA_TARGETS += DemoData
This attempt fails because (AFAICT) QMake does not support variable names
contained in other variables. It seems to be more of a one level
substitution. A makefile is generated, but the DemoDataX targets all have
no command lines. All attempts to display the contents of the 'commands'
field generate syntax errors.
DEMO_DATA_FILES = $$files($${SRC_DATA_DIR}DemoData/*)
DEMO_DATA_NAME = DemoData
for(FILE, DEMO_DATA_FILES){
$${DEMO_DATA_NAME}.target = $${FILE}
$${DEMO_DATA_NAME}.commands = $$COPY_CMD $${FILE}
$${BLD_DATA_DIR}DemoData
PRE_TARGETDEPS += $${FILE}
QMAKE_EXTRA_TARGETS += $${DEMO_DATA_NAME}
DEMO_DATA_NAME = $${DEMO_DATA_NAME}X
}
This approach works, but with two shortcomings. The minor one is that a
separate 'make install' step must be performed. The major one is that the
files are always copied unconditionally. Since our data files are large,
this is unacceptable timewise.
DemoData.path = $${BLD_DATA_DIR}DemoData
DemoData.files = $${SRC_DATA_DIR}DemoData/*
INSTALLS += DemoData
Is there a way to do this, or am I left with some sort of external script
or manually generated/maintained makefile?

UNIX: What should be Stack Size (ulimit -s) in UNIX?

UNIX: What should be Stack Size (ulimit -s) in UNIX?

How can I calculated the maximum Stack Size required for my program in
UNIX, so that my program never get crashed.
Suppose my program is
int main()
{
int number;
number++;
return 0;
}
1) What can be the Stack Size requried to run for this program? How it is
calculated ?
2) My Unix system gives ulimit -s 51200. Is this value 512MB really
required for my small program?
3) And what if I have a big program having Multithreads, some 500
functions, including some libraries, Macros, Dynamically allocated memory
etc. How much Stack Size is required for that ?

Tuesday, 27 August 2013

How to use each() to addClass for every matching row_id

How to use each() to addClass for every matching row_id

I would like to know if it's possible to use each() to add a css class
that would highlight each matching table row using JQuery. What I have is
a PHP array of keys that I would like to match up to the corresponding
table row ids. I'm still learning JQuery so I'm not that familiar with how
this can be done.
Can someone either point me to a thread that shows this or maybe show me
an example?
My table looks like this:
<table id="table1">
<tr id="row_23">
<td>row 23</td>
</tr>
<tr id="row_24">
<td>row 24</td>
</tr>
<tr id="row_25">
<td>row 25</td>
</tr>
</table>
...

TortoiseSVN merging branch to trunk

TortoiseSVN merging branch to trunk

I know this has been asked several times so I apologize for asking it
again, but I just want to be sure I understand the difference between the
different merges.
I'm the only dev on this project so I'm not worried about over-writing
other peoples work.
I created a branch of this project because i was about to add some new
features and in the event i needed to fix any bugs in the current code, I
didn't want to have to deal with working around half finished code. So
trunk contains the 'stable' release and the branch is basically alpha/beta
build.
Before i had a chance to really start on those changes, i wound up fixing
several bugs and committed them to the branch build. I want to merge the
branch back into trunk to commit those fixes, and then I can start on my
changes working on the branch.
When i go into TortoiseSVN and select merge, i have two options: Merge a
range of revisions OR Merge two different trees
First one says its for when I've made revisions to a branch or trunk and
want to port those changes to a different branch
Second one says it's when i want to merge the differences of two different
branches into my working copy.
When i try the first option, URL to merge from i pick my branch and all
revisions. Click next and when i click test I get a tree conflict over
some files that were moved/deleted/added.
When i try the same thing with the 2nd option (using a test merge) using
head revision, it seems to work. Which is the correct method? or are
neither of them correct for what i want to do?

Cygwin serial port permission denied

Cygwin serial port permission denied

I am trying to log data to a text or csv file from my serial port (data
which is showing in arduino serial monitor). Arduino is connected via USB,
I am using windows 7 and cygwin, and I have set the appropriate
permissions to the serial port /dev/ttyS2 (COM3) with chmod 755:
$chmod 755 ttyS2
$ ls -l ttyS2
crw-rw-rw- 1 Libby None 117, 2 Aug 27 12:23 ttyS2
I have installed PySerial, and when I execute command to write to a text
file, I get an error with permissions denied:
$ python -m serial.tools.miniterm /dev/ttyS2 >> templogger.csv
could not open port '/dev/ttyS2': could not open port /dev/ttyS2: [Errno
13] Permission denied: '/dev/ttyS2'
Why is permission denied? The serial port does not seem to be part of a
group (ls -l output says "None"), I am the owner ("Libby") and I have
read/write access to the port ("crw...").
Thanks in advance for any advice.

Using org.eclipse.core.resources with RAP

Using org.eclipse.core.resources with RAP

I am currently trying to port an Eclipse RCP plugin to RAP (it is my first
experience with RAP). I had a look at several sample applications and
tutorials on how to port, but all information I have got says that the
bundle org.eclipse.core.resources should be available (as long as I don't
misinterpret them completely).
I have resolved all other Required-Bundle-errors, but 'Bundle
'org.eclipse.core.resources' cannot be resolved' resides. It seems that
org.eclipse.core.resources is not included with the RAP target platform (I
installed it via Eclipse and checked the settings).
Is org.eclipse.core.resources not included anymore and if yes, what can I
use to replace it? Or how can I include it?

Can HTML5 datalist differentiate value and option text?

Can HTML5 datalist differentiate value and option text?

The list attribute / datalist element of HTML5 forms shows a dropdown menu
of choices one can pick from, edit, and even type in some text. All this
can be achieved at once with a clean and powerful code:
<input list="states">
<datalist id="states">
<option value="One">
<option value="Two">
</datalist>
However, how to make such a form send a value which is different from the
option text, as in the usual select / option (below)?
<select>
<option value="1">One</option>
<option value="2">Two</option>
</select>

how to store data in sqlserver using EF from a datatable or list

how to store data in sqlserver using EF from a datatable or list

In my project i am using MVC3 and Entity F/w . I have an excel sheet with
tabular data i am able to retrieve the data from excel sheet to datatable
or a list but now how i can store it to my Sqlserver table using Entity
framework only .If anyone know the solution please help me .
my excel sheet
User_Id Account_Name Account_Date Current_Balance Age 1 Abcd 12/10/2013
5000 26 2 Wxyz 10/12/2010 2100 31 3 Klmn 1/1/2000 3500 23 4 Pqrs 10/1/2001
8900 30 5 Tuvw 12/10/1990 9000 27
Retrieve data store in List
var excel = new ExcelQueryFactory("E:\\ExcelMvc.xlsx");
var dataContent = from c in excel.Worksheet("Sheet1")
select c;
List<ExcelMvcModels> LstData = new List<ExcelMvcModels>();
foreach (var item in dataContent)
{
LstData.Add(new ExcelMvcModels()
{ User_Id=item[0],
Account_Name = item[1],
Account_Date=item[2],
Current_Balance=item[3],
Age=Convert.ToInt32(item[4])
});
}
OR retrieve data store in Datatable
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new System.Data.DataColumn("User_Id",
typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("Account_Name",
typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("Account_Date",
typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("Current_Balance",
typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("Age", typeof(int)));
if (dataContent != null)
{
foreach (var item in dataContent)
{
dr = dt.NewRow();
dr[0] = item[0].Value.ToString();
dr[1] = item[1].Value.ToString();
dr[2] = item[2].Value.ToString();
dr[3] = item[3].Value.ToString();
dr[4] = item[4].Value.ToString();
dt.Rows.Add(dr);
}
}

Monday, 26 August 2013

Robotium how to click on UILabel in LinearLayout

Robotium how to click on UILabel in LinearLayout

i'm new to android automation ,here is my problem : i am testing Apk
file,i don't have resource code.i want to click UILabel in the
LinearLayout ,AS is shown in the following chartB Please help me out.
Thanks. http://i.stack.imgur.com/d6vdH.png

Converting wiki templates to HTML

Converting wiki templates to HTML

I'm experimenting with wikitext and wikipedia-client gems to obtain
content from the wikipedia api. Is there a javascript library and or
rubygem that helps with the javascript templates being used in the wiki
markdown?
Example:
require 'wikipedia-client'
page = Wikipedia.find( 'Mountain' ).content
parsed = Wikitext::Parser.new.parse(page)
# parsed => "At {{convert|6593|ft|m|0|abbr=on}} it is the third highest
peak in the national park"
See the parsed {{values}} ? I'm wondering if there is a viable solution
for converting the template components of wikipedia.

How to separate objects in a hidden input?

How to separate objects in a hidden input?

I have a hidden input that contains some objects in it. I put string "#"
between any two objects, but I want to put a string that isn't on
keyboard. How can I do it?
for (int i = 0; i < MyTable.Rows.Count; i++)
{
txtRows.Value += MyTable.Rows[i]["Row"].ToString();
if (i < MyTable.Rows.Count - 1)
{
txtRows.Value += "#";
}
}

Update upper limit /bound of for loop, while in for loop

Update upper limit /bound of for loop, while in for loop

I'm trying to update the upper bound of my for loop, while in the for loop.
Example
numvar = 3
for i=2 To numvar Step 2
'code...
numvar = numvar +1
next numvar
Thanks for your help!

Given a text representation of a MIME message, how can I recreate the message?

Given a text representation of a MIME message, how can I recreate the
message?

I have a GDB core dump that contains the header and body of a MIME
mutlipart/form-data request message. I need to somehow recreate the
message exactly and send it to my server so that I can debug why my code
is crashing.
The message is from a fairly standard form-data page. All of the
Content-Types are text/plain, except for one that is image/jpeg.
The problem is that the binary part of the body has boundaries already, so
I can't just extract the binary portion and generate the header
automatically via built-in Python MIME code.
Again, I need to recreate the initial message exactly how it was. What is
the simplest way to do this?

iOS 7 UI Enforcement [on hold]

iOS 7 UI Enforcement [on hold]

I know Apple have a tendancy to be fairly strict when it comes to
enforcing their guidelines at times. I have an app which uses a mock
wooden UI which I'd like to keep. I can't find on the developer site
whether a flat UI is a guideline or a requirement.

Maven plugin: copy a file content into another file

Maven plugin: copy a file content into another file

I am looking for the appropriate plugin to copy a file content into
another file.
My resource.xml has content like this:
<class>my.path.ResourceA</class>
<class>my.path.ResourceB</class>
<class>my.path.ResourceC</class>
and must be copied to destination.xml at the place of ${content}:
<aaa>some info</aaa>
${content}
What the proper maven plugin to do that task, please? Thank you in
advance. Nic

How keep things DRY with afnetworking

How keep things DRY with afnetworking

I'm writing a ios app which has to send and receive data from the API at
various screens in the app. Currently each view controller is calling this
code
// AFAppDotNetAPIClient is a subclass of AFHTTPClient, which defines the
base URL and default HTTP headers for NSURLRequests it creates
[[AFAppDotNetAPIClient sharedClient]
getPath:@"stream/0/posts/stream/global" parameters:nil
success:^(AFHTTPRequestOperation *operation, id JSON) {
NSLog(@"App.net Global Stream: %@", JSON);
} failure:nil];
I want to keep things DRY and so I created a requested builder and
response handler to create request and parse responses. I also want to
move all the API calls to one class but since it uses blocks I don't know
how do this.
Can someone explain how this is done so I call one method with a enum and
some params for request and I probably just get a NSDictionary back
without having API calls and blocks in all view controllers. Thanks

Sunday, 25 August 2013

How to update an entry by pressing enter in php?

How to update an entry by pressing enter in php?

I am new to php and want to create a form where the user has to enter data
in different rows where each row represent a single data point. I want to
design it in such a way that whenever data is entered against any row,
that particular data point is updated and stored in mysql server without
waiting for rest of the entries. It should happen as soon as data is
entered in a particular cell. Pressing of return should trigger update in
mysql server. Is it possible to do so in php or I need to use some other
technology

jquery post still goes through inspite of asp.net mvc 4 validation failure

jquery post still goes through inspite of asp.net mvc 4 validation failure

I want an asp.net mvc form to post to a controller and also show a message
on error or success, all of which using jquery. I want this jquery post to
happen only if the form validation is successful. The problem is that the
post happens even when the form validation has failed. I am using Data
annotations in the mvc framework to validate. Here is the code
View
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet"
type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")"
type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"
type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"
type="text/javascript"></script>
<div>
@using ( Html.BeginForm("jQueryPost", "Home",null, FormMethod.Post,
new { id="FormPost" }))
{
@Html.TextBoxFor(x => x.Name) @Html.ValidationMessageFor(x => x.Name)
<br />
@Html.TextBoxFor(x => x.LastName) @Html.ValidationMessageFor(x =>
x.LastName)
<br />
@Html.TextBoxFor(x => x.Age) @Html.ValidationMessageFor(x => x.Age)
<br />
<input type=submit value="submit" />
}
</div>
<script>
$(document).ready(function () {
$('#FormPost').submit(function (e) {
e.preventDefault(); //This line will prevent the form from
submitting
alert('ajax post here');
$.ajax({
type: 'POST',
url: $('#FormPost').attr('action'),
data: $('#FormPost').serialize(),
accept: 'application/json',
error: function (xhr, status, error) {
alert('error: ' + xhr.responseText + '-' + error);
},
success: function (response) {
alert('resp: ' + response);
}
});
});
});
</script>
The Controller
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult jQueryPost(IndexVM vm)
{
IndexVM _vm = vm;
try
{
//some code here
}
catch
{
Response.StatusCode = 406; // Or any other proper status code.
Response.Write("Custom error message");
return null;
}
return Json("name posted was: " + _vm.Name);
}

[ Buying & Selling ] Open Question : What car should I buy?

[ Buying & Selling ] Open Question : What car should I buy?

I need a new car for traveling to work and back and I don't know what to
get. I like my cars and I must admit I'm one of those guys who likes to
drive a fancy car. Trouble is I need to travel 100 miles, 5 days a week
going to work and back and I can't afford the petrol on a big fancy car
that just guzzles petrol. I was wondering if anyone has a car that they
really like and is really good on fuel consumption? I don't want a hybrid
and I refuse to drive something like a Mini or a Ford Ka. Any suggestions
people? Thanks, JD

[ Higher Education (University +) ] Open Question : i want transfer to a computer science program university in islamabad from preston...

[ Higher Education (University +) ] Open Question : i want transfer to a
computer science program university in islamabad from preston...

i want to transfer my computer science credits from preston university
islamabad to any other university offering computer science
program...which universities will accept me????

Saturday, 24 August 2013

AngularJS : taking care of the complete URL for the router (using ui-router)

AngularJS : taking care of the complete URL for the router (using ui-router)

I'm experimenting angularjs on my own website. My problem is that I want
the same content on the URL http://website.com/foo/bar with and without
JS.
When I come on "/" and JS, I can move to "/foo/bar", no problem.
If I refresh without JS, no problem.
If I refresh with JS, angular is not able to generate the wanted content.
I think the problem is from $location witch doesn't take care of the
complete url as suggest this issue.
How force angular to take care of the complete URL ?
Thanks.

How I can Use Regex Method To Validate Float Value ?

How I can Use Regex Method To Validate Float Value ?

i use WPF & c# 2010
i have textbox to enter Price .
i use DataErrorValidationRule.
i want to Force the user to enter Float value.
How I can Use Regex Method To Validate Float Value ?
is there Better Way To Validate float Value ?
thank you ....

Stop auto resizing of columns. RhythmBox

Stop auto resizing of columns. RhythmBox

I use rhythmbox as the default music player. I'm very fond of the built-in
rating function. I rate my music as I play them.
Now, all the visible columns are automatically spaced.
But as you can see in the screen shot,
https://www.facebook.com/photo.php?fbid=10201053490912794&set=a.1091910691337.2015564.1033592895&type=1&openInTag=1&relevant_count=1
if I want to rate a music 5 star, I have to move my mouse to far right
side of the screen, this action activates the scroll bar.
I tried resizing the columns. But every time a new music starts playing or
I switch to a different window, it is automatically resized as the screen
shot.
This is becoming increasingly annoying. Any Idea how I can get around this
problem?
I'm using 13.04 and I've the latest version of rhythmbox.

Parsing XML and showing Parent-Child Data in Storyboard

Parsing XML and showing Parent-Child Data in Storyboard

Im currently making a project which parsed the XML below and show the
data, Im showing the data in a story board where the first TableView will
only show the main categories, in the case here its Main Name1 and Main
Name2, but what Im really trying to do is when i click on any main
category name it will navigate me to its own sub-category and not to any
other sub-category or to all, coz i tried doing it and its only showing me
all the rest of the sub-category.
<categories>
<category>
<name>Main Name1</name>
<description>given description</description>
<image> Link Here </image>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
</category>
<category>
<name>Main Name2</name>
<description>given description</description>
<image> Link Here </image>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
<sub_cat>
<sub_name>Sub name</sub_name>
<sub_desc>sub cat description</sub_desc>
<sub_image> Link </sub_image>
</sub_cat>
</category>
</categories>
My parsing code is like this
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString
*)elementName namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if([elementName isEqualToString:@"category"] || [elementName
isEqualToString:@"sub_cat"]){
dataCurrent = [dataFileHolder alloc];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if([elementName isEqualToString:@"name"]){
dataCurrent.nameLabel = currentList;
}
if ([elementName isEqualToString:@"description"]){
dataCurrent.descLabel = currentList;
}
if ([elementName isEqualToString:@"image"]) {
dataCurrent.imageLinkLabel = currentList;
}
if ([elementName isEqualToString:@"sub_name"]) {
dataCurrent.childNameLabel = currentList;
}
if ([elementName isEqualToString:@"sub_desc"]) {
dataCurrent.childDetailLabel = currentList;
}
if ([elementName isEqualToString:@"sub_image"]) {
dataCurrent.childImageLink = currentList;
}
if ([elementName isEqualToString:@"category"]) {
[_listPopulated addObject:dataCurrent];
dataCurrent = nil;
currentList = nil;
}
}

how connect broadband in ubuntu

how connect broadband in ubuntu

i have bsnl broadband conection in that in windows OS we connect our
broadband in different method that is 1. first when i start my d-link
modem my win 7 wireless show connection in that it doesn't need any
password, just click it than i connect 2.after that i go to network
sharing center and click ppope and type my isp's username and password and
click conect than it connect. as i told you for connecting i need wireless
connection and after that ppope. so i need to know how get connected in
ubuntu with that, please provide me instruction, i need rapidly

Friday, 23 August 2013

Eclipse Compiler error saying connection variable cannot be resolved to a type

Eclipse Compiler error saying connection variable cannot be resolved to a
type

this is a Java Code i wrote in Eclipse to retrieve information from a
MySQL Database.. But the Compiler is giving an error saying conn cannot be
resolved to a type.. can anyone pls tel me what i may be doin wrng??
import java.sql.*;
public class plh {
static Connection conn=null;
static Statement s=null;
public static void main(String[] args){
try {
Class.forName("com.mysql.jdbc.Driver");
conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/wonkashop","root",
"");
String st= new String("select * from users;");
s= new conn.createStatement(st);//ERROR.. why??
}
catch (Exception e) {
System.out.println("Unable to connect to Database");
}
}
}

Wordpress custom titles

Wordpress custom titles

I am trying to add custom titles to my wordpress theme and I am having a
bit of trouble.
I know I can use AIOSeo but it adds so many functions that I wont use, so
I am trying to make this on my own.
I have added a few inputs in my theme settings page (one for home, one for
categories and so on) and I would like to be able to store my title
structure in those fields.
I have managed the storing part, but I cant make the proper output.
For instance, if for the index title I store "get_bloginfo('name')", when
I echo it, it says "get_bloginfo('name')" and not "My blog name"
How can I achieve that?
BTW, I am trying this
if ( is_page() ) {
echo $pagetitle;
Best regards!

How do I use a 9-patch?

How do I use a 9-patch?

I have a 9-patch image and what I want to do is to use it to "seperate"
the adMob ad from the app. I want to draw a light blue line exactly where
the ad is.
This is the 9-patch:

I added it to layout as ImageView and this is the XML code:
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="@drawable/ab_transparent_example" />
And this is the result:

But what I want to get is the 9-patch to take the size of the screen, to
make a full blue line from left to right of the screen. I've never worked
with 9-patch before, what am I doing wrong?

Filling a div with the current time

Filling a div with the current time

In the header of a page I want to insert a div that contains the current
date. I am not sure if jquery can handle this (perhaps php) is a better
way to go.
I want to populate the div in the header of the page with the current date
in the format (example) 20th August 2013.

CheckedListBox and List of Object's list

CheckedListBox and List of Object's list

I needed to give a name to a list, as well as implementing one or two
useful methods in addition. So this is my program architecture:
public class A
{
public void Method1()
{
...
}
public override string ToString()
{
...
}
}
public class B : List<A>
{
public override string ToString()
{
...
}
public void Method2()
{
...
}
}
And then, in my mainform, I'm creating and instancing:
BindingList<B> MyList = new BindingList<B> MyList();
To use it with a CheckedListBox, I'm using:
MyListBox.DataSource = MyList;
And then when I'm adding a new element to MyList, I've got the wrong text
in the CheckedListBox. Indeed, it shows just one string "(Collection)",
even if I have more than one item in MyList What's wrong with my code?

menu by default should hidden

menu by default should hidden

Hey guys i want the sensor to be hidden by default and it show when i
click on the particular node..and should be the same on page reload Here
is my code
<ul >
<?php if(isset($nodes)): ?>
<?php $count = 0; ?>
<?php foreach($nodes as $node) { ?>
<?php $node_id=$node['node_id']; ?>
<?php $sensors = config_sensor_model::getsensors($node_id); ?>
<?php $count++; ?>
<li onclick="menu(<?php echo $count; ?>)"><a href="#"><?php echo
$node['node_name']; ?> </a></li>
<ul id="<?php echo "sub_".$count; ?>">
<?php foreach($sensors as $sensorlog) { ?>
<li><a href="<?php echo site_url();
?>/dashboard/dashboard_graph/?node=<?php echo $node['node_id'];
?>&sensor=<?php echo $sensorlog->sensor_index;
?>&range=0&xticker=2&plot_graphs_value=1">&nbsp;&nbsp;&nbsp;&nbsp;<?php
echo $sensorlog->sensor_name; ?></a></li>
<?php } ?>
</ul>
<?php } ?>
<?php endif; ?>
</ul>
</div>
this is the javascript presently i am using
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
function menu(count)
{
$("#sub_"+count).toggle("fast");
}
</script>

Thursday, 22 August 2013

why sublimetext2 crashes when using SFTP

why sublimetext2 crashes when using SFTP

sublimeText2 crashed when using SFTP to save! but other function work
well. i have try unistall it and install it twice,but not work. my system
is window7. thank!

HTTPArty/Rails: How to handle the Response array

HTTPArty/Rails: How to handle the Response array

I am calling an API that returns an array of JSON objects and I cant seem
to properly access each element. This is a sample return value of the API
call
[{"param1":1,"param2":"blah1"},
{"param1":2,"param2":"blah2"},
{"param1":3,"param2":"blah3"}]
Here is me trying to call the API and print the first JSON response
object's parameter
result = HTTParty.get('http://randomapi.com',query: options)
@a = result[0]['param1']
# puts "#{result}"
puts "#{@a}"
Doing this prints nothing. I know I am successfully accessing the URL
because result will print the correct information.
I got information on how to access the JSON response through this URL
http://blog.teamtreehouse.com/its-time-to-httparty

unable to create more than 2 same relations between two nodes

unable to create more than 2 same relations between two nodes

Spent multiple days trying to figure out why this isn't working. My model
is Player-[:PLAYED_WITH_TEAM]->team-[:CONTESTED_IN]->league. Few instances
of this relation is as follows
bob-[:PLAYED_WITH_TEAM]->falcons-[:CONTESTED_IN]->ABC League
alice-[:PLAYED_WITH_TEAM]->falcons-[:CONTESTED_IN]->ABC League
bob-[:PLAYED_WITH_TEAM]->falcons-[:CONTESTED_IN]->XYZLeague
Bob played for the same team "Falcons" in two leagues ABC and XYZ. This is
the fact i want to capture. Since Bob played for the same team in 2
different leagues, I need to have two PLAYED_WITH_TEAM relations between
the same start (Bob) and end (Falcons) nodes.
I am using spring data and have the entities defined. I am able to create
2 such relationships but not more than two using spring data. i.e. if bob
played for the same team Falcons for another 3rd league, I am unable to
create that 3rd relation. I am not sure where the problem is. Below is my
code for creating the new relation. PlayedWith is a RelationshipEntity
with Player as the start node and Team as the end node.
private PlayedWith createPlayedWithRelation(League currentLeague, Team
team, Player p)
{
System.err.println("Creating PLAYED_WITH_TEAM relation between " +
team + " and " + p + " and " + currentLeague);
PlayedWith playedWith = template.createRelationshipBetween(p,
team, PlayedWith.class, "PLAYED_WITH_TEAM", true);
playedWith.setDuring(currentLeague.getStartDate());
playedWith.setInLeague(currentLeague);
playedWith.setPlayer(p);
playedWith.setTeam(team);
playedWith.setAsCaptain(p.isCaptain());
team.addPlayer(p);
template.save(playedWith);
return playedWith;
}
PlayedWith
@RelationshipEntity (type = "PLAYED_WITH_TEAM")
public class PlayedWith
{
@GraphId
private Long nodeId;
@StartNode
Player player;
@Fetch
@EndNode
Team team;
}
Let me know if there is an alternate way of storing this scenario.

WorldEdit not working in Versions folder!

WorldEdit not working in Versions folder!

WorldEdit 1.6.2 asks for the bin folder, but I can't find it. I tried
putting WorldEdit in the versions folder but it didn't work. Can anyone
help?

Automatically removing 'p' tags from the HTML

Automatically removing 'p' tags from the HTML

I have the following code, which supposedly removes all p tags that are
wrapped around images. I am literally copying and pasting this into my
functions.php. However, it's not working:
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .*
\/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
Do I need to change the function parameter with something more relevant to
my theme? I'm new to WordPress so apologies for what might seem like a
silly question.

Bitmap can't load a 2MB image

Bitmap can't load a 2MB image

This is the code I'm using:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap imatgeOriginal = BitmapFactory.decodeFile(imageUrl, options);
Bitmap resizedbitmap = Bitmap.createScaledBitmap(imatgeOriginal, 1000,
1000, true);
As you can see I resize the image with the Options, but anyways it just
crashes on the last line, throwing a NullPointerException. So
imatgeOriginal is null
Do you guys have any tip? Why is this happening?
The image is 2MB and the size is: 1105&#8198;×&#8198;1491
This code works perfectly with any other smaller image.

Error in custom provider, java Util.EmptyStackException while locating Context

Error in custom provider, java Util.EmptyStackException while locating
Context

I'm developing an android project v15 with RoboGuice 2.0 and ormlite.
I've implemented data access by using a Business Layer and a Dao Layer.
Each Activity / Service call business layer that handle also transactions
between Daos.
In my first attempt all is working, and in my Daos I have:
@Inject protected static DatabaseProvider databaseProvider;
So in roboguice modules configuration I do requestStaticInjection for the
relative dao class that require the provider.
I've opted for remove static keyword from databaseProvider and also to
remove the requestStaticInjection from modules configurations.
All seems to be ok, the app start and can access db. When the Dao is
called by an Activity context all works ok, but when the Dao is called
from a Service Context I get this exception:
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): Caused by:
com.google.inject.ProvisionException: Guice provision errors:
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): 1) Error in custom
provider, java.util.EmptyStackException
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:130)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): while locating
android.content.Context
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): 1 error
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
it.cpmapave.fgas.ioc.provider.DatabaseProvider.get(DatabaseProvider.java:18)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
it.cpmapave.fgas.dao.orm.GenericDaoOrm.getDao(GenericDaoOrm.java:32)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
it.cpmapave.fgas.dao.orm.GenericDaoOrm.queryForId(GenericDaoOrm.java:47)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
it.cpmapave.fgas.service.impl.IncaricoServiceImpl$1.call(IncaricoServiceImpl.java:103)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
it.cpmapave.fgas.service.impl.IncaricoServiceImpl$1.call(IncaricoServiceImpl.java:1)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:168)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): ... 8 more
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): Caused by:
java.util.EmptyStackException
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
java.util.Stack.peek(Stack.java:57)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
roboguice.inject.ContextScope$1.get(ContextScope.java:108)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): at
com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
08-22 09:11:12.735: E/IncaricoServiceImpl(1779): ... 14 more
Here is the method where i get Dao from ormlite databaseProvider:
protected Dao<T, Integer> getDao(){
try {
return databaseProvider.get().getDao(type);
} catch (SQLException e) {
if (LogConfig.ERROR_LOGS_ENABLED){
Log.e(LOG_TAG, "Errore creazione Dao "+type.getSimpleName(), e);
}
return null;
}
}
and here my DatabaseProvider:
public class DatabaseProvider implements Provider<OrmLiteSqliteOpenHelper> {
@Inject
private Provider<Context> contextProvider;
@Override
public OrmLiteSqliteOpenHelper get() {
return
OpenHelperManager.getHelper(contextProvider.get().getApplicationContext(),
DatabaseOpenHelper.class);
}
}
as states the exception, seems to be a context problem..
Thank you for any advice!
Marco

Wednesday, 21 August 2013

remove repeated item in an array

remove repeated item in an array

Hi all here is my array I need to remove repeated item in this array using
PHP I have tried array_unique function but it fetches me only one Data.
[1] => Array
(
[ref] => CALGB10603
)
[2] => Array
(
[ref] => CALGB10603
)
[3] => Array
(
[ref] => CALGB10603
)
[4] => Array
(
[ref] => CALGB10603
)
[5] => Array
(
[ref] => CAUY922A2109
)
[6] => Array
(
[ref] => CAUY922A2109
)
[7] => Array
(
[ref] => CAUY922A2109
)

ResKit 0.20.0 "Expected a type" eror

ResKit 0.20.0 "Expected a type" eror

Following code procudes a "Expected a type" error. Why?
@interface UUUExampleAPI ()
- (void)fireErrorBlock:(RKRequestDidFailLoadWithErrorBlock)failBlock
onErrorInResponse:(RKResponse *)response;
@end

Circular dependent: :destroy in ActiveRecord possible?

Circular dependent: :destroy in ActiveRecord possible?

Is it safe to have circular dependent: :destroy options in ActiveRecord
models?
class Student < ActiveRecord::Base
has_one :user, dependent: :destroy
end
class User < ActiveRecord::Base
belongs_to :student, dependent: :destroy
end
If I delete a user, it should delete the associated student. And vice-versa.

Http call parameters SoapUI

Http call parameters SoapUI

How can I Parameterize an http call parameter in soapui to read parameters
from a txt file for each iteration.
If needed can the parameters be encoded(url or gzip) before the call was
sent?
Any help (pointers/links/code) is greatly appreciated? Thank You

SQL Server Max Function

SQL Server Max Function

I have the following query:
SELECT
a.name, a.address, n.date, n.note
FROM a
LEFT JOIN n ON a.id = n.id
The a.id has a one to many relationship with n.id, so that many notes can
be assocaited with one a.name.
How do I return just the latest note for each a.name instead of all the
notes?
I'm using SQL Server 2008.
Thanks.

Unwanted White Lines in listings environment

Unwanted White Lines in listings environment

\documentclass{article}
\usepackage{listings}
\usepackage{color}
\begin{document}
\definecolor{light-gray}{gray}{0.95}
\lstset{basicstyle=\ttfamily\footnotesize,
backgroundcolor=\color{light-gray}, xleftmargin=0.7cm,
frame=tlbr, framesep=0.2cm, framerule=0pt,
}
\begin{lstlisting}[mathescape]
k = $\lfloor (10\log n \cdot \log\log n)^{1/3} \rfloor$;
k = $\lfloor (4\log n \cdot \log n)^{1/3} \rfloor$;
\end{lstlisting}
\end{document}
produces

An answer to a similar question said that "this line is just an artifact
of the viewer". But this line appears in two viewers and various zoom
steps. On top of that, one can clearly see that the 1/3 overlaps with the
white line. So I do not accept it as a mere artifact anymore.
How could this problem be approached? Is it possible to somehow put
another grey layer underneath the lstlisting environment which would "eat
up" any white lines?

PHP/TWIG : for loop to build HTML divs

PHP/TWIG : for loop to build HTML divs

I come from ASP.NET MVC and the following was easy enough to do. I'm
wondering how it can be done with PHP and TWIG.
I want to dynamically build a series of HTML div. A div looks like this:
<div class="grid_gallery-item">
<img src="img/gallery/gallery_grid1.jpg" alt=""/>
<a href="img/gallery/gallery_grid1.jpg"></a>
</div>
Ths src attribute of the image as well as the href of the hyperlink should
be different for every divs. I would like to do it in a for loop, using
the incrementer to change src and href paths.
One more difficulty is that I use assetic (symfony2) for my paths. So the
src attribute and href attribute are actually like:
{{asset('img/gallery/gallery_grid1.jpg')}}
How can I do that ?

Tuesday, 20 August 2013

Bind property we cannot change

Bind property we cannot change

Suppose we have class User, some properties like this:
public class User{
public string Name;
public int Age;
}
Due to some reason, we cannot modify the User(to implement the
INotifyPropertyChanged), but we want to bind to the user's name. So if the
name changed somewhere(not by us, means changes we may not very clear when
or where, but we know it would happen), the UI can changed too.
Any good suggestions?

Why isn't onclick working with my function?

Why isn't onclick working with my function?

I'm trying to make a true or false game in PHP/HTML for practice. I keep
changing things around to try to get it to work but nothing I try is
working.
function correct() {
echo "<center><b>You got it correct!</b> Good job, <u>your winning has
been added to the leaderboards.</u></center>";
}
function incorrect() {
echo "<center><b>You got it <i>wrong</i>.</b> Sorry for your loss,
<u>your loss has been added to the leaderboards.</u></center>";
}
if ($chooseQ == 0) {
echo"<center>...<br>";
echo"<a href='?true'>True</a> <a href='?false'>False</a></center>";
Any help?

Spring Annotations when java file is compiled

Spring Annotations when java file is compiled

I started learning spring today and i have a question regarding what
happens to the annotations when java files with annotations is compiled ?.
The reason i am asking this is because of the fundamental difference i see
when we choose to use the xml approach vs the annotations approach , and
what i think is the philosophy of spring. The way i understand is spring
says that all your java classes can be simple pojo's and all the spring
related config should be kept independent (Like xml file.)
In case of developing spring application using xml *.java files have no
idea about spring container and are compiled in to .class without any
spring related dependencies.
But now when we annotate the .java file and the file is compiled the
compiled file now has all spring related dependencies hard baked in to it
and no longer are your classes simple pojo's.
Is this correct ? I am not sure if i am missing some thing here.

How can I use a LifecycleListener in a gerrit plugin?

How can I use a LifecycleListener in a gerrit plugin?

I'm writing a gerrit plugin and want to close network connections on
plugin restart/shutdown. This can be done using a LifecycleListener.
As far as I know, there are two modes of operation for a gerrit plugin
concerning Guice. One is to not declare anything in the Manifest and use
auto-registration for everything, using annotations like @Listen and
@Export. The other is to create a Guice module and do all wiring manually
in that module.
I'd like to use auto-registration, but I can't make it work with a
LifecycleListener. Adding a @Listen annotation has no effect, the Listener
is getting ignored.
My code looks like this (minimized):
@Listen
@Singleton
public class CommitValidationTest implements CommitValidationListener {
@Listen
public static class Lifecycle implements LifecycleListener {
@Override
public void start() {
// write to log
}
@Override
public void stop() {
// write to log
}
}
}

android:shadow... don't work on TextView

android:shadow... don't work on TextView

i will use this code:
style.xml
<style name="InfoTextStyle" parent="AppBaseTheme">
<item name="android:textColor">#fff</item> <- works
<item name="android:textSize">18sp</item> <- works
<item name="android:shadowColor">#ff0000</item> <- don't works*
<item name="android:shadowRadius">5.0</item> <- *
<item name="android:shadowDx">2.0</item> <- *
<item name="android:shadowDy">2.0</item> <- *
</style>
activity_main.xml
<TextView
android:id="@+id/brightness"
style="@style/InfoTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:text="@string/brightness"
android:textAppearance="?android:attr/textAppearanceMedium" />
but the shadow don't work. I'm new in android but what am I doing wrong?,
sorry and thanks!

mysql regular expression condition to identify Android Tablet from useragent

mysql regular expression condition to identify Android Tablet from useragent

I have useragent information in mysql table, I would like to extract only
the "Android Tablet" rows alone,
I have found the regex pattern to match "Android Tablet" from
https://developers.google.com/chrome/mobile/docs/user-agent, ie.,
'Android' + 'Chrome/[.0-9]* (?!Mobile)'
Initially i have tried with below query
SELECT * FROM table_page_views WHERE user_agent REGEXP 'Android' +
'Chrome/[.0-9]* (?!Mobile)';
which was returning all results, without filtering any condition.
Then i have modified as below queries,
SELECT * FROM table_page_views WHERE user_agent REGEXP 'Android +
Chrome/[.0-9]* (?!Mobile)';
SELECT * FROM table_page_views WHERE user_agent REGEXP '\'Android\' +
\'Chrome/[.0-9]* (?!Mobile)\''
For these queries, I have got an error, saying
SQL Error (1139): Got error 'repetition-operator operand invalid' from regexp
So, I would like to have a filtering condition from the above given
pattern so, that I can identify the rows of useragent "Android tablet"
Thank you!

Monday, 19 August 2013

How do I set up an "intent" in my Android Manifest file so that I can create links from emails to my Android app?

How do I set up an "intent" in my Android Manifest file so that I can
create links from emails to my Android app?

I have been killing myself trying to figure out how to launch an Android
app from a link in an email, but the information is disperse and buried in
a lot of other contexts that are beyond me. I have looked at the Google
Developer Guide on the topic, and at similar questions here on Stack
Overflow.
Here is my specific situation: I have made an Android app using Adobe
Phonegap Build. This means the app is fundamentally built using HTML and
Javascript, and I do not know much of anything about native Android
programming (which I think is a variant of Java, but I could be wrong
about that.) This is part of why I am not understanding the information
being presented. In most contexts, it's assumed the reader is working from
within the native development environment and is conversant in all the
relevant terminology.
What I want to do is be able to include a link in an email that is sent to
a user's device, and then that user can click on the link and it will open
my app.
What I have learned so far is that one needs to set something called an
"intent" which, if I get the idea correctly, is just some XML parameters
that go inside the AndroidManifest.xml file. Once one has done that, one
can set create a link that will go to the app.
I do have the ability to manipulate my AndroidManifest.xml file, so if I
just had a clearer idea of what I put in it, I could probably do this.
This answer offers some example code for how to do that, but then says one
needs the "<data> element filled out", and I don't know what that means,
so that leaves me lost as to where this code goes, or what else needs to
be "filled".
At this point, what I am falling down on is:
What exactly is the code that I include in the AndroidManifest.xml file?
(Assuming my app is called "myapp")
What exactly is the syntax for the link that goes in the email?
If someone could be explicit about how to set this up, and be
understanding that I am coming from a beginner's position on this, that
would be great.

Rake db:migrate not ignoring old migrations?

Rake db:migrate not ignoring old migrations?

Running through Michael Hartl's well known Rails tutorial, hit this snag.
I have this in a migration file, created by rails generate model etc:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
end
Later, I added this second migration file:
class AddIndexToUsersEmail < ActiveRecord::Migration
def change
add_index :users, :email, unique: true
end
end
To try and update the database to include the new one, I followed the
instructions and ran rake db:migrate, but this gives me an error telling
me I'm trying to create a table that already exists, which is to say I'm
clearly missing something.
Am I...supposed to delete the first migration? That wouldn't make any
sense. What to do?
(These are the only files under db/migrate)

Do apple developer program allow Pakistani developer to sale inApp purchases?

Do apple developer program allow Pakistani developer to sale inApp purchases?

I am independent application developer from Pakistan having local bank
account and VISA credit card. I am planning to enroll in apple developer
program as an individual to sale my apps.
I have seen that google play do not allow Pakistani application developers
to sale paid applications and inApp purchases since there are some issues
with bank transfer etc
I have read apple developer guideline but did not find such restriction
based on region. Can anyone please confirm that what is their policy? Can
i enroll in program and avail full features.

GlobalSettings onStart fires only after first request

GlobalSettings onStart fires only after first request

I need to run some code only once when I starts the play server. When
using the GlobalSettings.OnStart() I notice that the code is executed only
after the first (http) request to the server. Any idea how can I run my
code just after the server starts and before any request is sent?
Thanks

Sunday, 18 August 2013

QSqlDatabase Transactions,QSqlQuery Creation and QSqlQuery finish

QSqlDatabase Transactions,QSqlQuery Creation and QSqlQuery finish

I noticed that the QSqlDatabase documentation says that
"Note: When using transactions, you must start the transaction before you
create your query."
Doesn't this limit the usefulness of QSqlQuery::prepare() in case of
transactions if you have to create the query only after you have started
the transaction? The same question has been asked here... but no
satisfactory answer was provided.
My another question is that if you prepare a query using
QSqlQuery::prepare() and call QSqlQuery::finish(), should the query be
prepared again? I am asking this because there is no mention of prepared
queries in case QSqlQuery::finish() in docs.

How can I code cellspacing=0 so it is valid HTML5?

How can I code cellspacing=0 so it is valid HTML5?

I have HTML looking like this:
<table class="table" style="clear: both;" width="100%" cellspacing="0">
My IDE is telling me that width and cellspacing are not valid HTML5.
Is there a way I can code this that's valid?

Javascript: rounded parentheses surrounding comma separated expressions

Javascript: rounded parentheses surrounding comma separated expressions

playing on js console i faced a curious syntax, i wonder if someone can
tell me more on that.. try this:
>( function f(){console.log('i am f')} , (function x(){console.log('i am
x')})() , y=2 , console.log('hello') )
i am x
hello
undefined
>f()
ReferenceError: f is not defined
>this.y
2
this will fail:
( var c=2 ) SyntaxError: Unexpected token var
so comma separated expressions inside parentheses are evaluated,
assignments happens to be against global scope, but named function
declarations references stay trapped inside just like a closure more...
putting that line inside a function declaration called with new:
function C(){
( function f(){console.log('i am f')} , (function x(){console.log('i
am x')})() , y=2 , console.log('hello') )
}
and then instantiating:
>var c=new C()
i am x
hello
undefined
>c.y
undefined
>this.y
2
happens exactly the same, just as executed in the global scope!
whats the usage / purpose of this construct?
one more:
>( function f(){console.log('i am f')} , f() )
ReferenceError: f is not defined
so the named function can't be referenced neither inside brackets

Component symbol not showing up in a Papyrus UML diagram

Component symbol not showing up in a Papyrus UML diagram

I am new to Papyrus. Few days ago I installed eclipse Kepler (Build id:
20130614-0229) with Papyrus 0.10.0v20130612
I created a model, then I added a component diagram. I added few
components to the diagram and I saw that the shapes were simple
rectangles. I was expecting the component symbol with two smaller
rectangles on one side.
If I open the properties of one of them, I select appearance and I check
the box "Element Icon" I can see a small component icon appearing beside
the name, but I was trying to set the shape of the containing rectangle.
In the same view (Properties->Appearance) I tried to change the stereotype
display from "Text" to "Icon" or "Text and Icon", but nothing happens. If
I close and reopen the stereotype display is set back to text.
Is it possible to set the shape of a component type to the usual component
symbol? How can I set it?
Does the "stereotype display" select box have anything to do with it? In
this case do I have to do something else to make it work?
Thanks for your answers.

xtemplate proposes 'objects,' but are they really objects? How can they be extended to become 'true' objects?

xtemplate proposes 'objects,' but are they really objects? How can they be
extended to become 'true' objects?

In chat, @cgneider just pointed me to xtemplate after poking around my own
startup ltx3obj. In section 3, the documentation states (at the time of
writing):
An object type (sometimes just "object") is an abstract idea of a document
element that takes a fixed number of arguments corresponding to the
information from the document author that it is representing. A sectioning
object, for example, might take three inputs:
"title", "short title", and "label".
But isn't this just a data structure at that point? Wiktionary defines an
object as an instance of a class, and it defines a class as
A set of objects having the same behavior (but typically differing in
state), or a template defining such a set.
Thus, objects have state and behavior, which I clearly put forward in
ltx3obj. I find it difficult to believe that xtemplate does not have a
means of specifying behavior for a class (or object). Unfortunately, I
can't find any explicit support other than templates, which actually do
the work of defining what an object is rather than just saying it is.
Moreover, templates do not (in a way that is immediately obvious) support
methods.
So in conclusion, I have three very closely related questions:
Is there a way xtemplate can be extended to include this?
Does xtemplate already include this functionality, and is just non-obvious
about it from the outside looking in?
If not, are there any plans to officially include this functionality?

Checkbox unchecked on reloading

Checkbox unchecked on reloading

I am working on flask and once I check a checkbox, again when I come back
to the same page , checkbox gets unchecked.I want the checkboxes to be
checked till the user manually unchecks them .
{% for entry in entries %}
<td> <input type="checkbox" name="pos" value="{{entry.clientid}}"
>Verified< /td>
{% endfor %}
this is the html page ,on reloading all the checkboxes gets unchecked again

Remove multiple substrings from a string - Java

Remove multiple substrings from a string - Java

I need to remove multiple substrings from a given String. Example -
String[] exclude = {"one","two","three"};
String input = "if we add one and two we get three"
I want my program to remove all occurrences of "one" or "two" or "three"
from the input string and return -
"if we add and we get"
How can i do this in Java ?

Saturday, 17 August 2013

Ubuntu has alternatives to: gconftool-2, such as dconf & gsettings, what about Centos?

Ubuntu has alternatives to: gconftool-2, such as dconf & gsettings, what
about Centos?

I did some google search and i found out
Ubuntu users talking about how dconf and gsettings
can do things that gconftool-2 can not do.
MY OPERATING SYSTEM IS:
Centos Linux Desktop 6.X
i ran a yum search for
dconf
gsettings
nothing was found.
is there something else i can use to manage the gnome-panel ?

Extracting images from HTML pages with Python

Extracting images from HTML pages with Python

The below is my code. It attempts to get the src of an image within an
image tag in html.
import re
for text in open('site.html'):
matches = re.findall(r'\ssrc="([^"]+)"', text)
matches = ' '.join(matches)
print(matches)
problem is when i put in something like:
<img src="asdfasdf">
It works but when i put in an ENTIRE HTML page it returns nothing. Why
does it do that? and how do i fix it?

Using stage.addEventListener inside a class is returning a null object reference during runtime

Using stage.addEventListener inside a class is returning a null object
reference during runtime

I want to add an event listener to the stage from inside a class called
"ChoiceBtn".
I get the error "1009: Cannot access a property or method of a null object
reference". I understand that this is because the object is not yet
instantiated.
Here is my code:
My main document code:
import ChoiceBtn;
var op1:ChoiceBtn = new ChoiceBtn("display meee", answer, 1, "a)", "4.jpg");
op1.x = 250;
op1.y = 60;
stage.addChild(op1);
My Class file:
package {
import AnswerEvent;
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.SimpleButton;
import flash.events.*;
import flash.ui.Mouse;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.net.URLRequest;
import flash.display.Stage;
public class ChoiceBtn extends Sprite{
public var path:String;
public var choiceText:String;
public var choiceLabel:String;
private var answer:Answer;
private var choiceNum:uint;
private var textFormat:TextFormat = new TextFormat();
private var choiceLabelHwd:TextField = new TextField();
private var choiceTextHwd:TextField = new TextField();
private var boundingRect:Sprite = new Sprite;
private var hitAreaWidth = 255;
private var hitAreaHeight = 45;
private var pic:Loader = new Loader;
public function ChoiceBtn(choiceText:String, answer:Answer,
choiceNum:uint, choiceLabel:String = "a)", picPath:String = null) {
//path - must be the path to a picture
//choiceText - the text to be displayed
//choiceLabel - the prefix selector such as answers '1' or 'a)' etc.
// constructor code
this.answer = answer;
this.choiceNum = choiceNum;
this.choiceLabel = choiceLabel;
this.choiceText = choiceText;
//add childs
addChild(this.choiceTextHwd);
addChild(this.choiceLabelHwd);
addChild(this.boundingRect); //must be added last so is on top
of everything else
//add Listeners
//stage.addEventListener(AnswerEvent.EVENT_ANSWERED, update);
//doesn't work
stage.addEventListener(AnswerEvent.EVENT_ANSWERED, this.update);
//doesn't work either
}
public function update(e:Event):void {
trace("in choice fired");
}
}
}
I don't understand why it doesn't work even when I use this before the
function. How can I create the eventlistener on the stage in this classes
constructor code and reference a function inside this class.

PySide QPropertyAnimation Not Starting

PySide QPropertyAnimation Not Starting

The problem is that when I call QPropertyAnimation.start(), nothing happens.
Color is the property I'm animating and button is the class.
class Button(QPushButton):
def __init__(self,text="",parent=None):
super(Button,self).__init__(text,parent)
self.setFixedHeight(60)
self.setFixedWidth(250)
self.innercolor = QColor(200,0,20)
def setcolor(self,value): self.innercolor = value
def getcolor(self): return self.innercolor
color = Property(QColor,getcolor,setcolor)
def paintEvent(self, event):
p = QPainter(self)
p.fillRect(self.rect(),self.color)
p.end()
def animated(self,value): print "animating"; self.update()
def enterEvent(self, event):
ani = QPropertyAnimation(self,"color")
ani.setStartValue(self.color)
ani.setEndValue(QColor(0,0,10))
ani.setDuration(2000)
ani.valueChanged.connect(self.animated)
ani.start()
print ani.state()
return QPushButton.enterEvent(self, event)
I'm confused because "animating" never prints out, but ani.state() says
the animation is running.
I'm not asking to debug my code or anything, but I think there must be
something I'm missing, either in my code or in my understanding of the use
of QPropertyAnimation.
I've searched google for an answer, but nothing came up, nothing relevant
to me anyway. The closest I found was (another SO question)[problem with
QPropertyAnimation in Qt, btu I still couldn't turn that into an answer
for myself.

TYPO3 autoload of external classes

TYPO3 autoload of external classes

I like to use autoload in TYPO3 6.0< for external classes e.g.
Symfony\Component\Yaml.
Is there an easier way to create an autoload than ext_autoload.php? The
library I what to use have very much classes to define if using
ext_autoload.
Thanks in advance!

Get rid of blank page effect between navigation

Get rid of blank page effect between navigation

I am using phpfox, and while navigating between different pages in my
site, i am seeing a temporary blank page jittering effect (for approx. 2
sec.) before the page starts loading.
Is there any way to get rid of this effect?

How to change color of keys in KeyboardView Class in custom keyboard android

How to change color of keys in KeyboardView Class in custom keyboard android

I am Working on Custom Keyboard App i need to set different themes for
keys or background color in KeyboardView class and get key color at
onCreateInputView() in SoftKeyboard extends InputMethodService Class but i
am not getting how to get particular key according to keycode so i can
change color or background of particular key
Need urgent help

Thursday, 8 August 2013

I have a bunch of errors in my Processing2+ program

I have a bunch of errors in my Processing2+ program

Are you the founder of the website called: http://processing.org/? if so
then I need help with The Mario Game Tutorial found on this website.
I can't find any information about the author who wrote the mario game
tutorial using a programming language called Processing 2+.
How do I find information about the author who wrote this Mario Game
Tutorial for Processing 2+, so I can have him or her help me finish this
tutorial?
when I run the mario game tutorial program, I get a fuction call error,
stating that The function clearScreen() does not exist, so I rem out The
function clearScreen() and a bunch of new errors came up stating:
The function addScreen(String, Mario.MainLevel) does not exist
cannot find a class or type named "Level"
unexpected token:(
cannot find a class or type named "LevelLayer"
how do I fix the errors listed above?

jQuery: Getting object value?

jQuery: Getting object value?

console.log(this) throws:
Object
eles: Object
container: x.fn.x.init[1]
ele: x.fn.x.init[1]
0: div.cropMain
context: document
length: 1
prevObject: x.fn.x.init[1]
selector: ".two .cropMain"
__proto__: Object[0]
img: x.fn.x.init[1]
How can I grab the selector value: ".two .cropMain"?

save mysql data to sql file using php, ready to import into sqlite

save mysql data to sql file using php, ready to import into sqlite

I have a script that generates a sql file from the data saved in a mysql
database. The data is stored in the mysql database without any added
slashes. This all works fine except for quotes. If there is a quote in the
mysql data then it stops the script from running. I have tried adding
slashes to the data that is extracted and put into the sql file, but this
doesn't work.. Is there a correct procedure to do this, or a better way to
get data from mysql into sqlite?

Show that the method is of order 3 if a =-5 and of order 2 if a is not equal to -5

Show that the method is of order 3 if a =-5 and of order 2 if a is not
equal to -5

I am studying ODEs and came across this exam question:

I have the solution here also:

I have been working on this exam question all day and have been stuck for
hours. What I don't understand is how the expansion has come about and why
(i.e. hxT and also (xn+h)). Please could someone explain this to me as
this would really really help!
Thank You

Creating a new object when a UIlabel is dragged and dropped on another using the Pan gesture recognizer

Creating a new object when a UIlabel is dragged and dropped on another
using the Pan gesture recognizer

i have a UIlabel on my view... i want to create another object when i drag
another UIlabel onto the previous UIlabel on the view. it should work in a
way that when i drag the label onto the previous one and drop it on the
previous UIlabel, it creates the object. the code i have doesnt recognize
the UIGestureStateEnded. it creates the object when i drag it across the
UIlabel. it doesnt wait for me to drop it on the UIlabel. this is the code
below. any help will be appreciated.
(void) panDetected:(UIPanGestureRecognizer *)paramSender{ BOOL
isRelationship; entity *mergedEntity; entity * currentSender=(entity*)
paramSender.view;
if (paramSender.state != UIGestureRecognizerStateEnded &&
paramSender.state != UIGestureRecognizerStateFailed) { CGPoint location =
[paramSender locationInView:paramSender.view.superview];
paramSender.view.center = location; currentSender.layer.borderColor =
[UIColor greenColor].CGColor; currentSender.layer.borderWidth = 3.0;
}
if (paramSender.state == UIGestureRecognizerStateEnded ) {
CGPoint location =
[paramSender locationInView:paramSender.view.superview];
paramSender.view.center = location;
CGRect frame1 = CGRectMake(location.x -
_diagramCanvas.frame.origin.x,location.y - _diagramCanvas.frame.origin.y,
currentSender.frame.size.width+SHAPE_OFFSETSIZE_X,
currentSender.frame.size.height+SHAPE_OFFSETSIZE_Y);
entity *newObject = [[entity alloc]initWithFrame:frame1];
newObject.text=currentSender.text; newObject.tag = 2; newObject.font =
currentSender.font; newObject.userInteractionEnabled = YES;
newObject.textAlignment = NSTextAlignmentCenter; [_diagramCanvas
addSubview:newObject]; newObject.backgroundColor = [UIColor brownColor];
UIPanGestureRecognizer *newPan = [[UIPanGestureRecognizer
alloc]initWithTarget:self action: @selector(panRecognized:)]; [newPan
setMaximumNumberOfTouches:1]; [self.view addGestureRecognizer:newPan];
[newObject addGestureRecognizer:newPan]; [currentSender
removeFromSuperview];
}
NSLog(@"I am here");
for(entity *eachComp in _diagramCanvas.subviews){
if((eachComp.tag==2 )){ if (CGRectIntersectsRect([currentSender.superview
convertRect:currentSender.frame toView:self.view], [eachComp.superview
convertRect:eachComp.frame toView:self.view])) { CGRect
currentSenderFrame=[currentSender.superview
convertRect:currentSender.frame toView:_diagramCanvas]; CGRect myViewsRect
= CGRectMake(currentSenderFrame.origin.x +80, currentSenderFrame.origin.y
+80, 80.0f, 80.0f); entity *newObject = [[entity alloc]
initWithFrame:myViewsRect ];
newObject.text=currentSender.text;
newObject.font = currentSender.font;
newObject.tag = 3;
newObject.adjustsFontSizeToFitWidth =YES;
newObject.userInteractionEnabled = YES;
newObject.textAlignment = NSTextAlignmentCenter;
newObject.backgroundColor = [UIColor redColor];
newObject.layer.cornerRadius = 37.5;
[_diagramCanvas addSubview:newObject];
UIPanGestureRecognizer *newPan = [[UIPanGestureRecognizer
alloc]initWithTarget:self action:
@selector(panRecognized:)];
[newPan setMaximumNumberOfTouches:1];
[newObject addGestureRecognizer:newPan];
[currentSender removeFromSuperview];

how to create and use a class in c# (with mongodb)

how to create and use a class in c# (with mongodb)

just learning c#. I am using the below code over and over again in my code
and believe I should create a class but not sure how to structure it...
Any help appreciated:
MongoServer mongo = MongoServer.Create();
mongo.Connect();
var db = mongo.GetDatabase("forms");
mongo.RequestStart(db);
var collection = db.GetCollection("forms");
var query = new QueryDocument("_id",ObjectId.Parse(Id));
var resultsCursor = collection.Find(query);
thanks in advance!

Check if offline files are being synced

Check if offline files are being synced

I have been trying to find a tool or a script that can automate a check to
see what users machines are making an offline cache.
Basically we want to know that all the machines on our network are making
offline copies of the users designated "homedrives" this being where they
can store all of their work files. Is there a tool, VBscript or command
line script that we can run to check that the files are always available
offline for the users rather than having to go to 150 users machines and
going to the Sync center and checking they have a sync setup

Skype4COM edited sent messages

Skype4COM edited sent messages

I would like to use the API 'Skype4COM' to edit already sent messages, I
have approached this before but seem to not have any luck in finding a
solution that will let me access/edit my last message sent. I'm sure it
has to do with the MessageStatus event but I cannot work out how to edit
them/remove them after they have sent.
public void MessageStatus(SKYPE4COMLib.ChatMessage pMessage,
SKYPE4COMLib.TChatMessageStatus Status)
{
if (Status.Equals(TChatMessageStatus.cmsSent))
{
if (pMessage.IsEditable)
{
//Remove message/edit message?
}
}
}

Wednesday, 7 August 2013

Difference between State pattern and and Strategy pattern

Difference between State pattern and and Strategy pattern

Looking at the GoF patterns I find the similarities between State and
Stategy pattern rather striking. Both swap out polymorphic classes to
modify behavior. Anyone else found the same?
What are the exact differences?

Windows 7 Screen and Audio Freezing Requiring Hard Reboot. Possible Graphics Card Issue

Windows 7 Screen and Audio Freezing Requiring Hard Reboot. Possible
Graphics Card Issue

Several months ago I was playing Minecraft and listening to the radio on
my Windows 7 desktop when the screen totally froze and the audio began
slurring, eventually descending into static then silence. I restarted my
computer and everything seemed fine. Several days later, I had the issue
again while playing Minecraft. At first it was by no means an annoyance
and rarely occurred when I played Minecraft. Fast forward to now, I
recently purchased a new game on Steam called Wargame: Airland Battle.
It's much more graphically intensive than Minecraft and rather than
experiencing this issue once every month or so, I've been having it occur
5 or 6 times in one day sometimes.
I don't know if the issue is getting worse or graphically intensive games
trigger the issue, and I genuinely don't know what to do.
The desktop I use was built by my brother and is several years old. It has
an Nvidia 8800 GTS graphics card. So far I've played with Airland Battle's
graphical settings with no effect. I've also done a clean install of the
graphics driver and done a cursory search of my desktop's innards. I have
also begun monitoring my GPU's temperature and have found that temperature
doesn't seem to affect the issue. I've had the freeze happen at 65 degrees
Celsius (which I'm told is a fine temperature for a GPU) and had it happen
in the mid seventies. I've also noted that the time spent gaming has no
effect on when the freeze occurs. Sometimes I can play for fifty minutes
with no freezing, sometimes just a few seconds, sometimes two hours. I
found a thread on the Nvidia forums where several other people with the
8800 GTS or similar cards reporting the exact same issue. However, those
folks along with myself have found no antidote. This whole issue is very
annoying and I hope that I will be able to find a solution quickly.
Here is a Dxdiag readout of the desktop in question:
https://www.dropbox.com/s/8iuv6lpcw58ihng/DxDiag.txt