GetDIBits failing when trying to save screenshot with ctypes?
I'm attempting to take and save a screenshot using just ctypes. I'm not
terrifically familiar with the Windows API, so I've been leaning pretty
heavily on the various example in the Microsoft Developer Network.
I've been using the following code from the MSDN as a template to try to
recreate with ctypes.
void SaveBitmap(char *szFilename,HBITMAP hBitmap)
{
HDC hdc=NULL;
FILE* fp=NULL;
LPVOID pBuf=NULL;
BITMAPINFO bmpInfo;
BITMAPFILEHEADER bmpFileHeader;
do{
hdc=GetDC(NULL);
ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));
bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
GetDIBits(hdc,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS);
if(bmpInfo.bmiHeader.biSizeImage<=0)
bmpInfo.bmiHeader.biSizeImage=bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
if((pBuf = malloc(bmpInfo.bmiHeader.biSizeImage))==NULL)
{
//MessageBox( NULL, "Unable to Allocate Bitmap Memory",
break;
}
bmpInfo.bmiHeader.biCompression=BI_RGB;
GetDIBits(hdc,hBitmap,0,bmpInfo.bmiHeader.biHeight,pBuf, &bmpInfo,
DIB_RGB_COLORS);
if((fp = fopen(szFilename,"wb"))==NULL)
{
//MessageBox( NULL, "Unable to Create Bitmap File", "Error",
MB_OK|MB_ICONERROR);
break;
}
bmpFileHeader.bfReserved1=0;
bmpFileHeader.bfReserved2=0;
bmpFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+bmpInfo.bmiHeader.biSizeImage;
bmpFileHeader.bfType='MB';
bmpFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
fwrite(&bmpFileHeader,sizeof(BITMAPFILEHEADER),1,fp);
fwrite(&bmpInfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp);
fwrite(pBuf,bmpInfo.bmiHeader.biSizeImage,1,fp);
}while(false);
if(hdc) ReleaseDC(NULL,hdc);
if(pBuf) free(pBuf);
if(fp) fclose(fp);
However, I'm having terrible luck getting the GetDIBits function to
succeed. I'm moderately confident that I've got the actual screengrab code
correct, but the save code is giving me a lot of trouble. And
frustratingly, I'm not sure why these functions are failing.
My Python code:
libc = ctypes.cdll.msvcrt
# handle to the entire desktop Window
hdc = windll.user32.GetDC(None)
# DC for the entire window
h_dest = windll.gdi32.CreateCompatibleDC(hdc)
width = windll.user32.GetSystemMetrics(SM_CXSCREEN)
height = windll.user32.GetSystemMetrics(SM_CYSCREEN)
hb_desktop = windll.gdi32.CreateCompatibleBitmap(hdc, width, height)
windll.gdi32.SelectObject(h_dest, hb_desktop)
print windll.gdi32.BitBlt(h_dest, 0,0, width, height, hdc, 0, 0, 'SRCCOPY')
# Save Section
# ==============
bmp_info = BITMAPINFO()
# hdc = windll.user32.GetDC(None)
bmp_info.bmiHeader.biSize = len(bytes(BITMAPINFOHEADER))
print windll.gdi32.GetDIBits(hdc, hb_desktop, 0,0, None, byref(bmp_info),
0x00)
bmp_info.bmiHeader.biSizeImage = bmp_info.bmiHeader.biWidth
*abs(bmp_info.bmiHeader.biHeight) * (bmp_info.bmiHeader.biBitCount+7)/8;
pBuf = libc.malloc(bmp_info.bmiHeader.biSizeImage)
bmp_info.bmiHeader.biCompression = 0x00000000
print windll.gdi32.GetDIBits(hdc, hb_desktop, 0,
bmp_info.bmiHeader.biHeight, pBuf, byref(bmp_info), 0x00)
bmp_header = BITMAPFILEHEADER()
bmp_header.bfReserved1 = 0
bmp_header.bfReserved2 = 0
bmp_header.bfSize = len(bytes(BITMAPFILEHEADER) + bytes(BITMAPINFOHEADER)
+ bytes(bmp_info.bmiHeader.biSizeImage))
bmp_header.bfType = 0x4D42
bmp_header.bfOffBits = len(bytes(BITMAPFILEHEADER) + bytes(BITMAPINFOHEADER))
fp = libc.fopen('asdfasd.bmp',"wb")
libc.fwrite(byref(bmp_header),
len(bytes(BITMAPFILEHEADER)), 1, fp)
libc.fwrite(byref(bmp_info.bmiHeader),
len(bytes(BITMAPFILEHEADER)), 1, fp)
libc.fwrite(pBuf, bmp_info.bmiHeader.biSizeImage, 1, fp)
I've added print statements to each GetDIBits call, and sure enough,
they're all returning a failed code. I'm completely stumped here.
Saturday, 31 August 2013
can the order of code make this program faster?
can the order of code make this program faster?
Hi this is my first post, I am learning how to write code so technically I
am a newbie.
I am learning python I am still at the very basics, I was getting to Know
the if statement and I tried to mix it with another concepts(function
definition,input,variables) in order to get a wider vision of python, I
wrote some code without a specific idea of what I wanted to do I just
wanted to mix everything that I have learned so far so probably I over do
it and its not practical, it "works" when I run it.
The question that I have its not about how to do it more efficient or with
less code it is about the order of code in all programming in general.
Here I'll show 2 different order of code that gives the same result with
exactly the same code(but with different order).
on (1) I define a function on the first line.
on (2) I define the same function closer to when I use it on line 5.
which one is faster? is defining a function "closer" to when I need it
impractical for the complexity of larger programs(but does it make it
faster), or defining a function "far" from where I need it makes a larger
program slower when running(but also more practical).
(1)
def t(n1,n2):
v=n1-n2
return abs(v)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()
(2)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
def t(n1,n2):
v=n1-n2
return abs(v)
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()
Hi this is my first post, I am learning how to write code so technically I
am a newbie.
I am learning python I am still at the very basics, I was getting to Know
the if statement and I tried to mix it with another concepts(function
definition,input,variables) in order to get a wider vision of python, I
wrote some code without a specific idea of what I wanted to do I just
wanted to mix everything that I have learned so far so probably I over do
it and its not practical, it "works" when I run it.
The question that I have its not about how to do it more efficient or with
less code it is about the order of code in all programming in general.
Here I'll show 2 different order of code that gives the same result with
exactly the same code(but with different order).
on (1) I define a function on the first line.
on (2) I define the same function closer to when I use it on line 5.
which one is faster? is defining a function "closer" to when I need it
impractical for the complexity of larger programs(but does it make it
faster), or defining a function "far" from where I need it makes a larger
program slower when running(but also more practical).
(1)
def t(n1,n2):
v=n1-n2
return abs(v)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()
(2)
a = int(input('how old are you? \n'))
b = int(input('how old is your best friend? \n'))
def t(n1,n2):
v=n1-n2
return abs(v)
c=t(a,b)
if a==b:
print ('you are both the same age')
else:
print('you are not the same age\nthe difference of years is %s
year(s)' % c)
input()
NSMutableArray with Cyrillic text
NSMutableArray with Cyrillic text
I try to load words from a txt file using following code:
NSURL *filePath = [[NSBundle mainBundle] URLForResource:@"testFile"
withExtension:@"txt"];
NSString*stringPath = [filePath absoluteString];
NSData *drfData = [NSData dataWithContentsOfURL:[NSURL
URLWithString:stringPath]];
NSString *str = [[NSString alloc]initWithData:drfData
encoding:NSUTF8StringEncoding];
Works great, even if I use cyrillic words ("ïðèâåò").
Now, I use following code to add each word as object to my NSMutableArray.
To detect what is a word, I separated them by comma in my testFile.txt
document.
int nLastPoint = 0;
int nCount = 0;
for (int i = 0; i< str.length; i++) {
if ([[str substringWithRange:NSMakeRange(i,
1)]isEqualToString:@","]) {
[lst_wordlist addObject:[[[str
substringWithRange:NSMakeRange(nLastPoint, nCount)]
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]] uppercaseString]];
nLastPoint = i+1;
nCount = 0;
}else{
nCount++;
}
}
int nLength = 0;
for (int i = 0; i< [lst_wordlist count]; i++) {
if ([[lst_wordlist objectAtIndex:i]length]>nLength) {
nLength = [[lst_wordlist objectAtIndex:i]length];
}
}
NSLog(@"%@",lst_wordlist);
Works great, again ONLY if I use english words. With Cyrillic words
doesn't work.
This is my NSLog when I use a cyrillic word.
"\U041f\U0420\U0418\U0412\U0415\U0422",
WORD2,
WORD3,
Any ideas? How can I fix it? I tried to change debugger from LLDB to GDB,
doesn't fix the problem.
I try to load words from a txt file using following code:
NSURL *filePath = [[NSBundle mainBundle] URLForResource:@"testFile"
withExtension:@"txt"];
NSString*stringPath = [filePath absoluteString];
NSData *drfData = [NSData dataWithContentsOfURL:[NSURL
URLWithString:stringPath]];
NSString *str = [[NSString alloc]initWithData:drfData
encoding:NSUTF8StringEncoding];
Works great, even if I use cyrillic words ("ïðèâåò").
Now, I use following code to add each word as object to my NSMutableArray.
To detect what is a word, I separated them by comma in my testFile.txt
document.
int nLastPoint = 0;
int nCount = 0;
for (int i = 0; i< str.length; i++) {
if ([[str substringWithRange:NSMakeRange(i,
1)]isEqualToString:@","]) {
[lst_wordlist addObject:[[[str
substringWithRange:NSMakeRange(nLastPoint, nCount)]
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]] uppercaseString]];
nLastPoint = i+1;
nCount = 0;
}else{
nCount++;
}
}
int nLength = 0;
for (int i = 0; i< [lst_wordlist count]; i++) {
if ([[lst_wordlist objectAtIndex:i]length]>nLength) {
nLength = [[lst_wordlist objectAtIndex:i]length];
}
}
NSLog(@"%@",lst_wordlist);
Works great, again ONLY if I use english words. With Cyrillic words
doesn't work.
This is my NSLog when I use a cyrillic word.
"\U041f\U0420\U0418\U0412\U0415\U0422",
WORD2,
WORD3,
Any ideas? How can I fix it? I tried to change debugger from LLDB to GDB,
doesn't fix the problem.
Background process in android is killed after a phone call or after long time in the background
Background process in android is killed after a phone call or after long
time in the background
Currently i am doing a project where i have to trace the path in the
Google Map. When the app is in background, after long time when i try to
resume the app, everything will be lost.The activity is recreated. Also
when a phone call is received, same thing happens. I have tried using
SharedPreferences. It works only when the app is kept in background for
less time. How can i get rid of this ?
time in the background
Currently i am doing a project where i have to trace the path in the
Google Map. When the app is in background, after long time when i try to
resume the app, everything will be lost.The activity is recreated. Also
when a phone call is received, same thing happens. I have tried using
SharedPreferences. It works only when the app is kept in background for
less time. How can i get rid of this ?
In NodeJS, how do I specify one ca certificate for client certificate checking, and another for showing the certificate chain to the...
In NodeJS, how do I specify one ca certificate for client certificate
checking, and another for showing the certificate chain to the...
I'm trying to write a program that uses client certificate authentication
as my primary authentication method. I have a certificate signed for my
website that I want to have this application use. I read
http://blog.nategood.com/nodejs-ssl-client-cert-auth-api-rest and was
going to implement my server as described by this person's article, but I
would like to present my signed certificate to browsers, and then sign
certificates they generate with the keygen attribute with my own
certificate authority.
example code:
var https = require("https");
var http = require("http");
var fs = require("fs");
var options = {
key:fs.readFileSync("./myserver.key"),
cert:fs.readFileSync("./server.crt"),
ca:fs.readFileSync("server.ca_bundle"),
//I want to have a separate certificate for checking client
certificates here, but I would be ok with any solution to the problem.
requestCert:true,
rejectUnauthorized: false
};
https.createServer(options, function (req, res) {
res.writeHead(200, "Content-type: text/plain");
res.write("Authorized: "+JSON.stringify(req.client.authorized))
}).listen(443);
checking, and another for showing the certificate chain to the...
I'm trying to write a program that uses client certificate authentication
as my primary authentication method. I have a certificate signed for my
website that I want to have this application use. I read
http://blog.nategood.com/nodejs-ssl-client-cert-auth-api-rest and was
going to implement my server as described by this person's article, but I
would like to present my signed certificate to browsers, and then sign
certificates they generate with the keygen attribute with my own
certificate authority.
example code:
var https = require("https");
var http = require("http");
var fs = require("fs");
var options = {
key:fs.readFileSync("./myserver.key"),
cert:fs.readFileSync("./server.crt"),
ca:fs.readFileSync("server.ca_bundle"),
//I want to have a separate certificate for checking client
certificates here, but I would be ok with any solution to the problem.
requestCert:true,
rejectUnauthorized: false
};
https.createServer(options, function (req, res) {
res.writeHead(200, "Content-type: text/plain");
res.write("Authorized: "+JSON.stringify(req.client.authorized))
}).listen(443);
css, how to stop an element being squashed by container
css, how to stop an element being squashed by container
jsfiddle
I want to stop the .outer from changing shape/size when the window is
resized to be narrower than .outers contents by only applying style
directly to .outer if that is possible.
HTML:
<div class='outer'>
<div class='inner' style='background:#f00'>
</div>
<div class='inner' style='background:#0f0'>
</div>
<div class='inner' style='background:#00f'>
</div>
</div>
CSS:
.outer, .inner{
display: inline-block;
position: relative;
float: left;
margin: 0;
border: 0;
padding: 0;
overflow: visible;
}
.outer{
/*what to put in here*/
}
.inner{
width:50px;
height:50px;
}
in the jsfiddle if you resize the result panel to be thinner, you will see
the blue get pushed on to the next row, followed by the green square, I
would like the outer to maintain its original shape/size so the three
.inners maintain their positions.
jsfiddle
I want to stop the .outer from changing shape/size when the window is
resized to be narrower than .outers contents by only applying style
directly to .outer if that is possible.
HTML:
<div class='outer'>
<div class='inner' style='background:#f00'>
</div>
<div class='inner' style='background:#0f0'>
</div>
<div class='inner' style='background:#00f'>
</div>
</div>
CSS:
.outer, .inner{
display: inline-block;
position: relative;
float: left;
margin: 0;
border: 0;
padding: 0;
overflow: visible;
}
.outer{
/*what to put in here*/
}
.inner{
width:50px;
height:50px;
}
in the jsfiddle if you resize the result panel to be thinner, you will see
the blue get pushed on to the next row, followed by the green square, I
would like the outer to maintain its original shape/size so the three
.inners maintain their positions.
Friday, 30 August 2013
How to add jquery ui custom icon (our own)
How to add jquery ui custom icon (our own)
I am using jquery-ui i want to create a jquery-ui custom icons
how can i create a custom icon where the icon image should be added can
anyone help me
widget.button(
icons: {
primary: "ui-icon-locked"
},
)
like this i want to add some user defined icon
I am using jquery-ui i want to create a jquery-ui custom icons
how can i create a custom icon where the icon image should be added can
anyone help me
widget.button(
icons: {
primary: "ui-icon-locked"
},
)
like this i want to add some user defined icon
Thursday, 29 August 2013
Windows Server 2008 compromised, how to restore?
Windows Server 2008 compromised, how to restore?
Server seems like modified a lot. I cannot start/run/do many tasks like
Task Manager, Server Backup, commandline password change, etc.
User names, full names don't match with their descriptions. Now
Administrator may not be the administrator.
I cannot enable/disable accounts.
Server is being used as bruteforce attacker: DuBrute was running.
I tried to reboot, SAM init error occured & BSOD appeared. I could recover
SAM file from older copy.
Now I cannot do many things. It looks like the server has been hacked a
week ago - file creation dates say-
I found a few registry files like this one:
HKEY_LOCAL_MACHINE\SAM\SAM\Domains\Builtin
Can I clear that mess or I have to restore from backup?
Server seems like modified a lot. I cannot start/run/do many tasks like
Task Manager, Server Backup, commandline password change, etc.
User names, full names don't match with their descriptions. Now
Administrator may not be the administrator.
I cannot enable/disable accounts.
Server is being used as bruteforce attacker: DuBrute was running.
I tried to reboot, SAM init error occured & BSOD appeared. I could recover
SAM file from older copy.
Now I cannot do many things. It looks like the server has been hacked a
week ago - file creation dates say-
I found a few registry files like this one:
HKEY_LOCAL_MACHINE\SAM\SAM\Domains\Builtin
Can I clear that mess or I have to restore from backup?
Running VS2012 unit tests from TFS2010 Team Build
Running VS2012 unit tests from TFS2010 Team Build
I have a Visual Studio 2012 solution using .NET 4.5 framework. The rest of
our development system is TFS2010. Recently some of our unit tests have
been failing on the build server only. After going through several rounds
of debugging I was able to determine that the cause of the failed tests
was most likely due to the version of MSTest being used on the build
server. The tests in question pass when run from VS2012 on my local
machine and when run from VS2012 on the actual build server.
I have followed the steps described in the following articles (I have not
found any useful articles directly relevant to VS2012 and TFS2010) without
success: Running VS2010 UnitTests project from TFS2008 Team Build and
VS2010, TFS 2008 and Unit Tests
On the build server I now have the following:
VS2010 Ultimate SP1 installed
VS2012 Update 3 installed
.NET 4.5 framework SDK installed
Changed Microsoft.TeamFoundation.Build.targets file in "C:\Program Files
(86)\MSBuild\Microsoft\VisualStudio\TeamBuild\" and "C:\Program
Files\MSBuild\Microsoft\VisualStudio\TeamBuild\" so the AssemblyFile
attribute of the TestToolsTask build task pointed to "C:\Program Files
(x86)\Microsoft Visual Studio
11.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
I have 2 build definitions that I have been testing with:
In the first build definition I have left the ToolPath of the "run MS
Test" activity blank so it then uses "C:\Program Files (x86)\Microsoft
Visual Studio 10.0\Common7\IDE"
In the other build definition I have changed the "Run MS Test" activity
ToolPath parameter to "C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE"
Both build definitions appear to be building correctly and are using the
following MSBuild.exe:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
The first build defintion runs the VS2010 version of MStest with any
errors, but 5 of the approx. 2030 tests fail. These tests do not fail when
run from within Visual Studaio 2012. An example of the command line is
(actual paths and server names removed):
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe
/nologo /usestderr /searchpathroot:"d:\Builds\xxxxx\Binaries"
/resultsfileroot:"d:\Builds\xxxxx\TestResults"
/testcontainer:"d:\Builds\xxxxx.dll"
/testcontainer:"d:\Builds\xxxxx.dll" /publish:"http://xxxxx
/publishbuild:"vstfs:///Build/Build/xxxxx" /teamproject:"xxxxx"
/platform:"x86" /flavor:"Debug"
When running the second build definition MSTest fails to run with the
output below. If I run this command from the command line on the build
server without the switches that are causing the Invalid switch error then
MSTest runs and the tests in question are passed:
The MSTestActivity was invoked without a value for Platform or Flavor. The
values x86 and Debug were used.
C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\MSTest.exe
/nologo /usestderr /searchpathroot:"d:\Builds\xxxxx\Binaries"
/resultsfileroot:"d:\Builds\xxxxx\TestResults"
/testcontainer:"d:\Builds\xxxxx.dll"
/publish:"http://xxxxx" /publishbuild:"vstfs:///Build/Build/xxxxx"
/teamproject:"xxxxx"
/platform:"x86" /flavor:"Debug"
Invalid switch "/publish".
Invalid switch "/publishbuild".
Invalid switch "/teamproject".
Invalid switch "/platform".
Invalid switch "/flavor".
For switch syntax, type "MSTest /help"
I have done a lot of runs of these builds but I hvae not been able to
resolve the problem. Is there anything else that I am missing that needs
to be done either on the build server or in the build definition?
In relation to the actual tests that are failing they have in common that
they are comparing objects in lists, but as mentioned they pass when run
from within VS2012.
I have a Visual Studio 2012 solution using .NET 4.5 framework. The rest of
our development system is TFS2010. Recently some of our unit tests have
been failing on the build server only. After going through several rounds
of debugging I was able to determine that the cause of the failed tests
was most likely due to the version of MSTest being used on the build
server. The tests in question pass when run from VS2012 on my local
machine and when run from VS2012 on the actual build server.
I have followed the steps described in the following articles (I have not
found any useful articles directly relevant to VS2012 and TFS2010) without
success: Running VS2010 UnitTests project from TFS2008 Team Build and
VS2010, TFS 2008 and Unit Tests
On the build server I now have the following:
VS2010 Ultimate SP1 installed
VS2012 Update 3 installed
.NET 4.5 framework SDK installed
Changed Microsoft.TeamFoundation.Build.targets file in "C:\Program Files
(86)\MSBuild\Microsoft\VisualStudio\TeamBuild\" and "C:\Program
Files\MSBuild\Microsoft\VisualStudio\TeamBuild\" so the AssemblyFile
attribute of the TestToolsTask build task pointed to "C:\Program Files
(x86)\Microsoft Visual Studio
11.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
I have 2 build definitions that I have been testing with:
In the first build definition I have left the ToolPath of the "run MS
Test" activity blank so it then uses "C:\Program Files (x86)\Microsoft
Visual Studio 10.0\Common7\IDE"
In the other build definition I have changed the "Run MS Test" activity
ToolPath parameter to "C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE"
Both build definitions appear to be building correctly and are using the
following MSBuild.exe:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
The first build defintion runs the VS2010 version of MStest with any
errors, but 5 of the approx. 2030 tests fail. These tests do not fail when
run from within Visual Studaio 2012. An example of the command line is
(actual paths and server names removed):
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe
/nologo /usestderr /searchpathroot:"d:\Builds\xxxxx\Binaries"
/resultsfileroot:"d:\Builds\xxxxx\TestResults"
/testcontainer:"d:\Builds\xxxxx.dll"
/testcontainer:"d:\Builds\xxxxx.dll" /publish:"http://xxxxx
/publishbuild:"vstfs:///Build/Build/xxxxx" /teamproject:"xxxxx"
/platform:"x86" /flavor:"Debug"
When running the second build definition MSTest fails to run with the
output below. If I run this command from the command line on the build
server without the switches that are causing the Invalid switch error then
MSTest runs and the tests in question are passed:
The MSTestActivity was invoked without a value for Platform or Flavor. The
values x86 and Debug were used.
C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\MSTest.exe
/nologo /usestderr /searchpathroot:"d:\Builds\xxxxx\Binaries"
/resultsfileroot:"d:\Builds\xxxxx\TestResults"
/testcontainer:"d:\Builds\xxxxx.dll"
/publish:"http://xxxxx" /publishbuild:"vstfs:///Build/Build/xxxxx"
/teamproject:"xxxxx"
/platform:"x86" /flavor:"Debug"
Invalid switch "/publish".
Invalid switch "/publishbuild".
Invalid switch "/teamproject".
Invalid switch "/platform".
Invalid switch "/flavor".
For switch syntax, type "MSTest /help"
I have done a lot of runs of these builds but I hvae not been able to
resolve the problem. Is there anything else that I am missing that needs
to be done either on the build server or in the build definition?
In relation to the actual tests that are failing they have in common that
they are comparing objects in lists, but as mentioned they pass when run
from within VS2012.
Wednesday, 28 August 2013
No string is returned from static function C#
No string is returned from static function C#
Hello I trying to make a function wich will shof a calender at a givven
location on a given form and the returns the selected date in a string.
This is what i've got so far:
public static string ShowCalendar(Point locatieCalender, Form F1)
{
MonthCalendar calender = new MonthCalendar();
calender.Location = locatieCalender;
calender.Show();
calender.Visible = true;
calender.BringToFront();
calender.Parent = F1;
string date = calender.SelectionRange.Start.ToShortDateString();
DateTime dateValue = DateTime.Parse(date);
string dateForTextbox = dateValue.ToString("dd-MM-yyyy");
//calender.Hide();
return dateForTextbox;
}
And the function call looks like this:
Point calenderLocatie = new Point(405, 69);
string dateForTextbox = HelpFunction.ShowCalendar(calenderLocatie,
this);
txtPeriode_Tot.Text = dateForTextbox;
The calender shows on the form but no string is returned. I've tried a
event handler but because of the static property this doesn't work.
Thanks in advance for the help.
Hello I trying to make a function wich will shof a calender at a givven
location on a given form and the returns the selected date in a string.
This is what i've got so far:
public static string ShowCalendar(Point locatieCalender, Form F1)
{
MonthCalendar calender = new MonthCalendar();
calender.Location = locatieCalender;
calender.Show();
calender.Visible = true;
calender.BringToFront();
calender.Parent = F1;
string date = calender.SelectionRange.Start.ToShortDateString();
DateTime dateValue = DateTime.Parse(date);
string dateForTextbox = dateValue.ToString("dd-MM-yyyy");
//calender.Hide();
return dateForTextbox;
}
And the function call looks like this:
Point calenderLocatie = new Point(405, 69);
string dateForTextbox = HelpFunction.ShowCalendar(calenderLocatie,
this);
txtPeriode_Tot.Text = dateForTextbox;
The calender shows on the form but no string is returned. I've tried a
event handler but because of the static property this doesn't work.
Thanks in advance for the help.
Make one variable double the value of the other with SASS
Make one variable double the value of the other with SASS
Im using SASS. I need on value to be double another value so the logic is
this:
.one {
padding: 'value';
}
.two {
padding: 'value times 2';
}
So it could be this:
.one {
padding: 2px;
}
.two {
padding: 4px;
}
Or this:
.one {
padding: 10px;
}
.two {
padding: 20px;
}
How can I write this?
Im using SASS. I need on value to be double another value so the logic is
this:
.one {
padding: 'value';
}
.two {
padding: 'value times 2';
}
So it could be this:
.one {
padding: 2px;
}
.two {
padding: 4px;
}
Or this:
.one {
padding: 10px;
}
.two {
padding: 20px;
}
How can I write this?
Parsing Json rest api response in C#
Parsing Json rest api response in C#
I am trying the pull a value from a rest api json response using C#
I have the follow code
client.BaseUrl = "https://api.cloud.appcelerator.com";
request.Resource = "/v1/chats/create.json?key=" + cac.AppCode.ToString();
request.Method = Method.POST;
request.AddUrlSegment("appkey", "key");
var response = client.Execute(request);
in the "response" i get a json content as follow:
{
"meta": {
"code": 200,
"status": "ok",
"method_name": "createChatMessage"
},
"response": {
"chats": [
{
"id": "521cfcd840926a0b3500449e",
"created_at": "2013-08-27T19:24:08+0000",
"updated_at": "2013-08-27T19:24:08+0000",
"message": " join to the chat group, welcome …",
"from": {
"id": "520f41e125e74b0b2400130a",
"first_name": "Administrator",
"created_at": "2013-08-17T09:26:57+0000",
"updated_at": "2013-08-27T19:23:10+0000",
"external_accounts": [
],
"email": "roy@tomax.co.il",
"confirmed_at": "2013-08-17T09:26:57+0000",
"username": "admin",
"admin": "true",
"stats": {
"photos": {
"total_count": 0
},
"storage": {
"used": 0
}
}
},
"chat_group": {
"id": "521cfcd840926a0b3500449d",
"created_at": "2013-08-27T19:24:08+0000",
"updated_at": "2013-08-27T19:24:08+0000",
"message": " join to the chat group, welcome …",
"participate_users": [
{
"id": "520f41e125e74b0b2400130a",
"first_name": "Administrator",
"created_at": "2013-08-17T09:26:57+0000",
"updated_at": "2013-08-27T19:23:10+0000",
"external_accounts": [
],
"email": "roy@tomax.co.il",
"confirmed_at": "2013-08-17T09:26:57+0000",
"username": "admin",
"admin": "true",
"stats": {
"photos": {
"total_count": 0
},
"storage": {
"used": 0
}
}
}
]
}
}
]
}
}
How do i pull the follow value "id": "521cfcd840926a0b3500449e" ? i am
using C#....
I am trying the pull a value from a rest api json response using C#
I have the follow code
client.BaseUrl = "https://api.cloud.appcelerator.com";
request.Resource = "/v1/chats/create.json?key=" + cac.AppCode.ToString();
request.Method = Method.POST;
request.AddUrlSegment("appkey", "key");
var response = client.Execute(request);
in the "response" i get a json content as follow:
{
"meta": {
"code": 200,
"status": "ok",
"method_name": "createChatMessage"
},
"response": {
"chats": [
{
"id": "521cfcd840926a0b3500449e",
"created_at": "2013-08-27T19:24:08+0000",
"updated_at": "2013-08-27T19:24:08+0000",
"message": " join to the chat group, welcome …",
"from": {
"id": "520f41e125e74b0b2400130a",
"first_name": "Administrator",
"created_at": "2013-08-17T09:26:57+0000",
"updated_at": "2013-08-27T19:23:10+0000",
"external_accounts": [
],
"email": "roy@tomax.co.il",
"confirmed_at": "2013-08-17T09:26:57+0000",
"username": "admin",
"admin": "true",
"stats": {
"photos": {
"total_count": 0
},
"storage": {
"used": 0
}
}
},
"chat_group": {
"id": "521cfcd840926a0b3500449d",
"created_at": "2013-08-27T19:24:08+0000",
"updated_at": "2013-08-27T19:24:08+0000",
"message": " join to the chat group, welcome …",
"participate_users": [
{
"id": "520f41e125e74b0b2400130a",
"first_name": "Administrator",
"created_at": "2013-08-17T09:26:57+0000",
"updated_at": "2013-08-27T19:23:10+0000",
"external_accounts": [
],
"email": "roy@tomax.co.il",
"confirmed_at": "2013-08-17T09:26:57+0000",
"username": "admin",
"admin": "true",
"stats": {
"photos": {
"total_count": 0
},
"storage": {
"used": 0
}
}
}
]
}
}
]
}
}
How do i pull the follow value "id": "521cfcd840926a0b3500449e" ? i am
using C#....
wpf mvvm recursive tree
wpf mvvm recursive tree
i have two classes
public class leaf
{
public string name { get; set; }
}
and
public class node
{
public ObservableCollection<node> nodeList = new
ObservableCollection<node>();
public ObservableCollection<leaf> leafList = new
ObservableCollection<leaf>();
public ObservableCollection<node> prop_nodeList { get { return
nodeList; } set { nodeList = value; } }
public ObservableCollection<leaf> prop_leafList { get { return
leafList; } set { leafList = value; } }
public string name { get; set; }
}
as you can see its work like roads or tree. node can have information on
another node and leaf.
i would like to show in user control tree formated like that
nethead is a main node, and its have two another node (b, a). node a have
two node(b,c) and 2 leaf (a1, a2). but i dont do it with mvvm. when i do
it with mvvm its look like
from C# im doing only
this.DataContext = mainNode; // its node which hold everething (its named
netHead)
from xaml its
<Grid>
<TreeView ItemsSource="{Binding prop_nodeList}">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:node}"
ItemsSource="{Binding prop_nodeList}">
<TextBlock Text="{Binding Path=name}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:leaf}"
ItemsSource="{Binding prop_leafList}">
<TextBlock Text="{Binding Path=name}"/>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
</Grid>
you see what i want to do ? i want to make double treeItem in TreeView,
but it doesnt work :( please help, its projekt for Ant Algorithm and i
want to do the best gui in class room
i have two classes
public class leaf
{
public string name { get; set; }
}
and
public class node
{
public ObservableCollection<node> nodeList = new
ObservableCollection<node>();
public ObservableCollection<leaf> leafList = new
ObservableCollection<leaf>();
public ObservableCollection<node> prop_nodeList { get { return
nodeList; } set { nodeList = value; } }
public ObservableCollection<leaf> prop_leafList { get { return
leafList; } set { leafList = value; } }
public string name { get; set; }
}
as you can see its work like roads or tree. node can have information on
another node and leaf.
i would like to show in user control tree formated like that
nethead is a main node, and its have two another node (b, a). node a have
two node(b,c) and 2 leaf (a1, a2). but i dont do it with mvvm. when i do
it with mvvm its look like
from C# im doing only
this.DataContext = mainNode; // its node which hold everething (its named
netHead)
from xaml its
<Grid>
<TreeView ItemsSource="{Binding prop_nodeList}">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:node}"
ItemsSource="{Binding prop_nodeList}">
<TextBlock Text="{Binding Path=name}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:leaf}"
ItemsSource="{Binding prop_leafList}">
<TextBlock Text="{Binding Path=name}"/>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
</Grid>
you see what i want to do ? i want to make double treeItem in TreeView,
but it doesnt work :( please help, its projekt for Ant Algorithm and i
want to do the best gui in class room
"The type initializer for 'Microsoft.Web.Deployment.DeploymentManager' threw an exception" error with VS2010 WebDeploy 3.5
"The type initializer for 'Microsoft.Web.Deployment.DeploymentManager'
threw an exception" error with VS2010 WebDeploy 3.5
I'm deploying a new web app project through VS2010 using WebDeploy 3.5
onto a remote dev server. I have managed to publish another web app
project to the site root using the same method. However, now I wanted my
new web app to go as an (in IIS term) "Application". However VS2010's
Publish dialog keeps on giving me the error "Web deployment task failed.
(The type initializer for 'Microsoft.Web.Deployment.DeploymentManager'
threw an exception.)". And I could not figure out what I am doing wrong.
My Publishing Profile looks exactly the same as the one I used for
publishing my other wep app project, except for the Site/Application. I
also tried importing the publishing profile from my IIS dev server. But
neither worked. I'm using the same VS2010 software to publish my second
web app project so it cannot be an issue on WebDeploy. I am using the same
network login which as publishing rights to the dev server. I've created
the Application on IIS7 and the folder sits within the same folder
hierarchy as the site root. Both the new web app project and the one I
successfully published earlier are MVC apps (which I do not think
matters).
threw an exception" error with VS2010 WebDeploy 3.5
I'm deploying a new web app project through VS2010 using WebDeploy 3.5
onto a remote dev server. I have managed to publish another web app
project to the site root using the same method. However, now I wanted my
new web app to go as an (in IIS term) "Application". However VS2010's
Publish dialog keeps on giving me the error "Web deployment task failed.
(The type initializer for 'Microsoft.Web.Deployment.DeploymentManager'
threw an exception.)". And I could not figure out what I am doing wrong.
My Publishing Profile looks exactly the same as the one I used for
publishing my other wep app project, except for the Site/Application. I
also tried importing the publishing profile from my IIS dev server. But
neither worked. I'm using the same VS2010 software to publish my second
web app project so it cannot be an issue on WebDeploy. I am using the same
network login which as publishing rights to the dev server. I've created
the Application on IIS7 and the folder sits within the same folder
hierarchy as the site root. Both the new web app project and the one I
successfully published earlier are MVC apps (which I do not think
matters).
Tuesday, 27 August 2013
Tool to auto generate Class fields of 'View' type from layout XML?
Tool to auto generate Class fields of 'View' type from layout XML?
I'm using eclipse Android SDK, as i can see there are code generator tool
builtin to generate getters() and setters() from the current class. I'd
like to know if there are such tools to auto generate Android View class
instances, into the current class from a given layout. Possibly auto
instantiate them in the onCreate() call back.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
tools:context=".Main" >
<TextView
style="@style/Divider_Title"
android:text="@string/pi_name_title" />
<View style="@style/Divider" />
<EditText
android:id="@+id/et_firstname"
style="@style/EditText"
android:hint="@string/pi_first_name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/et_lastname"
style="@style/EditText"
android:hint="@string/pi_last_name"
android:inputType="textPersonName" />
....
would generate for an already existing class SignIn
public class SignIn extends FragmentActivity {
private EditText et_firstname;
private EditText et_lastname;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
et_firstname = (EditText) findViewById(R.id.et_firstname);
et_lastname = (EditText) findViewById(R.id.et_lastname);
...
}
I'm using eclipse Android SDK, as i can see there are code generator tool
builtin to generate getters() and setters() from the current class. I'd
like to know if there are such tools to auto generate Android View class
instances, into the current class from a given layout. Possibly auto
instantiate them in the onCreate() call back.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical"
tools:context=".Main" >
<TextView
style="@style/Divider_Title"
android:text="@string/pi_name_title" />
<View style="@style/Divider" />
<EditText
android:id="@+id/et_firstname"
style="@style/EditText"
android:hint="@string/pi_first_name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/et_lastname"
style="@style/EditText"
android:hint="@string/pi_last_name"
android:inputType="textPersonName" />
....
would generate for an already existing class SignIn
public class SignIn extends FragmentActivity {
private EditText et_firstname;
private EditText et_lastname;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
et_firstname = (EditText) findViewById(R.id.et_firstname);
et_lastname = (EditText) findViewById(R.id.et_lastname);
...
}
Manage Intel RAID in Windows
Manage Intel RAID in Windows
I have a box with Intel C600 Series Chipset SATA RAID Controller. Three
RAID1 sets were configured at built time and Windows 2008 Server was
installed on one of the RAID sets. The box has been functioning as a
production SQL Server for the past 6 months.
I would like to view/manage this machine's RAID configuration from
Windows. What software do I need to install?
I looked into Intel RST and Matrix Storage Manager but I am still not
sure. If I open the link for Intel RST and then go to the Latest Downloads
I am presented with a list of software, most of which end with the words
"RAID driver". Is that going to give me access to a Windows app for
managing Intel RAID controller or is it just the driver? If the latter,
what's the download for the app?
The Matrix downloads seem to be all very old -- the latest is from 2009.
Thanks a lot for your help.
I have a box with Intel C600 Series Chipset SATA RAID Controller. Three
RAID1 sets were configured at built time and Windows 2008 Server was
installed on one of the RAID sets. The box has been functioning as a
production SQL Server for the past 6 months.
I would like to view/manage this machine's RAID configuration from
Windows. What software do I need to install?
I looked into Intel RST and Matrix Storage Manager but I am still not
sure. If I open the link for Intel RST and then go to the Latest Downloads
I am presented with a list of software, most of which end with the words
"RAID driver". Is that going to give me access to a Windows app for
managing Intel RAID controller or is it just the driver? If the latter,
what's the download for the app?
The Matrix downloads seem to be all very old -- the latest is from 2009.
Thanks a lot for your help.
Is it possible to install ORACLE RAC 11gR2 on vmware
Is it possible to install ORACLE RAC 11gR2 on vmware
Have a fair idea on installaion of 10g rac. want to install 11g on vmware.
is it possible to install on vmware? thankyou.
Have a fair idea on installaion of 10g rac. want to install 11g on vmware.
is it possible to install on vmware? thankyou.
java ee ajax bind selected radio buttons to controller
java ee ajax bind selected radio buttons to controller
i have a html table:
<table>
<tr>
<td>Connection</td>
<td>Action</td>
</tr>
<tr>
<td>On</td>
<td>
<input type"radio" checked="checked" value="0"
name="rs[0].selection"> off
<input type"radio" checked="checked" value="1"
name="rs[0].selection"> on
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="btnSubmit" text="submit"
/></td>
</tr>
</table>
i implemented a ajax polling to constantly update the data on this page.
what happen in the controller is it will get the data from database, set
it to the object and return it to the jstl view page.
here is the problem im encountering: - Connection is off, radio button
"off" is checked - i clicked radio button "on". - before i could click
submit, the ajax kicks in. when this happen, it updates the page and the
radio button "off" is checked.
how can i keep the radio button "on" checked??
i have a html table:
<table>
<tr>
<td>Connection</td>
<td>Action</td>
</tr>
<tr>
<td>On</td>
<td>
<input type"radio" checked="checked" value="0"
name="rs[0].selection"> off
<input type"radio" checked="checked" value="1"
name="rs[0].selection"> on
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="btnSubmit" text="submit"
/></td>
</tr>
</table>
i implemented a ajax polling to constantly update the data on this page.
what happen in the controller is it will get the data from database, set
it to the object and return it to the jstl view page.
here is the problem im encountering: - Connection is off, radio button
"off" is checked - i clicked radio button "on". - before i could click
submit, the ajax kicks in. when this happen, it updates the page and the
radio button "off" is checked.
how can i keep the radio button "on" checked??
Using HSQLDB in the embedded mode
Using HSQLDB in the embedded mode
I'am currently develop a java desktop application using netbeans
+hibernate + hsqldb in embedded mode
while creating a new database I've got this exception Cannot establish a
connection to jdbc:hsqldb:hsql://localhost using org.hsqldb.jdbcDriver
(java.net.ConnectException: Connection refused: connect)
I'am currently develop a java desktop application using netbeans
+hibernate + hsqldb in embedded mode
while creating a new database I've got this exception Cannot establish a
connection to jdbc:hsqldb:hsql://localhost using org.hsqldb.jdbcDriver
(java.net.ConnectException: Connection refused: connect)
Import/Export Hotmail Contacts with PHP
Import/Export Hotmail Contacts with PHP
Suppose in my website I have an user who wants to import his hotmail
contacts just by clicking a button. Also he can add contacts to his
hotmail contacts as well. I have done the same scenario with Gmail
contacts.
How can a hotmail contacts imported/exported through php?
Thanks in advance.
Suppose in my website I have an user who wants to import his hotmail
contacts just by clicking a button. Also he can add contacts to his
hotmail contacts as well. I have done the same scenario with Gmail
contacts.
How can a hotmail contacts imported/exported through php?
Thanks in advance.
Monday, 26 August 2013
how do i target a seeds.rb in an engine to avoid seeding my entire app?
how do i target a seeds.rb in an engine to avoid seeding my entire app?
My project is on Rails 3.2 and refinerycms v 2.0.10
I just generated a new engine and and ran my bundle and rails generate
commands, and my migration. Now, per the docs, I need to run db:seed but I
don't want to execute a db:seed at the app level because I have several
other engines and I don't want to re-seed them.
it is related to this question: Rails engine / How to use seed? but the
answer there is to run db:seed at the app level.
So how would I say something like rake myNewEngine:db:seed ? I know it can
be done but my google fu is apparently too weak to dredge it up.
My project is on Rails 3.2 and refinerycms v 2.0.10
I just generated a new engine and and ran my bundle and rails generate
commands, and my migration. Now, per the docs, I need to run db:seed but I
don't want to execute a db:seed at the app level because I have several
other engines and I don't want to re-seed them.
it is related to this question: Rails engine / How to use seed? but the
answer there is to run db:seed at the app level.
So how would I say something like rake myNewEngine:db:seed ? I know it can
be done but my google fu is apparently too weak to dredge it up.
Ajax template: how to handle head section
Ajax template: how to handle head section
I know it's easy stuff, but I'm new to this and I can't understand which
is the best approach.
Background
The template I'm working on is a dual theme Desktop/Mobile, UA Sniffing
based. Now I just added responsiveness through enquire.js and ajax and
everithing changed: I'm struggling in getting things to work properly, is
the first time I'm dealing with ajax.
Scenario
My template is dynamically loaded through ajax in fact if you try to
resize the width of the window below 1080px, the mobile template will show
up. (it will show up on every mobile device too but this is not important
for us atm)
So, responsiveness has been implemented with the help of enquire.js and
ajax calls (see code below).
Originally, the template was static so at the moment, the whole section is
still conditionally loaded through if statements in functions.php. (e.g.
the video script should just load on certain pages of the desktop version)
Issues
The mobile template -which has been styled with the mobile.css stylesheet-
doesn't seem to have any effect. Should I change the way stylesheets and
scripts are loaded due to the new ajax/enquire thing?
the content i.e. the_content(), doesn't show up. Why? And how to load it
in my scenario?
Follows the code
functions.php
//Load Stylesheet
function add_desktop_styles() {
wp_register_style('reset', get_template_directory_uri().'/reset.css');
wp_register_style('style', get_template_directory_uri().'/style.css',
array('reset') );
wp_enqueue_style('style');
//$mobile = mobile_device_detect();
//if ($mobile==true) {
if (wp_is_mobile()) {
wp_register_style('mobile',
get_template_directory_uri().'/mobile.css', array('reset') );
wp_enqueue_style('mobile');
}
}
add_action('wp_head', 'add_desktop_styles', '1');
//UA Sniffing
function devicecontrol() {
require_once('_/inc/mobile_device_detect.php');
}
add_action('wp_loaded', 'devicecontrol', '2');
//AJAX
function your_function_name() {
wp_enqueue_script( 'function',
get_template_directory_uri().'/_/js/my_js_stuff.js',
array('jquery','enquire'), true);
wp_localize_script( 'function', 'my_ajax_script', array( 'ajaxurl' =>
admin_url( 'admin-ajax.php' ) ) );
}
add_action('template_redirect', 'your_function_name');
function get_mobile_template()
{
include('templates/pages/homepage-phone.php');
die();
}
add_action("wp_ajax_nopriv_get_mobile_template", "get_mobile_template");
add_action("wp_ajax_get_mobile_template", "get_mobile_template");
function get_desktop_template()
{
if (!wp_is_mobile()) {
include('templates/pages/homepage-computer.php');
} else {
include('templates/pages/homepage-phone.php');
}
die();
}
add_action("wp_ajax_nopriv_get_desktop_template", "get_desktop_template");
add_action("wp_ajax_get_desktop_template", "get_desktop_template");
//jQuery
if ( !function_exists( 'core_mods' ) ) {
function core_mods() {
if ( !is_admin() ) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', (
"//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
), false);
wp_enqueue_script( 'jquery' );
}
}
add_action( 'wp_enqueue_scripts', 'core_mods','2' );
}
//Scripts Mobile
function add_mobile_scripts() {
wp_register_style('video-css',
get_template_directory_uri().'/_/js/videojs/video-js.css');
wp_enqueue_style('video-css');
wp_register_script( 'video-js',
get_template_directory_uri().'/_/js/videojs/video.js', null, false );
wp_enqueue_script( 'video-js' );
}
function isMobile() {
//$mobile = mobile_device_detect();
///if ($mobile==true)
if (wp_is_mobile()) {
add_mobile_scripts();
}
}
add_action( 'wp_enqueue_scripts', 'isMobile', '1' );
//Scripts Desktop
function addSlide() {
/*wp_register_script( 'modernizr',
get_template_directory_uri().'/_/js/modernizr.js', null, false );
wp_enqueue_script( 'modernizr' );*/
wp_register_script( 'enquire',
get_template_directory_uri().'/_/js/enquire.min.js', null, false );
wp_enqueue_script( 'enquire' );
wp_register_script( 'jwplayer',
get_template_directory_uri().'/_/js/jwplayer.js', null, false );
wp_enqueue_script( 'jwplayer' );
wp_register_script( 'bootstrap',
get_template_directory_uri().'/_/js/bootstrap.js', array('jquery'),
false );
wp_enqueue_script( 'bootstrap' );
wp_register_script( 'spk_slide',
get_template_directory_uri().'/_/js/slides.js', array('jquery'), false
);
wp_enqueue_script( 'spk_slide' );
}
// Slider just on front page
function isSlideshowPage() {
if ( is_front_page()
|| is_page('Bankkaufmann')
|| is_page('Hochschulabsolvent')
|| is_page('Professional')
|| is_page('Die Prüfungsstellen')
|| is_page('Von Beruf Verbandsprüfer')) {
addSlide();
}
}
add_action( 'wp_enqueue_scripts', 'isSlideshowPage' );
Js script
this script at the moment loads on all pages, I will wrap it and call it
from the page-template later
enquire.register("screen and (max-width:1080px)", {
// OPTIONAL
// If supplied, triggered when a media query matches.
match : function() {
jQuery.ajax({
url: my_ajax_script.ajaxurl,
data: ({action : 'get_mobile_template'}),
success: function(data) {
document.write(data);
}
});
},
unmatch : function() {$("body").empty();},
// OPTIONAL
// If supplied, triggered once, when the handler is registered.
setup : function() {},
// OPTIONAL, defaults to false
// If set to true, defers execution of the setup function
// until the first time the media query is matched
deferSetup : true,
// OPTIONAL
// If supplied, triggered when handler is unregistered.
// Place cleanup code here
destroy : function() {}
});
enquire.register("screen and (min-width:1081px)", {
// OPTIONAL
// If supplied, triggered when a media query matches.
match : function() {
jQuery.ajax({
url: my_ajax_script.ajaxurl,
data: ({action : 'get_desktop_template'}),
success: function(data) {
document.write(data);
}
});
},
unmatch : function() {$("body").empty();},
// OPTIONAL
// If supplied, triggered once, when the handler is registered.
setup : function() {},
// OPTIONAL, defaults to false
// If set to true, defers execution of the setup function
// until the first time the media query is matched
deferSetup : true,
// OPTIONAL
// If supplied, triggered when handler is unregistered.
// Place cleanup code here
destroy : function() {}
});
I know it's easy stuff, but I'm new to this and I can't understand which
is the best approach.
Background
The template I'm working on is a dual theme Desktop/Mobile, UA Sniffing
based. Now I just added responsiveness through enquire.js and ajax and
everithing changed: I'm struggling in getting things to work properly, is
the first time I'm dealing with ajax.
Scenario
My template is dynamically loaded through ajax in fact if you try to
resize the width of the window below 1080px, the mobile template will show
up. (it will show up on every mobile device too but this is not important
for us atm)
So, responsiveness has been implemented with the help of enquire.js and
ajax calls (see code below).
Originally, the template was static so at the moment, the whole section is
still conditionally loaded through if statements in functions.php. (e.g.
the video script should just load on certain pages of the desktop version)
Issues
The mobile template -which has been styled with the mobile.css stylesheet-
doesn't seem to have any effect. Should I change the way stylesheets and
scripts are loaded due to the new ajax/enquire thing?
the content i.e. the_content(), doesn't show up. Why? And how to load it
in my scenario?
Follows the code
functions.php
//Load Stylesheet
function add_desktop_styles() {
wp_register_style('reset', get_template_directory_uri().'/reset.css');
wp_register_style('style', get_template_directory_uri().'/style.css',
array('reset') );
wp_enqueue_style('style');
//$mobile = mobile_device_detect();
//if ($mobile==true) {
if (wp_is_mobile()) {
wp_register_style('mobile',
get_template_directory_uri().'/mobile.css', array('reset') );
wp_enqueue_style('mobile');
}
}
add_action('wp_head', 'add_desktop_styles', '1');
//UA Sniffing
function devicecontrol() {
require_once('_/inc/mobile_device_detect.php');
}
add_action('wp_loaded', 'devicecontrol', '2');
//AJAX
function your_function_name() {
wp_enqueue_script( 'function',
get_template_directory_uri().'/_/js/my_js_stuff.js',
array('jquery','enquire'), true);
wp_localize_script( 'function', 'my_ajax_script', array( 'ajaxurl' =>
admin_url( 'admin-ajax.php' ) ) );
}
add_action('template_redirect', 'your_function_name');
function get_mobile_template()
{
include('templates/pages/homepage-phone.php');
die();
}
add_action("wp_ajax_nopriv_get_mobile_template", "get_mobile_template");
add_action("wp_ajax_get_mobile_template", "get_mobile_template");
function get_desktop_template()
{
if (!wp_is_mobile()) {
include('templates/pages/homepage-computer.php');
} else {
include('templates/pages/homepage-phone.php');
}
die();
}
add_action("wp_ajax_nopriv_get_desktop_template", "get_desktop_template");
add_action("wp_ajax_get_desktop_template", "get_desktop_template");
//jQuery
if ( !function_exists( 'core_mods' ) ) {
function core_mods() {
if ( !is_admin() ) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', (
"//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
), false);
wp_enqueue_script( 'jquery' );
}
}
add_action( 'wp_enqueue_scripts', 'core_mods','2' );
}
//Scripts Mobile
function add_mobile_scripts() {
wp_register_style('video-css',
get_template_directory_uri().'/_/js/videojs/video-js.css');
wp_enqueue_style('video-css');
wp_register_script( 'video-js',
get_template_directory_uri().'/_/js/videojs/video.js', null, false );
wp_enqueue_script( 'video-js' );
}
function isMobile() {
//$mobile = mobile_device_detect();
///if ($mobile==true)
if (wp_is_mobile()) {
add_mobile_scripts();
}
}
add_action( 'wp_enqueue_scripts', 'isMobile', '1' );
//Scripts Desktop
function addSlide() {
/*wp_register_script( 'modernizr',
get_template_directory_uri().'/_/js/modernizr.js', null, false );
wp_enqueue_script( 'modernizr' );*/
wp_register_script( 'enquire',
get_template_directory_uri().'/_/js/enquire.min.js', null, false );
wp_enqueue_script( 'enquire' );
wp_register_script( 'jwplayer',
get_template_directory_uri().'/_/js/jwplayer.js', null, false );
wp_enqueue_script( 'jwplayer' );
wp_register_script( 'bootstrap',
get_template_directory_uri().'/_/js/bootstrap.js', array('jquery'),
false );
wp_enqueue_script( 'bootstrap' );
wp_register_script( 'spk_slide',
get_template_directory_uri().'/_/js/slides.js', array('jquery'), false
);
wp_enqueue_script( 'spk_slide' );
}
// Slider just on front page
function isSlideshowPage() {
if ( is_front_page()
|| is_page('Bankkaufmann')
|| is_page('Hochschulabsolvent')
|| is_page('Professional')
|| is_page('Die Prüfungsstellen')
|| is_page('Von Beruf Verbandsprüfer')) {
addSlide();
}
}
add_action( 'wp_enqueue_scripts', 'isSlideshowPage' );
Js script
this script at the moment loads on all pages, I will wrap it and call it
from the page-template later
enquire.register("screen and (max-width:1080px)", {
// OPTIONAL
// If supplied, triggered when a media query matches.
match : function() {
jQuery.ajax({
url: my_ajax_script.ajaxurl,
data: ({action : 'get_mobile_template'}),
success: function(data) {
document.write(data);
}
});
},
unmatch : function() {$("body").empty();},
// OPTIONAL
// If supplied, triggered once, when the handler is registered.
setup : function() {},
// OPTIONAL, defaults to false
// If set to true, defers execution of the setup function
// until the first time the media query is matched
deferSetup : true,
// OPTIONAL
// If supplied, triggered when handler is unregistered.
// Place cleanup code here
destroy : function() {}
});
enquire.register("screen and (min-width:1081px)", {
// OPTIONAL
// If supplied, triggered when a media query matches.
match : function() {
jQuery.ajax({
url: my_ajax_script.ajaxurl,
data: ({action : 'get_desktop_template'}),
success: function(data) {
document.write(data);
}
});
},
unmatch : function() {$("body").empty();},
// OPTIONAL
// If supplied, triggered once, when the handler is registered.
setup : function() {},
// OPTIONAL, defaults to false
// If set to true, defers execution of the setup function
// until the first time the media query is matched
deferSetup : true,
// OPTIONAL
// If supplied, triggered when handler is unregistered.
// Place cleanup code here
destroy : function() {}
});
Load in jQuery into a SVG open as a page
Load in jQuery into a SVG open as a page
I am able to hook mouse events on SVG elements by going into it with the
Chrome Web Inspector, assigning an id to the SVG polygon tag, and then
using the native $() which is equivalent to document.getElementById to
hook it:
$("#THISONE").addEventListener('click', function() { console.log('clicked
it'); });
Now I want to make this slightly less painful to work with so it'd be nice
if I can get jQuery DOM methods to work with.
So...
(function() {
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.js";
document.appendChild(jq);
})();
produces Uncaught TypeError: Cannot call method 'appendChild' of null. So
apparently even document doesn't exist. document is accessible from the js
console, but this function loaded as a bookmarklet does not work.
I then tried pasting the contents into the js console, it produces this:
Error: HierarchyRequestError: DOM Exception 3
code: 3
message: "HierarchyRequestError: DOM Exception 3"
name: "HierarchyRequestError"
stack: "Error: A Node was inserted somewhere it doesn't belong.↵
at <anonymous>:4:10↵ at Object.InjectedScript._evaluateOn
(<anonymous>:602:39)↵ at Object.InjectedScript._evaluateAndWrap
(<anonymous>:521:52)↵ at Object.InjectedScript.evaluate
(<anonymous>:440:21)"
__proto__: DOMException
Any tips?
My ideal goal is to have a bookmarklet that I can use on any SVG i open in
Chrome that will install a delegated event handler that can do things like
respond to clicks on certain elements to provide popups or change colors.
In particular I'm dealing with enormous SVGs of graphs produced by dot.
These graphs have long snakey edge paths which overlap in such a way that
it is near-impossible to follow them. So, I want to highlight just the
edges incident on a node if I click the node.
Failing that, I will resort to some hack that embeds the svg into a html
webpage, or is linked from a resource. Somewhat less elegant but workable
enough.
I am able to hook mouse events on SVG elements by going into it with the
Chrome Web Inspector, assigning an id to the SVG polygon tag, and then
using the native $() which is equivalent to document.getElementById to
hook it:
$("#THISONE").addEventListener('click', function() { console.log('clicked
it'); });
Now I want to make this slightly less painful to work with so it'd be nice
if I can get jQuery DOM methods to work with.
So...
(function() {
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.js";
document.appendChild(jq);
})();
produces Uncaught TypeError: Cannot call method 'appendChild' of null. So
apparently even document doesn't exist. document is accessible from the js
console, but this function loaded as a bookmarklet does not work.
I then tried pasting the contents into the js console, it produces this:
Error: HierarchyRequestError: DOM Exception 3
code: 3
message: "HierarchyRequestError: DOM Exception 3"
name: "HierarchyRequestError"
stack: "Error: A Node was inserted somewhere it doesn't belong.↵
at <anonymous>:4:10↵ at Object.InjectedScript._evaluateOn
(<anonymous>:602:39)↵ at Object.InjectedScript._evaluateAndWrap
(<anonymous>:521:52)↵ at Object.InjectedScript.evaluate
(<anonymous>:440:21)"
__proto__: DOMException
Any tips?
My ideal goal is to have a bookmarklet that I can use on any SVG i open in
Chrome that will install a delegated event handler that can do things like
respond to clicks on certain elements to provide popups or change colors.
In particular I'm dealing with enormous SVGs of graphs produced by dot.
These graphs have long snakey edge paths which overlap in such a way that
it is near-impossible to follow them. So, I want to highlight just the
edges incident on a node if I click the node.
Failing that, I will resort to some hack that embeds the svg into a html
webpage, or is linked from a resource. Somewhat less elegant but workable
enough.
MySQL Querying Issue using CodeIgniter
MySQL Querying Issue using CodeIgniter
So I was able to find the root cause of my earlier problem.
Turns out it was the querying that is the problem. Well, not on my side,
at least not that I think so. This problem has been bugging me for many
hours now. Unfortunately, it something I don't know how to fix.
Please check this code:
public function get_calendar_content($y,$m){
$query = $this->db->query("SELECT * from events WHERE event_date LIKE
'$y-$m%'");
$content=array();
foreach($query->result() as $q){
$content[substr($q->event_date,8,2)]=$q->event_details;
}
return $content;
}
This function ignores whatever I supply for the $m, or the month. It only
cares about the year. Plus, when I tried selecting all data from the
events table instead of having a where clause, it still only returns the
entries or data from the events table which is is dated in the month of
August.
When I tried writing the where clause explicitly to event_date LIKE
'2013-09', it wouldn't return any data at all. I don't understand what's
going on. For some unknown reason, the function would only return data
from August. What could my problem be?
So I was able to find the root cause of my earlier problem.
Turns out it was the querying that is the problem. Well, not on my side,
at least not that I think so. This problem has been bugging me for many
hours now. Unfortunately, it something I don't know how to fix.
Please check this code:
public function get_calendar_content($y,$m){
$query = $this->db->query("SELECT * from events WHERE event_date LIKE
'$y-$m%'");
$content=array();
foreach($query->result() as $q){
$content[substr($q->event_date,8,2)]=$q->event_details;
}
return $content;
}
This function ignores whatever I supply for the $m, or the month. It only
cares about the year. Plus, when I tried selecting all data from the
events table instead of having a where clause, it still only returns the
entries or data from the events table which is is dated in the month of
August.
When I tried writing the where clause explicitly to event_date LIKE
'2013-09', it wouldn't return any data at all. I don't understand what's
going on. For some unknown reason, the function would only return data
from August. What could my problem be?
Moving location of php the_title
Moving location of php the_title
I'm trying to make the area of my content pages which houses the page
title full width, so i can put an image back there, similar to this:
http://www.nielsen.com/us/en/newswire.html
I've tried to move the page-title div above the container on page.php, but
it always ends up back inside the container.
Here's an example of what I want moved on my site:
http://www.zachkeller.net/cp_site/?page_id=93
Here's my page.php code:
<?php get_header(); ?>
<!-- If there is no gallery, just grab the featured image -->
<?php if ( has_post_thumbnail() ) { ?>
<a class="featured-image" href="<?php the_permalink(); ?>"
title="<?php echo esc_attr( sprintf( __( 'Permalink to %s',
'okay' ), the_title_attribute( 'echo=0' ) ) ); ?>"
rel="bookmark"><?php the_post_thumbnail( 'large-image' );
?></a>
<?php } ?>
<div class="container-wrap">
<div class="container">
<div class="content">
<?php if ( have_posts() ) : while ( have_posts() )
: the_post(); ?>
<div class="blog-post clearfix">
<div class="blog-inside">
<div class="page-title">
<h1><?php the_title(); ?></h1>
</div>
<?php the_content(); ?>
</div><!-- blog inside -->
</div><!-- blog post -->
<?php endwhile; ?>
<?php endif; ?>
</div><!-- content -->
<?php get_sidebar(); ?>
</div><!-- container -->
</div><!-- container wrap -->
<?php get_footer(); ?>
I'm trying to make the area of my content pages which houses the page
title full width, so i can put an image back there, similar to this:
http://www.nielsen.com/us/en/newswire.html
I've tried to move the page-title div above the container on page.php, but
it always ends up back inside the container.
Here's an example of what I want moved on my site:
http://www.zachkeller.net/cp_site/?page_id=93
Here's my page.php code:
<?php get_header(); ?>
<!-- If there is no gallery, just grab the featured image -->
<?php if ( has_post_thumbnail() ) { ?>
<a class="featured-image" href="<?php the_permalink(); ?>"
title="<?php echo esc_attr( sprintf( __( 'Permalink to %s',
'okay' ), the_title_attribute( 'echo=0' ) ) ); ?>"
rel="bookmark"><?php the_post_thumbnail( 'large-image' );
?></a>
<?php } ?>
<div class="container-wrap">
<div class="container">
<div class="content">
<?php if ( have_posts() ) : while ( have_posts() )
: the_post(); ?>
<div class="blog-post clearfix">
<div class="blog-inside">
<div class="page-title">
<h1><?php the_title(); ?></h1>
</div>
<?php the_content(); ?>
</div><!-- blog inside -->
</div><!-- blog post -->
<?php endwhile; ?>
<?php endif; ?>
</div><!-- content -->
<?php get_sidebar(); ?>
</div><!-- container -->
</div><!-- container wrap -->
<?php get_footer(); ?>
New to JS; how do I make a script to receive an argument through a URL?
New to JS; how do I make a script to receive an argument through a URL?
I am new to JavaScript and I am trying to implement it into a website like
this.
A person wants to download a file. They click on a link, which takes them
to another HTML file with the download link, a keyword, and an
advertisement. So they would be on http://website.com/randompage and they
would click on a link to download a file which would take them to
website.com/download.html?keyword=text?file_url=http://website.com/file.txt
If website.com/download.html could accept 2 parameters into an imbedded
JavaScript (or a seperate file, whichever works better). Then the
download.html would show a link to download the file at variable file_url
and would display the keyword from variable keyword. Then an ad would be
displayed according to the keyword (my ad service does that for me). Is
this possible to do? I would like a sample script, if possible. The ad
code can be left out (I already have that part). Thanks in advance :)
I am new to JavaScript and I am trying to implement it into a website like
this.
A person wants to download a file. They click on a link, which takes them
to another HTML file with the download link, a keyword, and an
advertisement. So they would be on http://website.com/randompage and they
would click on a link to download a file which would take them to
website.com/download.html?keyword=text?file_url=http://website.com/file.txt
If website.com/download.html could accept 2 parameters into an imbedded
JavaScript (or a seperate file, whichever works better). Then the
download.html would show a link to download the file at variable file_url
and would display the keyword from variable keyword. Then an ad would be
displayed according to the keyword (my ad service does that for me). Is
this possible to do? I would like a sample script, if possible. The ad
code can be left out (I already have that part). Thanks in advance :)
Joining Two query
Joining Two query
select
a.Enquiry_Id,a.Ckeck_In,a.check_Out,a.Hotel_Name,a.Meal_Plan,a.Room_Type,a.Occupancy_Type,a.Room_QT,a.Adults
from Accomodation a
where a.Enquiry_Id = 74
select q.Enquiry_Id,q.Start,q1.Stay_At from Quick_Plan q,Quick_Plan q1
where q.Enquiry_Id = 74 and q1.Enquiry_Id = 74 and q.Stay_At = q1.Start
result of 1st query is
74 2013-08-03 2013-08-04 ADS CP deluxe Double 1 2
and the result of 2nd query is
74 Ahmedabad Agra
nw i want to combine these two query so that i get the result like
74 2013-08-03 2013-08-04 ADS CP deluxe Double 1 2
Ahmedabad Agra
select
a.Enquiry_Id,a.Ckeck_In,a.check_Out,a.Hotel_Name,a.Meal_Plan,a.Room_Type,a.Occupancy_Type,a.Room_QT,a.Adults
from Accomodation a
where a.Enquiry_Id = 74
select q.Enquiry_Id,q.Start,q1.Stay_At from Quick_Plan q,Quick_Plan q1
where q.Enquiry_Id = 74 and q1.Enquiry_Id = 74 and q.Stay_At = q1.Start
result of 1st query is
74 2013-08-03 2013-08-04 ADS CP deluxe Double 1 2
and the result of 2nd query is
74 Ahmedabad Agra
nw i want to combine these two query so that i get the result like
74 2013-08-03 2013-08-04 ADS CP deluxe Double 1 2
Ahmedabad Agra
Sunday, 25 August 2013
Facebook October 2013 breaking changes affect Feed and send
Facebook October 2013 breaking changes affect Feed and send
We are using feed/post api and send dialog box for our app in Facebook, As
October 2013 breaking changes are removing feed/post so, I am not able to
post as it is declined by Facebook also we can not share post with
multiple user as privacy is moved out, its more one-to-one communication.
In send dialog the description field is removed so cann't send any
pre-populated description in messages.
I am looking for a workaround as its hitting the major functionality of my
app, as to share information between the users.
Please help.
We are using feed/post api and send dialog box for our app in Facebook, As
October 2013 breaking changes are removing feed/post so, I am not able to
post as it is declined by Facebook also we can not share post with
multiple user as privacy is moved out, its more one-to-one communication.
In send dialog the description field is removed so cann't send any
pre-populated description in messages.
I am looking for a workaround as its hitting the major functionality of my
app, as to share information between the users.
Please help.
MSDeploy: How to delete a single file on remote server
MSDeploy: How to delete a single file on remote server
How do I delete a single file on remote server. I want to delete
offline_app.htm only leaving the rest of the content in tact.
Tips appreciated.
How do I delete a single file on remote server. I want to delete
offline_app.htm only leaving the rest of the content in tact.
Tips appreciated.
compiling aosp 4.2.2 on xperia z tab
compiling aosp 4.2.2 on xperia z tab
i followed the readme https://github.com/sonyxperiadev/device-sony-sgp321
But i can't build it succesfully. This error gives me a lot of headache:
target Prebuilt: libarity
(out/target/product/sgp321/obj/JAVA_LIBRARIES/libarity_intermediates/javalib.jar)
target Prebuilt: zxing-core-1.7
(out/target/product/sgp321/obj/JAVA_LIBRARIES/zxing-core-1.7_intermediates/javalib.jar)
target thumb C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/../wrapper/QualcommCamera.cpp
target thumb C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHAL.cpp target thumb
C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHWI.cpp target thumb
C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraStream.cpp In file
included from
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHAL.h:21:0, from
hardware/qcom/camera/QCamera/HAL2/core/../wrapper/QualcommCamera.cpp:39:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/../wrapper/QualcommCamera.o]
Fehler 1 make: * Warte auf noch nicht beendete Prozesse... In file
included from
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHAL.h:21:0, from
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHAL.cpp:28:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/src/QCameraHAL.o]
Fehler 1 In file included from
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHAL.h:21:0, from
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHWI.cpp:29:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/src/QCameraHWI.o]
Fehler 1 In file included from
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraStream.cpp:25:0:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/src/QCameraStream.o]
Fehler 1
I'm using the Aosp 4.2.2_r1.2 repo from google. Thanks.
i followed the readme https://github.com/sonyxperiadev/device-sony-sgp321
But i can't build it succesfully. This error gives me a lot of headache:
target Prebuilt: libarity
(out/target/product/sgp321/obj/JAVA_LIBRARIES/libarity_intermediates/javalib.jar)
target Prebuilt: zxing-core-1.7
(out/target/product/sgp321/obj/JAVA_LIBRARIES/zxing-core-1.7_intermediates/javalib.jar)
target thumb C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/../wrapper/QualcommCamera.cpp
target thumb C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHAL.cpp target thumb
C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHWI.cpp target thumb
C++: camera.msm8960 <=
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraStream.cpp In file
included from
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHAL.h:21:0, from
hardware/qcom/camera/QCamera/HAL2/core/../wrapper/QualcommCamera.cpp:39:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/../wrapper/QualcommCamera.o]
Fehler 1 make: * Warte auf noch nicht beendete Prozesse... In file
included from
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHAL.h:21:0, from
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHAL.cpp:28:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/src/QCameraHAL.o]
Fehler 1 In file included from
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHAL.h:21:0, from
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraHWI.cpp:29:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/src/QCameraHWI.o]
Fehler 1 In file included from
hardware/qcom/camera/QCamera/HAL2/core/src/QCameraStream.cpp:25:0:
hardware/qcom/camera/QCamera/HAL2/core/inc/QCameraHWI.h:31:26: fatal
error: gralloc_priv.h: No such file or directory compilation terminated.
make: *
[out/target/product/sgp321/obj/SHARED_LIBRARIES/camera.msm8960_intermediates/src/QCameraStream.o]
Fehler 1
I'm using the Aosp 4.2.2_r1.2 repo from google. Thanks.
Saturday, 24 August 2013
Thermodynamics of Heat Seeking missiles
Thermodynamics of Heat Seeking missiles
I have been told that many infrared homing missiles operate at very low
temperatures in order to reduce noise, and that they use canisters of
compressed air that expand isothermally (thus cooling the surroundings).
However, it seems unlikely to me that this thermodynamic process can
counteract the heat produced from the missile's rocket enough to make a
significant difference. How much cooling is really done, and what
temperature does the system have to operate at in order to be functional?
I have been told that many infrared homing missiles operate at very low
temperatures in order to reduce noise, and that they use canisters of
compressed air that expand isothermally (thus cooling the surroundings).
However, it seems unlikely to me that this thermodynamic process can
counteract the heat produced from the missile's rocket enough to make a
significant difference. How much cooling is really done, and what
temperature does the system have to operate at in order to be functional?
Printing to CSV file with automatic width
Printing to CSV file with automatic width
Is there any way in Pandas to write a DataFrame to a csv file where the
column widths are automatically adjusted? (i.e. akin to what Pandas does
when printing a DataFrame to the screen)
At the moment if I do
df.to_csv(string_buf, sep = ' ', Index=False)
print(string_buf.getvalue())
I get:
column1 column2 column3
0 4 james matching68 -100
1 44 george foo -500
2 14 jason trinitron -400
3 1 tom trinitron -400
4 1 lukas esp -100
By the way, It's also strange that it prints the Index even though I
explicitly disabled it.
Is there any way in Pandas to write a DataFrame to a csv file where the
column widths are automatically adjusted? (i.e. akin to what Pandas does
when printing a DataFrame to the screen)
At the moment if I do
df.to_csv(string_buf, sep = ' ', Index=False)
print(string_buf.getvalue())
I get:
column1 column2 column3
0 4 james matching68 -100
1 44 george foo -500
2 14 jason trinitron -400
3 1 tom trinitron -400
4 1 lukas esp -100
By the way, It's also strange that it prints the Index even though I
explicitly disabled it.
All my pages apart from index lead to a 404 page
All my pages apart from index lead to a 404 page
My settings for permalinks: default : /?p=123 works but if I switch to by
post name All pages stop working and just go to a 404
My settings for permalinks: default : /?p=123 works but if I switch to by
post name All pages stop working and just go to a 404
Construction of a Triangle
Construction of a Triangle
The method which I adopt for constructing the triangle is very similar to
the method used in the construction of the batman curve.
If you are not familiar with this technique I suggest you look at this
answer concerning the construction of the batman curve so you may become
familiar with the method.
Okay So I am trying to construct a right-angled triangle. First I start
with this equation:
$$|x|+|y|=1$$ This produces a square as such:
Now to cut this in half I turn the absolute function into it's root
representation and swap the square and radical for $x$:
$$\left(\sqrt{x}\right)^2+\sqrt{y^2}-1=0$$
that produces this:
Now this is the first part of the equation.
Second part focuses on a line $x=0$ from $x=-1$ to $x=1$. This is what I
came up with: $$x\sqrt{1-y^2}=0$$
Now in theory I should be able to multiply the two expressions from the
LHS of equation $1$ and $2$ to get my desired triangle. However this is
not the case and the $2^{\text{nd}}$ expression becomes hidden. However
what I have found is that if you add an arbitrarily small value to $x$ it
becomes visible but it is not geometrically a triangle. So I have devised
a hypothesis about the expression.
$$\left(\left(\sqrt{x}\right)^2+\sqrt{y^2}-1\right)x\sqrt{1-y^2}=0$$ The
equation that doesn't work.
$$\left(\left(\sqrt{x}\right)^2+\sqrt{y^2}-1\right)\left(\lim_{\epsilon\to0}
x + \epsilon\right)\sqrt{1-y^2}=0$$ This is my hypothesis.
So my questions are:
Am I going down the right track in constructing a triangle if so:
Is there anything I can do to improve my current work?
Why is it that the second expression gets hidden?
If not:
What route should I be taking?
Is there a general equation for a triangle?
The method which I adopt for constructing the triangle is very similar to
the method used in the construction of the batman curve.
If you are not familiar with this technique I suggest you look at this
answer concerning the construction of the batman curve so you may become
familiar with the method.
Okay So I am trying to construct a right-angled triangle. First I start
with this equation:
$$|x|+|y|=1$$ This produces a square as such:
Now to cut this in half I turn the absolute function into it's root
representation and swap the square and radical for $x$:
$$\left(\sqrt{x}\right)^2+\sqrt{y^2}-1=0$$
that produces this:
Now this is the first part of the equation.
Second part focuses on a line $x=0$ from $x=-1$ to $x=1$. This is what I
came up with: $$x\sqrt{1-y^2}=0$$
Now in theory I should be able to multiply the two expressions from the
LHS of equation $1$ and $2$ to get my desired triangle. However this is
not the case and the $2^{\text{nd}}$ expression becomes hidden. However
what I have found is that if you add an arbitrarily small value to $x$ it
becomes visible but it is not geometrically a triangle. So I have devised
a hypothesis about the expression.
$$\left(\left(\sqrt{x}\right)^2+\sqrt{y^2}-1\right)x\sqrt{1-y^2}=0$$ The
equation that doesn't work.
$$\left(\left(\sqrt{x}\right)^2+\sqrt{y^2}-1\right)\left(\lim_{\epsilon\to0}
x + \epsilon\right)\sqrt{1-y^2}=0$$ This is my hypothesis.
So my questions are:
Am I going down the right track in constructing a triangle if so:
Is there anything I can do to improve my current work?
Why is it that the second expression gets hidden?
If not:
What route should I be taking?
Is there a general equation for a triangle?
how to connect to google play service and load leaderboard
how to connect to google play service and load leaderboard
I want to connect my game with google play service. i have read
documentation on android developer and try to following type-a-number
sample and still can't load leaderboard.
i have import baseGameUtils, but i use andengine so i didn't use extends
BaseGameActivity from google.
what i have until now:
- GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) return success
- startActivityForResult(pickAccountIntent, REQUEST_CODE_PICK_ACCOUNT); is
working well and i got my account name from onActivityResult(..);
- i already put this on my manifest.
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
my questions are
1. can i use google play service without extends BaseGameActivity?
2. if i use gameHelper.beginUserInitiatedSignIn(); after i got my account
name, i got this on log cat. (what this connected mean? because i still
got error on next question)
08-25 00:09:01.890: D/BaseGameActivity(11222):
isGooglePlayServicesAvailable returned 0
08-25 00:09:01.890: D/BaseGameActivity(11222): beginUserInitiatedSignIn:
starting new sign-in flow.
08-25 00:09:01.890: D/BaseGameActivity(11222): All clients now connected.
Sign-in successful.
08-25 00:09:01.890: D/BaseGameActivity(11222): All requested clients
connected. Sign-in succeeded!
3 . how do i use connect()? i have read and tried about gameClient and
GameClientBuilder but i have no idea how to use that. when i tried run
this code.
startActivityForResult(gameHelper.getGamesClient().getAllLeaderboardsIntent(),
RC_UNUSED);
i got this log.
08-25 00:09:05.660: E/AndroidRuntime(11222):
java.lang.IllegalStateException: Not connected. Call connect() and wait
for onConnected() to be called.
4 . to use leaderboard i know i must use code from google play store such
as CgkIx****AIQAA. but i didn't found where i must put this code to load
leaderboard.
sorry for long question, but i think if there is a sample that only for
connect and either access achievement or leaderboard it will answer all my
question. please don't tell me to see type-a-number sample, i did that and
i need another sample code.
I want to connect my game with google play service. i have read
documentation on android developer and try to following type-a-number
sample and still can't load leaderboard.
i have import baseGameUtils, but i use andengine so i didn't use extends
BaseGameActivity from google.
what i have until now:
- GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) return success
- startActivityForResult(pickAccountIntent, REQUEST_CODE_PICK_ACCOUNT); is
working well and i got my account name from onActivityResult(..);
- i already put this on my manifest.
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
my questions are
1. can i use google play service without extends BaseGameActivity?
2. if i use gameHelper.beginUserInitiatedSignIn(); after i got my account
name, i got this on log cat. (what this connected mean? because i still
got error on next question)
08-25 00:09:01.890: D/BaseGameActivity(11222):
isGooglePlayServicesAvailable returned 0
08-25 00:09:01.890: D/BaseGameActivity(11222): beginUserInitiatedSignIn:
starting new sign-in flow.
08-25 00:09:01.890: D/BaseGameActivity(11222): All clients now connected.
Sign-in successful.
08-25 00:09:01.890: D/BaseGameActivity(11222): All requested clients
connected. Sign-in succeeded!
3 . how do i use connect()? i have read and tried about gameClient and
GameClientBuilder but i have no idea how to use that. when i tried run
this code.
startActivityForResult(gameHelper.getGamesClient().getAllLeaderboardsIntent(),
RC_UNUSED);
i got this log.
08-25 00:09:05.660: E/AndroidRuntime(11222):
java.lang.IllegalStateException: Not connected. Call connect() and wait
for onConnected() to be called.
4 . to use leaderboard i know i must use code from google play store such
as CgkIx****AIQAA. but i didn't found where i must put this code to load
leaderboard.
sorry for long question, but i think if there is a sample that only for
connect and either access achievement or leaderboard it will answer all my
question. please don't tell me to see type-a-number sample, i did that and
i need another sample code.
R How to optimize the transformation parameters in dynamic linear regression?
R How to optimize the transformation parameters in dynamic linear regression?
I have a data-set with a dependent variable y that I'm trying to explain
and n independent variables (X matrix). I'm doing a constrained
multi-linear regression model in R. So instead of using the lm() function,
I'm using optimization packages (genalg, BBoptim, quadprog) to find the
best coefficients (betas) to the model by minimizing the sum of squared
errors SSE, and respecting the constraints. So I'm manually doing OLS.
This is working.
Now the problem is, some of my independent variables are transformed to
capture a lagged effect in time using logistic functions. Which makes my X
matrix dynamic. I want to find the best coefficients of the
transformations and consequently the best betas, such that the SSE is
minimized in the multi-linear regression. In other words, I think i have a
case of dynamic multi-linear regression.
In Excel solver, i used to do the optimization easily but It doesn't seem
to be that easy in R. Any pointers would be highly appreciated.
Thanks, YB
I have a data-set with a dependent variable y that I'm trying to explain
and n independent variables (X matrix). I'm doing a constrained
multi-linear regression model in R. So instead of using the lm() function,
I'm using optimization packages (genalg, BBoptim, quadprog) to find the
best coefficients (betas) to the model by minimizing the sum of squared
errors SSE, and respecting the constraints. So I'm manually doing OLS.
This is working.
Now the problem is, some of my independent variables are transformed to
capture a lagged effect in time using logistic functions. Which makes my X
matrix dynamic. I want to find the best coefficients of the
transformations and consequently the best betas, such that the SSE is
minimized in the multi-linear regression. In other words, I think i have a
case of dynamic multi-linear regression.
In Excel solver, i used to do the optimization easily but It doesn't seem
to be that easy in R. Any pointers would be highly appreciated.
Thanks, YB
git submodule update --init Error while installing dot-emacs files
git submodule update --init Error while installing dot-emacs files
I try to install a dotfiles config for emacs
(https://github.com/dhaley/dot-emacs). I did all like instructed (download
and install of the macport of emacs via brew, clone of the repsitory) and
now when I use the command git submodules update --init I get the
following error:
$git submodule update --init
fatal: reference is not a tree: a2bcba9a92873900055dcaff640e4d31a650947e
fatal: reference is not a tree: 05f9cebc64842efa2968d49adb08330d15c7ffe8
fatal: reference is not a tree: 89611c7a6947787bf2f591e64e22b7444ea5ed41
Unable to checkout 'a2bcba9a92873900055dcaff640e4d31a650947e' in submodule
path 'override/bbdb'
Unable to checkout '05f9cebc64842efa2968d49adb08330d15c7ffe8' in submodule
path 'site-lisp/auctex'
Unable to checkout '89611c7a6947787bf2f591e64e22b7444ea5ed41' in submodule
path 'site-lisp/drupal-mode'
Some of these did not have an entry in the .gitmodules file and I added it
manually. But now I have no clue how to fix this error. I new to emacs and
the hole dotfile thing so if you can give me a hint it would be great (on
stackoverflow I found Git submodule head 'reference is not a tree' error
but did not really understand if this is my problem and how to fix it)
PS: I send a mail to Damon Haley the maintainer of the repository with a
link to this, as I found no forum to discuss issues on the github
repository.
Best Regards and thanks to everybody contribution to this greate community,
Dennis
I try to install a dotfiles config for emacs
(https://github.com/dhaley/dot-emacs). I did all like instructed (download
and install of the macport of emacs via brew, clone of the repsitory) and
now when I use the command git submodules update --init I get the
following error:
$git submodule update --init
fatal: reference is not a tree: a2bcba9a92873900055dcaff640e4d31a650947e
fatal: reference is not a tree: 05f9cebc64842efa2968d49adb08330d15c7ffe8
fatal: reference is not a tree: 89611c7a6947787bf2f591e64e22b7444ea5ed41
Unable to checkout 'a2bcba9a92873900055dcaff640e4d31a650947e' in submodule
path 'override/bbdb'
Unable to checkout '05f9cebc64842efa2968d49adb08330d15c7ffe8' in submodule
path 'site-lisp/auctex'
Unable to checkout '89611c7a6947787bf2f591e64e22b7444ea5ed41' in submodule
path 'site-lisp/drupal-mode'
Some of these did not have an entry in the .gitmodules file and I added it
manually. But now I have no clue how to fix this error. I new to emacs and
the hole dotfile thing so if you can give me a hint it would be great (on
stackoverflow I found Git submodule head 'reference is not a tree' error
but did not really understand if this is my problem and how to fix it)
PS: I send a mail to Damon Haley the maintainer of the repository with a
link to this, as I found no forum to discuss issues on the github
repository.
Best Regards and thanks to everybody contribution to this greate community,
Dennis
Domain of Dependence of a Scalar first-order Hyperbolic Conservation Law
Domain of Dependence of a Scalar first-order Hyperbolic Conservation Law
For a linear advection equation: $u_t+cu_x =0$ on
$(x,t)\in(-\infty,\infty)\times[0,\infty)$ With Cauchy initial data :
$u(0,t) = u_0(x)$
The dependence of a solution at a fixed space-time point $u(X,T)$ is a
single point $X-cT$ since $u(X,T)=u_0(X-cT)$,and characteristics are
straight lines with constant slope (constant wave velocity).
What about this scalar pde:
$u_t+f(u)_x =0 $ where $f''(u)<0$ on
$(x,t)\in(-\infty,\infty)\times[0,\infty)$
and $u(0,t) = u_0(x)$
My particular case is a concave, smooth quadratic flux function. Here
$f'(u)$ will produce shock and rarefaction waves, so how do we derive the
domain of dependence of the solution at a fixed space-time point $u(X,T)$
for this case?
For a linear advection equation: $u_t+cu_x =0$ on
$(x,t)\in(-\infty,\infty)\times[0,\infty)$ With Cauchy initial data :
$u(0,t) = u_0(x)$
The dependence of a solution at a fixed space-time point $u(X,T)$ is a
single point $X-cT$ since $u(X,T)=u_0(X-cT)$,and characteristics are
straight lines with constant slope (constant wave velocity).
What about this scalar pde:
$u_t+f(u)_x =0 $ where $f''(u)<0$ on
$(x,t)\in(-\infty,\infty)\times[0,\infty)$
and $u(0,t) = u_0(x)$
My particular case is a concave, smooth quadratic flux function. Here
$f'(u)$ will produce shock and rarefaction waves, so how do we derive the
domain of dependence of the solution at a fixed space-time point $u(X,T)$
for this case?
How can I match reference-style markdown links?
How can I match reference-style markdown links?
I am interested in using Javascript to find all reference-style markdown
links in a string of text. So I would want the following:
[all the things][things] => "things"
[something] => "something"
But not:
[o hai](http://example.com)
[o hai] (http://example.com)
In other words, an open square bracket followed by a close square bracket,
capturing the text inside, but not the same followed by a set of
parentheses.
Make sense? Thanks!
I am interested in using Javascript to find all reference-style markdown
links in a string of text. So I would want the following:
[all the things][things] => "things"
[something] => "something"
But not:
[o hai](http://example.com)
[o hai] (http://example.com)
In other words, an open square bracket followed by a close square bracket,
capturing the text inside, but not the same followed by a set of
parentheses.
Make sense? Thanks!
Friday, 23 August 2013
C# - Force one application to close when a different application has closed, then close itself
C# - Force one application to close when a different application has
closed, then close itself
So, I'm writing a program, here's the start of it!
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process.Start(@"C:\\Windows\\ehome\\ehshell.exe");
System.Diagnostics.Process.Start(@"E:\\Xpadder\\WMC.xpaddercontroller");
}
}
}
All it does is open the two files, What I want it to do is also wait until
it detects when ehshell.exe stops running and then force another program
(in this case xpadder) to end aswell
I've had a look for cose for doing this, but I'm not the best at C# and
not 100% sure what I'm looking for!
closed, then close itself
So, I'm writing a program, here's the start of it!
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process.Start(@"C:\\Windows\\ehome\\ehshell.exe");
System.Diagnostics.Process.Start(@"E:\\Xpadder\\WMC.xpaddercontroller");
}
}
}
All it does is open the two files, What I want it to do is also wait until
it detects when ehshell.exe stops running and then force another program
(in this case xpadder) to end aswell
I've had a look for cose for doing this, but I'm not the best at C# and
not 100% sure what I'm looking for!
How to make it so that actions will be performed every second?
How to make it so that actions will be performed every second?
How can I make it so that actions will be performed every second? For
example, I would like to create a java applet that displays a picture of a
car's progress on a race track every second, if it is moving over 5
coordinates every second.
Thanks so much!
How can I make it so that actions will be performed every second? For
example, I would like to create a java applet that displays a picture of a
car's progress on a race track every second, if it is moving over 5
coordinates every second.
Thanks so much!
How to see if object is contained in an embedded NSArray, then grab the other items in the set
How to see if object is contained in an embedded NSArray, then grab the
other items in the set
I currently have a NSArray which contains many NSArrays, each containing a
pair of NSStrings such like the following: [["A", "B"], ["U", "A"], ["X",
"Y"], ...], and I am interested first checking to see if it contains a
particular object, and then grabbing the other paired object and putting
it in an array. For example, if I am checking for "A" in the above array,
the result array would contain ["B", "U"]
I know how to iterate over each array, but am trouble deciding how to grab
the paired object inside the array... thanks!
for (NSArray *innerArray in outerArray){
if ([innerArray containsObject: @"A"]){
//how to extract the other object and save it to an array?
}
}
other items in the set
I currently have a NSArray which contains many NSArrays, each containing a
pair of NSStrings such like the following: [["A", "B"], ["U", "A"], ["X",
"Y"], ...], and I am interested first checking to see if it contains a
particular object, and then grabbing the other paired object and putting
it in an array. For example, if I am checking for "A" in the above array,
the result array would contain ["B", "U"]
I know how to iterate over each array, but am trouble deciding how to grab
the paired object inside the array... thanks!
for (NSArray *innerArray in outerArray){
if ([innerArray containsObject: @"A"]){
//how to extract the other object and save it to an array?
}
}
ajaxComplete is not working in ie 8 and 7
ajaxComplete is not working in ie 8 and 7
I have page to display data by ajax request. But after get the data i
could not find the data properly worked as jQuery used. So i used these
function
jQuery(document).ajaxComplete(function(){
var $productoverlay = jQuery('#product-details-overlay');
jQuery('#slider-related').tinycarousel({display:1});
jQuery('#fotorama').fotorama();
jQuery('#product-details-overlay .close-item').click( function(){
jQuery.when($productoverlay.fadeOut(500)).then(function() {
var productpos = $productoverlay.offset();
var itemlists = jQuery('#itemlists .item:last').offset();
jQuery('#itemlists').css({
height: (itemlists.top + 30) + 'px',
});
$productoverlay.remove();
});
});
});
and it is working perfectly. when checked in ie 8 and 7, the ajaxcomplete
function is not working. Is there any way to working in ie 8 and 7
perfectly.
I have page to display data by ajax request. But after get the data i
could not find the data properly worked as jQuery used. So i used these
function
jQuery(document).ajaxComplete(function(){
var $productoverlay = jQuery('#product-details-overlay');
jQuery('#slider-related').tinycarousel({display:1});
jQuery('#fotorama').fotorama();
jQuery('#product-details-overlay .close-item').click( function(){
jQuery.when($productoverlay.fadeOut(500)).then(function() {
var productpos = $productoverlay.offset();
var itemlists = jQuery('#itemlists .item:last').offset();
jQuery('#itemlists').css({
height: (itemlists.top + 30) + 'px',
});
$productoverlay.remove();
});
});
});
and it is working perfectly. when checked in ie 8 and 7, the ajaxcomplete
function is not working. Is there any way to working in ie 8 and 7
perfectly.
implementing jTable MVC 4
implementing jTable MVC 4
I have following
****** controller ***********
namespace DLM.Controllers{
public class BooksController : Controller
{
private IRepositoryContainer _repository;
//
// GET: /Books/
public ActionResult Index()
{
return View();
}
[HttpPost]
public JsonResult ListBooks(int jtStartIndex = 0, int jtPageSize = 0,
string jtSorting = null)
{
try
{
//Get data from database
int bookCount = _repository.BookRepository.GetBooksCount();
List<Books> book =
_repository.BookRepository.GetBooks(jtStartIndex, jtPageSize,
jtSorting);
//Return result to jTable
return Json(new { Result = "OK", Records = book,
TotalRecordCount = bookCount });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
***** ListBooks View ************
{
@Styles.Render("~/Scripts/jtable/jtable.2.3.0/themes/metro/darkgray/jtable.min.css")
<script src="/Scripts/jtable/jtable.2.3.0/jquery.jtable.min.js"
type="text/javascript"></script>
<div id="BookTableContainer"></div>
<script type="text/javascript">
$(document).ready(function () {
$('#BookTableContainer').jtable({
title: 'The Student List',
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
defaultSorting: 'Book Title ASC', //Set default sorting
actions: {
listAction: '/Books/Index',
deleteAction: '/Books/DeleteBook',
updateAction: '/Books/UpdateBook',
createAction: '/Books/AddBook'
},
fields: {
BooksID: {
key: true,
create: false,
edit: false,
list: false
},
Code_No: {
title: 'Book Code',
width: '23%'
},
Title: {
title: 'Book Title',
list: false
},
Author: {
title: 'Author',
list: false
},
Page_No: {
title: 'Number of Pages',
width: '13%'
},
Y_of_P: {
title: 'Year of Publication',
width: '12%'
},
Language: {
title: 'Language',
width: '15%'
},
Subject: {
title: 'Subject',
list: false
},
Publisher: {
title: 'Publisher',
list: false
},
Keyword: {
title: 'Keywords',
type: 'textarea',
width: '12%',
sorting: false
}
}
});
//Load student list from server
$('#BookTableContainer').jtable('load');
});
</script>
}
ISSUE *****************
When I am trying to access /Books/ListBooks There is an error The resource
cannot be found.
Please help me out i am new to jTable and it's implementation.
I have following
****** controller ***********
namespace DLM.Controllers{
public class BooksController : Controller
{
private IRepositoryContainer _repository;
//
// GET: /Books/
public ActionResult Index()
{
return View();
}
[HttpPost]
public JsonResult ListBooks(int jtStartIndex = 0, int jtPageSize = 0,
string jtSorting = null)
{
try
{
//Get data from database
int bookCount = _repository.BookRepository.GetBooksCount();
List<Books> book =
_repository.BookRepository.GetBooks(jtStartIndex, jtPageSize,
jtSorting);
//Return result to jTable
return Json(new { Result = "OK", Records = book,
TotalRecordCount = bookCount });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
***** ListBooks View ************
{
@Styles.Render("~/Scripts/jtable/jtable.2.3.0/themes/metro/darkgray/jtable.min.css")
<script src="/Scripts/jtable/jtable.2.3.0/jquery.jtable.min.js"
type="text/javascript"></script>
<div id="BookTableContainer"></div>
<script type="text/javascript">
$(document).ready(function () {
$('#BookTableContainer').jtable({
title: 'The Student List',
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
defaultSorting: 'Book Title ASC', //Set default sorting
actions: {
listAction: '/Books/Index',
deleteAction: '/Books/DeleteBook',
updateAction: '/Books/UpdateBook',
createAction: '/Books/AddBook'
},
fields: {
BooksID: {
key: true,
create: false,
edit: false,
list: false
},
Code_No: {
title: 'Book Code',
width: '23%'
},
Title: {
title: 'Book Title',
list: false
},
Author: {
title: 'Author',
list: false
},
Page_No: {
title: 'Number of Pages',
width: '13%'
},
Y_of_P: {
title: 'Year of Publication',
width: '12%'
},
Language: {
title: 'Language',
width: '15%'
},
Subject: {
title: 'Subject',
list: false
},
Publisher: {
title: 'Publisher',
list: false
},
Keyword: {
title: 'Keywords',
type: 'textarea',
width: '12%',
sorting: false
}
}
});
//Load student list from server
$('#BookTableContainer').jtable('load');
});
</script>
}
ISSUE *****************
When I am trying to access /Books/ListBooks There is an error The resource
cannot be found.
Please help me out i am new to jTable and it's implementation.
Thursday, 22 August 2013
How to get the custom field value at thank you page
How to get the custom field value at thank you page
I adda ed the below code to function.php page and it shows the select box
at checkout page fine. But how can i get the value of selected item at the
thank you page.
add_filter( 'woocommerce_checkout_fields' ,
'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['point_side'] = array(
'label' => __('<strong>Select Where Your Points Should Go</strong>',
'woocommerce'),
'placeholder' => _x('custom_field', 'placeholder',
'woocommerce'),
'required' => true,
'clear' => false,
'type' => 'select',
'class' => array('form-row-wide'),
'options' => array(
'default1' => __('Defult1', 'woocommerce' ),
'ls' => __('Left Side', 'woocommerce' ),
'rs' => __('Right Side', 'woocommerce' )
)
);
return $fields;
}
Any helps appreciated.
I adda ed the below code to function.php page and it shows the select box
at checkout page fine. But how can i get the value of selected item at the
thank you page.
add_filter( 'woocommerce_checkout_fields' ,
'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['point_side'] = array(
'label' => __('<strong>Select Where Your Points Should Go</strong>',
'woocommerce'),
'placeholder' => _x('custom_field', 'placeholder',
'woocommerce'),
'required' => true,
'clear' => false,
'type' => 'select',
'class' => array('form-row-wide'),
'options' => array(
'default1' => __('Defult1', 'woocommerce' ),
'ls' => __('Left Side', 'woocommerce' ),
'rs' => __('Right Side', 'woocommerce' )
)
);
return $fields;
}
Any helps appreciated.
Returning multiple array values from loop
Returning multiple array values from loop
I have an activity in my app that takes a searchword and returns file
names that contain that search term. I am trying to modify this code so
that it can split a search term and show files that contain any of the
search terms. For instance if the search term is "big dog" it will return
files that have "big" in the title and also files that contain "dog" in
the title.
The part of the code is:
if (f.isDirectory()){
return true; // Don't discard any subdirectories
}
else {
String delimiter = " +"; /* delimiter */
searchname.searchname = searchname.searchname.toUpperCase();
//Split the search string
String [] tempname = searchname.searchname.split(delimiter);
//Array for the file names to be stored
boolean[] namestring = new boolean[tempname.length];
//Counter
int count;
count = 0;
for(int i=0; i<tempname.length; i++)
{
//While i is less than tempname size store filename to
namestring array
namestring[i] = name.toUpperCase().contains(tempname[i]);
//Add one to count
count = +1;
//Once count = tempname length you can return all of
the array values
if (count == tempname.length){
return namestring[i];
}
}
}
return false;
My java is pretty basic and I might be missing something very obvious.
Thank you very much for your help
I have an activity in my app that takes a searchword and returns file
names that contain that search term. I am trying to modify this code so
that it can split a search term and show files that contain any of the
search terms. For instance if the search term is "big dog" it will return
files that have "big" in the title and also files that contain "dog" in
the title.
The part of the code is:
if (f.isDirectory()){
return true; // Don't discard any subdirectories
}
else {
String delimiter = " +"; /* delimiter */
searchname.searchname = searchname.searchname.toUpperCase();
//Split the search string
String [] tempname = searchname.searchname.split(delimiter);
//Array for the file names to be stored
boolean[] namestring = new boolean[tempname.length];
//Counter
int count;
count = 0;
for(int i=0; i<tempname.length; i++)
{
//While i is less than tempname size store filename to
namestring array
namestring[i] = name.toUpperCase().contains(tempname[i]);
//Add one to count
count = +1;
//Once count = tempname length you can return all of
the array values
if (count == tempname.length){
return namestring[i];
}
}
}
return false;
My java is pretty basic and I might be missing something very obvious.
Thank you very much for your help
Getting error while training my data
Getting error while training my data
Below is my code , which is running fine but after a long processing it
show me the run time error
//FlannBasedMatcher matcher;
std::vector< DMatch > matches;
double max_dist = 0;
double min_dist = 100;
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("FlannBased");
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();
//SurfDescriptorExtractor extractor;
SurfFeatureDetector detector(500);
std::vector<KeyPoint> keypoints;
int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bow(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Mat img_keypoints_1;
Mat descriptors_1;
string YourImagesDirectory="D:\\Cars\\";
vector<string> files=listFilesInDirectory(YourImagesDirectory+"*.jpg");
//Load NOT cars!
string YourImagesDirectory_2="D:\\not_cars\\";
vector<string> files_no=listFilesInDirectory(YourImagesDirectory_2+"*.jpg");
// Initialize constant values
const int nb_cars = files.size();
const int not_cars = files_no.size();
const int num_img = nb_cars + not_cars; // Get the number of images
const int image_area = 40*30;
// Initialize your training set.
cv::Mat training_mat(num_img,image_area,CV_32FC1);
cv::Mat labels(num_img,1,CV_32FC1);
cv::Mat tmp_dst( 500, 450, CV_8UC1 ); // to the right size for resize
// Set temp matrices
cv::Mat tmp_img;
std::vector<string> all_names;
all_names.assign(files.begin(),files.end());
all_names.insert(all_names.end(), files_no.begin(), files_no.end());
// Load image and add them to the training set
int count = 0;
vector<string>::const_iterator i;
string Dir;
for (i = all_names.begin(); i != all_names.end(); ++i)
{
Dir=( (count < files.size() ) ? YourImagesDirectory :
YourImagesDirectory_2);
tmp_img = cv::imread( Dir +*i, 0 );
resize( tmp_img, tmp_dst, tmp_dst.size() );
Mat row_img = tmp_dst; // get a one line image.
detector.detect( row_img, keypoints);
extractor->compute( row_img, keypoints, descriptors_1);
bow.add(descriptors_1);
++count;
}
int count_2=0;
vector<string>::const_iterator k;
Mat vocabulary = bow.cluster();
dextract.setVocabulary(vocabulary);
for (k = all_names.begin(); k != all_names.end(); ++k)
{
Dir=( (count_2 < files.size() ) ? YourImagesDirectory :
YourImagesDirectory_2);
tmp_img = cv::imread( Dir +*k, 0 );
resize( tmp_img, tmp_dst, tmp_dst.size() );
Mat row_img = tmp_dst; // get a one line image.
detector.detect( row_img, keypoints);
dextract.compute( row_img, keypoints, descriptors_1);
training_mat.push_back(descriptors_1);
labels.at< float >(count, 0) = (count<nb_cars)?1:-1; // 1 for car, -1
otherwise*/
++count_2;
}
// Train your SVM
CvSVMParams Params;
Params.svm_type=CvSVM::C_SVC;
Params.kernel_type=CvSVM::LINEAR;
Params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);
Params.gamma=3;
CvSVM svm;
svm.train(training_mat,labels,cv::Mat(),cv::Mat(),Params);
svm.save("trainsvm.txt");
Error :
and how do i know that now my data is trained according to my need and now
i can implement on my real time app to detect objects from video
Below is my code , which is running fine but after a long processing it
show me the run time error
//FlannBasedMatcher matcher;
std::vector< DMatch > matches;
double max_dist = 0;
double min_dist = 100;
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("FlannBased");
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();
//SurfDescriptorExtractor extractor;
SurfFeatureDetector detector(500);
std::vector<KeyPoint> keypoints;
int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bow(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Mat img_keypoints_1;
Mat descriptors_1;
string YourImagesDirectory="D:\\Cars\\";
vector<string> files=listFilesInDirectory(YourImagesDirectory+"*.jpg");
//Load NOT cars!
string YourImagesDirectory_2="D:\\not_cars\\";
vector<string> files_no=listFilesInDirectory(YourImagesDirectory_2+"*.jpg");
// Initialize constant values
const int nb_cars = files.size();
const int not_cars = files_no.size();
const int num_img = nb_cars + not_cars; // Get the number of images
const int image_area = 40*30;
// Initialize your training set.
cv::Mat training_mat(num_img,image_area,CV_32FC1);
cv::Mat labels(num_img,1,CV_32FC1);
cv::Mat tmp_dst( 500, 450, CV_8UC1 ); // to the right size for resize
// Set temp matrices
cv::Mat tmp_img;
std::vector<string> all_names;
all_names.assign(files.begin(),files.end());
all_names.insert(all_names.end(), files_no.begin(), files_no.end());
// Load image and add them to the training set
int count = 0;
vector<string>::const_iterator i;
string Dir;
for (i = all_names.begin(); i != all_names.end(); ++i)
{
Dir=( (count < files.size() ) ? YourImagesDirectory :
YourImagesDirectory_2);
tmp_img = cv::imread( Dir +*i, 0 );
resize( tmp_img, tmp_dst, tmp_dst.size() );
Mat row_img = tmp_dst; // get a one line image.
detector.detect( row_img, keypoints);
extractor->compute( row_img, keypoints, descriptors_1);
bow.add(descriptors_1);
++count;
}
int count_2=0;
vector<string>::const_iterator k;
Mat vocabulary = bow.cluster();
dextract.setVocabulary(vocabulary);
for (k = all_names.begin(); k != all_names.end(); ++k)
{
Dir=( (count_2 < files.size() ) ? YourImagesDirectory :
YourImagesDirectory_2);
tmp_img = cv::imread( Dir +*k, 0 );
resize( tmp_img, tmp_dst, tmp_dst.size() );
Mat row_img = tmp_dst; // get a one line image.
detector.detect( row_img, keypoints);
dextract.compute( row_img, keypoints, descriptors_1);
training_mat.push_back(descriptors_1);
labels.at< float >(count, 0) = (count<nb_cars)?1:-1; // 1 for car, -1
otherwise*/
++count_2;
}
// Train your SVM
CvSVMParams Params;
Params.svm_type=CvSVM::C_SVC;
Params.kernel_type=CvSVM::LINEAR;
Params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);
Params.gamma=3;
CvSVM svm;
svm.train(training_mat,labels,cv::Mat(),cv::Mat(),Params);
svm.save("trainsvm.txt");
Error :
and how do i know that now my data is trained according to my need and now
i can implement on my real time app to detect objects from video
MongoDB not using compound index on '_id'
MongoDB not using compound index on '_id'
I have a collection in MongoDB which has following documents.
/* 0 */
{
"T" : [
374135056604448742
],
"_id" : {
"#" : 7778532275691,
"ts" : ISODate("2013-07-26T02:25:00Z")
}
}
/* 1 */
{
"T" : [
1056188940167152853
],
"_id" : {
"#" : 34103385525388,
"ts" : ISODate("2013-07-30T03:00:00Z")
}
}
/* 2 */
{
"T" : [
1056188940167152853
],
"_id" : {
"#" : 34103385525388,
"ts" : ISODate("2013-07-30T03:18:00Z")
}
}
Now, I'm trying to query some documents with following query.
db.entries.find({
'_id.ts': {'$gte': beginTS, '$lte': endTS},
'_id.#' : 884327843395156951
}).hint([('_id', 1)]).explain()
According to my understanding, since _id is a compound field, and Mongo
always maintains a index on _id, hence to answer above query, Mongo should
have used the index on '_id'. However, the answer to the above query is as
following:
{u'allPlans': [{u'cursor': u'BtreeCursor _id_',
u'indexBounds': {u'_id': [[{u'$minElement': 1}, {u'$maxElement': 1}]]},
u'n': 2803,
u'nscanned': 4869528,
u'nscannedObjects': 4869528}],
u'cursor': u'BtreeCursor _id_',
u'indexBounds': {u'_id': [[{u'$minElement': 1}, {u'$maxElement': 1}]]},
u'indexOnly': False,
u'isMultiKey': False,
u'millis': 128415,
u'n': 2803,
u'nChunkSkips': 0,
u'nYields': 132,
u'nscanned': 4869528,
u'nscannedAllPlans': 4869528,
u'nscannedObjects': 4869528,
u'nscannedObjectsAllPlans': 4869528,
u'scanAndOrder': False,
As it can be observed, MongoDB is doing an entire scan of DB to find just
handful of documents. I don't know what the hell is wrong here.
I tried changing the order of query, but same result. I have no idea what
is happening here. Any help if deeply appreciated.
I have a collection in MongoDB which has following documents.
/* 0 */
{
"T" : [
374135056604448742
],
"_id" : {
"#" : 7778532275691,
"ts" : ISODate("2013-07-26T02:25:00Z")
}
}
/* 1 */
{
"T" : [
1056188940167152853
],
"_id" : {
"#" : 34103385525388,
"ts" : ISODate("2013-07-30T03:00:00Z")
}
}
/* 2 */
{
"T" : [
1056188940167152853
],
"_id" : {
"#" : 34103385525388,
"ts" : ISODate("2013-07-30T03:18:00Z")
}
}
Now, I'm trying to query some documents with following query.
db.entries.find({
'_id.ts': {'$gte': beginTS, '$lte': endTS},
'_id.#' : 884327843395156951
}).hint([('_id', 1)]).explain()
According to my understanding, since _id is a compound field, and Mongo
always maintains a index on _id, hence to answer above query, Mongo should
have used the index on '_id'. However, the answer to the above query is as
following:
{u'allPlans': [{u'cursor': u'BtreeCursor _id_',
u'indexBounds': {u'_id': [[{u'$minElement': 1}, {u'$maxElement': 1}]]},
u'n': 2803,
u'nscanned': 4869528,
u'nscannedObjects': 4869528}],
u'cursor': u'BtreeCursor _id_',
u'indexBounds': {u'_id': [[{u'$minElement': 1}, {u'$maxElement': 1}]]},
u'indexOnly': False,
u'isMultiKey': False,
u'millis': 128415,
u'n': 2803,
u'nChunkSkips': 0,
u'nYields': 132,
u'nscanned': 4869528,
u'nscannedAllPlans': 4869528,
u'nscannedObjects': 4869528,
u'nscannedObjectsAllPlans': 4869528,
u'scanAndOrder': False,
As it can be observed, MongoDB is doing an entire scan of DB to find just
handful of documents. I don't know what the hell is wrong here.
I tried changing the order of query, but same result. I have no idea what
is happening here. Any help if deeply appreciated.
How do I get vim to input the bar/pipe character in my vimrc?
How do I get vim to input the bar/pipe character in my vimrc?
I've tried the following, but it doesn't work.
inoremap <C-\> <Esc>$a<Space>do<Space><Bar><Bar><CR>end<Esc>k$i
I'm trying to map a shortcut for ruby do || .. end blocks.
I've tried the following, but it doesn't work.
inoremap <C-\> <Esc>$a<Space>do<Space><Bar><Bar><CR>end<Esc>k$i
I'm trying to map a shortcut for ruby do || .. end blocks.
Remove unwanted resource strings in Silverlight Application in Visual Studio 2010
Remove unwanted resource strings in Silverlight Application in Visual
Studio 2010
I have a silverlight application(Silverlight 4.0) and have a lot of
strings in the ApplicationStrings.resx file. I want to remove the unwanted
resource strings in the resource file. Please help me out.
Studio 2010
I have a silverlight application(Silverlight 4.0) and have a lot of
strings in the ApplicationStrings.resx file. I want to remove the unwanted
resource strings in the resource file. Please help me out.
Wednesday, 21 August 2013
Function (called from setTimeout) not returning value
Function (called from setTimeout) not returning value
I'm learning JavaScript by writing a Chrome extension for a website. The
website has a section that displays a list of 4 videos, with a button to
load more videos. When you click this button, it loads a new list of
videos via an AJAX call.
I have a function, getNextVideo(), which gets the URL of the next video in
the list. For example, if you are on the third video, then it'll grab the
URL for the fourth video. If you're on the fourth video, then it'll
simulate a click (which loads the new list of videos) via a function
getNextVideoList() and then grab the first in the newly loaded list after
a 1s timeout to wait for the DOM to update (I tried to use mutation
observers but it was too complicated for my skill level).
function getNextVideo()
{
if (getVideoPosition() == 4)
{
function ad()
{
getVideo(1);
}
setTimeout(ad, 1000);
getNextVideoList();
}
else
{
var index = getVideoPosition() + 1;
return getVideo(index);
}
}
getVideoPosition() gets the index of the video in the list using some
simple jQuery nth-child selectors. It returns the values 1, 2, 3, or 4.
getVideo(n) takes the index of the video (1, 2, 3, or 4) and returns the
URL of that video. The returned value looks like this in the console:
"http://video.example.com/video-id"
My problem is that when I run getNextVideo() on a video that is 4th in the
queue, I get undefined returned in my console. How do I make the
getNextVideo() function return the URL of the first video in the list
after the AJAX call and subsequent DOM update?
I'm learning JavaScript by writing a Chrome extension for a website. The
website has a section that displays a list of 4 videos, with a button to
load more videos. When you click this button, it loads a new list of
videos via an AJAX call.
I have a function, getNextVideo(), which gets the URL of the next video in
the list. For example, if you are on the third video, then it'll grab the
URL for the fourth video. If you're on the fourth video, then it'll
simulate a click (which loads the new list of videos) via a function
getNextVideoList() and then grab the first in the newly loaded list after
a 1s timeout to wait for the DOM to update (I tried to use mutation
observers but it was too complicated for my skill level).
function getNextVideo()
{
if (getVideoPosition() == 4)
{
function ad()
{
getVideo(1);
}
setTimeout(ad, 1000);
getNextVideoList();
}
else
{
var index = getVideoPosition() + 1;
return getVideo(index);
}
}
getVideoPosition() gets the index of the video in the list using some
simple jQuery nth-child selectors. It returns the values 1, 2, 3, or 4.
getVideo(n) takes the index of the video (1, 2, 3, or 4) and returns the
URL of that video. The returned value looks like this in the console:
"http://video.example.com/video-id"
My problem is that when I run getNextVideo() on a video that is 4th in the
queue, I get undefined returned in my console. How do I make the
getNextVideo() function return the URL of the first video in the list
after the AJAX call and subsequent DOM update?
Check equality between colors
Check equality between colors
Consider the following:
\colorlet{mycolour1}{black}
AND
\colorlet{mycolour2}{black}
How do I use a command like
\ifthenelse{\equal{mycolour1}{mycolour2}}{TRUE}{FALSE}
In other words, how can I check equality between two colors?
Consider the following:
\colorlet{mycolour1}{black}
AND
\colorlet{mycolour2}{black}
How do I use a command like
\ifthenelse{\equal{mycolour1}{mycolour2}}{TRUE}{FALSE}
In other words, how can I check equality between two colors?
Django EmailField accepts invalid values
Django EmailField accepts invalid values
I'm currently using the default EmailField attribute on my form. The issue
I'm running into is that the form considers an invalid email such as
name@mail.56 to be valid. Do I need to implement my own validators on this
field to make it work correctly?
I was under the impression that having:
#models.py
email = models.EmailField(max_length=254, blank=False, unique=True,
error_messages={'required': 'Please provide your email address.',
'unique': 'An account with this email exist.'},)
Or having:
#forms.py
email = forms.EmailField()
will take care of this type of validation for me but it doesn't seem so.
I'm currently using the default EmailField attribute on my form. The issue
I'm running into is that the form considers an invalid email such as
name@mail.56 to be valid. Do I need to implement my own validators on this
field to make it work correctly?
I was under the impression that having:
#models.py
email = models.EmailField(max_length=254, blank=False, unique=True,
error_messages={'required': 'Please provide your email address.',
'unique': 'An account with this email exist.'},)
Or having:
#forms.py
email = forms.EmailField()
will take care of this type of validation for me but it doesn't seem so.
Cannot convert to type spring.oxm.marshaller: no matching editors or conversion strategy found
Cannot convert to type spring.oxm.marshaller: no matching editors or
conversion strategy found
I have been struggling with that error for long time, have googled, looked
at the examples around the web and still not getting to work. To be honest
I don't understand why my project throws this error.
Caused by: java.lang.IllegalStateException: Cannot convert value of type
[java.lang.String] to required type [org.springframework.oxm.Marshaller]
for property 'marshaller': no matching editors or conversion strategy
found
at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:264)
at
org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448)
... 52 more)
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.TestCase.fail(TestCase.java:227)
at junit.framework.TestSuite$1.runTest(TestSuite.java:100)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
So my setup is Spring Web Services, Jaxb2, maven. I have predefined xsd
files and generated java classes from them by jaxb2 maven plugin.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>schema1-xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/</schemaDirectory>
<schemaFiles>ApplicationResponse.xsd</schemaFiles>
<packageName>com.package.response</packageName>
</configuration>
</execution>
</executions>
</plugin>
My pom has additionally these dependencies:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.7</version>
<!-- <exclusions>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
</exclusions> -->
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.stream</groupId>
<artifactId>sjsxp</artifactId>
<version>1.0.2</version>
</dependency>
Here is my appContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<context:component-scan base-package="com.package" />
<sws:annotation-driven />
<bean id="messageFactory"
class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant
static-field="org.springframework.ws.soap.SoapVersion.SOAP_11"
/>
</property>
</bean>
<bean id="webServiceTemplate"
class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory"/>
<property name="defaultUri" value="https://example/address/hidden"/>
<property name="marshaller" value="marshaller" />
<property name="unmarshaller" value="marshaller" />
</bean>
<bean id="marshaller"
class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath"
value="com.package.request:com.package.request" />
</bean>
</beans>
My service client class
@Component
public class NorServiceClient implements NorService {
@Autowired
private WebServiceTemplate wsTemplate;
public void setDefaultUri(String defaultUri) {
wsTemplate.setDefaultUri(defaultUri);
}
public ApplicationResponse downloadFileList(ApplicationRequest request) {
// Command: DownloadFileList
return (ApplicationResponse)
wsTemplate.marshalSendAndReceive(request);
}
}
And my test case:
public class AppTest extends TestCase {
private ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("/appContext.xml");
@Test
public void testApplicationRequest() {
assertNotNull(new Object());
System.out.println("Context: " + context);
NorService norService = (NorService)
context.getBean("norServiceClient");
ApplicationRequest request = new ApplicationRequest();
nordeaService.downloadFileList(request);
}
}
When launching my app it doesn't even get to the service.downloadFileList,
it throws the exception when initializing context. So I don't think it may
be the problem that I have instatiated just empty ApplicationRequest
object.
Where could the problem lie? By all the examples in the internet I have
done setup the same way, but in my project it throws the exception that no
matching editors or conversion strategy found
conversion strategy found
I have been struggling with that error for long time, have googled, looked
at the examples around the web and still not getting to work. To be honest
I don't understand why my project throws this error.
Caused by: java.lang.IllegalStateException: Cannot convert value of type
[java.lang.String] to required type [org.springframework.oxm.Marshaller]
for property 'marshaller': no matching editors or conversion strategy
found
at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:264)
at
org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448)
... 52 more)
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.TestCase.fail(TestCase.java:227)
at junit.framework.TestSuite$1.runTest(TestSuite.java:100)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
So my setup is Spring Web Services, Jaxb2, maven. I have predefined xsd
files and generated java classes from them by jaxb2 maven plugin.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>schema1-xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/</schemaDirectory>
<schemaFiles>ApplicationResponse.xsd</schemaFiles>
<packageName>com.package.response</packageName>
</configuration>
</execution>
</executions>
</plugin>
My pom has additionally these dependencies:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.7</version>
<!-- <exclusions>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
</exclusions> -->
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.stream</groupId>
<artifactId>sjsxp</artifactId>
<version>1.0.2</version>
</dependency>
Here is my appContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<context:component-scan base-package="com.package" />
<sws:annotation-driven />
<bean id="messageFactory"
class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant
static-field="org.springframework.ws.soap.SoapVersion.SOAP_11"
/>
</property>
</bean>
<bean id="webServiceTemplate"
class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory"/>
<property name="defaultUri" value="https://example/address/hidden"/>
<property name="marshaller" value="marshaller" />
<property name="unmarshaller" value="marshaller" />
</bean>
<bean id="marshaller"
class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath"
value="com.package.request:com.package.request" />
</bean>
</beans>
My service client class
@Component
public class NorServiceClient implements NorService {
@Autowired
private WebServiceTemplate wsTemplate;
public void setDefaultUri(String defaultUri) {
wsTemplate.setDefaultUri(defaultUri);
}
public ApplicationResponse downloadFileList(ApplicationRequest request) {
// Command: DownloadFileList
return (ApplicationResponse)
wsTemplate.marshalSendAndReceive(request);
}
}
And my test case:
public class AppTest extends TestCase {
private ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("/appContext.xml");
@Test
public void testApplicationRequest() {
assertNotNull(new Object());
System.out.println("Context: " + context);
NorService norService = (NorService)
context.getBean("norServiceClient");
ApplicationRequest request = new ApplicationRequest();
nordeaService.downloadFileList(request);
}
}
When launching my app it doesn't even get to the service.downloadFileList,
it throws the exception when initializing context. So I don't think it may
be the problem that I have instatiated just empty ApplicationRequest
object.
Where could the problem lie? By all the examples in the internet I have
done setup the same way, but in my project it throws the exception that no
matching editors or conversion strategy found
What's a good approach for updating millions of rows independently?
What's a good approach for updating millions of rows independently?
I have a MongoDB database with millions of users in collection.
Another collection keeps activity related to users, with 3 entries types:
receive, open and click (email activity)
Based on it's own activity (compared to entire collection average) a user
needs to receive a flag daily: active, inactive, passive. I compute a
daily average for the entire collection. That was easy.
How would be a good approach to compute it for every user, compare it with
the whole AVG and add an attribute?
I have a MongoDB database with millions of users in collection.
Another collection keeps activity related to users, with 3 entries types:
receive, open and click (email activity)
Based on it's own activity (compared to entire collection average) a user
needs to receive a flag daily: active, inactive, passive. I compute a
daily average for the entire collection. That was easy.
How would be a good approach to compute it for every user, compare it with
the whole AVG and add an attribute?
zsh prompt garbled when launching screen from ssh command
zsh prompt garbled when launching screen from ssh command
When I ssh to a server with oh my zsh set-up and run screen directly from
the ssh command like this:
ssh -t -lbdb bdb-dev.myorg.com screen -R -x
the prompt is garbaged:
? ? bdb@bdb-dev:~/big_data_broker/ui [ve-bdb] git:?master? ?
? ?
If I ssh to the same server, then launch screen from there:
~ ⮀ ssh -lbdb -t bdb-dev
Last login: Wed Aug 21 12:50:49 2013 from 10.x.x.x
╭ ➜ bdb@bdb-dev:~ [ve-bdb]
╰ ➤ screen -R -x
then the prompt is ok:
╭ ➜ bdb@bdb-dev:~/big_data_broker/ui [ve-bdb] git:&lsqauo;master›
✗
╰ ➤
I have dumped environment variables in both cases to a file and diffed:
they are the same.
my .screenrc on the server is:
autodetach on # Autodetach session on hangup instead of terminating screen
completely
startup_message off # Turn off the splash screen
defscrollback 30000 # Use a 30000-line scrollback buffer
vbell off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=
kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m
%{W}%c %{g}]'
term xterm
# Make xterm scrolling work properly with screen.
termcapinfo xterm-256color|xterm-color|xterm|xterms|xs|rxvt ti@:te@
Using iTerm2 Build 1.0.0.20130624 on OSX 10.8.4, virtualenvwrapper and the
'seeker' oh-my-zh theme.
Why is the prompt garbaged in the first case and how to fix it?
When I ssh to a server with oh my zsh set-up and run screen directly from
the ssh command like this:
ssh -t -lbdb bdb-dev.myorg.com screen -R -x
the prompt is garbaged:
? ? bdb@bdb-dev:~/big_data_broker/ui [ve-bdb] git:?master? ?
? ?
If I ssh to the same server, then launch screen from there:
~ ⮀ ssh -lbdb -t bdb-dev
Last login: Wed Aug 21 12:50:49 2013 from 10.x.x.x
╭ ➜ bdb@bdb-dev:~ [ve-bdb]
╰ ➤ screen -R -x
then the prompt is ok:
╭ ➜ bdb@bdb-dev:~/big_data_broker/ui [ve-bdb] git:&lsqauo;master›
✗
╰ ➤
I have dumped environment variables in both cases to a file and diffed:
they are the same.
my .screenrc on the server is:
autodetach on # Autodetach session on hangup instead of terminating screen
completely
startup_message off # Turn off the splash screen
defscrollback 30000 # Use a 30000-line scrollback buffer
vbell off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=
kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m
%{W}%c %{g}]'
term xterm
# Make xterm scrolling work properly with screen.
termcapinfo xterm-256color|xterm-color|xterm|xterms|xs|rxvt ti@:te@
Using iTerm2 Build 1.0.0.20130624 on OSX 10.8.4, virtualenvwrapper and the
'seeker' oh-my-zh theme.
Why is the prompt garbaged in the first case and how to fix it?
Can't create an instance
Can't create an instance
I have a console application and a web application.the web application
call the console application and the console application create an
instance of a MSWORD .it is working fine in visual studio.But when I host
the web app in IIS and try localhost:222 it don't work. here is my code
web app code
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim info = New System.Diagnostics.ProcessStartInfo()
info.FileName="F:\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe"
info.Arguments = TextBox1.Text & " " & TextBox2.Text
info.UseShellExecute = True
Dim process = New System.Diagnostics.Process()
process.StartInfo = info
process.Start()
process.WaitForExit()
End Sub
And the console app code is
Public Sub Main(args As String())
' CREATE AN OBJECT FOR WORD
Dim objWord As Object
objWord = CreateObject("Word.Application")
objWord.visible = True
End Sub
Anybody know what is the problem.
I have a console application and a web application.the web application
call the console application and the console application create an
instance of a MSWORD .it is working fine in visual studio.But when I host
the web app in IIS and try localhost:222 it don't work. here is my code
web app code
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim info = New System.Diagnostics.ProcessStartInfo()
info.FileName="F:\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe"
info.Arguments = TextBox1.Text & " " & TextBox2.Text
info.UseShellExecute = True
Dim process = New System.Diagnostics.Process()
process.StartInfo = info
process.Start()
process.WaitForExit()
End Sub
And the console app code is
Public Sub Main(args As String())
' CREATE AN OBJECT FOR WORD
Dim objWord As Object
objWord = CreateObject("Word.Application")
objWord.visible = True
End Sub
Anybody know what is the problem.
Tuesday, 20 August 2013
Obtaining BreezeJS Predicate equivalent on the Server Side
Obtaining BreezeJS Predicate equivalent on the Server Side
There are times when I wish to execute the same query on the server as I
do on the client when using the BreezeJS library.
Here's a trivial example. Imagine the results of a query are limited on
the client for paging using skip() and take(). An "Export" function would
allow the download of the unpaged dataset; ie: without the "take/skip"
restrictions.
Now in a simple "Select * from TableName" type of query, this is trivial,
but what if the breeze Predicate is complex, and dynamically created
(precluding using a well-known server side SQL View).
Ideally, I'd like to know the source code that the Breeze.js .NET client
uses to translate the Predicate into a Linq Where clause.
This isn't my best question I've ever posted, so if you're willing to
help, and need more info, please comment and I'll be happy to post an
example or more details.
There are times when I wish to execute the same query on the server as I
do on the client when using the BreezeJS library.
Here's a trivial example. Imagine the results of a query are limited on
the client for paging using skip() and take(). An "Export" function would
allow the download of the unpaged dataset; ie: without the "take/skip"
restrictions.
Now in a simple "Select * from TableName" type of query, this is trivial,
but what if the breeze Predicate is complex, and dynamically created
(precluding using a well-known server side SQL View).
Ideally, I'd like to know the source code that the Breeze.js .NET client
uses to translate the Predicate into a Linq Where clause.
This isn't my best question I've ever posted, so if you're willing to
help, and need more info, please comment and I'll be happy to post an
example or more details.
Group of finite ideles
Group of finite ideles
A simple question:
If $\overline{\mathbb{Q}}$ denotes the algebraic closure of $\mathbb{Q}$
in $\mathbb{C}$ then what is the definition of the group of $finite$
ideles of $\overline{\mathbb{Q}}$?
Many thanks
A simple question:
If $\overline{\mathbb{Q}}$ denotes the algebraic closure of $\mathbb{Q}$
in $\mathbb{C}$ then what is the definition of the group of $finite$
ideles of $\overline{\mathbb{Q}}$?
Many thanks
Why can't I chown to nobody over nfsv4?
Why can't I chown to nobody over nfsv4?
Server: FreeBSD 9.2-RC1, ZFS
Client: FreeBSD 9.0-RELEASE-p3
Filesystem is exported with "alldirs,maproot=root".
On the client, I can chown a file to any user but nobody.
client# touch foo
client# ls -l foo
-rw-r--r-- 1 root staff 0 Aug 20 11:18 foo
client# chown chris foo
client# ls -l foo
-rw-r--r-- 1 chris staff 0 Aug 20 11:18 foo
client# chown root foo
client# ls -l foo
-rw-r--r-- 1 root staff 0 Aug 20 11:18 foo
client# chown nobody foo
No name and/or group mapping for uid,gid:(65534,-1)
chown: foo: Operation not permitted
nobody exists on both client and server, with UID 65534 in both places. It
looks like this is something to do with nfsv4's user mapping (nfsuserd),
but I'm not finding good documentation on how that works. I've read hints
that nobody is handled specially.
Server: FreeBSD 9.2-RC1, ZFS
Client: FreeBSD 9.0-RELEASE-p3
Filesystem is exported with "alldirs,maproot=root".
On the client, I can chown a file to any user but nobody.
client# touch foo
client# ls -l foo
-rw-r--r-- 1 root staff 0 Aug 20 11:18 foo
client# chown chris foo
client# ls -l foo
-rw-r--r-- 1 chris staff 0 Aug 20 11:18 foo
client# chown root foo
client# ls -l foo
-rw-r--r-- 1 root staff 0 Aug 20 11:18 foo
client# chown nobody foo
No name and/or group mapping for uid,gid:(65534,-1)
chown: foo: Operation not permitted
nobody exists on both client and server, with UID 65534 in both places. It
looks like this is something to do with nfsv4's user mapping (nfsuserd),
but I'm not finding good documentation on how that works. I've read hints
that nobody is handled specially.
How to get the values from a multi dimension array
How to get the values from a multi dimension array
I have a result from my db query that's look like this when dump and the
query is doing what is expected, bu I am have a little problem getting the
array values. I am using PHP PDO to get the result.
$result = $_stmt->fetchAll();
$row = count($result);
print_r($result);
Array ( [0] => Array ( [SUM(od_price * od_qty)] => 69.85 [0] => 69.85 )
[1] => Array ( [SUM(od_price * od_qty)] => 13.97 [0] => 13.97 )
) 69.8513.97
You can see that the result contains both an array and a string values. I
have an option to get either the array or the string value. But I would
rather to get the array values since the the string values are all
togather. Can some one please explain what I am doing that's wrong in the
foreach loop?
if($row == 2)
{
foreach ($result as $k)
{
echo $price_1 = $k[0][0]; // expected 69.85
echo $price_2 = $k[0][1]; // expected 13.97
}
unset($k);
}
I need to get the expected values, but instead I am getting the string
values that are all togather.
I have a result from my db query that's look like this when dump and the
query is doing what is expected, bu I am have a little problem getting the
array values. I am using PHP PDO to get the result.
$result = $_stmt->fetchAll();
$row = count($result);
print_r($result);
Array ( [0] => Array ( [SUM(od_price * od_qty)] => 69.85 [0] => 69.85 )
[1] => Array ( [SUM(od_price * od_qty)] => 13.97 [0] => 13.97 )
) 69.8513.97
You can see that the result contains both an array and a string values. I
have an option to get either the array or the string value. But I would
rather to get the array values since the the string values are all
togather. Can some one please explain what I am doing that's wrong in the
foreach loop?
if($row == 2)
{
foreach ($result as $k)
{
echo $price_1 = $k[0][0]; // expected 69.85
echo $price_2 = $k[0][1]; // expected 13.97
}
unset($k);
}
I need to get the expected values, but instead I am getting the string
values that are all togather.
Upgrading without losing Visual Studio
Upgrading without losing Visual Studio
If we upgrade from Windows 8 to Windows 8.1, do we need to re-install
Visual Studio (any version) or any of the usual dev tools or
redistributables?
I found http://windows.microsoft.com/en-au/windows-8/preview-faq but it
only says "You can keep Windows Settings, personal files, and most apps."
with no other information about which apps you can't keep.
If we upgrade from Windows 8 to Windows 8.1, do we need to re-install
Visual Studio (any version) or any of the usual dev tools or
redistributables?
I found http://windows.microsoft.com/en-au/windows-8/preview-faq but it
only says "You can keep Windows Settings, personal files, and most apps."
with no other information about which apps you can't keep.
Google Maps LatLng returning (NaN,NaN)
Google Maps LatLng returning (NaN,NaN)
I am obtaining my clients geographic coordinates with the following code:
loc={}
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function(position){
loc.lat = position.coords.latitude;
loc.lng = position.coords.longitude;
});
}
I am then trying to turn this into a google map coordinate with the
following code
var clientLocation = new google.maps.LatLng(loc.lat, loc.lng);
This however is returning
(NaN,NaN)
Can anyone suggest what I may be doing wrong?
I am obtaining my clients geographic coordinates with the following code:
loc={}
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function(position){
loc.lat = position.coords.latitude;
loc.lng = position.coords.longitude;
});
}
I am then trying to turn this into a google map coordinate with the
following code
var clientLocation = new google.maps.LatLng(loc.lat, loc.lng);
This however is returning
(NaN,NaN)
Can anyone suggest what I may be doing wrong?
Subscribe to:
Comments (Atom)