Maximum purchased toys time out
So yeah, I have a homework sort of question which I've solved but keeps
giving a timeout error on test cases and I can't figure out why.
You need to buy your nephew toys for his birthday. But you only have
limited money. However, you want to buy as many unique toys as you can for
your nephew. Write a function that will return the max number of unique
toys you can buy.
The arguments to the functions are the integer array costs that contains
the costs for each toy and the integer budget which is the max amount of
money you can spend.
Return the integer representing the max number of unique toys you can buy
Constraints
If N is the number of toys and K is the budget... 1<=N<=105 1<=K<=109
1<=price of any toy<=109
Sample Input
costs: {1, 12, 5, 111, 200, 1000, 10} budget: 50 Sample Return Value
4 Explanation
He can buy only 4 toys at most. These toys have the following prices:
1,12,5,10.
so this is what I wrote and it keeps giving a timeout error on 10
testcases. I can't figure out why
function maxPurchasedToys(costs, budget) {
var costsLess=[];
var removeFromArray=function(arr, value){
for(i in arr){
if(arr[i]==value){
arr.splice(i,1);
break;
}
}
return costsLess;
}
//First let's get a new array consisting only of costs that are equal
to or below the budget
costs.map(function(x){x<budget?costsLess.push(x):1;})
var sum=0;
costsLess.map(function(x){sum+=x;});//Get the sum of budget
while(sum>=budget){
var max=Math.max.apply( Math, costsLess );
costsLess=removeFromArray(costsLess,max);//Remove the biggest
element to ensure that the costs fall within budget
sum=0;
costsLess.map(function(x){sum+=x;});//Get the new sum of budget
}
return costsLess.length;
}
I tried the following cases: the original test case, [5000,2000,20,200],50
and a few more. All executed fine
Saturday, 31 August 2013
Too much function call when painting using Direct2D, not efficient?
Too much function call when painting using Direct2D, not efficient?
The following code is from a example in Microsoft SDK, compared to GDI,
much more extra calls when painting. Because the function may be called
very frequently, it is not efficient, isn't it? And hr =
CreateDeviceResources(hWnd); uses something implicit, I don't think it is
a good design, because it is not clear, I can find the render target here.
BTW, if I want to past some code, do I have to indent every line with
spaces?
LRESULT DemoApp::OnPaint(HWND hWnd)
{
HRESULT hr = S_OK;
PAINTSTRUCT ps;
if (BeginPaint(hWnd, &ps))
{
// Create render target if not yet created
hr = CreateDeviceResources(hWnd);
if (SUCCEEDED(hr) && !(m_pRT->CheckWindowState() &
D2D1_WINDOW_STATE_OCCLUDED))
{
m_pRT->BeginDraw();
m_pRT->SetTransform(D2D1::Matrix3x2F::Identity());
// Clear the background
m_pRT->Clear(D2D1::ColorF(D2D1::ColorF::White));
D2D1_SIZE_F rtSize = m_pRT->GetSize();
// Create a rectangle same size of current window
D2D1_RECT_F rectangle = D2D1::RectF(0.0f, 0.0f, rtSize.width,
rtSize.height);
// D2DBitmap may have been released due to device loss.
// If so, re-create it from the source bitmap
if (m_pConvertedSourceBitmap && !m_pD2DBitmap)
{
m_pRT->CreateBitmapFromWicBitmap(m_pConvertedSourceBitmap,
NULL, &m_pD2DBitmap);
}
// Draws an image and scales it to the current window size
if (m_pD2DBitmap)
{
m_pRT->DrawBitmap(m_pD2DBitmap, rectangle);
}
hr = m_pRT->EndDraw();
// In case of device loss, discard D2D render target and
D2DBitmap
// They will be re-create in the next rendering pass
if (hr == D2DERR_RECREATE_TARGET)
{
SafeRelease(m_pD2DBitmap);
SafeRelease(m_pRT);
// Force a re-render
hr = InvalidateRect(hWnd, NULL, TRUE)? S_OK : E_FAIL;
}
}
EndPaint(hWnd, &ps);
}
return SUCCEEDED(hr) ? 0 : 1;
}
The following code is from a example in Microsoft SDK, compared to GDI,
much more extra calls when painting. Because the function may be called
very frequently, it is not efficient, isn't it? And hr =
CreateDeviceResources(hWnd); uses something implicit, I don't think it is
a good design, because it is not clear, I can find the render target here.
BTW, if I want to past some code, do I have to indent every line with
spaces?
LRESULT DemoApp::OnPaint(HWND hWnd)
{
HRESULT hr = S_OK;
PAINTSTRUCT ps;
if (BeginPaint(hWnd, &ps))
{
// Create render target if not yet created
hr = CreateDeviceResources(hWnd);
if (SUCCEEDED(hr) && !(m_pRT->CheckWindowState() &
D2D1_WINDOW_STATE_OCCLUDED))
{
m_pRT->BeginDraw();
m_pRT->SetTransform(D2D1::Matrix3x2F::Identity());
// Clear the background
m_pRT->Clear(D2D1::ColorF(D2D1::ColorF::White));
D2D1_SIZE_F rtSize = m_pRT->GetSize();
// Create a rectangle same size of current window
D2D1_RECT_F rectangle = D2D1::RectF(0.0f, 0.0f, rtSize.width,
rtSize.height);
// D2DBitmap may have been released due to device loss.
// If so, re-create it from the source bitmap
if (m_pConvertedSourceBitmap && !m_pD2DBitmap)
{
m_pRT->CreateBitmapFromWicBitmap(m_pConvertedSourceBitmap,
NULL, &m_pD2DBitmap);
}
// Draws an image and scales it to the current window size
if (m_pD2DBitmap)
{
m_pRT->DrawBitmap(m_pD2DBitmap, rectangle);
}
hr = m_pRT->EndDraw();
// In case of device loss, discard D2D render target and
D2DBitmap
// They will be re-create in the next rendering pass
if (hr == D2DERR_RECREATE_TARGET)
{
SafeRelease(m_pD2DBitmap);
SafeRelease(m_pRT);
// Force a re-render
hr = InvalidateRect(hWnd, NULL, TRUE)? S_OK : E_FAIL;
}
}
EndPaint(hWnd, &ps);
}
return SUCCEEDED(hr) ? 0 : 1;
}
Open map location from Apple maps in my mapping app
Open map location from Apple maps in my mapping app
I'm developing an iOS mapping app. I would like to open a location from
the built-in maps app into my app. Ideally, my app would show up in the
Maps location sharing sheet along with Mail, Twitter, and Facebook. Is
this possible?
The best I've come up with is configuring my app as a routing app so that
Maps can send a routing request to my app, and using the destination as
the point being shared. There are a few problems with that, though. First,
my app doesn't do routing, so that's misleading to the user. Second, in my
opinion, there are too many steps for the user to get to the routing
options screen. Lastly, Apple might not approve an app that advertises
itself to the system as being a routing provider but doesn't actually do
any routing.
I've searched around quite a bit, but I haven't seen this question asked,
and I haven't found anything in Apple's documentation. Any suggestions?
I'm developing an iOS mapping app. I would like to open a location from
the built-in maps app into my app. Ideally, my app would show up in the
Maps location sharing sheet along with Mail, Twitter, and Facebook. Is
this possible?
The best I've come up with is configuring my app as a routing app so that
Maps can send a routing request to my app, and using the destination as
the point being shared. There are a few problems with that, though. First,
my app doesn't do routing, so that's misleading to the user. Second, in my
opinion, there are too many steps for the user to get to the routing
options screen. Lastly, Apple might not approve an app that advertises
itself to the system as being a routing provider but doesn't actually do
any routing.
I've searched around quite a bit, but I haven't seen this question asked,
and I haven't found anything in Apple's documentation. Any suggestions?
Audio assets in Rails brings No route matches
Audio assets in Rails brings No route matches
I'm trying to use an audio file in rails. I created a folder audios under
app\assets\. I would like to use the assets precompile so I don't want to
put the file under folder app\public
Right now I'm getting
ActionController::RoutingError (No route matches [GET]
"/audios/audio_file.wav")
If I change the url from URL/audios/audio_file.wav to
URL/assets/audio_file.wav it works. How can i fix the problem? What is the
right way?
I'm trying to use an audio file in rails. I created a folder audios under
app\assets\. I would like to use the assets precompile so I don't want to
put the file under folder app\public
Right now I'm getting
ActionController::RoutingError (No route matches [GET]
"/audios/audio_file.wav")
If I change the url from URL/audios/audio_file.wav to
URL/assets/audio_file.wav it works. How can i fix the problem? What is the
right way?
Class to minimize all forms
Class to minimize all forms
How I will Convert this into class which minimize all the childform? When
I try to transfer it into class I got error :
The type or namespace name 'MdiChildren' could not be found (are you
missing a using directive or an assembly reference?)
public void minimizeAll()
{
foreach (Form childForm in MdiChildren)
{
childForm.WindowState = FormWindowState.Minimized;
}
}
How I will Convert this into class which minimize all the childform? When
I try to transfer it into class I got error :
The type or namespace name 'MdiChildren' could not be found (are you
missing a using directive or an assembly reference?)
public void minimizeAll()
{
foreach (Form childForm in MdiChildren)
{
childForm.WindowState = FormWindowState.Minimized;
}
}
Begin search on first keypress in jQuery Chosen
Begin search on first keypress in jQuery Chosen
I am using jQuery chosen as an alternative to normal html 'select'. I went
through its documentation and also its source files but couldn't achieve
what I wanted.
My database is very large(50K entries). I populate the select tab with
this data. When I click on this select it takes ages to drop down.
Here is the demo of my project.
Can I achieve the following in chosen.
-When I click select tag It should not show all the data initially.
-When I enter at least one charachter, results should get displayed.
If its not possible, is there an alternative to chosen which would solve
the issue? Thanks.
I am using jQuery chosen as an alternative to normal html 'select'. I went
through its documentation and also its source files but couldn't achieve
what I wanted.
My database is very large(50K entries). I populate the select tab with
this data. When I click on this select it takes ages to drop down.
Here is the demo of my project.
Can I achieve the following in chosen.
-When I click select tag It should not show all the data initially.
-When I enter at least one charachter, results should get displayed.
If its not possible, is there an alternative to chosen which would solve
the issue? Thanks.
#EANF#
#EANF#
this is my variable in setings.php
$error = output_errors($errors);
i want to echo out in my jQuery file 'settings.js'
$('#save_settings').click(function(){
var first_name = $('#first_name').val();
var last_name = $('#last_name').val();
var email = $('#email').val();
$.post('settings.php', { first_name: first_name, last_name: last_name,
email: email});
alert(error);
$('#show').html('settings
saved').fadeIn(500).delay(2000).fadeOut(500);
});
this is my variable in setings.php
$error = output_errors($errors);
i want to echo out in my jQuery file 'settings.js'
$('#save_settings').click(function(){
var first_name = $('#first_name').val();
var last_name = $('#last_name').val();
var email = $('#email').val();
$.post('settings.php', { first_name: first_name, last_name: last_name,
email: email});
alert(error);
$('#show').html('settings
saved').fadeIn(500).delay(2000).fadeOut(500);
});
cant get backgoundworker to work
cant get backgoundworker to work
as i said in the question i cant get background worker to work this is my
first time using it so i dont know if i have done something wrong heres my
code
int cardcount = 0;
string lev = "";
string att = "";
string atk = "";
string def = "";
string ctp = "";
string id = "";
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
if (folderBrowserDialog1.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
{
string folder = folderBrowserDialog1.SelectedPath;
DirectoryInfo dinfo = new
DirectoryInfo(folderBrowserDialog1.SelectedPath);
FileInfo[] Files = dinfo.GetFiles("*.jpg");
int count = Files.Length;
int current = 0;
foreach (FileInfo file in Files)
{
string path = Path.GetFileNameWithoutExtension(file.Name);
int cardid = Convert.ToInt32(path);
if (Program.CardData.ContainsKey(cardid))
{
DevPro_CardManager.cardmaker.IMG =
LoadBitmap(folderBrowserDialog1.SelectedPath + "//" +
file.Name);
id = Program.CardData[cardid].Id.ToString();
lev = Program.CardData[cardid].Level.ToString();
att = Program.CardData[cardid].Attribute.ToString();
if (att == "1")
{
att = "earth";
}
else if (att == "2")
{
att = "water";
}
else if (att == "4")
{
att = "fire";
}
else if (att == "8")
{
att = "wind";
}
else if (att == "16")
{
att = "light";
}
else if (att == "32")
{
att = "dark";
}
else if (att == "64")
{
att = "divine";
}
if (Program.CardData[cardid].Atk.ToString() == "-2")
{
atk = "????";
}
else
{
atk = Program.CardData[cardid].Atk.ToString();
}
if (Program.CardData[cardid].Def.ToString() == "-2")
{
def = "????";
}
else
{
def = Program.CardData[cardid].Def.ToString();
}
ctp = Program.CardData[cardid].Type.ToString();
if (ctp == "2" || ctp == "130" || ctp == "65538" ||
ctp == "131074" || ctp == "262146" || ctp == "524290")
{
ctp = "spell";
}
else if (ctp == "4" || ctp == "1048580" || ctp ==
"131076")
{
ctp = "trap";
}
else if (ctp == "129" || ctp == "161")
{
ctp = "ritual";
}
else if (ctp == "65" || ctp == "97")
{
ctp = "fusion";
}
else if (ctp == "8193" || ctp == "8225" || ctp ==
"12321")
{
ctp = "synchro";
}
else if (ctp == "8388609" || ctp == "8388641")
{
ctp = "xyz";
}
else if (ctp == "33" || ctp == "545" || ctp == "1057"
|| ctp == "2081" || ctp == "4129" || ctp == "4194337")
{
ctp = "effect";
}
else if (ctp == "17" || ctp == "4113")
{
ctp = "normal";
}
else if (ctp == "16401")
{
ctp = "token";
}
cardcount = cardcount + 1;
backgroundWorker1.ReportProgress((current * 100) /
count);
}
}
}
}
void backgroundWorker1_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
// The progress percentage is a property of e
progressBar1.Value = e.ProgressPercentage;
label8.Text = cardcount.ToString();
comboBox2.SelectedItem = lev;
comboBox1.SelectedItem = att;
textBox2.Text = atk;
textBox1.Text = def;
comboBox3.SelectedItem = ctp;
GenerateCard();
ImageResizer.CropImage(361, 523, pictureBox1.Image, @"anime
cards\" + Path.GetFileName(id));
}
and the code for the button that launches it
private void button5_Click(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
please help or say if im doing something wrong thanks
as i said in the question i cant get background worker to work this is my
first time using it so i dont know if i have done something wrong heres my
code
int cardcount = 0;
string lev = "";
string att = "";
string atk = "";
string def = "";
string ctp = "";
string id = "";
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
if (folderBrowserDialog1.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
{
string folder = folderBrowserDialog1.SelectedPath;
DirectoryInfo dinfo = new
DirectoryInfo(folderBrowserDialog1.SelectedPath);
FileInfo[] Files = dinfo.GetFiles("*.jpg");
int count = Files.Length;
int current = 0;
foreach (FileInfo file in Files)
{
string path = Path.GetFileNameWithoutExtension(file.Name);
int cardid = Convert.ToInt32(path);
if (Program.CardData.ContainsKey(cardid))
{
DevPro_CardManager.cardmaker.IMG =
LoadBitmap(folderBrowserDialog1.SelectedPath + "//" +
file.Name);
id = Program.CardData[cardid].Id.ToString();
lev = Program.CardData[cardid].Level.ToString();
att = Program.CardData[cardid].Attribute.ToString();
if (att == "1")
{
att = "earth";
}
else if (att == "2")
{
att = "water";
}
else if (att == "4")
{
att = "fire";
}
else if (att == "8")
{
att = "wind";
}
else if (att == "16")
{
att = "light";
}
else if (att == "32")
{
att = "dark";
}
else if (att == "64")
{
att = "divine";
}
if (Program.CardData[cardid].Atk.ToString() == "-2")
{
atk = "????";
}
else
{
atk = Program.CardData[cardid].Atk.ToString();
}
if (Program.CardData[cardid].Def.ToString() == "-2")
{
def = "????";
}
else
{
def = Program.CardData[cardid].Def.ToString();
}
ctp = Program.CardData[cardid].Type.ToString();
if (ctp == "2" || ctp == "130" || ctp == "65538" ||
ctp == "131074" || ctp == "262146" || ctp == "524290")
{
ctp = "spell";
}
else if (ctp == "4" || ctp == "1048580" || ctp ==
"131076")
{
ctp = "trap";
}
else if (ctp == "129" || ctp == "161")
{
ctp = "ritual";
}
else if (ctp == "65" || ctp == "97")
{
ctp = "fusion";
}
else if (ctp == "8193" || ctp == "8225" || ctp ==
"12321")
{
ctp = "synchro";
}
else if (ctp == "8388609" || ctp == "8388641")
{
ctp = "xyz";
}
else if (ctp == "33" || ctp == "545" || ctp == "1057"
|| ctp == "2081" || ctp == "4129" || ctp == "4194337")
{
ctp = "effect";
}
else if (ctp == "17" || ctp == "4113")
{
ctp = "normal";
}
else if (ctp == "16401")
{
ctp = "token";
}
cardcount = cardcount + 1;
backgroundWorker1.ReportProgress((current * 100) /
count);
}
}
}
}
void backgroundWorker1_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
// The progress percentage is a property of e
progressBar1.Value = e.ProgressPercentage;
label8.Text = cardcount.ToString();
comboBox2.SelectedItem = lev;
comboBox1.SelectedItem = att;
textBox2.Text = atk;
textBox1.Text = def;
comboBox3.SelectedItem = ctp;
GenerateCard();
ImageResizer.CropImage(361, 523, pictureBox1.Image, @"anime
cards\" + Path.GetFileName(id));
}
and the code for the button that launches it
private void button5_Click(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
please help or say if im doing something wrong thanks
Friday, 30 August 2013
How to write a file inside Isolated Storage in C?
How to write a file inside Isolated Storage in C?
Let's say I open a file for writing in C.
fopen_s(&myFilePointer, "filename.bin", "wb");
If I debug my Windows Phone application from the Windows Phone Runtime
Component side, I see that there's a file somewhere that is written. At
least, there is no crash when writing.
But strangely, if I open a tool like IsoStoreSpy, I don't see any new file
in the application root folder. Does that means my created file doesn't
exist?
Should I specify a special directory when I want to write to the Isolated
Storage?
[Edit]
I'm also opening a file for reading the same way (no directory, no
isolated storage specific operation), and it works, no matter if I add it
as a resource or as a content. Then when the file is converted with a
codec to a destination, I can't see that file when exploring the phone.
Let's say I open a file for writing in C.
fopen_s(&myFilePointer, "filename.bin", "wb");
If I debug my Windows Phone application from the Windows Phone Runtime
Component side, I see that there's a file somewhere that is written. At
least, there is no crash when writing.
But strangely, if I open a tool like IsoStoreSpy, I don't see any new file
in the application root folder. Does that means my created file doesn't
exist?
Should I specify a special directory when I want to write to the Isolated
Storage?
[Edit]
I'm also opening a file for reading the same way (no directory, no
isolated storage specific operation), and it works, no matter if I add it
as a resource or as a content. Then when the file is converted with a
codec to a destination, I can't see that file when exploring the phone.
Thursday, 29 August 2013
How can I get which 'IF' condition makes loop true with OR & AND?
How can I get which 'IF' condition makes loop true with OR & AND?
assume if i have code like:
if(condition1 || condition2 || condition 3 || condition4)
{
// this inner part will executed if one of the condition true. Now I want
to know by which condition this part is executed.
}
else
{
}
assume if i have code like:
if(condition1 || condition2 || condition 3 || condition4)
{
// this inner part will executed if one of the condition true. Now I want
to know by which condition this part is executed.
}
else
{
}
Wednesday, 28 August 2013
Sanitize cell values with SuperCSV
Sanitize cell values with SuperCSV
What is the best way to sanitize fields from a csv in supercsv? For
example the First_Name column: trim the field, capitalize the first
letter, remove various characters (quotes, commas, asterisks etc). Is it
to write a custom CellProcessor like FmtName()? Maybe another one for
FmtEmail() that lowercases everything, removes certain invalid characters?
What is the best way to sanitize fields from a csv in supercsv? For
example the First_Name column: trim the field, capitalize the first
letter, remove various characters (quotes, commas, asterisks etc). Is it
to write a custom CellProcessor like FmtName()? Maybe another one for
FmtEmail() that lowercases everything, removes certain invalid characters?
image to grow outside Javafx gridpane cell
image to grow outside Javafx gridpane cell
I would like to add an image to javafx2 gridpane as per code below,
however I would like this image to not be restricted inside its cell. I
would like the image to basically flow outside the cell.
GridPane moon_pane = new GridPane();
moon_pane.setId("prayertime_pane");
moon_pane.setGridLinesVisible(true);
moon_pane.setPadding(new Insets(10, 10, 10, 10));
moon_pane.setAlignment(Pos.BASELINE_CENTER);
moon_pane.setVgap(10);
moon_pane.setHgap(10);
Text moon_phase_text = new Text("60% full");
moon_phase_text.setId("prayer-text-english");
moon_pane.setHalignment(moon_phase_text,HPos.LEFT);
moon_pane.setValignment(moon_phase_text,VPos.CENTER);
moon_pane.setConstraints(moon_phase_text, 0, 0);
moon_pane.getChildren().add(moon_phase_text);
ImageView Moon_img = new ImageView(new
Image(getClass().getResourceAsStream("/Images/Full_Moon.png")));
// moon_pane.setHalignment(Moon_img,HPos.CENTER);
// moon_pane.setValignment(Moon_img,VPos.CENTER);
Moon_img.setFitWidth(100);
Moon_img.setFitHeight(100);
moon_pane.add(Moon_img, 1, 0);
Text next_moon_text = new Text("13/02");
next_moon_text.setId("prayer-text-english");
moon_pane.setHalignment(next_moon_text,HPos.LEFT);
moon_pane.setValignment(next_moon_text,VPos.CENTER);
moon_pane.setConstraints(next_moon_text, 2, 0);
moon_pane.getChildren().add(next_moon_text);
I would like to add an image to javafx2 gridpane as per code below,
however I would like this image to not be restricted inside its cell. I
would like the image to basically flow outside the cell.
GridPane moon_pane = new GridPane();
moon_pane.setId("prayertime_pane");
moon_pane.setGridLinesVisible(true);
moon_pane.setPadding(new Insets(10, 10, 10, 10));
moon_pane.setAlignment(Pos.BASELINE_CENTER);
moon_pane.setVgap(10);
moon_pane.setHgap(10);
Text moon_phase_text = new Text("60% full");
moon_phase_text.setId("prayer-text-english");
moon_pane.setHalignment(moon_phase_text,HPos.LEFT);
moon_pane.setValignment(moon_phase_text,VPos.CENTER);
moon_pane.setConstraints(moon_phase_text, 0, 0);
moon_pane.getChildren().add(moon_phase_text);
ImageView Moon_img = new ImageView(new
Image(getClass().getResourceAsStream("/Images/Full_Moon.png")));
// moon_pane.setHalignment(Moon_img,HPos.CENTER);
// moon_pane.setValignment(Moon_img,VPos.CENTER);
Moon_img.setFitWidth(100);
Moon_img.setFitHeight(100);
moon_pane.add(Moon_img, 1, 0);
Text next_moon_text = new Text("13/02");
next_moon_text.setId("prayer-text-english");
moon_pane.setHalignment(next_moon_text,HPos.LEFT);
moon_pane.setValignment(next_moon_text,VPos.CENTER);
moon_pane.setConstraints(next_moon_text, 2, 0);
moon_pane.getChildren().add(next_moon_text);
Tuesday, 27 August 2013
.Execute not available on a type safe Entity Framework query (Include & where)
.Execute not available on a type safe Entity Framework query (Include &
where)
I have a question regarding entity framework queries.
I have a query which is using the Extension methods provided by EF, so i
can use type safe includes and where clause. But as the Include is with a
lambda parameter it is an extension method on IQueryable that returns an
IQueryable in order to chain methods like Where. Include with a string
parameter is a method on ObjectQuery that returns an ObjectQuery. Execute
is a method on ObjectQuery, not IQueryable so it is not available when you
use IQueryable methods.
Is there a way to call .Execute but with IQueryable?
return
this.Storage.Customer.OfType<Preferred>()
.Include(b => b.Order)
.Where(cust => cust.Id == customerId && cust.CustomerType== (int)cusType)
.SingleOrDefault();
Thanks,
where)
I have a question regarding entity framework queries.
I have a query which is using the Extension methods provided by EF, so i
can use type safe includes and where clause. But as the Include is with a
lambda parameter it is an extension method on IQueryable that returns an
IQueryable in order to chain methods like Where. Include with a string
parameter is a method on ObjectQuery that returns an ObjectQuery. Execute
is a method on ObjectQuery, not IQueryable so it is not available when you
use IQueryable methods.
Is there a way to call .Execute but with IQueryable?
return
this.Storage.Customer.OfType<Preferred>()
.Include(b => b.Order)
.Where(cust => cust.Id == customerId && cust.CustomerType== (int)cusType)
.SingleOrDefault();
Thanks,
async each series does not return as expected
async each series does not return as expected
Im using async library, specifically the each method, but Im not getting
the expected result.
function instanceMethod (final_callback) {
obj = this;
async.parallel([
function (callback) {
getTopReplies (obj, function (err, result){
if (err) return callback(err);
if (result) {
obj.topReplies = result;
callback();
}
});
}, function (err){
if (err) return final_callback(err, false);
return final_callback (false, true);
});
This is the function Im calling from an async.parallel list of functions
function getTopReplies (obj, callback) {
mongoose.model('Post').find({replyTo: obj._id, draft: false})
.limit(3).sort('-createdAt')
.exec(function(err, tops){
if (err) return callback(err);
var result = [];
if (tops) {
async.eachSeries(tops, function(top, callback) {
result.push(top._id);
callback();
}, function (err){
if (err) return callback(err);
return callback(null, result);
});
}
});
}
theres a case where result should return two top posts id in the array but
it always returns 1 or if theres only 1 top reply to a post it returns
empty.
Is there anything wrong on my code?
Is the result array to be initiated somewhere else, like is it getting
reinitiated everytime, the each function is called or something?
Thank you!
Im using async library, specifically the each method, but Im not getting
the expected result.
function instanceMethod (final_callback) {
obj = this;
async.parallel([
function (callback) {
getTopReplies (obj, function (err, result){
if (err) return callback(err);
if (result) {
obj.topReplies = result;
callback();
}
});
}, function (err){
if (err) return final_callback(err, false);
return final_callback (false, true);
});
This is the function Im calling from an async.parallel list of functions
function getTopReplies (obj, callback) {
mongoose.model('Post').find({replyTo: obj._id, draft: false})
.limit(3).sort('-createdAt')
.exec(function(err, tops){
if (err) return callback(err);
var result = [];
if (tops) {
async.eachSeries(tops, function(top, callback) {
result.push(top._id);
callback();
}, function (err){
if (err) return callback(err);
return callback(null, result);
});
}
});
}
theres a case where result should return two top posts id in the array but
it always returns 1 or if theres only 1 top reply to a post it returns
empty.
Is there anything wrong on my code?
Is the result array to be initiated somewhere else, like is it getting
reinitiated everytime, the each function is called or something?
Thank you!
Mongoid parsing and storing a date
Mongoid parsing and storing a date
I am receiving dates from a web form that come in format of "Thursday,
November 8th 8:20 p.m. (et)". I want to ensure that I store this in
MongoDB (I'm using Mongoid as my client driver) in an appropriate DateTime
field. Using Ruby or any available type library, what's the best way to
ensure when I'm parsing this date time that I store it in a way that won't
break the DateTime field Mongoid/MongoDB support?
I am receiving dates from a web form that come in format of "Thursday,
November 8th 8:20 p.m. (et)". I want to ensure that I store this in
MongoDB (I'm using Mongoid as my client driver) in an appropriate DateTime
field. Using Ruby or any available type library, what's the best way to
ensure when I'm parsing this date time that I store it in a way that won't
break the DateTime field Mongoid/MongoDB support?
Fixed 8 columns to 100% width in html table
Fixed 8 columns to 100% width in html table
I know this a simple question but still I'm a little bit confuse. This is
regarding my html table, i want to make my column 1 to column 8 (..) to be
fixed only to 100% width or 100% html width view, and the rest of the
column from column 9 and so forth, which is generated dynamically to be
scrollable horizontally. For example if i have 9 column table, when i load
my page the column 1 to column 8 would be visible and the 9th column can
only be seen when i scroll horizontally.
i already use tale-layout:fixed; but still it doesn't fit the column 1 to
column 8 100% of my page. If there were 10 column, its seems ok but if
there's alot of column like 15 thats the time my column 1 to column 8 to
become shrink and doesnt follow anymore my css width value.
any advice?
I know this a simple question but still I'm a little bit confuse. This is
regarding my html table, i want to make my column 1 to column 8 (..) to be
fixed only to 100% width or 100% html width view, and the rest of the
column from column 9 and so forth, which is generated dynamically to be
scrollable horizontally. For example if i have 9 column table, when i load
my page the column 1 to column 8 would be visible and the 9th column can
only be seen when i scroll horizontally.
i already use tale-layout:fixed; but still it doesn't fit the column 1 to
column 8 100% of my page. If there were 10 column, its seems ok but if
there's alot of column like 15 thats the time my column 1 to column 8 to
become shrink and doesnt follow anymore my css width value.
any advice?
How to determine in ASP.NET C# that a request is coming from a PC or a mobile device
Smooth font in debian wheezy last cersion
Smooth font in debian wheezy last cersion
I just put under debian wheezy but I noticed that the fonts are not smooth
like on Ubuntu, my question: how to make font smooth and pretty as on
Ubuntu 12.04? Thank You
I just put under debian wheezy but I noticed that the fonts are not smooth
like on Ubuntu, my question: how to make font smooth and pretty as on
Ubuntu 12.04? Thank You
Monday, 26 August 2013
How many icons i can place in iphone tool bar? is there any limit?
How many icons i can place in iphone tool bar? is there any limit?
How many icons i can place in iphone tool bar? is there any limit? Can we
add more than 5 like 6 or 7
How many icons i can place in iphone tool bar? is there any limit? Can we
add more than 5 like 6 or 7
AS3 air app on ios image orientation wrong after saving to server
AS3 air app on ios image orientation wrong after saving to server
I have an app that is built in AS3/Air for iOS devices. In the app I allow
users to select images from the camera roll using the code from here
http://www.adobe.com/devnet/air/articles/uploading-images-media-promise.html
however with some images, when they are uploaded they are rotated
incorrectly.
I have read there are some EXIF data but I have no idea how to get this or
if this is the right data to get to set orientation.
Any help is appreciated.
I have an app that is built in AS3/Air for iOS devices. In the app I allow
users to select images from the camera roll using the code from here
http://www.adobe.com/devnet/air/articles/uploading-images-media-promise.html
however with some images, when they are uploaded they are rotated
incorrectly.
I have read there are some EXIF data but I have no idea how to get this or
if this is the right data to get to set orientation.
Any help is appreciated.
can I get log into an iPad without using security code?
can I get log into an iPad without using security code?
I would like to know if there is a way to use someone's iPad without
having to type in the security code.
I would like to know if there is a way to use someone's iPad without
having to type in the security code.
How do I authenticate with the Play Purchase Status API using OAuth 2.0?
How do I authenticate with the Play Purchase Status API using OAuth 2.0?
I am using the Play Purchase Status API to help reconcile expiration of
in-app subscriptions. Specifically I am trying to match the
"validUntilTimestampMsec" up against recorded statuses that are managed
via IAB notifications. I am following the Authorization instructions here:
https://developers.google.com/android-publisher/authorization, but I am
wondering how to use the access and refresh tokens. After you get an
access and refresh token pair that looks like this:
{
"access_token" : "ya29.ZStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "1/zaaHNytlC3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho"
}
It shows how to access.
Once you have an access token, you can make calls to the API by appending
the token as a query parameter:
https://www.googleapis.com/androidpublisher/v1/...?access_token=...
I believe Play Purchase Status API needs to have v1.1 instead of v1, and
the rest of the first ellipsis is specific to what you are doing. The
second ellipsis setting the access_token is unclear to me whether it
should be the JSON containing the access/refresh pair or simply the access
token attribute of that JSON object. I am also curious as to whether this
pair stays persistent. On my back-end I want to pass a request to check a
subscription status. My PHP code simply builds the URL for the GET
request, and I attempt to use file_get_contents( $reqUrl ) where $reqUrl
is the url.
If I add the access_token URL parameter to the end of my URL query string,
should that work indefinitely, or should my code be generating new access
and refresh tokens each time it is about to call the API? Help in
answering these questions is much appreciated!
I am using the Play Purchase Status API to help reconcile expiration of
in-app subscriptions. Specifically I am trying to match the
"validUntilTimestampMsec" up against recorded statuses that are managed
via IAB notifications. I am following the Authorization instructions here:
https://developers.google.com/android-publisher/authorization, but I am
wondering how to use the access and refresh tokens. After you get an
access and refresh token pair that looks like this:
{
"access_token" : "ya29.ZStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "1/zaaHNytlC3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho"
}
It shows how to access.
Once you have an access token, you can make calls to the API by appending
the token as a query parameter:
https://www.googleapis.com/androidpublisher/v1/...?access_token=...
I believe Play Purchase Status API needs to have v1.1 instead of v1, and
the rest of the first ellipsis is specific to what you are doing. The
second ellipsis setting the access_token is unclear to me whether it
should be the JSON containing the access/refresh pair or simply the access
token attribute of that JSON object. I am also curious as to whether this
pair stays persistent. On my back-end I want to pass a request to check a
subscription status. My PHP code simply builds the URL for the GET
request, and I attempt to use file_get_contents( $reqUrl ) where $reqUrl
is the url.
If I add the access_token URL parameter to the end of my URL query string,
should that work indefinitely, or should my code be generating new access
and refresh tokens each time it is about to call the API? Help in
answering these questions is much appreciated!
Use personal SSL Certificate created on my own?
Use personal SSL Certificate created on my own?
I'm new to SSL Certificates. I've seen some tutorials about creating
personal certificates but I didn't go far reading.
It seems that I can create a personal SSL Certificate and use it on my
website, but the question is:
Will it do its job nicely?
Will the connection with my customers will be encrypted?
Is it possible to create a personal SSL Extended Validation certificate on
my own, or do I need a certificate authority?
My point is I don't need insurance; I just want to add another layer of
protection and safety for my customers. They wont actually buy on my page,
but from paypal, but a SSL certtificate will increase they trust to the
site. I don't care if some company will take responsibility and appear on
my certificate info.
I'm new to SSL Certificates. I've seen some tutorials about creating
personal certificates but I didn't go far reading.
It seems that I can create a personal SSL Certificate and use it on my
website, but the question is:
Will it do its job nicely?
Will the connection with my customers will be encrypted?
Is it possible to create a personal SSL Extended Validation certificate on
my own, or do I need a certificate authority?
My point is I don't need insurance; I just want to add another layer of
protection and safety for my customers. They wont actually buy on my page,
but from paypal, but a SSL certtificate will increase they trust to the
site. I don't care if some company will take responsibility and appear on
my certificate info.
Deleting GDI objects does not decrease their number
Deleting GDI objects does not decrease their number
When I look in the Task Manager on the number of GDI objects for my
process, then I see that not every call of function DeleteObject() for a
GDI object causes decrementing this number, and the function call does not
return FALSE (as it should if the object deletion was unsuccessful). I'm
using plain Windows API GDI functions without additional libraries and
wrappers such as MFC. Why such situation can happen and does it mean GDI
resource leakage?
When I look in the Task Manager on the number of GDI objects for my
process, then I see that not every call of function DeleteObject() for a
GDI object causes decrementing this number, and the function call does not
return FALSE (as it should if the object deletion was unsuccessful). I'm
using plain Windows API GDI functions without additional libraries and
wrappers such as MFC. Why such situation can happen and does it mean GDI
resource leakage?
R: creating a new column filled with random numbers
R: creating a new column filled with random numbers
Sorry for this simple question, I haven't found a fitting solution for
this in my search. I'd like to create a new column in my data frame and
fill it with random numbers between 1 to 100 (can repeat).
Below is the code I'm currently using,
data$newrow <- rep(1:100,replace=T, nrow(data))
I receive this error:
Error in$<-.data.frame(tmp, "newrow", value = c(1L, 2L, : replacement has
2088800 rows, data has 20888
Can you help me fix my code?
Sorry for this simple question, I haven't found a fitting solution for
this in my search. I'd like to create a new column in my data frame and
fill it with random numbers between 1 to 100 (can repeat).
Below is the code I'm currently using,
data$newrow <- rep(1:100,replace=T, nrow(data))
I receive this error:
Error in$<-.data.frame(tmp, "newrow", value = c(1L, 2L, : replacement has
2088800 rows, data has 20888
Can you help me fix my code?
API call not working on Linux
API call not working on Linux
I am trying to call a different server API using HTTPClient. I am
successfully able to call the API on my localbox, but when I call this API
from linux box, it is giving "java.net.ConnectException: Connection timed
out"
String searchBase = "http://username:password@dev.xxxx.xo/api/aaa;
HttpClient client = new HttpClient();
client.getParams().setAuthenticationPreemptive(true);
Credentials credentials = new UsernamePasswordCredentials("username",
"pass");
client.getState().setCredentials(AuthScope.ANY, credentials);
PostMethod post = new PostMethod(searchBase);
post.setRequestEntity(new StringRequestEntity(object.toString(),
"application/json", "UTF-8"));
Please Help me.
I am trying to call a different server API using HTTPClient. I am
successfully able to call the API on my localbox, but when I call this API
from linux box, it is giving "java.net.ConnectException: Connection timed
out"
String searchBase = "http://username:password@dev.xxxx.xo/api/aaa;
HttpClient client = new HttpClient();
client.getParams().setAuthenticationPreemptive(true);
Credentials credentials = new UsernamePasswordCredentials("username",
"pass");
client.getState().setCredentials(AuthScope.ANY, credentials);
PostMethod post = new PostMethod(searchBase);
post.setRequestEntity(new StringRequestEntity(object.toString(),
"application/json", "UTF-8"));
Please Help me.
show text in select box in jquery
show text in select box in jquery
I have a select box and according the selected value I want to show the
value in next selected box. My code is like:
$('#category').change(function(){
var cat_val = $('#category option:selected').text();
if(cat_val == 'Online'){
$('#workshop-row').hide();
$('#bu_id').val(22);
}else{
$('#workshop-row').show();
}
});
By doing $('#bu_id').val(22); I can get the value. But I need to set the
text not val() like
$('#bu_id option:selected').text("Online");
That means if I select Online from the first select box then in the 2nd
select box, the value whose text is Online will be selected.
Please guide me. Thanks in advance.
I have a select box and according the selected value I want to show the
value in next selected box. My code is like:
$('#category').change(function(){
var cat_val = $('#category option:selected').text();
if(cat_val == 'Online'){
$('#workshop-row').hide();
$('#bu_id').val(22);
}else{
$('#workshop-row').show();
}
});
By doing $('#bu_id').val(22); I can get the value. But I need to set the
text not val() like
$('#bu_id option:selected').text("Online");
That means if I select Online from the first select box then in the 2nd
select box, the value whose text is Online will be selected.
Please guide me. Thanks in advance.
Sunday, 25 August 2013
How to convert numbers into strings in python? 1 -> 'one'
How to convert numbers into strings in python? 1 -> 'one'
If i want a program where I let the user input a number (e.g. 1, 13, 4354)
how can i get it to print (one, thirteen, four three five four) does that
make sense? if it's two digit, print it as though it's joined (thirty-one)
but if it's more than 2 just print them sepretly, one the same line joined
with a space, I tried to do this with a dictionary, and I think it's
possible, but i can't figure out how to do it?
l = input('Enter the number: ')
if len(l) > 2:
nums = {'1':'one',
'2':'two',
'3':'three',
'4':'four',
'5':'five',
'6':'six',
'7':'seven',
'8':'eight',
'9':'nine'}
elif len(l) == 2:
tens = {'1}'how
for k, v in nums.items():
print(k, v)
This is obviously a wrong code, but I would like the finished result to
look something like this? thanks in advance!
If i want a program where I let the user input a number (e.g. 1, 13, 4354)
how can i get it to print (one, thirteen, four three five four) does that
make sense? if it's two digit, print it as though it's joined (thirty-one)
but if it's more than 2 just print them sepretly, one the same line joined
with a space, I tried to do this with a dictionary, and I think it's
possible, but i can't figure out how to do it?
l = input('Enter the number: ')
if len(l) > 2:
nums = {'1':'one',
'2':'two',
'3':'three',
'4':'four',
'5':'five',
'6':'six',
'7':'seven',
'8':'eight',
'9':'nine'}
elif len(l) == 2:
tens = {'1}'how
for k, v in nums.items():
print(k, v)
This is obviously a wrong code, but I would like the finished result to
look something like this? thanks in advance!
UnsatisfiedLinkError Libgdx Desktop (NOT MOBILE!)
UnsatisfiedLinkError Libgdx Desktop (NOT MOBILE!)
I am running into issues with LibGDX on Desktop. I keep getting the
following error when trying to launch the application:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer(I)Ljava/nio/ByteBuffer;
at com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer(Native Method)
at
com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(BufferUtils.java:288)
at com.badlogic.gdx.graphics.glutils.VertexArray.<init>(VertexArray.java:62)
at com.badlogic.gdx.graphics.glutils.VertexArray.<init>(VertexArray.java:53)
at com.badlogic.gdx.graphics.Mesh.<init>(Mesh.java:148)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:173)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:142)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:121)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:115)
I have the following libraries added to my project: gdx.jar
gdx-sources.jar gdx-natives.jar gdx-backend-lwjgl.jar
gdx-backend-lwjgl-natives.jar
Am I missing something?
I have searched high and low, but everything I find is for Android and
tells me to add the .so libs from the arm folders to my project, but that
doesn't make sense to me for a desktop project on wintel platform.
I am running into issues with LibGDX on Desktop. I keep getting the
following error when trying to launch the application:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer(I)Ljava/nio/ByteBuffer;
at com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer(Native Method)
at
com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(BufferUtils.java:288)
at com.badlogic.gdx.graphics.glutils.VertexArray.<init>(VertexArray.java:62)
at com.badlogic.gdx.graphics.glutils.VertexArray.<init>(VertexArray.java:53)
at com.badlogic.gdx.graphics.Mesh.<init>(Mesh.java:148)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:173)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:142)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:121)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:115)
I have the following libraries added to my project: gdx.jar
gdx-sources.jar gdx-natives.jar gdx-backend-lwjgl.jar
gdx-backend-lwjgl-natives.jar
Am I missing something?
I have searched high and low, but everything I find is for Android and
tells me to add the .so libs from the arm folders to my project, but that
doesn't make sense to me for a desktop project on wintel platform.
Why Can't I create an instance of a C++ class defined in the same namespace as the class definition?
Why Can't I create an instance of a C++ class defined in the same
namespace as the class definition?
A friend of mine is working on learning C++ and I was helping him along.
We are both using Visual studio 2010.
the following code gives an error:
#include <iostream>
using namespace std;
namespace Characters
{
class PlayerStats
{
public:
int HPMax, HPCurrent;
};
PlayerStats John;
John.HPMax = 1;
Characters::John.HPMax = 1;
}
the line "PlayerStats John;" seems to resolve just fine, however the lines
after ( "John.HPMax = 1;", and "Characters::John.HPMax = 1;") give the
error "Error: this declaration has no storage class or type specifier" is
it illegal to set the member variables inside the namespace in this manner
or is there something else that I am missing?
namespace as the class definition?
A friend of mine is working on learning C++ and I was helping him along.
We are both using Visual studio 2010.
the following code gives an error:
#include <iostream>
using namespace std;
namespace Characters
{
class PlayerStats
{
public:
int HPMax, HPCurrent;
};
PlayerStats John;
John.HPMax = 1;
Characters::John.HPMax = 1;
}
the line "PlayerStats John;" seems to resolve just fine, however the lines
after ( "John.HPMax = 1;", and "Characters::John.HPMax = 1;") give the
error "Error: this declaration has no storage class or type specifier" is
it illegal to set the member variables inside the namespace in this manner
or is there something else that I am missing?
Can't fix the undefined index error
Can't fix the undefined index error
I have been surfing for a solution to this problem for awhile now and most
of what I find is that people who aren't checking to see the the $_GET
variable is set are the ones having this error. However, I do check if
they are set yet I still come up with this error. Here is my code:
$customer_id = $_GET['customer_id'];
$actual_customer_id = $_GET['actual_customer_id'];
if (isset($_GET['customer_id'])&& $_GET['actual_customer_id'])
{
$query = "SELECT rewards_points.points,customers.id AS customerID,
customers.email
FROM rewards_points,customers WHERE rewards_points.customer_id=
$customers_id AND
$actual_customer_id = rewards_points.actual_customer_id";
}
$query = "SELECT rewards_points.points,customers.id AS customerID,
customers.email
FROM rewards_points,customers";
And the error is:
Notice: Undefined index: customer_id in
/Applications/MAMP/htdocs/insertintotestt.php on line 14
Notice: Undefined index: actual_customer_id in
/Applications/MAMP/htdocs/insertintotestt.php on line 15
[{"points":"20","customerID":"1","email":"someEmail@gmail.com
{"points":"20","customerID":"2","email":"otherEmail@gmail.com"},
{"points":"10","customerID":"1","email":"aha238@gmail.com"},
{"points":"10","customerID":"2","email":"spgiegg@gmail.com"},
{"points":"15","customerID":"1","email":"aha238@gmail.com"},
{"points":"15","customerID":"2","email":"spgiegg@gmail.com"},
{"points":"25","customerID":"1","email":"aha238@gmail"},
{"points":"25","customerID":"2","email":"spgiegg@gmail.com"}]
I have been surfing for a solution to this problem for awhile now and most
of what I find is that people who aren't checking to see the the $_GET
variable is set are the ones having this error. However, I do check if
they are set yet I still come up with this error. Here is my code:
$customer_id = $_GET['customer_id'];
$actual_customer_id = $_GET['actual_customer_id'];
if (isset($_GET['customer_id'])&& $_GET['actual_customer_id'])
{
$query = "SELECT rewards_points.points,customers.id AS customerID,
customers.email
FROM rewards_points,customers WHERE rewards_points.customer_id=
$customers_id AND
$actual_customer_id = rewards_points.actual_customer_id";
}
$query = "SELECT rewards_points.points,customers.id AS customerID,
customers.email
FROM rewards_points,customers";
And the error is:
Notice: Undefined index: customer_id in
/Applications/MAMP/htdocs/insertintotestt.php on line 14
Notice: Undefined index: actual_customer_id in
/Applications/MAMP/htdocs/insertintotestt.php on line 15
[{"points":"20","customerID":"1","email":"someEmail@gmail.com
{"points":"20","customerID":"2","email":"otherEmail@gmail.com"},
{"points":"10","customerID":"1","email":"aha238@gmail.com"},
{"points":"10","customerID":"2","email":"spgiegg@gmail.com"},
{"points":"15","customerID":"1","email":"aha238@gmail.com"},
{"points":"15","customerID":"2","email":"spgiegg@gmail.com"},
{"points":"25","customerID":"1","email":"aha238@gmail"},
{"points":"25","customerID":"2","email":"spgiegg@gmail.com"}]
Jquery Mutliple value autocomplete with php mysql
Jquery Mutliple value autocomplete with php mysql
I am trying to implement jquery multiple value auto-complete with php and
mysql, I am getting auto-complete on first search term, but after
selecting it, its doesn't show auto-complete for 2nd search term after
comma.
Please for the same, thanks in advance. Below are the file codes.
searchp.php file Code :
<link
href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css""
rel="stylesheet"/>
<form action='' method='post'>
<p><label>Skills:</label><input type='text' name='search' value=''
id="search"></p>
</form>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript"
src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
$( "#search" )
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "ui-autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source:'auto-skills.php',
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
})
});
</script>
auto-skills.php File Code
<?php
include_once("include/#config.php");
$q = strtolower($_GET["term"]);
$req = "SELECT SkillName FROM skills WHERE SkillName LIKE '%".$q."%' AND
SkillStatus = 1 ";
$query = mysql_query($req);
while($row = mysql_fetch_array($query))
$results[] = array('label' => $row['SkillName']);
echo json_encode($results);
?>
I am trying to implement jquery multiple value auto-complete with php and
mysql, I am getting auto-complete on first search term, but after
selecting it, its doesn't show auto-complete for 2nd search term after
comma.
Please for the same, thanks in advance. Below are the file codes.
searchp.php file Code :
<link
href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css""
rel="stylesheet"/>
<form action='' method='post'>
<p><label>Skills:</label><input type='text' name='search' value=''
id="search"></p>
</form>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript"
src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
$( "#search" )
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "ui-autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source:'auto-skills.php',
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
})
});
</script>
auto-skills.php File Code
<?php
include_once("include/#config.php");
$q = strtolower($_GET["term"]);
$req = "SELECT SkillName FROM skills WHERE SkillName LIKE '%".$q."%' AND
SkillStatus = 1 ";
$query = mysql_query($req);
while($row = mysql_fetch_array($query))
$results[] = array('label' => $row['SkillName']);
echo json_encode($results);
?>
Saturday, 24 August 2013
Renderscript compilation doesn't generate files in 'gen' dir
Renderscript compilation doesn't generate files in 'gen' dir
I have a renderscript in my android project which compiles properly. The
.bc file generated looks correct and there's also the corresponding .class
file that gets generated (ScriptC_...class). However, I can't seem to find
the 'gen' directory.
How do I go about fixing this? I'm on AndroidStudio 0.2.5, API 17. Here's
the project structure:
<root>
.idea
build
<projectname>
classes
ScriptC_blah.class
lib
src
main
gen
java
...moredirs...
<sourcecode>
app.iml
build.gradle
I have a renderscript in my android project which compiles properly. The
.bc file generated looks correct and there's also the corresponding .class
file that gets generated (ScriptC_...class). However, I can't seem to find
the 'gen' directory.
How do I go about fixing this? I'm on AndroidStudio 0.2.5, API 17. Here's
the project structure:
<root>
.idea
build
<projectname>
classes
ScriptC_blah.class
lib
src
main
gen
java
...moredirs...
<sourcecode>
app.iml
build.gradle
Parse a list of integers using boomerang
Parse a list of integers using boomerang
I'm trying to parse URLs of the form
/123/456/789
using the following code:
{-# LANGUAGE OverloadedStrings, TemplateHaskell, TypeOperators #-}
import Prelude hiding ((.), id)
import Control.Category ((.), id)
import Text.Boomerang.TH (derivePrinterParsers)
import Web.Routes.Boomerang
data Indices = Indices [Integer]
$(derivePrinterParsers ''Indices)
sitemap :: Router () (Sitemap :- ())
sitemap = rIndices . rList (integer . eos)
Unfortunately, trying to run this parser with
> parse sitemap ["0", "1"]
causes an infinite loop.
Is there any simple way to parse a list of slash-separated integers?
I'm trying to parse URLs of the form
/123/456/789
using the following code:
{-# LANGUAGE OverloadedStrings, TemplateHaskell, TypeOperators #-}
import Prelude hiding ((.), id)
import Control.Category ((.), id)
import Text.Boomerang.TH (derivePrinterParsers)
import Web.Routes.Boomerang
data Indices = Indices [Integer]
$(derivePrinterParsers ''Indices)
sitemap :: Router () (Sitemap :- ())
sitemap = rIndices . rList (integer . eos)
Unfortunately, trying to run this parser with
> parse sitemap ["0", "1"]
causes an infinite loop.
Is there any simple way to parse a list of slash-separated integers?
Use UConverter class on PHP 5.3
Use UConverter class on PHP 5.3
I have PHP 5.3.1 installed on my system (Ubuntu 12) with intl extension
installed with apt-get install php5-intl. While I'm able to use such intl
classes as Collator and Locale, I can't seem to use other classes like
UConverter:
echo UConverter::UTF16;
outputs
Fatal error: Class 'UConverter' not found in ...
Do I need to upgrade intl extension to the latest version? Would I
preferably be able to do so while keeping PHP at the current version?
I have PHP 5.3.1 installed on my system (Ubuntu 12) with intl extension
installed with apt-get install php5-intl. While I'm able to use such intl
classes as Collator and Locale, I can't seem to use other classes like
UConverter:
echo UConverter::UTF16;
outputs
Fatal error: Class 'UConverter' not found in ...
Do I need to upgrade intl extension to the latest version? Would I
preferably be able to do so while keeping PHP at the current version?
factory method pattern in java
factory method pattern in java
Is it a good practice to have objects specific to some implementation as
member variables in a factory class ? For e.g., in the code below, s1 and
s2 are required for constructing OneChannel and secondChannel objects
respectively. Is it a good practice to declare these as member variables
inside the factory ? If not, what can e the other alternative.
public class CommunicationChannelFactoryImpl {
@Autowired
SomeClass s1;
@Autowired
SomeOtherClass s2;
public CommunicationChannel getCommunicationChannel(String channel,
Map<String, String> channelProperties) {
if(channel.equals("ONE") {
return new OneChannel(s1);
}
if(channel.equals("TWO") {
return new SecondChannel(s2);
}
}
}
Please note that s1 ad s2 are singleton objects
Is it a good practice to have objects specific to some implementation as
member variables in a factory class ? For e.g., in the code below, s1 and
s2 are required for constructing OneChannel and secondChannel objects
respectively. Is it a good practice to declare these as member variables
inside the factory ? If not, what can e the other alternative.
public class CommunicationChannelFactoryImpl {
@Autowired
SomeClass s1;
@Autowired
SomeOtherClass s2;
public CommunicationChannel getCommunicationChannel(String channel,
Map<String, String> channelProperties) {
if(channel.equals("ONE") {
return new OneChannel(s1);
}
if(channel.equals("TWO") {
return new SecondChannel(s2);
}
}
}
Please note that s1 ad s2 are singleton objects
Windows 7 Adobe Air installation
Windows 7 Adobe Air installation
i am facing a issue installing Adobe Air. I tried the Adobe Air
Troubleshooter
http://helpx.adobe.com/air/kb/troubleshoot-air-installation-windows.html
but still no solution.
This is the message:
An error occurred while installing Adobe AIR.
Installation may not be allowed by your administrator.
Please contact your administrator.
My OS is Win7
The Runtime installer has some issues as of my understanding but not sure
how to fix.
What i did:
CCLEANER REG CLEAN
UNINSTALL COMPLETE Adobe Sw.
Standalone installer latest version AdobeAIRInstaller.exe
Silentmode installation did not work.
Enabling User Manager did not work.
Tried old Versions, did not work.
Anyone faced same issues?
Thanks, Luca
####################### INSTALL LOG:
[2013-08-24:13:31:38] Relaunching with elevation
[2013-08-24:13:31:38] Launching subprocess with commandline
c:\users\luca\appdata\local\temp\air96e1.tmp\adobe air installer.exe -ei
[2013-08-24:13:31:40] Runtime Installer begin with version 3.8.0.870 on
Windows 7 x86
[2013-08-24:13:31:40] Commandline is: -stdio \\.\pipe\AIR_8000_0 -ei
[2013-08-24:13:31:40] No installed runtime detected
[2013-08-24:13:31:40] Starting silent runtime install. Installing runtime
version 3.8.0.870
[2013-08-24:13:31:40] Installing msi at
c:\users\luca\appdata\local\temp\air96e1.tmp\setup.msi with guid
{0A5B39D2-7ED6-4779-BCC9-37F381139DB3}
[2013-08-24:13:31:41] Error occurred during msi install operation;
beginning rollback: [ErrorEvent type="error" bubbles=false
cancelable=false eventPhase=2 text="1603" errorID=0]
[2013-08-24:13:31:41] Rolling back install of
c:\users\luca\appdata\local\temp\air96e1.tmp\setup.msi
[2013-08-24:13:31:41] Rollback complete
[2013-08-24:13:31:41] Exiting due to error: [ErrorEvent type="error"
bubbles=false cancelable=false eventPhase=2 text="1603" errorID=0]
[2013-08-24:13:31:41] Exiting due to error: [ErrorEvent type="error"
bubbles=false cancelable=false eventPhase=2 text="1603" errorID=0]
[2013-08-24:13:31:41] Runtime Installer end with exit code 7
[2013-08-24:13:32:11] Runtime Installer end with exit code 7
i am facing a issue installing Adobe Air. I tried the Adobe Air
Troubleshooter
http://helpx.adobe.com/air/kb/troubleshoot-air-installation-windows.html
but still no solution.
This is the message:
An error occurred while installing Adobe AIR.
Installation may not be allowed by your administrator.
Please contact your administrator.
My OS is Win7
The Runtime installer has some issues as of my understanding but not sure
how to fix.
What i did:
CCLEANER REG CLEAN
UNINSTALL COMPLETE Adobe Sw.
Standalone installer latest version AdobeAIRInstaller.exe
Silentmode installation did not work.
Enabling User Manager did not work.
Tried old Versions, did not work.
Anyone faced same issues?
Thanks, Luca
####################### INSTALL LOG:
[2013-08-24:13:31:38] Relaunching with elevation
[2013-08-24:13:31:38] Launching subprocess with commandline
c:\users\luca\appdata\local\temp\air96e1.tmp\adobe air installer.exe -ei
[2013-08-24:13:31:40] Runtime Installer begin with version 3.8.0.870 on
Windows 7 x86
[2013-08-24:13:31:40] Commandline is: -stdio \\.\pipe\AIR_8000_0 -ei
[2013-08-24:13:31:40] No installed runtime detected
[2013-08-24:13:31:40] Starting silent runtime install. Installing runtime
version 3.8.0.870
[2013-08-24:13:31:40] Installing msi at
c:\users\luca\appdata\local\temp\air96e1.tmp\setup.msi with guid
{0A5B39D2-7ED6-4779-BCC9-37F381139DB3}
[2013-08-24:13:31:41] Error occurred during msi install operation;
beginning rollback: [ErrorEvent type="error" bubbles=false
cancelable=false eventPhase=2 text="1603" errorID=0]
[2013-08-24:13:31:41] Rolling back install of
c:\users\luca\appdata\local\temp\air96e1.tmp\setup.msi
[2013-08-24:13:31:41] Rollback complete
[2013-08-24:13:31:41] Exiting due to error: [ErrorEvent type="error"
bubbles=false cancelable=false eventPhase=2 text="1603" errorID=0]
[2013-08-24:13:31:41] Exiting due to error: [ErrorEvent type="error"
bubbles=false cancelable=false eventPhase=2 text="1603" errorID=0]
[2013-08-24:13:31:41] Runtime Installer end with exit code 7
[2013-08-24:13:32:11] Runtime Installer end with exit code 7
Looking for a good library of Tasker scripts/recipes
Looking for a good library of Tasker scripts/recipes
I am looking for a library of Tasker scripts/recipes.
By "Good", I mean the following features are a must:
Sizable (say, 1000 recipes total at least)
Fully categorized recipes
Fully searchable (don't care if internally or via Google)
Preferably, has user based voting/ratings, and a user base of 1000+ people
who rate.
I don't really care what format the recipes/scripts are (e.g something
that is code readable by Tasker, or instructions readable by a person, are
both fine).
What I am NOT looking for:
* Some blog article with 'top 10 Tasker recipes
* Actual tasker scripts posted as answers
I am looking for a library of Tasker scripts/recipes.
By "Good", I mean the following features are a must:
Sizable (say, 1000 recipes total at least)
Fully categorized recipes
Fully searchable (don't care if internally or via Google)
Preferably, has user based voting/ratings, and a user base of 1000+ people
who rate.
I don't really care what format the recipes/scripts are (e.g something
that is code readable by Tasker, or instructions readable by a person, are
both fine).
What I am NOT looking for:
* Some blog article with 'top 10 Tasker recipes
* Actual tasker scripts posted as answers
Friday, 23 August 2013
Get mysql result in javascript global array for further searching through list
Get mysql result in javascript global array for further searching through
list
I need to have a MySQL table result in JS array so that i can search
through the names when typed in a text box. I mean, lets say i have a
table with some names, now when the page is requested, it should populate
a div with the list of the names from MYSQL, the div needs to have an
input box in which when initials are typed, the list below should find the
names matching the keywords kind of like search.
For this, i think i need to store the mysql result in a JS array so that
on the onkeyup and onkeypress event of the text box, it should search for
the matching results from the array items and populate the list with only
those items.
I know, i'll have to make an ajax request on document.ready to fetch the
results from database but then have no idea, how to store it in an array
and then search through that on the text box events.
list
I need to have a MySQL table result in JS array so that i can search
through the names when typed in a text box. I mean, lets say i have a
table with some names, now when the page is requested, it should populate
a div with the list of the names from MYSQL, the div needs to have an
input box in which when initials are typed, the list below should find the
names matching the keywords kind of like search.
For this, i think i need to store the mysql result in a JS array so that
on the onkeyup and onkeypress event of the text box, it should search for
the matching results from the array items and populate the list with only
those items.
I know, i'll have to make an ajax request on document.ready to fetch the
results from database but then have no idea, how to store it in an array
and then search through that on the text box events.
inline multiple matching within a search string in perl
inline multiple matching within a search string in perl
I have OpenGL code for which I would like to have some special indentation
after running astyle. For example,
glBegin(GL_LINES);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glEnd();
The above code I want to change to some thing like below.
glBegin(GL_LINES);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glEnd();
In this special case whatever is there in between glBegin and glEnd I want
to shift by 4 white spaces.
I want to do this inline and using perl.
I have OpenGL code for which I would like to have some special indentation
after running astyle. For example,
glBegin(GL_LINES);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glEnd();
The above code I want to change to some thing like below.
glBegin(GL_LINES);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glVertex2f(1.0f, 2.0f);
glEnd();
In this special case whatever is there in between glBegin and glEnd I want
to shift by 4 white spaces.
I want to do this inline and using perl.
How do you put a Hide/Show DIV within another Hide/Show DIV
How do you put a Hide/Show DIV within another Hide/Show DIV
I want to create a form similar to the one on http://gazelle.com/ but I
have no idea how to do it. How is it possible? I want to use javascript
and HTML.
I want to create a form similar to the one on http://gazelle.com/ but I
have no idea how to do it. How is it possible? I want to use javascript
and HTML.
Widget position on Screen
Widget position on Screen
Just made my first android widget but it seems to occupy to much space.
As you can see from the photos, I can't put it more closer to the upper
side of the screen. It seems to be a big widget, but it is not. And so i
can't put app icon upper of it or at its right side.
Here is style:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
...OTHER CODE
<padding android:left="8dip"
android:top="8dip"
android:right="8dip"
android:bottom="8dip" />
</shape>
And here is widget xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="8dp"
android:id="@+id/linearwidget"
android:background="@drawable/widgetstyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/labelmedia"
android:padding="5dp"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:textColor="#ff27b8d1"
android:textSize="12sp"
android:textStyle="bold"
android:text="MEDIA"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="@android:color/white"
android:textSize="15sp"
android:textStyle="bold"
android:layout_below="@id/labelmedia"
android:id="@+id/media"
android:layout_centerInParent="true"
android:text="12.55"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/labelbase"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:padding="5dp"
android:textColor="#ff27b8d1"
android:textSize="12sp"
android:textStyle="bold"
android:text="BASE LAUREA"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="@android:color/white"
android:textSize="15sp"
android:textStyle="bold"
android:layout_below="@id/labelbase"
android:id="@+id/base"
android:layout_centerInParent="true"
android:text="12.55"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/labelcrediti"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:padding="5dp"
android:textColor="#ff27b8d1"
android:textSize="12sp"
android:textStyle="bold"
android:text="CREDITI"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="@android:color/white"
android:textSize="14sp"
android:textStyle="bold"
android:layout_below="@id/labelcrediti"
android:id="@+id/crediti"
android:layout_centerInParent="true"
android:text="120/180"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Any help on how to let it be smaller as it is?
Just made my first android widget but it seems to occupy to much space.
As you can see from the photos, I can't put it more closer to the upper
side of the screen. It seems to be a big widget, but it is not. And so i
can't put app icon upper of it or at its right side.
Here is style:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
...OTHER CODE
<padding android:left="8dip"
android:top="8dip"
android:right="8dip"
android:bottom="8dip" />
</shape>
And here is widget xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="8dp"
android:id="@+id/linearwidget"
android:background="@drawable/widgetstyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/labelmedia"
android:padding="5dp"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:textColor="#ff27b8d1"
android:textSize="12sp"
android:textStyle="bold"
android:text="MEDIA"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="@android:color/white"
android:textSize="15sp"
android:textStyle="bold"
android:layout_below="@id/labelmedia"
android:id="@+id/media"
android:layout_centerInParent="true"
android:text="12.55"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/labelbase"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:padding="5dp"
android:textColor="#ff27b8d1"
android:textSize="12sp"
android:textStyle="bold"
android:text="BASE LAUREA"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="@android:color/white"
android:textSize="15sp"
android:textStyle="bold"
android:layout_below="@id/labelbase"
android:id="@+id/base"
android:layout_centerInParent="true"
android:text="12.55"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/labelcrediti"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:padding="5dp"
android:textColor="#ff27b8d1"
android:textSize="12sp"
android:textStyle="bold"
android:text="CREDITI"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="@android:color/white"
android:textSize="14sp"
android:textStyle="bold"
android:layout_below="@id/labelcrediti"
android:id="@+id/crediti"
android:layout_centerInParent="true"
android:text="120/180"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Any help on how to let it be smaller as it is?
Domain name required for sender address
Domain name required for sender address
I'm trying to setup postfix on a new vps I just got and this is the first
time doing any kind of email setup. I am getting an error when trying to
perform a test email. I posted my config and error and I'm wondering if I
made a mistake somewhere? I'm running a Ubuntu 12.04 LTS VPS.
Getting error:
mail from:<jhvisser>
250 2.1.0 <jhvisser>... Sender ok
rcpt to:<jhvisser>
553 5.5.4 <jhvisser>... Domain name required for sender address jhvisser
With config:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = yes
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt
smtpd_tls_key_file = /etc/ssl/private/smtpd.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = jhvisser.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = jhvisser.com
mydestination = jhvisser.com, localhost.com, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_auth_only = no
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
I'm trying to setup postfix on a new vps I just got and this is the first
time doing any kind of email setup. I am getting an error when trying to
perform a test email. I posted my config and error and I'm wondering if I
made a mistake somewhere? I'm running a Ubuntu 12.04 LTS VPS.
Getting error:
mail from:<jhvisser>
250 2.1.0 <jhvisser>... Sender ok
rcpt to:<jhvisser>
553 5.5.4 <jhvisser>... Domain name required for sender address jhvisser
With config:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = yes
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt
smtpd_tls_key_file = /etc/ssl/private/smtpd.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = jhvisser.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = jhvisser.com
mydestination = jhvisser.com, localhost.com, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_auth_only = no
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
Replacing Windows 8 with Ubuntu
Replacing Windows 8 with Ubuntu
Just bought a Samsung Series 9 laptop (I7, 128GB SSD) with Windows 8
preinstalled. Can I remove and save Windows 8 (perhaps for future use) and
install Ubuntu instead?
Just bought a Samsung Series 9 laptop (I7, 128GB SSD) with Windows 8
preinstalled. Can I remove and save Windows 8 (perhaps for future use) and
install Ubuntu instead?
Thursday, 22 August 2013
Getting like count of n posts of n users in realtime with node.js
Getting like count of n posts of n users in realtime with node.js
In a project am working ,users will be able to login with facebook then
they will be able to post a photo or any post from my site and it will
appear in their profile.i need to get the like count for all the posts of
all the users in real time with node.js.currently i have code to get like
count for a single post of an user.
In a project am working ,users will be able to login with facebook then
they will be able to post a photo or any post from my site and it will
appear in their profile.i need to get the like count for all the posts of
all the users in real time with node.js.currently i have code to get like
count for a single post of an user.
What are the good tutorial sites to learn rdlc reportdesigning?
What are the good tutorial sites to learn rdlc reportdesigning?
Any one knows what are the good tutorials available in net to have some
good idea about rdlc report designing.specially
grouping,subtotal,joining,sub report, binding multiple datasets to
report...like stuffs. I dont need a tutorial like how to bind data set to
report...like basics. many tutorials I have fond that only cover that
steps and no go further digging.
Any one knows what are the good tutorials available in net to have some
good idea about rdlc report designing.specially
grouping,subtotal,joining,sub report, binding multiple datasets to
report...like stuffs. I dont need a tutorial like how to bind data set to
report...like basics. many tutorials I have fond that only cover that
steps and no go further digging.
jQuery does not recognize Euro symbol
jQuery does not recognize Euro symbol
i have a problem with euro symbol. Suppose a value like 20 Now i want to
extract the value to get 20. But jQuery can't recognize symbol. Please
anyone help me out.
i have a problem with euro symbol. Suppose a value like 20 Now i want to
extract the value to get 20. But jQuery can't recognize symbol. Please
anyone help me out.
How long does Linux (by default) cache information about files in the disk?
How long does Linux (by default) cache information about files in the disk?
I'm testing whether some changes I made to some code are effective or not.
For this, I need to know how the file system cache normally works. I'm
assuming the default is what we're getting, since we probably haven't
tweaked anything interesting regarding this.
Essentially, if from my code I ask "does this file exist?", the answer
comes back in "x" milliseconds. If I ask again a few minutes later, the
answer comes back much, much quicker, so I'm guessing there's some caching
going on there.
How long should I wait if I want to test again, with the cache flushed, so
it'll take "long" again? (I want to see if I fixed a performance problem
in my web app, but I can only know that it's fixed if the info about files
existence isn't cached, because if it is, it does run fast)
I know this is not the most eloquent question, and the answer is probably
"it depends", I'm asking for a sane default. In other words, if I test
again in 3 hours, or 6, or whatever, can I count on it not being cached?
As far as I can tell... This is a Ubuntu server, kernel version:
3.9.3-x86-linode52, Ubuntu version: Ubuntu 12.04.3 LTS, hosted on Linode.
The file system is ext3
Thank you!
Daniel
I'm testing whether some changes I made to some code are effective or not.
For this, I need to know how the file system cache normally works. I'm
assuming the default is what we're getting, since we probably haven't
tweaked anything interesting regarding this.
Essentially, if from my code I ask "does this file exist?", the answer
comes back in "x" milliseconds. If I ask again a few minutes later, the
answer comes back much, much quicker, so I'm guessing there's some caching
going on there.
How long should I wait if I want to test again, with the cache flushed, so
it'll take "long" again? (I want to see if I fixed a performance problem
in my web app, but I can only know that it's fixed if the info about files
existence isn't cached, because if it is, it does run fast)
I know this is not the most eloquent question, and the answer is probably
"it depends", I'm asking for a sane default. In other words, if I test
again in 3 hours, or 6, or whatever, can I count on it not being cached?
As far as I can tell... This is a Ubuntu server, kernel version:
3.9.3-x86-linode52, Ubuntu version: Ubuntu 12.04.3 LTS, hosted on Linode.
The file system is ext3
Thank you!
Daniel
Javamail - sending mail with login different from email
Javamail - sending mail with login different from email
Got a problem with my email method, code below:
public static void send( final String username, final String password,
String recipientEmail, String ccEmail, String title, String message,
String from, String host, String port )
throws AddressException, MessagingException
{
try
{
Session session;
Properties props = System.getProperties();
props.setProperty( "mail.smtps.host", host );
props.setProperty( "mail.smtp.port", port );
props.setProperty( "mail.mime.charset", "utf8" );
session = Session.getInstance( props, null );
// session.setDebug( true );
String uFrom = from;
// setting encoding properly
/*
* try { uFrom = new String( from.getBytes( "UTF-8" ),
"ISO-8859-1" ); } catch (
* UnsupportedEncodingException e ) { // logi ! }
*/
// -- Create a new message --
final MimeMessage msg = new MimeMessage( session );
// -- Set the FROM and TO fields --
msg.setFrom( new InternetAddress( username ) );
msg.setRecipients( Message.RecipientType.TO,
InternetAddress.parse( recipientEmail, false ) );
if ( ccEmail.length() > 0 )
{
msg.setRecipients( Message.RecipientType.CC,
InternetAddress.parse( ccEmail, false ) );
}
InternetAddress adress = new InternetAddress( username, uFrom );
adress.setAddress( username + "@naszedziecko.com.pl" );
adress.setPersonal( uFrom, "ISO-8859-2" );
msg.setSubject( title, "utf-8" );
msg.setFrom( adress );
msg.setText( message, "utf-8" );
msg.setSentDate( new Date() );
SMTPTransport t = (SMTPTransport) session.getTransport( "smtps" );
t.connect( host, username, password );
t.sendMessage( msg, msg.getAllRecipients() );
t.close();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
And the problem is that my client is using mail where login is eg.
'superinfo' and the real mail is 'info@domain.com'.
When system is using this mail to send a message i get:
com.sun.mail.smtp.SMTPSenderFailedException: 553 5.3.0 ... No such user
Got a problem with my email method, code below:
public static void send( final String username, final String password,
String recipientEmail, String ccEmail, String title, String message,
String from, String host, String port )
throws AddressException, MessagingException
{
try
{
Session session;
Properties props = System.getProperties();
props.setProperty( "mail.smtps.host", host );
props.setProperty( "mail.smtp.port", port );
props.setProperty( "mail.mime.charset", "utf8" );
session = Session.getInstance( props, null );
// session.setDebug( true );
String uFrom = from;
// setting encoding properly
/*
* try { uFrom = new String( from.getBytes( "UTF-8" ),
"ISO-8859-1" ); } catch (
* UnsupportedEncodingException e ) { // logi ! }
*/
// -- Create a new message --
final MimeMessage msg = new MimeMessage( session );
// -- Set the FROM and TO fields --
msg.setFrom( new InternetAddress( username ) );
msg.setRecipients( Message.RecipientType.TO,
InternetAddress.parse( recipientEmail, false ) );
if ( ccEmail.length() > 0 )
{
msg.setRecipients( Message.RecipientType.CC,
InternetAddress.parse( ccEmail, false ) );
}
InternetAddress adress = new InternetAddress( username, uFrom );
adress.setAddress( username + "@naszedziecko.com.pl" );
adress.setPersonal( uFrom, "ISO-8859-2" );
msg.setSubject( title, "utf-8" );
msg.setFrom( adress );
msg.setText( message, "utf-8" );
msg.setSentDate( new Date() );
SMTPTransport t = (SMTPTransport) session.getTransport( "smtps" );
t.connect( host, username, password );
t.sendMessage( msg, msg.getAllRecipients() );
t.close();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
And the problem is that my client is using mail where login is eg.
'superinfo' and the real mail is 'info@domain.com'.
When system is using this mail to send a message i get:
com.sun.mail.smtp.SMTPSenderFailedException: 553 5.3.0 ... No such user
Yii-booster: property responsiveTable does not work, why?
Yii-booster: property responsiveTable does not work, why?
In TbExtendedGridView there is a property responsiveTable:
"New by setting the responsiveTable property to true (this is for all
extended versions of TbGridView), tables will be automatically converted
to suit mobile size. Try it by resizing the browser window and check this
first example." source
But it fails to properly work when resizing, why? Has anybody made it to
work?
In TbExtendedGridView there is a property responsiveTable:
"New by setting the responsiveTable property to true (this is for all
extended versions of TbGridView), tables will be automatically converted
to suit mobile size. Try it by resizing the browser window and check this
first example." source
But it fails to properly work when resizing, why? Has anybody made it to
work?
Source of US Dicom images with planar configuration 1?
Source of US Dicom images with planar configuration 1?
I'm making a Dicom tool using Dcmtk C++ library. I'm trying to make the
tool compatible with different types of Dicom images. As part of that, I'm
looking for Ultrasound Dicom images with Planar Configuration 1, right I
only have with Planar Configuration 0. Could any one say me where I can
get some free US Dicom images with Planar Configuration 1?
Thanks.
I'm making a Dicom tool using Dcmtk C++ library. I'm trying to make the
tool compatible with different types of Dicom images. As part of that, I'm
looking for Ultrasound Dicom images with Planar Configuration 1, right I
only have with Planar Configuration 0. Could any one say me where I can
get some free US Dicom images with Planar Configuration 1?
Thanks.
Wednesday, 21 August 2013
change device orientation compatible for ios6 and ios5
change device orientation compatible for ios6 and ios5
I NEED: rotate device programmatically from portrait to landscape
compatible for iOS6 and iOS5. THE PROBLEM: I cannot use [UIDevice
setOrientation] function on ios6.
WHAT I HAVE: the code for iOS6:
- (BOOL) shouldAutorotate
{
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
the code for iOS5:
-
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
So, I need write the code that rotate on iOS5:
-(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated];
// [[UIDevice currentDevice] setOrientation] - I cannot use it
// ???
}
I NEED: rotate device programmatically from portrait to landscape
compatible for iOS6 and iOS5. THE PROBLEM: I cannot use [UIDevice
setOrientation] function on ios6.
WHAT I HAVE: the code for iOS6:
- (BOOL) shouldAutorotate
{
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
the code for iOS5:
-
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
So, I need write the code that rotate on iOS5:
-(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated];
// [[UIDevice currentDevice] setOrientation] - I cannot use it
// ???
}
How to handle unnecessary whitespace leading to widows/orphans?
How to handle unnecessary whitespace leading to widows/orphans?
I'm working on my paper using TexMaker and this is what's happening:
I'm getting unnecessary whitespace before paragraph 'B'. As a result of
the unnecessary whitespace I have a widow/orphan of an equation reference
at the start of the next page. I'm pretty much at my wits end wondering
what is the problem here.
Here is the LaTeX code for the paragraph and the corresponding equation
section:
\subsection{Computing Tester/Developer Payoffs}
\label{subsec:payoffs}
In a security game defenders may employ mixed strategies i.e., selecting a
particular action with some probability as opposed to a deterministic
choice. This distribution decreases predictability of choice of
actions that may be exploited by an adversary. For our testing game we
refer to the set of distributions as a \textit{coverage vector}, $C$
that gives the probability, $c_t$, that a particular test suite $t$,
covering a particular requirement will be executed. We then compute
the expected payoffs for the testers and developers as shown in
Equations~\eqref{eqn:tC-EU} through ~\eqref{eqn:attack-set}
\begin{IEEEeqnarray}{c}
\label{eqn:tC-EU} U_\tester(t,C) = c_t \cdot \testercovered +
(1-c_t)\cdot \testeruncovered \\
\label{eqn:CA-EU} U_\tester(C,\reqvector) = \sum_{t \in T} \attackprob
\cdot (c_t \cdot \testercovered + (1-c_t)\cdot \testeruncovered) \\
\label{eqn:attack-set} \Gamma (C) = \{t:U_\dev(t,C) \geq
U_\dev(t',C)\, \forall t' \in T\}
\end{IEEEeqnarray}
%...remaining text
There is nothing out of the ordinary in the code IMO. Why does this happen
and how should I fix it (whitespace + widow/orphan)? This abruptly started
happening after editing the paper. I'm guessing it's something to do with
auto layout of LaTeX and not really something in the code.
PS: If it's of any use, here's the code for the table in the screenshot
above:
{\begin{table*}[!t]
\caption{Compact representation of game showing tester and developer
utilities}
\label{table:game}
\renewcommand\arraystretch{1.5}
\begin{tabular}{*{11}{|c}|}
\cline{2-11}
\multicolumn{1}{c|}{}& \multicolumn{2}{c|}{Requirement 1} &
\multicolumn{2}{c|}{Requirement 2} & \multicolumn{2}{c|}{Requirement 3} &
\multicolumn{2}{c|}{Requirement 4} & \multicolumn{2}{c|}{Requirement 5}\\
\cline{2-11}
\multicolumn{1}{c|}{}& Covered & Uncovered & Covered &
Uncovered & Covered & Uncovered & Covered &
Uncovered & Covered & Uncovered \\ \hline
Tester's utility & 2 & -10 & 7 & -4
& 6 & -1 & 9 & -9
& 9 & -9 \\ \hline
Developer's utility & -7 & 4 & -1 & 3
& -6 & 5 & -3 & 7
& -10 & 3 \\ \hline
\end{tabular}
\end{table*}}
I'm working on my paper using TexMaker and this is what's happening:
I'm getting unnecessary whitespace before paragraph 'B'. As a result of
the unnecessary whitespace I have a widow/orphan of an equation reference
at the start of the next page. I'm pretty much at my wits end wondering
what is the problem here.
Here is the LaTeX code for the paragraph and the corresponding equation
section:
\subsection{Computing Tester/Developer Payoffs}
\label{subsec:payoffs}
In a security game defenders may employ mixed strategies i.e., selecting a
particular action with some probability as opposed to a deterministic
choice. This distribution decreases predictability of choice of
actions that may be exploited by an adversary. For our testing game we
refer to the set of distributions as a \textit{coverage vector}, $C$
that gives the probability, $c_t$, that a particular test suite $t$,
covering a particular requirement will be executed. We then compute
the expected payoffs for the testers and developers as shown in
Equations~\eqref{eqn:tC-EU} through ~\eqref{eqn:attack-set}
\begin{IEEEeqnarray}{c}
\label{eqn:tC-EU} U_\tester(t,C) = c_t \cdot \testercovered +
(1-c_t)\cdot \testeruncovered \\
\label{eqn:CA-EU} U_\tester(C,\reqvector) = \sum_{t \in T} \attackprob
\cdot (c_t \cdot \testercovered + (1-c_t)\cdot \testeruncovered) \\
\label{eqn:attack-set} \Gamma (C) = \{t:U_\dev(t,C) \geq
U_\dev(t',C)\, \forall t' \in T\}
\end{IEEEeqnarray}
%...remaining text
There is nothing out of the ordinary in the code IMO. Why does this happen
and how should I fix it (whitespace + widow/orphan)? This abruptly started
happening after editing the paper. I'm guessing it's something to do with
auto layout of LaTeX and not really something in the code.
PS: If it's of any use, here's the code for the table in the screenshot
above:
{\begin{table*}[!t]
\caption{Compact representation of game showing tester and developer
utilities}
\label{table:game}
\renewcommand\arraystretch{1.5}
\begin{tabular}{*{11}{|c}|}
\cline{2-11}
\multicolumn{1}{c|}{}& \multicolumn{2}{c|}{Requirement 1} &
\multicolumn{2}{c|}{Requirement 2} & \multicolumn{2}{c|}{Requirement 3} &
\multicolumn{2}{c|}{Requirement 4} & \multicolumn{2}{c|}{Requirement 5}\\
\cline{2-11}
\multicolumn{1}{c|}{}& Covered & Uncovered & Covered &
Uncovered & Covered & Uncovered & Covered &
Uncovered & Covered & Uncovered \\ \hline
Tester's utility & 2 & -10 & 7 & -4
& 6 & -1 & 9 & -9
& 9 & -9 \\ \hline
Developer's utility & -7 & 4 & -1 & 3
& -6 & 5 & -3 & 7
& -10 & 3 \\ \hline
\end{tabular}
\end{table*}}
how to get values of cells p:datatable in javascript
how to get values of cells p:datatable in javascript
i have one p:datatable (primefaces data table) with 4 rows 13 columns,
roweditable using ajax. where i rendered 4 rows (records) in 12 columns
each column has radiobox on the top if i select any column i want to get
values of that col in javascript and then do something with values then
set those values to column number 13 which does not have radio box when i
saw source code from browser i see id e.g somethingId:0:j_xxx,
somethingId:1:j_xxx so on.. i can not understand this.. please HELP!!
sorry for my bad english!! thanks.
i have one p:datatable (primefaces data table) with 4 rows 13 columns,
roweditable using ajax. where i rendered 4 rows (records) in 12 columns
each column has radiobox on the top if i select any column i want to get
values of that col in javascript and then do something with values then
set those values to column number 13 which does not have radio box when i
saw source code from browser i see id e.g somethingId:0:j_xxx,
somethingId:1:j_xxx so on.. i can not understand this.. please HELP!!
sorry for my bad english!! thanks.
Bootstrap Multiselect Integration with WTForms
Bootstrap Multiselect Integration with WTForms
I'm new to WTForms and was wondering how to integrate a bootstrap styled
multiselect like this one
http://davidstutz.github.io/bootstrap-multiselect/ into WTForms.
I know I can write the HTML directly to create the multiselect dropdown
form but I'd rather work with WTForm objects to keep my forms consistent.
Is there a simple way to convert the WTForms SelectMultipleField class
into a dropdown multiselect box? Or is something more sophisticated
needed?
Thanks!
I'm new to WTForms and was wondering how to integrate a bootstrap styled
multiselect like this one
http://davidstutz.github.io/bootstrap-multiselect/ into WTForms.
I know I can write the HTML directly to create the multiselect dropdown
form but I'd rather work with WTForm objects to keep my forms consistent.
Is there a simple way to convert the WTForms SelectMultipleField class
into a dropdown multiselect box? Or is something more sophisticated
needed?
Thanks!
Oozie issue with ssh action performing on the Edge node of the cluster
Oozie issue with ssh action performing on the Edge node of the cluster
'm trying to schedule a oozie job through ssh action on the edge node. As
my bash scripts for each of the phases in the process flow. Here, i'm
facing lot of issues like ilts not at all allowing to start the job. I
have read in different blogs stating that if we have to setup
password-less ssh so that we can eliminate this type of issue, but its not
safe to do because the cluster will become vulnerable!! Moreover if this
type of passwordless ssh setup can be done on devclusters but when it
comes to production it may give the same errors (which is kerberized)
there we may not be able to generate passwordless -ssh. Is there any other
method to resolve this type of issue or please suggest what can be done to
trigger a job at the edge node if the files are in HDFS
below i have placed one of the error lod msg
error log...... 2013-08-08 06:03:51,627 INFO
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[*-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@:start:] Start action
[0000044-130719141217337-oozie-oozi-W@:start:] with user-retry state :
userRetryCount [0], userRetryMax [0], userRetryInterval [10] 2013-08-08
06:03:51,627 WARN org.apache.oozie.command.wf.ActionStartXCommand:
USER[root] GROUP[-] TOKEN[] APP[*wf]
JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@:start:]
[0000044-130719141217337-oozie-oozi-W@:start:]Action status=DONE
2013-08-08 06:03:51,627 WARN
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[**-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@:start:]
[0000044-130719141217337-oozie-oozi-W@:start:]Action updated in DB!
2013-08-08 06:03:51,718 INFO
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Start action
[0000044-130719141217337-oozie-oozi-W@sshtest] with user-retry state :
userRetryCount [0], userRetryMax [0], userRetryInterval [10] 2013-08-08
06:03:51,718 INFO org.apache.oozie.action.ssh.SshActionExecutor:
USER[root] GROUP[-] TOKEN[] APP[-wf]
JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] start() begins
2013-08-08 06:03:51,721 INFO
org.apache.oozie.action.ssh.SshActionExecutor: USER[root] GROUP[-] TOKEN[]
AP{P*-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Attempting to copy
ssh base scripts to remote host [root@***] 2013-08-08 06:03:51,801 WARN
org.apache.oozie.action.ssh.SshActionExecutor: USER[root] GROUP[-] TOKEN[]
APP[**-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Error while executing
ssh EXECUTION 2013-08-08 06:03:51,801 WARN
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[**-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Error starting action
[sshtest]. ErrorType [NON_TRANSIENT], ErrorCode [AUTH_FAILED], Message
[AUTH_FAILED: Not able to perform operation [ssh -o
PasswordAuthentication=no -o KbdInteractiveDevices=no -o
StrictHostKeyChecking=no -o ConnectTimeout=20 root@** mkdir -p
oozie-oozi/0000044-130719141217337-oozie-oozi-W/sshtest--ssh/ ]
'm trying to schedule a oozie job through ssh action on the edge node. As
my bash scripts for each of the phases in the process flow. Here, i'm
facing lot of issues like ilts not at all allowing to start the job. I
have read in different blogs stating that if we have to setup
password-less ssh so that we can eliminate this type of issue, but its not
safe to do because the cluster will become vulnerable!! Moreover if this
type of passwordless ssh setup can be done on devclusters but when it
comes to production it may give the same errors (which is kerberized)
there we may not be able to generate passwordless -ssh. Is there any other
method to resolve this type of issue or please suggest what can be done to
trigger a job at the edge node if the files are in HDFS
below i have placed one of the error lod msg
error log...... 2013-08-08 06:03:51,627 INFO
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[*-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@:start:] Start action
[0000044-130719141217337-oozie-oozi-W@:start:] with user-retry state :
userRetryCount [0], userRetryMax [0], userRetryInterval [10] 2013-08-08
06:03:51,627 WARN org.apache.oozie.command.wf.ActionStartXCommand:
USER[root] GROUP[-] TOKEN[] APP[*wf]
JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@:start:]
[0000044-130719141217337-oozie-oozi-W@:start:]Action status=DONE
2013-08-08 06:03:51,627 WARN
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[**-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@:start:]
[0000044-130719141217337-oozie-oozi-W@:start:]Action updated in DB!
2013-08-08 06:03:51,718 INFO
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Start action
[0000044-130719141217337-oozie-oozi-W@sshtest] with user-retry state :
userRetryCount [0], userRetryMax [0], userRetryInterval [10] 2013-08-08
06:03:51,718 INFO org.apache.oozie.action.ssh.SshActionExecutor:
USER[root] GROUP[-] TOKEN[] APP[-wf]
JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] start() begins
2013-08-08 06:03:51,721 INFO
org.apache.oozie.action.ssh.SshActionExecutor: USER[root] GROUP[-] TOKEN[]
AP{P*-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Attempting to copy
ssh base scripts to remote host [root@***] 2013-08-08 06:03:51,801 WARN
org.apache.oozie.action.ssh.SshActionExecutor: USER[root] GROUP[-] TOKEN[]
APP[**-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Error while executing
ssh EXECUTION 2013-08-08 06:03:51,801 WARN
org.apache.oozie.command.wf.ActionStartXCommand: USER[root] GROUP[-]
TOKEN[] APP[**-wf] JOB[0000044-130719141217337-oozie-oozi-W]
ACTION[0000044-130719141217337-oozie-oozi-W@sshtest] Error starting action
[sshtest]. ErrorType [NON_TRANSIENT], ErrorCode [AUTH_FAILED], Message
[AUTH_FAILED: Not able to perform operation [ssh -o
PasswordAuthentication=no -o KbdInteractiveDevices=no -o
StrictHostKeyChecking=no -o ConnectTimeout=20 root@** mkdir -p
oozie-oozi/0000044-130719141217337-oozie-oozi-W/sshtest--ssh/ ]
How to implement SnapMode for Grid in QML
How to implement SnapMode for Grid in QML
I need to use a grid(not gridview) and i need to achieve
GridView.SnapToRow for the same.
Below is my code:
import QtQuick 1.0
Rectangle {
width: 1368
height: 768
Text{
id:parentTxt
anchors.top: parentTxt0.bottom
}
Timer{running: true;repeat: false;interval:200;onTriggered: {calc()}}
function calc(){
var totalItems=testGrid.count+((testBtn.visible)?1:0)
var dividedVal=totalItems/testGrid.columns
var absVal=Math.floor(dividedVal)
var diffVal=dividedVal-absVal;
testGrid.rowCount=(diffVal>0)?(absVal+1):absVal
parentTxt.text=testGrid.rowCount
}
Text{
id:parentTxt0
text:"Move up"
MouseArea{
anchors.fill: parent;
onClicked: {
calc()
gridFlick.contentY+=137
}
}
}
Text{
id:parentTxt02
text:"Move down"
anchors.left: parentTxt0.right
anchors.leftMargin: 20
MouseArea{
anchors.fill: parent;
onClicked: {
calc()
if(gridFlick.contentY!=0)gridFlick.contentY-=137
}
}
}
Text{
id:parentTxt03
text:"toggleVisiblitiy"
anchors.left: parentTxt02.right
anchors.leftMargin: 20
MouseArea{
anchors.fill: parent;
onClicked: {
testBtn.visible=!testBtn.visible;
calc()
}
}
}
Rectangle {
width: 770
height: 274
anchors.centerIn: parent
color:"#330000ff"
clip:true;
Flickable{
id:gridFlick
interactive: true;
width: parent.width
height: parent.height
contentWidth: testGrid.width; contentHeight: 137*testGrid.rowCount
flickableDirection:Flickable.VerticalFlick
boundsBehavior:Flickable.StopAtBounds
Grid{
id:testGrid
property int count:15
property int rowCount: 0
columns: 5;
width: parent.width
height: parent.height
Rectangle{
id:testBtn
color:"transparent"
height:137
width: 154
Text {
anchors.centerIn: parent;
wrapMode: Text.WordWrap
text: "back"
}
MouseArea{
anchors.fill: parent;
onClicked: {
parentTxt.text="back"
}
}
}
Repeater{
model:testGrid.count;
delegate:Rectangle{
color:"transparent"
height:137
width: 154
Text {
anchors.centerIn: parent;
wrapMode: Text.WordWrap
text: index
}
MouseArea{
anchors.fill: parent;
onClicked: {
parentTxt.text=index
}
}
}
}
}
}
}
}
Can any one provide some idea to this?
I need to use a grid(not gridview) and i need to achieve
GridView.SnapToRow for the same.
Below is my code:
import QtQuick 1.0
Rectangle {
width: 1368
height: 768
Text{
id:parentTxt
anchors.top: parentTxt0.bottom
}
Timer{running: true;repeat: false;interval:200;onTriggered: {calc()}}
function calc(){
var totalItems=testGrid.count+((testBtn.visible)?1:0)
var dividedVal=totalItems/testGrid.columns
var absVal=Math.floor(dividedVal)
var diffVal=dividedVal-absVal;
testGrid.rowCount=(diffVal>0)?(absVal+1):absVal
parentTxt.text=testGrid.rowCount
}
Text{
id:parentTxt0
text:"Move up"
MouseArea{
anchors.fill: parent;
onClicked: {
calc()
gridFlick.contentY+=137
}
}
}
Text{
id:parentTxt02
text:"Move down"
anchors.left: parentTxt0.right
anchors.leftMargin: 20
MouseArea{
anchors.fill: parent;
onClicked: {
calc()
if(gridFlick.contentY!=0)gridFlick.contentY-=137
}
}
}
Text{
id:parentTxt03
text:"toggleVisiblitiy"
anchors.left: parentTxt02.right
anchors.leftMargin: 20
MouseArea{
anchors.fill: parent;
onClicked: {
testBtn.visible=!testBtn.visible;
calc()
}
}
}
Rectangle {
width: 770
height: 274
anchors.centerIn: parent
color:"#330000ff"
clip:true;
Flickable{
id:gridFlick
interactive: true;
width: parent.width
height: parent.height
contentWidth: testGrid.width; contentHeight: 137*testGrid.rowCount
flickableDirection:Flickable.VerticalFlick
boundsBehavior:Flickable.StopAtBounds
Grid{
id:testGrid
property int count:15
property int rowCount: 0
columns: 5;
width: parent.width
height: parent.height
Rectangle{
id:testBtn
color:"transparent"
height:137
width: 154
Text {
anchors.centerIn: parent;
wrapMode: Text.WordWrap
text: "back"
}
MouseArea{
anchors.fill: parent;
onClicked: {
parentTxt.text="back"
}
}
}
Repeater{
model:testGrid.count;
delegate:Rectangle{
color:"transparent"
height:137
width: 154
Text {
anchors.centerIn: parent;
wrapMode: Text.WordWrap
text: index
}
MouseArea{
anchors.fill: parent;
onClicked: {
parentTxt.text=index
}
}
}
}
}
}
}
}
Can any one provide some idea to this?
Do you use capitalization in titles?
Do you use capitalization in titles?
This is a stylistic question. Or maybe about grammar... I don't know. When
and why do you use uppercase first letters?
I am German and in German documents, it is clear, to write all words like
always even when appearing in a title. The first letter of a title is
always capitalized.
In English, I understand, there are different rules. But are there
differences between UK- and US-English? Should that be localized to where
the thesis is written?
Until now, I have the feeling, that capitalizing main titles is done
everywhere (in English area)
This is a Book Title
In the US, chapter titles follow this rule
This is an US Chapter Title
but not in the UK
This is an UK chapter title
Are there any rules around? What is your experience?
Would there be a possibility to switch all the Table of
SomethingCapitalized to Table of something-not-capitalized?
This is a stylistic question. Or maybe about grammar... I don't know. When
and why do you use uppercase first letters?
I am German and in German documents, it is clear, to write all words like
always even when appearing in a title. The first letter of a title is
always capitalized.
In English, I understand, there are different rules. But are there
differences between UK- and US-English? Should that be localized to where
the thesis is written?
Until now, I have the feeling, that capitalizing main titles is done
everywhere (in English area)
This is a Book Title
In the US, chapter titles follow this rule
This is an US Chapter Title
but not in the UK
This is an UK chapter title
Are there any rules around? What is your experience?
Would there be a possibility to switch all the Table of
SomethingCapitalized to Table of something-not-capitalized?
Tuesday, 20 August 2013
How to interchange data between Java Program and C++ Program
How to interchange data between Java Program and C++ Program
I constructed a java program using netbeans IDE that has ability to
connect with a respective DLL; I want to connect and interchange data
between my java program(.jar) and VSC++ program(.exe) through DLLs.JNI
uses single Dll to invoke C/C++ function in native manner,In order to
increase the efficiency I tried to connect and interchange primitive data
types between Java program and C++ program using that DLL(JNI
implemented).
Unfortunately C++ program cannot obtain data values that has been changed
by Java Program.Fot example - If I declare a global int variable in
DLL,java program can catch that int variable and can update it but If I
run my C++ program(exe) loading same DLL simultaneously it cannot receive
the updated value of that int variable declared in the DLL.
Therefore I need a solution to share/Interchange at least primitive data
and their respective values between a JAVA and C++ Program using JNI (in
spite of date transferring through Sockets).JAVA TO C/C++ & C/C++ to JAVA
using DLLs.
PLEASE HELP ME!! THANK YOU
I constructed a java program using netbeans IDE that has ability to
connect with a respective DLL; I want to connect and interchange data
between my java program(.jar) and VSC++ program(.exe) through DLLs.JNI
uses single Dll to invoke C/C++ function in native manner,In order to
increase the efficiency I tried to connect and interchange primitive data
types between Java program and C++ program using that DLL(JNI
implemented).
Unfortunately C++ program cannot obtain data values that has been changed
by Java Program.Fot example - If I declare a global int variable in
DLL,java program can catch that int variable and can update it but If I
run my C++ program(exe) loading same DLL simultaneously it cannot receive
the updated value of that int variable declared in the DLL.
Therefore I need a solution to share/Interchange at least primitive data
and their respective values between a JAVA and C++ Program using JNI (in
spite of date transferring through Sockets).JAVA TO C/C++ & C/C++ to JAVA
using DLLs.
PLEASE HELP ME!! THANK YOU
Mute jQuery Migrate in Ruby on Rails test environment
Mute jQuery Migrate in Ruby on Rails test environment
Our rails project receives a lot of JQMIGRATE message when running tests, eg:
JQMIGRATE: jQuery.fn.attr(selected) may use property instead of attribute
JQMIGRATE: jQuery.browser is deprecated
Obviously it would be good to fix them, but they seem to be due to other
gems anyway.
I've seen reference to jQuery.migrateMute = true, but not sure where to
include it, and more importantly, would like to mute in test environment
but not development. What's the best way?
Our rails project receives a lot of JQMIGRATE message when running tests, eg:
JQMIGRATE: jQuery.fn.attr(selected) may use property instead of attribute
JQMIGRATE: jQuery.browser is deprecated
Obviously it would be good to fix them, but they seem to be due to other
gems anyway.
I've seen reference to jQuery.migrateMute = true, but not sure where to
include it, and more importantly, would like to mute in test environment
but not development. What's the best way?
R Base Graphic: Annotate with logical symbols (and/or)
R Base Graphic: Annotate with logical symbols (and/or)
I would like to add the logical symbols and (È) and or (É) to a base
graph in R.
I figured that the way to go will probably be using an expression, but I
can't figure out how, as their unicode codes \u2227 and \u2228 are not
working. Perhaps because I am on windows (win 7, 64 bit).
What I have:
plot(1, 1, pch = "")
text(1, 1.2, expression(paste("low ", italic(P), "(", italic(p), " and ",
italic(q), "), -1 SD")), cex = 1.2)
text(1, 0.8, expression(paste("low ", italic(P), "(\u00ac", italic(p), "
or ", italic(q), "), -1 SD")), cex = 1.2)
I would like to replace the literal and and or with their symbol counterpart.
I would like to add the logical symbols and (È) and or (É) to a base
graph in R.
I figured that the way to go will probably be using an expression, but I
can't figure out how, as their unicode codes \u2227 and \u2228 are not
working. Perhaps because I am on windows (win 7, 64 bit).
What I have:
plot(1, 1, pch = "")
text(1, 1.2, expression(paste("low ", italic(P), "(", italic(p), " and ",
italic(q), "), -1 SD")), cex = 1.2)
text(1, 0.8, expression(paste("low ", italic(P), "(\u00ac", italic(p), "
or ", italic(q), "), -1 SD")), cex = 1.2)
I would like to replace the literal and and or with their symbol counterpart.
How to merge mdi parent child toolstrip?
How to merge mdi parent child toolstrip?
How can i find toolstrip1 control on child form. This does not work:
private void EUF_MdiChildActivate(object sender, EventArgs e)
{
ToolStripManager.Merge(this.ActiveMdiChild.Controls("toolStrip1"),
toolStrip1);
}
I get an error :
Error 1
Non-invocable member 'System.Windows.Forms.Control.Controls' cannot
be used like a method.
How can i find toolstrip1 control on child form. This does not work:
private void EUF_MdiChildActivate(object sender, EventArgs e)
{
ToolStripManager.Merge(this.ActiveMdiChild.Controls("toolStrip1"),
toolStrip1);
}
I get an error :
Error 1
Non-invocable member 'System.Windows.Forms.Control.Controls' cannot
be used like a method.
Using a function query from Solr
Using a function query from Solr
I'm trying to calculate the tf*idf of a term in my index.
Following Yonik's post from
http://yonik.com/posts/solr-relevancy-function-queries/ I tried
http://localhost:8080/solr/select/?fl=score,id&defType=func&q=mul(tf(texto_completo,bug),idf(texto,bug))
(where texto_completo is the field, and 'bug' is the term) without much
success. The response was:
error 400: The request sent by the client was syntactically incorrect (null).
I went ahead and looked at this answer /a/13477887 so I tried to do a
simpler function query:
http://localhost:8080/solr/select/?q={!func}docFreq(texto_completo,bug)
And yet, I got the same error.
What is my syntax lacking to work properly?
I'm trying to calculate the tf*idf of a term in my index.
Following Yonik's post from
http://yonik.com/posts/solr-relevancy-function-queries/ I tried
http://localhost:8080/solr/select/?fl=score,id&defType=func&q=mul(tf(texto_completo,bug),idf(texto,bug))
(where texto_completo is the field, and 'bug' is the term) without much
success. The response was:
error 400: The request sent by the client was syntactically incorrect (null).
I went ahead and looked at this answer /a/13477887 so I tried to do a
simpler function query:
http://localhost:8080/solr/select/?q={!func}docFreq(texto_completo,bug)
And yet, I got the same error.
What is my syntax lacking to work properly?
WPF XAML - Glassy effect for image
WPF XAML - Glassy effect for image
Is it possible to create a glassy display of an image like the thumbnails
that are contained in this example (for example the thumbnail with the
image of Gordon Ramsay has a nice blue glass effect for the image that i
want to recreate)?
Would you knoe how I should go about tackling it? DropShadowBitmapEffect and
<Border BorderThickness="1"
Height="94" Width="175.5" Margin="3,3,0,3"
HorizontalAlignment="Left" VerticalAlignment="Center">
<Border.BorderBrush>
<SolidColorBrush Color="#FFF9F9F9" Opacity="0.5"/>
</Border.BorderBrush>
<Border.BitmapEffect>
<DropShadowBitmapEffect ShadowDepth="1"
Softness="0.305" Color="#FFF9F9F9"/>
</Border.BitmapEffect>
<Image Name="myImg" Stretch="Fill"/>
</Border>
Is it possible to create a glassy display of an image like the thumbnails
that are contained in this example (for example the thumbnail with the
image of Gordon Ramsay has a nice blue glass effect for the image that i
want to recreate)?
Would you knoe how I should go about tackling it? DropShadowBitmapEffect and
<Border BorderThickness="1"
Height="94" Width="175.5" Margin="3,3,0,3"
HorizontalAlignment="Left" VerticalAlignment="Center">
<Border.BorderBrush>
<SolidColorBrush Color="#FFF9F9F9" Opacity="0.5"/>
</Border.BorderBrush>
<Border.BitmapEffect>
<DropShadowBitmapEffect ShadowDepth="1"
Softness="0.305" Color="#FFF9F9F9"/>
</Border.BitmapEffect>
<Image Name="myImg" Stretch="Fill"/>
</Border>
Android Activity has leaked window
Android Activity has leaked window
I am getting following error in my logcat.
What i am trying to do is to get files from server. The same code is
running f9 with sdcard but when i get files from thorugh thread then i am
getting following error in my logcat.
ERROR/WindowManager(20040): Activity idtech.ESDN.Map has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@416a97b0 that was
originally added here android.view.WindowLeaked: Activity idtech.ESDN.Map
has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@416a97b0 that was
originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:380)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292) at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224) at
android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
at android.view.Window$LocalWindowManager.addView(Window.java:547)
at android.app.Dialog.show(Dialog.java:277)
at idtech.ESDN.Map$LoadFile.onPreExecute(Map.java:59)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
at android.os.AsyncTask.execute(AsyncTask.java:534)
at idtech.ESDN.Map.onActivityResult(Map.java:221)
at android.app.Activity.dispatchActivityResult(Activity.java:5194)
at
android.app.ActivityThread.deliverResults(ActivityThread.java:3180)
at
android.app.ActivityThread.handleSendResult(ActivityThread.java:3227)
at android.app.ActivityThread.access$1100(ActivityThread.java:137)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4838)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
I am getting following error in my logcat.
What i am trying to do is to get files from server. The same code is
running f9 with sdcard but when i get files from thorugh thread then i am
getting following error in my logcat.
ERROR/WindowManager(20040): Activity idtech.ESDN.Map has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@416a97b0 that was
originally added here android.view.WindowLeaked: Activity idtech.ESDN.Map
has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@416a97b0 that was
originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:380)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292) at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224) at
android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
at android.view.Window$LocalWindowManager.addView(Window.java:547)
at android.app.Dialog.show(Dialog.java:277)
at idtech.ESDN.Map$LoadFile.onPreExecute(Map.java:59)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
at android.os.AsyncTask.execute(AsyncTask.java:534)
at idtech.ESDN.Map.onActivityResult(Map.java:221)
at android.app.Activity.dispatchActivityResult(Activity.java:5194)
at
android.app.ActivityThread.deliverResults(ActivityThread.java:3180)
at
android.app.ActivityThread.handleSendResult(ActivityThread.java:3227)
at android.app.ActivityThread.access$1100(ActivityThread.java:137)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4838)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Monday, 19 August 2013
programs to push files to remote copmuter
programs to push files to remote copmuter
Objective: Have a folder on my desktop, drop files into this folder, this
begins a transfer from my computer to a remote computer. if the transfer
is interrupted the transfer should resume from that point.
I have no need of "cloud storage", my objective is only to transfer the
files. I realize that a P2P transfer requires both machines to be online
at the same time, but this is not a problem for my use.
I know command line solutions exist, but I'd prefer a drag and drop
interface.
I'd prefer a solution that includes end to end encryption.
Use case:
I often wish to send large video files from my laptop to my home computer
while traveling.
In my perfect solution, I'd simply drop those files into my "transfer to
home computer" folder. This would begin the transfer. I could shutdown my
laptop at any point (temporarily halting the transfer) and upon rebooting
my latop, the transfer would resume.
Ideas: dropbox ssh teamviewer / vnc / rdp wuala
While teamviewer does contain a file transfer mechanism, but the
teamviewer window must remain open for the duration if the transfer is to
succeed. Also, this method is not robust, no resume is possible after a
disconnection.
Dropbox is not encrypted, and suffers from a storage cap.
ssh is commandline based, and I've found no gui interfaces that will
achieve my objective.
wuala is encrypted, but I can't tell from their info if I can arrange so
that the download begins automatically on my home computer.
Objective: Have a folder on my desktop, drop files into this folder, this
begins a transfer from my computer to a remote computer. if the transfer
is interrupted the transfer should resume from that point.
I have no need of "cloud storage", my objective is only to transfer the
files. I realize that a P2P transfer requires both machines to be online
at the same time, but this is not a problem for my use.
I know command line solutions exist, but I'd prefer a drag and drop
interface.
I'd prefer a solution that includes end to end encryption.
Use case:
I often wish to send large video files from my laptop to my home computer
while traveling.
In my perfect solution, I'd simply drop those files into my "transfer to
home computer" folder. This would begin the transfer. I could shutdown my
laptop at any point (temporarily halting the transfer) and upon rebooting
my latop, the transfer would resume.
Ideas: dropbox ssh teamviewer / vnc / rdp wuala
While teamviewer does contain a file transfer mechanism, but the
teamviewer window must remain open for the duration if the transfer is to
succeed. Also, this method is not robust, no resume is possible after a
disconnection.
Dropbox is not encrypted, and suffers from a storage cap.
ssh is commandline based, and I've found no gui interfaces that will
achieve my objective.
wuala is encrypted, but I can't tell from their info if I can arrange so
that the download begins automatically on my home computer.
Why isn't my JavaScript executing?
Why isn't my JavaScript executing?
pCan anyone please explain to me why this isn't executing. I give up! I
pretty much followed the skeleton code I always do. It's always worked
before, why not now? Hopefully it's not a typo I haven't caught. /p
precode lt;?php session_start(); ?gt; lt;htmlgt; lt;headgt; lt;script
type=text/javascript
src=https://maps.googleapis.com/maps/api/js?sensor=falsegt;lt;/scriptgt;
lt;script src=http://code.jquery.com/jquery-1.9.1.min.jsgt;lt;/scriptgt;
lt;style type=text/cssgt; .phptext { font-family: arial; color: blue;
font-size: 20px; margin-bottom: 20px; } lt;/stylegt; lt;scriptgt; function
verify() { alert('hi'); var email = document.getElementById(email).value;
var month = document.getElementById(month).value; var day =
document.getElementById(day).value; var year =
document.getElementById(year).value; var hour =
document.getElementById(hour).value; var min =
document.getElementById(minutes).value; var message =
document.getElementById(message).value; var date = month + / + day + / +
year; var emailcheck, datecheck, messagecheck = true; emailcheck =
checkEmail(email); messagecheck = checkmessage(message); function
checkEmail(email) {//funciton to check email var regex = /\S+@\S+\.\S+/;
return regex.test(eMail); } function checkmessage(message) {/ var count =
biography.split(/\b\S+\b/g).length - 1; return (count gt; 0 amp;amp; count
lt;= 25) } } lt;/scriptgt; lt;?php
if(isset($_SESSION['loggedin'])amp;amp;$_SESSION['loggedin']==true) { echo
lt;div class = 'phptext'gt; Welcome to the member's area,
.$_SESSION[username].!lt;/divgt;; } else { echo Hmmmmm, you know you need
to be logged in to view this.; die(); } ?gt; lt;/headgt; lt;body align =
center style = padding-top: 40px;gt; lt;form id = form onsubmit = return
verify();gt; lt;div id = emailgt; E-mail: lt;input type=email name=email
id = emailgt; lt;/divgt; lt;div id = dategt; lt;brgt; lt;labelgt;Select
Datelt;/labelgt; lt;brgt; lt;select name = month id = monthgt; lt;option
value = 0gt;Monthlt;/optiongt; lt;option value = 1gt;Januarylt;/optiongt;
lt;option value = 2gt;Februarylt;/optiongt; lt;option value =
3gt;Marchlt;/optiongt; lt;option value = 4gt;Aprillt;/optiongt; lt;option
value = 5gt;Maylt;/optiongt; lt;option value = 6gt;Junelt;/optiongt;
lt;option value = 7gt;Julylt;/optiongt; lt;option value =
8gt;Augustlt;/optiongt; lt;option value = 9gt;Septemberlt;/optiongt;
lt;option value = 10gt;Octoberlt;/optiongt; lt;option value =
11gt;Novemberlt;/optiongt; lt;option value = 12gt;Decemberlt;/optiongt;
lt;/selectgt; lt;select name = day id = daygt; lt;option value =
0gt;Daylt;/optiongt; lt;option value=1gt;1 lt;/optiongt; lt;option
value=2gt;2lt;/optiongt; lt;option value=3gt;3lt;/optiongt; lt;option
value=4gt;4lt;/optiongt; lt;option value=5gt;5lt;/optiongt; lt;option
value=6gt;6lt;/optiongt; lt;option value=7gt;7lt;/optiongt; lt;option
value=8gt;8lt;/optiongt; lt;option value=9gt;9lt;/optiongt; lt;option
value=10gt;10lt;/optiongt; lt;option value=11gt;11lt;/optiongt; lt;option
value=12gt;12lt;/optiongt; lt;option value=13gt;13lt;/optiongt; lt;option
value=14gt;14lt;/optiongt; lt;option value=15gt;15lt;/optiongt; lt;option
value=16gt;16lt;/optiongt; lt;option value=17gt;17lt;/optiongt; lt;option
value=18gt;18lt;/optiongt; lt;option value=19gt;19lt;/optiongt; lt;option
value=20gt;20lt;/optiongt; lt;option value=21gt;21lt;/optiongt; lt;option
value=22gt;22lt;/optiongt; lt;option value=23gt;23lt;/optiongt; lt;option
value=24gt;24lt;/optiongt; lt;option value=25gt;25lt;/optiongt; lt;option
value=26gt;26lt;/optiongt; lt;option value=27gt;27lt;/optiongt; lt;option
value=28gt;28lt;/optiongt; lt;option value=29gt;29lt;/optiongt; lt;option
value=30gt;30lt;/optiongt; lt;option value=31gt;31lt;/optiongt;
lt;/selectgt; lt;select name = year id = yeargt; lt;option value =
0gt;Yearlt;/optiongt; lt;option value = 2011gt;2011lt;/optiongt; lt;option
value = 2012gt;2012lt;/optiongt; lt;option value =
2013gt;2013lt;/optiongt; lt;option value = 2014gt;2014lt;/optiongt;
lt;option value = 2015gt;2015lt;/optiongt; lt;/selectgt; lt;/divgt; lt;div
id = timegt; lt;brgt; lt;labelgt;Select timelt;/labelgt; lt;brgt;
lt;select name = hour id = hourgt; lt;option value = 0gt;Hourlt;/optiongt;
lt;option value = 1gt;01lt;/optiongt; lt;option value =
2gt;02lt;/optiongt; lt;option value = 3gt;03lt;/optiongt; lt;option value
= 4gt;04lt;/optiongt; lt;option value = 5gt;05lt;/optiongt; lt;option
value = 6gt;06lt;/optiongt; lt;option value = 7gt;07lt;/optiongt;
lt;option value = 8gt;08lt;/optiongt; lt;option value =
9gt;09lt;/optiongt; lt;option value = 10gt;10lt;/optiongt; lt;option value
= 11gt;11lt;/optiongt; lt;option value = 12gt;12lt;/optiongt;
lt;/selectgt; lt;select name = minutes id = minutesgt; lt;option value =
0gt;Minute(s)lt;/optiongt; lt;option value = 60gt;00lt;/optiongt;
lt;option value = 30gt;30lt;/optiongt; lt;/selectgt; lt;/divgt; lt;div id
= messagegt; lt;brgt; lt;pgt; Enter Message lt;/pgt; lt;textarea rows=4
cols=50gt;lt;/textareagt; lt;/divgt; lt;div id = buttongt; lt;button id =
submitButton type = submit value = Submitgt; Submit lt;/buttongt;
lt;/divgt; lt;/formgt; lt;/bodygt; lt;/htmlgt; /code/pre
pCan anyone please explain to me why this isn't executing. I give up! I
pretty much followed the skeleton code I always do. It's always worked
before, why not now? Hopefully it's not a typo I haven't caught. /p
precode lt;?php session_start(); ?gt; lt;htmlgt; lt;headgt; lt;script
type=text/javascript
src=https://maps.googleapis.com/maps/api/js?sensor=falsegt;lt;/scriptgt;
lt;script src=http://code.jquery.com/jquery-1.9.1.min.jsgt;lt;/scriptgt;
lt;style type=text/cssgt; .phptext { font-family: arial; color: blue;
font-size: 20px; margin-bottom: 20px; } lt;/stylegt; lt;scriptgt; function
verify() { alert('hi'); var email = document.getElementById(email).value;
var month = document.getElementById(month).value; var day =
document.getElementById(day).value; var year =
document.getElementById(year).value; var hour =
document.getElementById(hour).value; var min =
document.getElementById(minutes).value; var message =
document.getElementById(message).value; var date = month + / + day + / +
year; var emailcheck, datecheck, messagecheck = true; emailcheck =
checkEmail(email); messagecheck = checkmessage(message); function
checkEmail(email) {//funciton to check email var regex = /\S+@\S+\.\S+/;
return regex.test(eMail); } function checkmessage(message) {/ var count =
biography.split(/\b\S+\b/g).length - 1; return (count gt; 0 amp;amp; count
lt;= 25) } } lt;/scriptgt; lt;?php
if(isset($_SESSION['loggedin'])amp;amp;$_SESSION['loggedin']==true) { echo
lt;div class = 'phptext'gt; Welcome to the member's area,
.$_SESSION[username].!lt;/divgt;; } else { echo Hmmmmm, you know you need
to be logged in to view this.; die(); } ?gt; lt;/headgt; lt;body align =
center style = padding-top: 40px;gt; lt;form id = form onsubmit = return
verify();gt; lt;div id = emailgt; E-mail: lt;input type=email name=email
id = emailgt; lt;/divgt; lt;div id = dategt; lt;brgt; lt;labelgt;Select
Datelt;/labelgt; lt;brgt; lt;select name = month id = monthgt; lt;option
value = 0gt;Monthlt;/optiongt; lt;option value = 1gt;Januarylt;/optiongt;
lt;option value = 2gt;Februarylt;/optiongt; lt;option value =
3gt;Marchlt;/optiongt; lt;option value = 4gt;Aprillt;/optiongt; lt;option
value = 5gt;Maylt;/optiongt; lt;option value = 6gt;Junelt;/optiongt;
lt;option value = 7gt;Julylt;/optiongt; lt;option value =
8gt;Augustlt;/optiongt; lt;option value = 9gt;Septemberlt;/optiongt;
lt;option value = 10gt;Octoberlt;/optiongt; lt;option value =
11gt;Novemberlt;/optiongt; lt;option value = 12gt;Decemberlt;/optiongt;
lt;/selectgt; lt;select name = day id = daygt; lt;option value =
0gt;Daylt;/optiongt; lt;option value=1gt;1 lt;/optiongt; lt;option
value=2gt;2lt;/optiongt; lt;option value=3gt;3lt;/optiongt; lt;option
value=4gt;4lt;/optiongt; lt;option value=5gt;5lt;/optiongt; lt;option
value=6gt;6lt;/optiongt; lt;option value=7gt;7lt;/optiongt; lt;option
value=8gt;8lt;/optiongt; lt;option value=9gt;9lt;/optiongt; lt;option
value=10gt;10lt;/optiongt; lt;option value=11gt;11lt;/optiongt; lt;option
value=12gt;12lt;/optiongt; lt;option value=13gt;13lt;/optiongt; lt;option
value=14gt;14lt;/optiongt; lt;option value=15gt;15lt;/optiongt; lt;option
value=16gt;16lt;/optiongt; lt;option value=17gt;17lt;/optiongt; lt;option
value=18gt;18lt;/optiongt; lt;option value=19gt;19lt;/optiongt; lt;option
value=20gt;20lt;/optiongt; lt;option value=21gt;21lt;/optiongt; lt;option
value=22gt;22lt;/optiongt; lt;option value=23gt;23lt;/optiongt; lt;option
value=24gt;24lt;/optiongt; lt;option value=25gt;25lt;/optiongt; lt;option
value=26gt;26lt;/optiongt; lt;option value=27gt;27lt;/optiongt; lt;option
value=28gt;28lt;/optiongt; lt;option value=29gt;29lt;/optiongt; lt;option
value=30gt;30lt;/optiongt; lt;option value=31gt;31lt;/optiongt;
lt;/selectgt; lt;select name = year id = yeargt; lt;option value =
0gt;Yearlt;/optiongt; lt;option value = 2011gt;2011lt;/optiongt; lt;option
value = 2012gt;2012lt;/optiongt; lt;option value =
2013gt;2013lt;/optiongt; lt;option value = 2014gt;2014lt;/optiongt;
lt;option value = 2015gt;2015lt;/optiongt; lt;/selectgt; lt;/divgt; lt;div
id = timegt; lt;brgt; lt;labelgt;Select timelt;/labelgt; lt;brgt;
lt;select name = hour id = hourgt; lt;option value = 0gt;Hourlt;/optiongt;
lt;option value = 1gt;01lt;/optiongt; lt;option value =
2gt;02lt;/optiongt; lt;option value = 3gt;03lt;/optiongt; lt;option value
= 4gt;04lt;/optiongt; lt;option value = 5gt;05lt;/optiongt; lt;option
value = 6gt;06lt;/optiongt; lt;option value = 7gt;07lt;/optiongt;
lt;option value = 8gt;08lt;/optiongt; lt;option value =
9gt;09lt;/optiongt; lt;option value = 10gt;10lt;/optiongt; lt;option value
= 11gt;11lt;/optiongt; lt;option value = 12gt;12lt;/optiongt;
lt;/selectgt; lt;select name = minutes id = minutesgt; lt;option value =
0gt;Minute(s)lt;/optiongt; lt;option value = 60gt;00lt;/optiongt;
lt;option value = 30gt;30lt;/optiongt; lt;/selectgt; lt;/divgt; lt;div id
= messagegt; lt;brgt; lt;pgt; Enter Message lt;/pgt; lt;textarea rows=4
cols=50gt;lt;/textareagt; lt;/divgt; lt;div id = buttongt; lt;button id =
submitButton type = submit value = Submitgt; Submit lt;/buttongt;
lt;/divgt; lt;/formgt; lt;/bodygt; lt;/htmlgt; /code/pre
RegExClean error
RegExClean error
I have a street Name column and in the column the records are like this
**Street_Names**
243 abcd Ex. Strt
342 xcvd Ex. Strt
I need the out put in 3 columns as below
**Column1 column2 column3**
243 abcd Extension Street
342 xcvd Extension Street
I tried using RegexClean Component
match expression: for\s(?<N_Street_Name_N>-?\d\d?)\sN_Street_Names
Replace Expression: ${N_Street_Name_N}
This is just a beginning but I am having a value returned as
NULL
I have a street Name column and in the column the records are like this
**Street_Names**
243 abcd Ex. Strt
342 xcvd Ex. Strt
I need the out put in 3 columns as below
**Column1 column2 column3**
243 abcd Extension Street
342 xcvd Extension Street
I tried using RegexClean Component
match expression: for\s(?<N_Street_Name_N>-?\d\d?)\sN_Street_Names
Replace Expression: ${N_Street_Name_N}
This is just a beginning but I am having a value returned as
NULL
Javascript result into httpcontext.current
Javascript result into httpcontext.current
I have some javascript code in an mvc4 project that returns a string. I
want this to be passed back on every request to the server. I wanted to
avoid the overhead of modifying every controller and page to pass this
thing around and just unify it to every request, can be both post and get.
I didn't know if there was some way to put the javascript result into
httpcontext.current.
I cannot put this in session or viewdata as this is a key on how to access
the session variables.
I have some javascript code in an mvc4 project that returns a string. I
want this to be passed back on every request to the server. I wanted to
avoid the overhead of modifying every controller and page to pass this
thing around and just unify it to every request, can be both post and get.
I didn't know if there was some way to put the javascript result into
httpcontext.current.
I cannot put this in session or viewdata as this is a key on how to access
the session variables.
Sunday, 18 August 2013
How to convert image into nsdata
How to convert image into nsdata
I am using
imageData = UIImagePNGRepresentation(imgvw.image); and while posting [dic
setobject imagedate for key @"image"];
after
NSData *data=[NSJSONSerialization dataWithJSONObject:dic
options:NSJSONWritingPrettyPrinted error:&theError];
now app is crashing Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Invalid type in JSON write
(NSConcreteMutableData)
I am using
imageData = UIImagePNGRepresentation(imgvw.image); and while posting [dic
setobject imagedate for key @"image"];
after
NSData *data=[NSJSONSerialization dataWithJSONObject:dic
options:NSJSONWritingPrettyPrinted error:&theError];
now app is crashing Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Invalid type in JSON write
(NSConcreteMutableData)
Given the E[X] of a discrete uniform random variable...
Given the E[X] of a discrete uniform random variable...
The expected value of a discrete uniform random variable U is 6.5.
a) Find P(U=3).
b) Find the variance of U.
Discrete uniform variables have the following characteristics:
The mean (expected value) is (a+b)/2.
The variance is ((n^2) - 1) / 12.
n = b-a+1.
pmf = 1/n.
My work:
So, I need to find the PMF where U=3. To do that I need to find n. Since I
only have the mean, it follows 6.5 = (a+b)/2. But, I know neither a or b,
so how do I solve? Should my final answer have a variable in it? Is there
another way to figure this out?
wikipedia - uniform discrete distribution
The expected value of a discrete uniform random variable U is 6.5.
a) Find P(U=3).
b) Find the variance of U.
Discrete uniform variables have the following characteristics:
The mean (expected value) is (a+b)/2.
The variance is ((n^2) - 1) / 12.
n = b-a+1.
pmf = 1/n.
My work:
So, I need to find the PMF where U=3. To do that I need to find n. Since I
only have the mean, it follows 6.5 = (a+b)/2. But, I know neither a or b,
so how do I solve? Should my final answer have a variable in it? Is there
another way to figure this out?
wikipedia - uniform discrete distribution
LibGDX and Admob: I don't see the ads
LibGDX and Admob: I don't see the ads
I tried everything, the code works without errors but i don't see my ads.
On my admob account there is no request also...
Here is my code
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View gameView = initializeForView(new com.me.game.App(), false);
AdView adView = createAdView();
RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams adParams =
new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_BASELINE);
LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
layout.addView(adView, adParams);
layout.addView(gameView, layoutParams);
setContentView(layout);
startAdvertising(adView);
}
private AdView createAdView() {
AdView adView = new AdView(this, AdSize.SMART_BANNER,"PUBLISHER_ID");
return adView;
}
private void startAdvertising(AdView adView) {
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("A0FA8C8161016266010B4E4239CD92D5"); // My Test
Device
adView.loadAd(adRequest);
}
}
I tried everything, the code works without errors but i don't see my ads.
On my admob account there is no request also...
Here is my code
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View gameView = initializeForView(new com.me.game.App(), false);
AdView adView = createAdView();
RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams adParams =
new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_BASELINE);
LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
layout.addView(adView, adParams);
layout.addView(gameView, layoutParams);
setContentView(layout);
startAdvertising(adView);
}
private AdView createAdView() {
AdView adView = new AdView(this, AdSize.SMART_BANNER,"PUBLISHER_ID");
return adView;
}
private void startAdvertising(AdView adView) {
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("A0FA8C8161016266010B4E4239CD92D5"); // My Test
Device
adView.loadAd(adRequest);
}
}
Why can I call a subclass method with a superclass pointer in Objective-C?
Why can I call a subclass method with a superclass pointer in Objective-C?
I have two classes, NSMom and NSSon. NSMom is NSSon's super class.
NSMom *mom = [[NSSon alloc] init];
is valid as long as I call NSMom's methods, right?
But how come that mom pointer can call one of NSSon's methods (which is
defined as an additional method in the subclass)?
I have two classes, NSMom and NSSon. NSMom is NSSon's super class.
NSMom *mom = [[NSSon alloc] init];
is valid as long as I call NSMom's methods, right?
But how come that mom pointer can call one of NSSon's methods (which is
defined as an additional method in the subclass)?
Sass not compiling in textmate
Sass not compiling in textmate
I'm trying to use SASS for the first time with textmate. I seem to have
installed it correctly by following the instructions on the git page -
https://github.com/MarioRicalde/SCSS.tmbundle but I can't find any
information on how I can now use it.
When I make a .sass file the new Sass syntax is highlighted but when I
save it is not compiled. Am I missing something?
I'm trying to use SASS for the first time with textmate. I seem to have
installed it correctly by following the instructions on the git page -
https://github.com/MarioRicalde/SCSS.tmbundle but I can't find any
information on how I can now use it.
When I make a .sass file the new Sass syntax is highlighted but when I
save it is not compiled. Am I missing something?
Does anybody know the reason why QuotationEvaluator is so slow?
Does anybody know the reason why QuotationEvaluator is so slow?
It's common knowledge in the F# community that the PowerPack's quotation
compiling facility produces very slow code, so slow in fact that it
performs even worse than naive interpretation. I've been looking into the
reasons for this, but I haven't been able to find a convincing answer so
far. There have been claims that this happens either because of
inefficient representation of things like pattern matches in quotations or
because of an inherent inefficient with Expression Trees used by the
library. I'd like to illustrate why I think neither is true with a simple
example:
#r "FSharp.Powerpack.Linq.dll"
open System
open System.Linq.Expressions
open Microsoft.FSharp.Quotations.Patterns
let powerpack = Microsoft.FSharp.Linq.QuotationEvaluator.Compile <@ 1 + 1 @>
// explicitly rewrite above quotation with expression trees
let expressionTree =
let (Call(_,addM,_)) = <@ 1 + 1 @>
let constExpr (x : 'T) = Expression.Constant(box x, typeof)
let eval = Expression.Call(addM, constExpr 1, constExpr 1)
let lambda = Expression.Lambda>(eval)
lambda.Compile()
#time
// QuotationEvaluator ~ 2.5 secs
for i in 1 .. 1000000 do
powerpack () |> ignore
// native evaluation ~ 1 msec
for i in 1 .. 1000000 do
(fun () -> 1 + 1) () |> ignore
// naive expression tree ~ 19 msec
for i in 1 .. 1000000 do
expressionTree.Invoke () |> ignore
Something clearly goes wrong here. The question is, what?
It's common knowledge in the F# community that the PowerPack's quotation
compiling facility produces very slow code, so slow in fact that it
performs even worse than naive interpretation. I've been looking into the
reasons for this, but I haven't been able to find a convincing answer so
far. There have been claims that this happens either because of
inefficient representation of things like pattern matches in quotations or
because of an inherent inefficient with Expression Trees used by the
library. I'd like to illustrate why I think neither is true with a simple
example:
#r "FSharp.Powerpack.Linq.dll"
open System
open System.Linq.Expressions
open Microsoft.FSharp.Quotations.Patterns
let powerpack = Microsoft.FSharp.Linq.QuotationEvaluator.Compile <@ 1 + 1 @>
// explicitly rewrite above quotation with expression trees
let expressionTree =
let (Call(_,addM,_)) = <@ 1 + 1 @>
let constExpr (x : 'T) = Expression.Constant(box x, typeof)
let eval = Expression.Call(addM, constExpr 1, constExpr 1)
let lambda = Expression.Lambda>(eval)
lambda.Compile()
#time
// QuotationEvaluator ~ 2.5 secs
for i in 1 .. 1000000 do
powerpack () |> ignore
// native evaluation ~ 1 msec
for i in 1 .. 1000000 do
(fun () -> 1 + 1) () |> ignore
// naive expression tree ~ 19 msec
for i in 1 .. 1000000 do
expressionTree.Invoke () |> ignore
Something clearly goes wrong here. The question is, what?
Error calling activity with receiver
Error calling activity with receiver
I have a Receiver that gets SMS but I try to call an Activity with an
Intent as shown below: public class Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
Bundle mBundle = arg1.getExtras();
SmsMessage[] messages = null;
String strMessage = "";
if (mBundle != null)
{
Object[] duster = (Object[]) mBundle.get("pdus");
messages = new SmsMessage[duster.length];
for (int k = 0; k < messages.length; k++)
{
messages[k] = SmsMessage.createFromPdu((byte[])duster[k]);
strMessage += messages[k].getMessageBody().toString();
}
//Toast.makeText(arg0, "Hi", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, Popups.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("message", "My popup number " + 1);
context.startActivity(intent);
}
}
}
But when I try to do this, I get this error. Anyone know what I am doing
wrong? I have the Permissions RECEIVE_SMS and PROCESS_OUTGOING_CALLS
E/AndroidRuntime(32612): java.lang.RuntimeException: Unable to start receiver
com.example.textalerts.Receiver:
android.content.ActivityNotFoundException: Unable to fin
d explicit activity class
{com.example.textalerts/com.example.textalerts.Popups}; have you
declared this activity in your AndroidManifest.xml?
I have a Receiver that gets SMS but I try to call an Activity with an
Intent as shown below: public class Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
Bundle mBundle = arg1.getExtras();
SmsMessage[] messages = null;
String strMessage = "";
if (mBundle != null)
{
Object[] duster = (Object[]) mBundle.get("pdus");
messages = new SmsMessage[duster.length];
for (int k = 0; k < messages.length; k++)
{
messages[k] = SmsMessage.createFromPdu((byte[])duster[k]);
strMessage += messages[k].getMessageBody().toString();
}
//Toast.makeText(arg0, "Hi", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, Popups.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("message", "My popup number " + 1);
context.startActivity(intent);
}
}
}
But when I try to do this, I get this error. Anyone know what I am doing
wrong? I have the Permissions RECEIVE_SMS and PROCESS_OUTGOING_CALLS
E/AndroidRuntime(32612): java.lang.RuntimeException: Unable to start receiver
com.example.textalerts.Receiver:
android.content.ActivityNotFoundException: Unable to fin
d explicit activity class
{com.example.textalerts/com.example.textalerts.Popups}; have you
declared this activity in your AndroidManifest.xml?
Saturday, 17 August 2013
Repeat colnames in R
Repeat colnames in R
I'm trying to figure out how to repeat a set of column names. Sometimes
I'll have 1 set of columns to name and some other times I'll have 4 sets
of columns to names. For example:
1 set of column names:
r a
2 set of column names:
r a r a
I've tried using this for loop:
for(cnt in 1 numSetCol){
colnames(data[,cnt]) <- "r"
colnames(data[,cnt+1]) <- "a"
cnt <- cnt + 2
}
I get the error: attempt to set colnames on object with less than two
dimensions.
Any help on how to do this would be great.
Thanks!
I'm trying to figure out how to repeat a set of column names. Sometimes
I'll have 1 set of columns to name and some other times I'll have 4 sets
of columns to names. For example:
1 set of column names:
r a
2 set of column names:
r a r a
I've tried using this for loop:
for(cnt in 1 numSetCol){
colnames(data[,cnt]) <- "r"
colnames(data[,cnt+1]) <- "a"
cnt <- cnt + 2
}
I get the error: attempt to set colnames on object with less than two
dimensions.
Any help on how to do this would be great.
Thanks!
What is the best approach for Android Service and data communication
What is the best approach for Android Service and data communication
I am looking for the best approach to share data between a service and 2
different clients (an app and a widget). Currently my application kicks
off a thread that downloads a large amount of data every 15 seconds or so
in the background, stuffs them into an object graph, which is then
consumed by the main app on a configurable time interval. This works for
the primary app but isn't sufficient for the widget that I want to develop
as well, because the object graph will be out of process (and the approach
is kind of messy IMO).
So I am looking to extract the data retrieval part into a service (or if
there is a better suggestion, something else). My question is, what is the
best way to communicate the data received from this service with the
clients? Or would you not use a service and instead use something else?
Because of the overhead on the client, I want the service to notify the
clients when data is ready as opposed to the client continuously polling
the service.....if possible...of course.
I have looked at broadcasting the intent (both app and widget would
receive) but I think I have to serialize the entire object graph and then
inflate it in the client in order to do that. Is that correct? I am
concerned with the speed at which I can accomplish the re-inflate client
side.
Is there a better way to ship the data back to the clients? I would prefer
to ship the objects if that is possible and not serialize...but if that is
the best way, then I will do it.
Any help is greatly appreciated!
I am looking for the best approach to share data between a service and 2
different clients (an app and a widget). Currently my application kicks
off a thread that downloads a large amount of data every 15 seconds or so
in the background, stuffs them into an object graph, which is then
consumed by the main app on a configurable time interval. This works for
the primary app but isn't sufficient for the widget that I want to develop
as well, because the object graph will be out of process (and the approach
is kind of messy IMO).
So I am looking to extract the data retrieval part into a service (or if
there is a better suggestion, something else). My question is, what is the
best way to communicate the data received from this service with the
clients? Or would you not use a service and instead use something else?
Because of the overhead on the client, I want the service to notify the
clients when data is ready as opposed to the client continuously polling
the service.....if possible...of course.
I have looked at broadcasting the intent (both app and widget would
receive) but I think I have to serialize the entire object graph and then
inflate it in the client in order to do that. Is that correct? I am
concerned with the speed at which I can accomplish the re-inflate client
side.
Is there a better way to ship the data back to the clients? I would prefer
to ship the objects if that is possible and not serialize...but if that is
the best way, then I will do it.
Any help is greatly appreciated!
Subscribe to:
Comments (Atom)