Saturday, 31 August 2013

Bootstrap Popover on Input : hover

Bootstrap Popover on Input : hover

I'm using simple form and trying to get the popover working for an Input.
The form Input:
<p>
<%= f.input :title, input_html: { class: 'login-form-block' },
:autofocus=>true, label: false, placeholder: "Title",
:hint => "Enter a Title for your Clip" %>
</p>
I added addclip.js to vendors/assets/javascripts and //= require
addclip.js in my application.js
I'm trying to get the popover work upon hovering the input field
Bootstrap Docs say:
Options can be passed via data attributes or JavaScript. For data
attributes, append the option name to data-, as in data-animation="".
and i guess i need the hover option

Could someone help me combine everything together and explain me the
Javascript i have to include to get this working, for my input?

Sivlerlight application not bring data through Wcf service on drop box

Sivlerlight application not bring data through Wcf service on drop box

I have created a silverlight application and my db is on some host, i have
connected my db to silverlight application through wcf service, it runs
well on my pc, and bring data from db. But when i host it on dropbox
public folder, it runs but db data not coming. i have

How to send not declared selector without performSelector:?

How to send not declared selector without performSelector:?

Background: I have an object (let's call it BackendClient) that represents
connection with server. Its methods are generated to single @protocol and
they are all synchronous, so I want to create proxy object that will call
them in background. The main problem is return value, which I obviously
can't return from async method, so I need to pass a callback. The "easy"
way will be copy all BackendClient's methods and add callback argument.
But that's not very dynamic way of solving that problem, while ObjectiveC
nature is dynamic. That's where performSelector: appears. It solves
problem entirely, but it almost kills proxy object transparency.
Problem: I want to be able to send not declared selector to proxy
(subclass of NSProxy) object as if it was already declared. For example, I
have method:
-(AuthResponse)authByRequest:(AuthRequest*)request
in BackendClient protocol. And I want proxy call look like this:
[proxyClient authByRequest:myRequest withCallback:myCallback];
But this wouldn't compile because
No visible @interface for 'BackendClientProxy' declares the selector
'authByRequest:withCallBack:'
OK. Let's calm down compiler a bit:
[(id)proxyClient authByRequest:myRequest withCallback:myCallback];
Awww. Another error:
No known instance method for selector 'authByRequest:withCallBack:'
The only thing that comes to my mind and this point is somehow construct
new @protocol with needed methods at runtime, but I have no idea how to do
that.
Conclusion: I need to suppress this compilation error. Any idea how to do
that?

addClass converting from JQuery to MooTools

addClass converting from JQuery to MooTools

I have Kunena forum template for Joomla that use MooTools 1.4. I
integrated in this theme bootstrap tooltip functionality and addedd
MooTools addClass to trigger tooltips in some classess. I checked MooTools
doc's and the code should looks like below:
$$('h3 a, .tk-page-header h1 .tk-latestpost a, .tk-topic-title a,
.tk-topic-info a, .tk-preview-avatar a, .tk-social-icons a,
.kpost-user-icons a, .kicon-profile, .tk-user-info-body li a,
span.kkarma-plus, span.kkarma-minus, .btnImage').addClass(' hasTooltip');
Above code can be seen on http://jsfiddle.net/AgpbL/ (scroll to the bottom)
Unfortunately it doesn't work, so I created jQuerry script
jQuery(document).ready(function(a){
a("h3 a, .tk-page-header h1 .tk-latestpost a, .tk-topic-title a,
.tk-topic-info a, .tk-preview-avatar a, .tk-social-icons a,
.kpost-user-icons a, .kicon-profile, .tk-user-info-body li a,
span.kkarma-plus, span.kkarma-minus, .btnImage").addClass("
hasTooltip");
});
(jQuery);
and it works very well itself. Unfortunately it cause a conflict with
MooTools so I went back to MooTools and (after searching stackoverflow) I
created another code:
$$('h3 a, .tk-page-header h1 .tk-latestpost a, .tk-topic-title a,
.tk-topic-info a, .tk-preview-avatar a, .tk-social-icons a,
.kpost-user-icons a, .kicon-profile, .tk-user-info-body li a,
span.kkarma-plus, span.kkarma-minus, .btnImage').addEvents({
'mouseenter': function() { $(this).addClass(' hasTooltip'); },
'mouseleave': function() { $(this).removeClass(' hasTooltip'); }
});
and no effect again.
Comparing basic myElement.addClass(className); MooTools to .addClass(
className ) jQuery I couldn't find big differences but obviously something
is wrong I'm not able to understand.
Any help or pointing to elsewhere is much appreciated.

MySQL use of LEFT JOIN vs WHERE col1=col2

MySQL use of LEFT JOIN vs WHERE col1=col2

I'm curious about the difference between using joins (the different types
of 'join') and using WHERE table1.col1 = table2.col2.
Here is my specific example I did to "test" my knowledge:
$cxn = mysqli_connect($host,$user,$password,$dbname);
if (mysqli_connect_errno()) {echo "No connection" . mysqli_connect_error();}
$query = " SELECT icd9.icd9codenodot,
icd9.icd9code,
icd9.icd9short,
icd10.icd10code,
icd10.icd10short ".
" FROM icd9, icd9icd10gem, icd10 ".
" WHERE (icd9.icd9long LIKE '%$firstword%') AND
(icd9.icd9codenodot = icd9icd10gem.icd9) AND
(icd10.icd10code = icd9icd10gem.icd10)";
$query = " SELECT icd9.icd9codenodot,
icd9.icd9code,
icd9.icd9short,
icd10.icd10code,
icd10.icd10short ".
" FROM icd9 LEFT JOIN (icd9icd10gem, icd10)
ON (icd9icd10gem.icd9 = icd9.icd9codenodot AND
icd9icd10gem.icd10 = icd10.icd10code)".
" WHERE (icd9.icd9long LIKE '%$firstword%')";
$result = mysqli_query($cxn, $query) or die ("could not query database 1");
while ($row = mysqli_fetch_array($result))
{
echo stuff
}
Fluency in any "language" requires the ability to express a single concept
in a variety of ways, and since I'm doing pretty good at the WHERE
table1.var1 = table2.var2 type of "join" I thought I'd try to use the
formal "join".
To use the script I comment out one of the queries, run it, then comment
out the other query and run it. (the relevant lines have the * in front of
them)
Both of them produce almost exactly the same result (one orders the rows a
little differently, but the overall result is the same).
On this forum, I've found a comment from one programmer to that effect
that (s)he doesn't like joins and only does the WHERE table1.var1 =
table2.var2.
My question: 1. Is there a reason why I/a person should use one technique
(join) over the other (WHERE table1.var1 = table2.var2 - which in reality
is a "type" of join)?
Thanks very much for any comments.

Fedex Special Rate Request using python-fedex

Fedex Special Rate Request using python-fedex

I am having a problem with fedex rate service request. I need to get the
Saturday Delivery rate from fedex. How can i get this? I am using
python-fedex module.
I have tried using
rate_request.RequestedShipment.ServiceType = None
rate_request.VariableOptions = 'SATURDAY_DELIVERY'
with other parameters. Please give me some hints. I am just stucked with it.
Thanks, Sohel.

MySQL query to find unmapped result

MySQL query to find unmapped result

The question title is a little bit vague as I don't know how to explain it
briefly.
I have 3 tables:
Project (projectid, name, description)
Person(personid, name, description)
ProjectPerson(projectid, personid)
Project and Person has a many to many relationship through ProjectPerson
table
I want to create an SQL Query to find all persons that is not in any Project.
I have a solution: get all persons, get all entries in ProjectPerson and
remove person entries that exist in ProjectPerson.
However it seems a little bit stupid. Could anyone advise me a better way?
Thanks in advance

Friday, 30 August 2013

Removing specific lines in text file

Removing specific lines in text file

So, I've been working a bit on a personal project, and mainly just for
practice as I'm just an apprentice to Python. I've learnt a lot, and I am
starting to do my own projects so that I can learn interactively and learn
a lot more.
The project I've been doing recently is basically a homework
planner/recorder, where you can input homework assignments so to say, see
all your homework assignments, clear the file, etc. Now, I've been working
on the most recent where it would remove a specific line (homework
assignment) of the file and I have no idea on how to do this the most
efficient way.
I understand there's no real way to remove a specific line from a file,
but I just can't get my hand around how I'd do it. So, for example, say I
have 5 homework assignments in the file.
1st Homework
2nd Homework
3rd Homework
4th Homework
5th Homework
Now, I want to remove the first line, so I get to the removing HW function
(by typing !delhw) and then it retrieves my homework assignments, shows me
them on the screen,a nd I gotta type in 0-4. I want to delete the first
homework assignment so I type in 0, and then it removes that line and
there we go.
Could someone explain to me a few ways I could go about this? My first
thought was I'd have to write everything in the initial file over to
another, then write it back except for the 1st line if I typed in 0 and
same for every line.

Thursday, 29 August 2013

Eclipse+Derby - Program runs outside; Classpath+Eclipse conflict?

Eclipse+Derby - Program runs outside; Classpath+Eclipse conflict?

When running the SimpleApp example from the Apache Derby packet by command
line (java SimpleApp) it works flawless, so the classpath must be set
correctly. But when running inside Eclipse the
"java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver"
error occurrs.
Could it be that eclipse somehow doesn't take the current classpath into
account?
(Running on Win7x64, JRE+JDK7.25, Derby 10.10.1.1,
CLASSPATH=C:\Users\User\Desktop\eclipse\workspace\db-derby-10.10.1.1-bin\lib\der
by.jar;C:\Users\User\Desktop\eclipse\workspace\db-derby-10.10.1.1-bin\lib\derbyt
ools.jar;.)

Circle shaped texture libGdx

Circle shaped texture libGdx

I've been searching for answer for about 2 hours now and I haven't found
my desired answer. My question is, Is it possible, and how, to draw a
circle-shaped texture, so that outside the circle, texture would be
transparent, is it even possible?
Thanks in advance! This site has been a great help so far!

Wednesday, 28 August 2013

What is the purpose of specifying captured variable in lambda expression?

What is the purpose of specifying captured variable in lambda expression?

I have this code:
int i = 0;
[&i](){i++;}();
But I can omit i and just use:
[&](){i++;}();
What is the purpose of specifying &i? (and similarly =var and =). Is it
affecting compile time or runtime performance?

Searching multiple columns in a text_field_tag

Searching multiple columns in a text_field_tag

3.5 and ruby 1.8.7 I'm trying to create a multiple search working with 4
columns (name,name2,last_name,last_name2), want to search in a text box my
4 columns but i don't want to create 24 conditions, is there any other way
to do this or maybe creating a conditional FOR instead of 24 conditions
I want to search by
name and name2
name and name2 and last_name
name and last_name
last_name and last_name2
...
There are 24 conditions
Actually my controller is working but i don't want to write 24 conditions
, here is my problem
**Here is my model**
class Project < ActiveRecord::Base
end
*************Here is my controller****************
class ProjectsController < ApplicationController
def index
@projects = Project.find(:all, :conditions => "(
name LIKE \"#{params[:query]}%\" OR
name2 LIKE \"#{params[:query]}%\" OR
last_name LIKE \"#{params[:query]}%\" OR
last_name2 LIKE \"#{params[:query]}%\" OR
(concat(name, \" \", last_name) LIKE \"#{params[:query]}%\")OR
(concat(name, \" \", name2 ) LIKE \"#{params[:query]}%\")OR
(concat(last_name, \" \", last_name2) LIKE \"#{params[:query]}%\")OR
(concat(name, \" \", name2, \" \",last_name, \" \",last_name2) LIKE
\"#{params[:query]}%\")OR
(concat(name, \" \", name2, \" \",last_name) LIKE
\"#{params[:query]}%\")) ")
end
end
Here is search form
*********************Here is my view
<div id="search-area">
<div id="searchbox">
<form name="search-form" id="search-form">
<label for="query"><%= ('BUSCAR') %>
<%= image_tag("loader.gif",
:align => "absmiddle",
:border => 0,
:id => "loader",
:style =>"display: none;" ) %>
</label>
<%= text_field_tag "query", params[:query], :autocomplete => 'on' %>
</form>
</div>
</div>
Someone can help me to convert this in a conditional for? or maybe other
way to find 4 columns in a text_field_tag

Can't get jQuery .each() to work

Can't get jQuery .each() to work

I have this HTML code in 3 sections of my page:
<div class="pjesmarrje">
<a href="#"
onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href),'facebook-share-dialog','width=626,height=436');
return false;">
<div></div>
<span>Kliko këtu për pjesëmarrje</span>
</a>
</div>
And, I am trying to change the background image of the div inside when its
clicked. I got this jQuery code:
$(document).ready(function() {
$(".pjesmarrje").click(function() {
$(".pjesmarrje div").css("background-image",
"url(images/mumanin_s2.png)");
});
});
When I click one of the elements, all the others get their background
images changed too. I don't want that to happen, I want the bg image to be
changed only when that particular element is clicked. I tried to use the
.each() function, but it didn't work.
Any help is appreciated. Thanks.

Excel report from TFS for all testing effort including exploratory testing sessions

Excel report from TFS for all testing effort including exploratory testing
sessions

We are currently producing weekly reports on test team performance using
Excel via the Cube and these have worked well up to now. We report on
weekly testing statistics for test cases executed and their outcome, bugs
raised and work items updated, etc.
With the introduction of exploratory testing during this sprint of testing
any exploratory sessions performed are not included in the testing
statistics, and the pivot table field list does not seem to include any
options for the exploratory sessions.
Could someone please help identify if this is possible?
After a Google search I was only able to locate details of how to run
exploratory test sessions and how to view testing results from the Test
Plan in Test Manager 2012.

How to change alert message in alertbox in wpf

How to change alert message in alertbox in wpf

I'd like to display message in alertbox based on how many days left till
the deadline, say if there is one day left, the alertbox comes out and say
"One day left of your renewal date!". I use the following code
if ((RenewalDate.Value - DateTime.Now).TotalDays == 5)
MessageBox.Show("Your deadline is within 5
days");
else if ((RenewalDate.Value -
DateTime.Now).TotalDays == 4)
MessageBox.Show("Your deadline is 4 days left");
else if ((RenewalDate.Value -
DateTime.Now).TotalDays == 3)
MessageBox.Show("Your deadline is 3 days left");
else if ((RenewalDate.Value -
DateTime.Now).TotalDays == 2)
MessageBox.Show("Your deadline is 2 days left");
else if ((RenewalDate.Value -
DateTime.Now).TotalDays == 1)
MessageBox.Show("Your deadline is 1 days left");
But it does not work. I have no idea why. Any ideas? Thanks in advance. My
code as follows:
private int _OrganisationID = 1;
private DateTime? _RenewalDate;
public event PropertyChangedEventHandler PropertyChanged;
[Required(ErrorMessage = "OrganisationID is required.")]
public int OrganisationID
{
get { return _OrganisationID; }
set
{
if (_OrganisationID == value)
return;
_OrganisationID = value;
PropertyChanged(this, new
PropertyChangedEventArgs("OrganisationID"));
}
}
[Required(ErrorMessage = "RenewalDate is a required field.")]
public DateTime? RenewalDate
{
get { return _RenewalDate; }
set
{
_RenewalDate = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new
PropertyChangedEventArgs("RenewalDate"));
}
}
}
DispatcherTimer timer = new DispatcherTimer();
// DateTime myDeadLine = new DateTime();
public void InitTimer()
{
// Checks every minute
timer.Interval = new TimeSpan(0, 1, 0);
timer.Tick += timer_Tick;
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
//if (( RenewalDate.Value - DateTime.Now).TotalDays <= 1)
// MessageBox.Show("Your Alert Message");
}
private void TabControl_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
if (e.Source is TabControl)
{
if (ClientDeadLines.IsSelected)
{
using (var context = new ProActiveDBEntities())
{
var org = context.Organisations.Where(o =>
o.OrganisationID == this.OrganisationID).FirstOrDefault();
if (org != null)
{
RenewalDate = org.RenewalDate;
if ((RenewalDate.Value - DateTime.Now).TotalDays <= 2)
MessageBox.Show("Your Alert Message");
}
else
{
MessageBox.Show("Unable to retrieve data, please set
up organsiation first.");
}
}
}
}
}

Tuesday, 27 August 2013

AutoReturn and Link-back don't work

AutoReturn and Link-back don't work

I have a Payment page setup and I have followed through the docs on
PayPal's website and I have tried to make it so that the user is
automatically redirected back to my website (thank you page - using
AutoReturn) i have also set a return url in the PayPal buy now button form
code on my page - but after i completed test payment (and also a LIVE test
payment), the page stayed at paypal and did not redirect back to my site -
and there was no way to get back to my site from that paypal page. There
was no link that said "go back to mysite.com" or whatever like there
usually is.
Now I'm wondering, why? It's a little inconvenient for users. Even
confusing. How do I make PayPal take them back to my site? I've followed
PayPal's instructions and I've spent days going over it but it just
doesn't do it.

Deleting from parent object a child object when something happens in a child's internal thread C#

Deleting from parent object a child object when something happens in a
child's internal thread C#

Let's say I have ObjectA (of classA), which contains:
List<classB> bList;
now let's suppose that in each objectB there are a couple of threads which
are running (they can't be accessed from outisde objectB), threadB1 and
threadB2.
Now, in a certain objectB of such list, threadB2 discovers that
objectBRemove==true.
When that happens, I want to terminate all threads from such object and
remove it from bList (I effectively want to destroy this objectB).
I thought I could rise an event inside objectB and subscribe a objectA's
method to such event:
public void onObjectBRemove(object sender, EventArgs e)
{
bList.Remove((classB)sender);
}
When this is called after objectB's event rising this should remove
objectB from the list. Then, the garbage collector should notice objectB
becoming unreferenced and thus deleting it, also terminating all internal
threads.
Is this supposed to work? Is this a reasonable approach to the problem at
hand? Thanks.

How to access a List collection across winforms

How to access a List collection across winforms

I have a list of this custom class.
public class Item
{
public string @Url;
public string Name;
public double Price;
public Item(string @url, string name, double price)
{
this.Url = url;
this.Name = name;
this.Price = price;
}
public void setPrice(Button button)
{
this.Price = Convert.ToDouble(button.Text);
}
}
Now in my main winform this is declared
List<Item> items = new List<Item>();
the fields are set through an add button as following they take
information from 3 text boxes and store it in a new item.
Regex url = new
Regex(@"^[a-zA-Z0-9\-\.]+\.(com|org|net|ca|mil|edu|COM|ORG|NET|CA|MIL|EDU)$");
Regex name = new Regex(@"^[0-9, a-z, A-Z, \-]+$");
Regex price = new Regex(@"^[0-9, \.]+$");
if (url.IsMatch(urlText.Text) && name.IsMatch(nameText.Text) &&
price.IsMatch(priceText.Text))
{
itemListBox.Items.Add(nameText.Text);
double item_Price = Convert.ToDouble(priceText.Text);
items.Add(new Item(@itemURL.Text, itemName.Text, item_Price));
nameText.Clear();
priceText.Clear();
urlText.Clear();
}
else
{
match(url, urlText, urlLabel);
match(price, priceText, priceLabel);
match(name, nameText, nameLabel);
}
As you can see in the above code it also adds the name of the item to an
item list box. Now I have another windows form that pop's up when the edit
button is clicked. How can i make the item list box in the edit form show
exactly like the item list box from the main windows form?
In a basic question how can i transfer the list of items to the edit form.
I've tried passing it through a constructor because I want the edited
information to remain constant no matter what winform. the constructor was
declared in the Edit Form:
public Edit(ref List<Item> i)
{
itemList = i;
InitializeComponent();
}

Using LINQ's .Any() on a DataTable

Using LINQ's .Any() on a DataTable

I have a datatable loaded up with some records and I am then pulling a
query from another file and want to check if the ID that I pull in this
query exists in my datatable.
foreach (var item in records)
{
bool hasit = dt.AsEnumerable().Any(p => p.Field<string>(0) == item.ID);
if (!hasit)
{
//Logic
}
}
I'm using that .Any() function and expecting it to return true if there is
an ID in the first field of the datatable that matches the id in the
records collection. It continually returns false though, am I missing
something? Is there a better way to do this?

Strange syslog for my server

Strange syslog for my server

Today i go on my log with nano /var/log/syslog
I have this, and i think it's not very good :
http://gyazo.com/67a357b3fd2bb5f77089aafd01f64229.png
I wonder if there is a cron job to not running in a vacuum ...
I post /var/log/auth.log too :
http://gyazo.com/343054d2233d2fab80f6a8dd3890151d.png
Thx for yout help :)
Link :

How can I use Cancan permissions to filter the papertrail versions that I retrieve for a timeline?

How can I use Cancan permissions to filter the papertrail versions that I
retrieve for a timeline?

I have a few models with version changes I am tracking using Papertrail. I
want to pull out the version for a timeline view of recent activity, but
users should only see changes to models which they have permission to
view.
I use Cancan to control access to all areas of the app, and the Ability
class has all the business logic I need. However, it specifies the model
name e.g. Post in the rulesets, whereas PaperTrail uses the Version model
to store changes.
How can I (efficiently) tie the two systems together so that I can ask the
DB to only return Version models where the associated model is visible to
the user? I can do this by just getting the whole timeline of the whole
site and looping over it in Ruby, but this is not scalable and I need to
use scopes so that it happens in SQL.

Unable to connect to the Report Server

Unable to connect to the Report Server

SQL Server 2008 R2 Express
Report Services Configuration Manager
When I launch it, shows correct Server Name, but report server instance is
blank. When I press FIND I get:
"Unable to connect to the Report Server ".
I tried uninstalling SQL Server completely, rebooting, reinstalling a
fresh download. Same result. I've googled every article I can find -
nothing.
Can anyone point me in the right direction? Thanks.

Monday, 26 August 2013

trouble aligning div side by side

trouble aligning div side by side

I'm trying to get the shoutbox on www.talkjesus.com (vBulletin forum) to
float left while the verse of the day (orange) to float on the very right
side of the shoutbox. I've tried so many variations but it's not working,
I'm stuck. Your help appreciated.
The forumhome template code I'm using now is:
<div class="blockbody formcontrols floatcontainer">
<div id="wgo_onlineusers" class="wgo_subblock">
<h3 class="blocksubhead"
style="background-color:#82BA1B; color: #fff
!important; font-size: 22px; font-weight:
300">shoutbox</h3>
<div style="text-align: center; line-height: 0" class="blockrow">
<div><iframe frameborder="0" width="100%" height="200"
src="http://www.cbox.ws/box/?boxid=439&amp;boxtag=7868&amp;sec=main"
marginheight="2" marginwidth="2" scrolling="auto"
allowtransparency="yes" name="cboxmain1-439"" id="cboxmain1-439"
style="border-bottom: 1px solid #e4e4e4;"></iframe></div>
<div style="position:relative"><iframe frameborder="0" width="350"
height="70"
src="http://www.cbox.ws/box/?boxid=439&amp;boxtag=7868&sec=form&nme={vb:raw
cboxnme}&nmekey={vb:raw cboxkey}&pic={vb:raw cboxav}&lnk={vb:raw
cboxav}" marginheight="2" marginwidth="2" scrolling="no"
allowtransparency="yes" name="cboxform1-439"
id="cboxform1-439"></iframe></div>
</div>
</div>
</div>
<br />
<div class="blockbody formcontrols floatcontainer">
<div id="wgo_onlineusers" class="wgo_subblock">
<h3 class="blocksubhead" style="background-color:#E66B1B; color: #fff
!important; font-size: 22px; font-weight: 300">verse of the day</h3>
<div>
<div style="font-size:16px; line-height:28px; padding:10px; color:
#797979">
<script type="text/javascript"
src="http://www.christnotes.org/syndicate.php?content=dbv&amp;type=js2&amp;tw=auto&amp;tbg=ffffff&amp;bw=0&amp;bc=000000&amp;ta=L&amp;tc=43A6DF&amp;tf=Open
Sans&amp;ts=14&amp;ty=B&amp;va=L&amp;vc=43A6DF&amp;vf=Open
Sans&amp;vs=12&amp;tt=3&amp;trn=NASB
"></script>
</div>
</div>
</div>
</div>

Editing a gridview with AutoGenerateEditButton = true

Editing a gridview with AutoGenerateEditButton = true

I created a gridview dynamically and added the AutoGenerateEditButton =
true; property and i see that it adds the edit link to all the fields when
it loads the table into the gridview. But when i click the edit button
nothing happens, except for a postback. What am i doing wrong?
GridView gridData = new GridView();
gridData.ID = "test";
gridData.AutoGenerateEditButton = true;
gridData.RowEditing += (sender, e) => grid_RowEditing(tbl, e,
sender);
gridData.DataSource = tbl;
gridData.DataBind();
protected void grid_RowEditing(DataTable tbl, GridViewEditEventArgs e,
object sender)
{
((GridView)sender).EditIndex = e.NewEditIndex;
// call your databinding method here
((GridView)sender).DataSource = tbl ;
((GridView)sender).DataBind();
}

Unity Tweak Tool won't Launch Ubuntu 13.04

Unity Tweak Tool won't Launch Ubuntu 13.04

I am having a problem with unity tweak tool. I use unity as my desktop
(actually laptop) interface. When I downloaded it and opened it for the
first time, it came with an error saying it crashed and needed to
relaunch, so I relaunched but to no prevail. then one forum suggested to
download the new beta version from specific repositories, but after I did
that and I tried to launch nothing happened. Then I tried it on terminal
and here is what it said
samuel@KVT-Linux:~$ sudo unity-tweak-tool
[sudo] password for samuel:
schema com.canonical.indicator.sound not installed
Traceback (most recent call last):
File "/usr/bin/unity-tweak-tool", line 72, in <module>
UnityTweakTool.Application()
File "/usr/lib/python3/dist-packages/UnityTweakTool/__init__.py", line
92, in __init__
self.run(pageid)
File "/usr/lib/python3/dist-packages/UnityTweakTool/__init__.py", line
104, in run
self.connectpages()
File "/usr/lib/python3/dist-packages/UnityTweakTool/__init__.py", line
117, in connectpages
from UnityTweakTool.section.unity import Unity
File "/usr/lib/python3/dist-packages/UnityTweakTool/section/unity.py",
line 813, in <module>
Unity.add_page(unitysettings)
File
"/usr/lib/python3/dist-packages/UnityTweakTool/section/skeletonpage.py",
line 48, in add_page
page.refresh()
File "/usr/lib/python3/dist-packages/UnityTweakTool/elements/option.py",
line 62, in refresh
self.ho.refresh()
File
"/usr/lib/python3/dist-packages/UnityTweakTool/section/spaghetti/unity.py",
line 92, in refresh
interested_players = gsettings.sound.get_strv('interested-media-players')
AttributeError: 'NoneType' object has no attribute 'get_strv'
samuel@KVT-Linux:~$
any idea how to fix this? any help would be appreciated, thanks

Migrate from 32bi to 64bit - OpenCV/MinGW/Eclipse

Migrate from 32bi to 64bit - OpenCV/MinGW/Eclipse

I'm working with opencv for couple of months under windows 32bit,with
eclipse and mingw. After many hours, my program go through build, link
without errors, but when start it crashes... my favorite "dont send"
window.....
Source:
#include <opencv.hpp>
#include <windows.h>
#include <iostream>
using namespace std;
using namespace cv;
int main() {
Mat img(Mat::zeros(100, 100, CV_8U));
//imshow("window", img);
cout << "hello world!" << endl;
system("PAUSE");
return 0;
}
While imshow is comented, there is no problem, but when try to use imshow
or waitKey, it compiles, but crashes ...
Build commands:
g++ "-IW:\\Software\\opencv\\build\\include"
"-IW:\\Software\\opencv\\build\\include\\opencv"
"-IW:\\Software\\opencv\\build\\include\\opencv2" -O3 -g3 -Wall -Wextra
-c -fmessage-length=0 -o "src\\HelloWorld.o" "..\\src\\HelloWorld.cpp"
g++ "-LW:\\Software\\opencv\\build\\x64\\mingw\\lib" -o HelloWorld.exe
"src\\HelloWorld.o" -lopencv_calib3d246 -lopencv_contrib246
-lopencv_core246 -lopencv_features2d246 -lopencv_flann246
-lopencv_gpu246 -lopencv_highgui246 -lopencv_imgproc246
-lopencv_legacy246 -lopencv_ml246 -lopencv_nonfree246
-lopencv_objdetect246 -lopencv_photo246 -lopencv_stitching246
-lopencv_superres246 -lopencv_video246 -lopencv_videostab246
The system is: Win7 64bit, Eclipse CDT Kepler, Mingw. Before trat I was
working on XP 32bit. Is there a possibility that the problem comes from
the operating system ?

How to Setup Domain Name on VPS

How to Setup Domain Name on VPS

i have finished setting up my vps it is actually a cloud vps but i think
that dosn't matter the way we setup vps
i know setting up control panel will make things easy but i don't want to
install cp
i have successfully installed lamp and modules that i need .
but i can't figure out how to add my domain that is registered on
namesilo.com with private nameserver to my server
i am doing domain stuff without CP first time so please bear with me
do I need to install bind so that my domain resolve to my server IP well
if it is true I already tried many tutorials available over net but none
of them seems to be working for me



i have domain example.com with nameserver ns3 and ns4 registered with two
ip's provided by my hosting

Crash app in Thread.setDefaultUncaughtExceptionHandler

Crash app in Thread.setDefaultUncaughtExceptionHandler

I would like to crash my app on purpose after logging my own error. The
Handler is registered in Application.onCreate():
// set global exception handler
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, final Throwable ex) {
// unregister
Thread.setDefaultUncaughtExceptionHandler(null);
// do report ...
// crash app -does not work, app is frozen
if (ex instanceof RuntimeException)
throw (RuntimeException) ex;
throw new RuntimeException("Re-throw", ex);
}
However, my app freezes instead of crashing with a dialog. How can I crash
the application as it would if I hadn't registered the handler?

Wordpress all image's path change

Wordpress all image's path change

in my wordpress site suddenly something has changed and all the images of
the website and blogs are not displaying instead image not found is
appearing.
After checking the images path i found it as below for a single image.
<img
src="http://www.azraar.com/blog/wp-content/uploads/2012/02/mysql_logo.png"
title="mysql_logo" alt="" data-imgh="340" data-imgw="930">
actually this is wrong, (path) it should be as following
http://www.azraar.com/wp-content/uploads/2012/02/mysql_logo.png (/blog/ is
omitted)
Then it does point to correct image. so i am wondering how can i change
the entire images in my website to load without the /blog section in image
path.
I also checked the db of wp.. found the postmeta table contains these
images paths info but it doesnt contain in the entire paths.. it only has
like this for all images.. 2012/02/mysql_logo.png
any workaround for this ?

Sunday, 25 August 2013

How to check crash log using android ndk in cocos2d-x

How to check crash log using android ndk in cocos2d-x

I use cocos2d-x to develop a game, after it runs perfectly in iOs, I turn
around to android platform.
But it run somewhere in android, and I only receive some error log like this:
08-26 10:49:23.823: A/libc(2884): Fatal signal 11 (SIGSEGV) at 0x0000000c
(code=1), thread 2917 (Thread-285)
With this, I can't fix the crash log.
So my question is how can I check the stack of crash log?
And in SO, there are some similar questions, but with none useful answer
to me.
Using ndk-stack to read crash logs
Unable to get line no from stack trace in android ndk
How to get Useful crashlog information Android Cocos2dx C++

How to replace radio buttons with images

How to replace radio buttons with images

How do I fix this code so that the images show up. They aren't showing up
where the radio buttons used to be. I've tried several different methods
on different occassions and this seems to be the most promising but I just
can't seem to make the images appear where they should. Please don't tell
me how many times this was answered because you don't know how many
attempts I gave MANY of them. I just want help with getting the images in
place of the radio buttons with javascript. Please use jsfiddle for
examples. I may be missing labels but I don't know where to put them.
http://jsfiddle.net/uuyAq/
<!DOCTYPE html>
<html>
<head>
<script>
var images = {
1: 'http://wepriceit.webs.com/ipad-5-image.jpg',
2: 'http://wepriceit.webs.com/ipad-5-image.jpg',
3: 'http://wepriceit.webs.com/ipad-5-image.jpg',
4: 'http://wepriceit.webs.com/ipad-5-image.jpg',
5: 'http://wepriceit.webs.com/ipad-5-image.jpg'
};
$('input[type=radio][name^=question]').each(function() {
var id = this.id;
$(this)
.hide() // hide the radio button
.after('<img src="'+ images[id] +'">'); // insert the image
// after corresponding radio
});
</script>
</head>
<body>
<script>
function tryToMakeLink()
{
//get all selected radios
var q1=document.querySelector('input[name="q1"]:checked');
var q2=document.querySelector('input[name="q2"]:checked');
var q3=document.querySelector('input[name="q3"]:checked');
//make sure the user has selected all 3
if (q1==null || q2==null ||q3==null)
{
document.getElementById("linkDiv").innerHTML="<input type=button
disabled=disabled value=Next>";
}
else
{
//now we know we have 3 radios, so get their values
q1=q1.value;
q2=q2.value;
q3=q3.value;
//now check the values to display a different link for the desired
configuration
if (q1=="AT&T" && q2=="8GB" && q3=="Black")
{
document.getElementById("linkDiv").innerHTML="<input type=button
value=Next
onclick=\"window.location.href='http://google.com/';\">att 8gb
black</input>";
}
else if (q1=="Other" && q2=="8GB" && q3=="White")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://yahoo.com/';\">other 8b
white</input>";
}
else if (q1=="AT&T" && q2=="16GB" && q3=="White")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://bing.com/';\">another option</input>";
}
else if (q1=="AT&T" && q2=="16GB" && q3=="Black")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://gmail.com/';\">oops</input>";
}
else if (q1=="AT&T" && q2=="8GB" && q3=="White")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://hotmail.com/';\">can't</input>";
}
else if (q1=="Other" && q2=="8GB" && q3=="Black")
{
document.getElementById("linkDiv").innerHTML="<input type=button
value=Next
onclick=\"window.location.href='http://images.google.com/';\">yours</input>";
}
else if (q1=="Other" && q2=="16GB" && q3=="White")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://youtube.com/';\">mines</input>";
}
else if (q1=="Other" && q2=="16GB" && q3=="Black")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://docs.google.com/';\">what</input>";
}
else if (q1=="Unlocked" && q2=="8GB" && q3=="White")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://wepriceit.webs.com/';\">red</input>";
}
else if (q1=="Unlocked" && q2=="8GB" && q3=="Black")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://webs.com/';\">orange</input>";
}
else if (q1=="Unlocked" && q2=="16GB" && q3=="White")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://gazelle.com/';\">green</input>";
}
else if (q1=="Unlocked" && q2=="16GB" && q3=="Black")
{
document.getElementById("linkDiv").innerHTML="<input
type=button value=Next
onclick=\"window.location.href='http://glyde.com/';\">blue</input>";
}
}
}
</script>
<form name="quiz" id='quiz'>
What carrier do you have?
<ul style="margin-top: 1pt" id="navlist">
<li style="list-style: none;"><input type="radio"
onclick=tryToMakeLink();
name="q1" value="AT&T" id="1"/>AT&T</li><label for="1"/>
<li style="list-style: none;"><input type="radio"
onclick=tryToMakeLink();
name="q1" value="Other" id="2"/>Other</li><label for="2"/>
<li style="list-style: none;"><input type="radio"
onclick=tryToMakeLink();
name="q1" value="Unlocked" id="3"/>Unlocked</li><label for="3"/>
</ul>
What is your phones capicity?
<ul style="margin-top: 1pt" id="navlist">
<li style="list-style: none;"><input type="radio"
onclick=tryToMakeLink();
name="q2" value="8GB" id="4"/>8GB</li><label for="4"/>
<li style="list-style: none;"><input type="radio"
onclick=tryToMakeLink();
name="q2" value="16GB" id="5"/>16GB</li><label for="5"/>
</ul>
What color is your phone?
<ul style="margin-top: 1pt" id="navlist">
<li style="list-style: none;"><input type="radio"
onclick=tryToMakeLink();
name="q3" value="Black" id="6"/>Black</li><label for="6"/>
<li style="list-style: none;"><input type="radio"
onclick=tryToMakeLink();
name="q3" value="White" id="7"/>White</li><label for="7"/>
</ul>
<br>
<div id=linkDiv>
<input type=button disabled=disabled value=Next>
</div>
</form>
</body>
</html>
http://jsfiddle.net/uuyAq/

Differentiate $x \sqrt{1+y}+y \sqrt{1+x}=0$

Differentiate $x \sqrt{1+y}+y \sqrt{1+x}=0$

If $x \sqrt{1+y}+y \sqrt{1+x}=0$, prove that $(1+x^2)\frac{dy}{dx}+1=0.$
The answer I got is $$\frac{dy}{dx}= -\frac{2 \sqrt{1+x} \sqrt{1+y}+y}{x+2
\sqrt{1+x}\sqrt{1+y}}$$ but I cannot simplify it further.
Please provide your assistance.

Saturday, 24 August 2013

Find Fourier Series of the function $f(x)= \sin x \cos(2x) $ [duplicate]

Find Fourier Series of the function $f(x)= \sin x \cos(2x) $ [duplicate]

This question already has an answer here:
What is the odd fourier extention of sin x cos(2x) 1 answer
Find Fourier Series of the function $f(x)= \sin x \cos(2x) $ in the range
$ -\pi \leq x \leq \pi $
any help much appreciated
I need find out
$a_0$ and $a_1$ and $b_1$
I can find $a_0$ which is simply integrating something with respect to the
limits I can get as far as
$$\frac{1}{2} \int_{-\pi}^\pi \ \frac12 (\sin (3x)-\sin(x)) dx$$
How would I integrate the above expression ?
secondly how would I calculate $a_1$ and $b_1$ but despite knowing the
general formula to find the fourier series Im having trouble applying them
to this question

Usps price calculator returns an empty array

Usps price calculator returns an empty array

I found the updated way of getting a price from USPS, I didn't write this
code (why rewrite something that's already written eh?), but I understand
how all of this works, what I don't understand is why I get an empty
array? What am I missing, or anything wrong here. Any help is appreciated
class UspsCalculator{
public function USPSParcelRate($weightLB, $weightOZ, $size, $dest_zip) {
$userName = '11111111'; //Fake Name for privacy purposes
$orig_zip = '33617';
$url = 'https://secure.shippingapis.com/ShippingAPITest.dll';
$servicecode = "IntlRateV2";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
$data = "API=RateV4&XML=<RateV4Request
USERID=\"$userName\"><Package
ID=\"1ST\"><Service>ALL</Service><ZipOrigination>$orig_zip</ZipOrigination><ZipDestination>$dest_zip</ZipDestination><Pounds>$weightLB</Pounds><Ounces>$weightOZ</Ounces><Container/><Size>$size</Size><Machinable>FALSE</Machinable></Package></RateV4Request>";
// print_r($data);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$result=curl_exec ($ch);
$data = strstr($result, '<?');
print_r($data); // Uncomment to show XML in comments
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $data, $vals, $index);
xml_parser_free($xml_parser);
$params = array();
$level = array();
foreach ($vals as $xml_elem)
{
if ($xml_elem['type'] == 'open')
{
if (array_key_exists('attributes',$xml_elem))
{
list($level[$xml_elem['level']],$extra) =
array_values($xml_elem['attributes']);
} else
{
$level[$xml_elem['level']] = $xml_elem['tag'];
}
}
if ($xml_elem['type'] == 'complete') {
$start_level = 1;
$php_stmt = '$params';
while($start_level < $xml_elem['level']) {
$php_stmt .= '[$level['.$start_level.']]';
$start_level++;
}
$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
eval($php_stmt);
}
}
curl_close($ch);
// echo '<pre>'; print_r($params); echo'</pre>'; // to see the
full array
return $params['RATEV3RESPONSE']['1ST'][$servicecode]['RATE'];
}
}
?>

Match last occurence with regex

Match last occurence with regex

I would like to match last occurence of a pattern using regex.
I have some text structured this way:
Pellentesque habitant morbi tristique senectus et netus et
lesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae
ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam
egestas <br>semper<br>tizi ouzou<br>Tizi Ouzou<br>
I want to match the last text between two <br> in my case <br>Tizi
Ouzou<br>, ideally the Tizi Ouzou string
Note that there is some white spaces after the last <br>
I've tried this:
<br>.*<br>\s*$
but it selects everything starting from the first <br> to the last.
NB: I'm on python, and I'm using pythex to test my regex

How to write a byte form input to output files?

How to write a byte form input to output files?

I am trying to write a tester for a function that takes writes info bit by
bit from one file to another. I am pretty sure that BitOutputStream class
works since the code below prints out an 'A' as expected. But when I
change the code to the second version below that takes the input file and
writes the output file the input does not match the output. I am not sure
if I am inadvertently changing something I shouldn't or the input file has
certain "hidden" characters that cause the mismatch or byte shifting to
occur. I suspect I might not be using get() correctly. Any help would be
greatly appreciated.
/* first (working) version */
int main(int argc, char* argv[])
{
BitOutputStream bos(std::cout); // channel output to stdout
bos.writeBit(1);
bos.writeBit(0);
bos.writeBit(0);
bos.writeBit(0);
bos.writeBit(0);
bos.writeBit(0);
bos.writeBit(0);
bos.writeBit(1);
// prints an 'A' as expected
return 0;
}
/* second (non-working) version */
int main(int argc, char* argv[])
{
std::string ifileName = std::string(argv[1]);
std::string ofileName = std::string(argv[2]);
ofstream ofile;
ifstream ifile;
if(ifile)
ifile.open(ifileName, ios::binary);
if(ofile)
ofile.open(ofileName, ios::binary);
BitOutputStream bos(ofile);
int i;
while (ifile.good()) {
i = bos.writeBit(ifile.get()); // could the error be due to incorrect
usage of get()?
std::cout << i << std::endl; // just to see how many bits have been
processed
}
bos.flush();
ifile.close();
ofile.close();
return i;
}
The first version I call with
./a.out
The second version I call with
./a.out input output
which prints 1 2 3 to the terminal indication writeBit was called three
times but I expected it to be called 8 times for 'A', so why 3 times only?
input file has just 'A' in it. calling hexdump on input file generates:
0000000 0a41
0000002
calling hexdump on output file generates:
0000000 0005
0000001
Also why does hexdump generate 7 0's before 0a-'linefeed' and 41-'A' and
what is the meaning of '0000002' at the end? What can I change in the
second version of the code so the hexdump for input and output match?

What ensures big holes in my bread?

What ensures big holes in my bread?

Is it a high hydration rate? Minimal kneading? High-protein flour to hold
hydration?

@RequestMapping in spring not working

@RequestMapping in spring not working

I am new in spring mvc.I created one controller newController.java in
springproject.My code is below:
@RequestMapping(value = "/Receiver", method = RequestMethod.GET)
public String recvHttpGet(Model model) {
System.out.println("here get");
}
@RequestMapping(value = "/Receiver", method = RequestMethod.POST)
public String recvHttpPost(Model model) {
System.out.println("here post");
}
@RequestMapping(value = "/", method = RequestMethod.GET)
public String show(Model model) {
return "index";
}
whenever I tried to run it using normally then index.jsp page is show but
whenever i tried to call /Receiver url it shows 404 error.Please help
me.Also whenever i changed in recvHttpGet method return "index" it also
shows 404 error.Also nothing to be written in console.

Friday, 23 August 2013

How to improve Ubuntu's perormance in Virtual Box

How to improve Ubuntu's perormance in Virtual Box

I have a HP laptop with decent specs, Processor - AMD A8
RAM - 4 GB
Graphics - 1.5 GB don't remember the model, but there are two Amd Radeon
one 512 Mb integrated and one 1 GB dedicated Radeon, both clubbed using
crossfire.
Operating system - Windows 8 64 bit
I have installed ubuntu 13.04 on a virtual box virtual machiene and have
allocated decent 1GB ram and a single processor to it.
But problem is this VM is painfully slow. Its next to useless. When I
allocate similar configuration to Windows 7 VM, it works just fine even
withAero on.
So any suggestion what may be the reason for this.
I am facing one more problem, whenever i switch on any VM with mouse
integration on after that my trackpads swipe gestures stop working on Host
machine even if I switch off the VM. Any help appreciated.

Display Partial in Modal with Foundation and Rails

Display Partial in Modal with Foundation and Rails

I am trying to create what I thought was a simple modal login window in
rails using foundation. Unfortunately it isn't as easy I thought.
Basically what I am trying to do is provide a link to the user on the main
page that when they click, will display the devise signup form in a modal
window.
Can someone help me out? Thanks!

github: can no longer commit changes

github: can no longer commit changes

I had everything working for over a month and all of a sudden I can no
longer commit my changes.
I use netbeans ide and when I commit changes, in the popup I see the
message:'No files available for commit.'
When I try to do a push to remote, I select my git repository location
(same as usual) but when I click on Next to select local branch, there's
nothing showing.
Has anyone encounter this problem ?

How to compare Objects attributes in an ArrayList?

How to compare Objects attributes in an ArrayList?

I am fairly new to Java and I have exhausted all of my current resources
to find an answer. I am wondering if it possible to access an Objects
first property to see if it matches a particular integer?
For example, I am trying to obtain a Product that is within my Database by
searching for it by it's Product ID. Therefore, if I create two products
such as, Product ipad = new Product(12345, "iPad", 125.0,
DeptCode.COMPUTER); and Product ipod = new Product(12356, "iPod", 125.0,
DeptCode.ELECTRONICS); (I have included this Product class below), and add
them to an Arraylist such as, List<Product> products = new
ArrayList<Product>(); how can I loop through this ArrayList in order to
find that product by its ID? This is the method I am working on:
List<Product> products = new ArrayList<Product>();
@Override
public Product getProduct(int productId) {
// TODO Auto-generated method stub
for(int i=0; i<products.size(); i++){
//if statement would go here
//I was trying: if (Product.getId() == productId) {
System.out.println(products.get(i));
}
return null;
}`
I know that I can include a conditional statement in the for loop but I
cant figure out how to access the getId() method in the Product class to
compare it the productId parameter?
package productdb;
public class Product {
private Integer id;
private String name;
private double price;
private DeptCode dept;
public Product(String name, double price, DeptCode code) {
this(null, name, price, code);
}
public Product(Integer id, String name, double price, DeptCode code) {
this.id = id;
this.name = name;
this.price = price;
this.dept = code;
}
public String getName() {
return name;
}
public double getPrice() {
return price;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public DeptCode getDept() {
return dept;
}
public void setDept(DeptCode dept) {
this.dept = dept;
}
public void setName(String name) {
this.name = name;
}
public void setPrice(double price) {
this.price = price;
}
@Override
public String toString() {
String info = String.format("Product [productId:%d, name: %s,
dept: %s, price: %.2f",
id, name, dept, price);
return info;
}
}
Please let me know

Invalid left hand assignment

Invalid left hand assignment

Could someone please explain why following code throws Invalid left hand
assignment error on this = evt.target;
validateNumber: function( evt ) {
this = evt.target;
if (/\D/g.test(el.value)) {
// Filter non-digits from input value.
el.value = el.value.replace(/\D/g, '');
}
},

Proper way to create ranking table?

Proper way to create ranking table?

I am creating tennis site which of course needs to display results.
Currently to get ranking I need to sum scores for each player and then
order them, even if I only need single player results. I think that it
will be really slow when player count in system will rise. That's why I
need some way to cache results and update them only when something
changed(or add some sort of timeout when results has to updated).
Also other requirement would be being able to calculate total scores i.e.
I will have several competitions and I will need to show scores for all
competitions, and for each competition separately.
What I currently thought of would be single table to store everything.
It's schema would be:
ranking_tbl shema
rank_type(could be competition, team, player or something else)
rank_owner(who owns those ranks, can be team player ranks - owner would be
team)
rank_item(who is ranked, in team example would be player )
score(actual score to rank by)
rank(precached rank, updated only when new scores added)
Ranking will be important part of my system and used heavily so I need it
to be as efficient as possible.
Question: Is there better way to achieve ranking than using my table shema?

Thursday, 22 August 2013

how to use twitter api with javascript?

how to use twitter api with javascript?

I am using the below code to search about something -
$.getJSON('https://api.twitter.com/1.1/search/tweets.json?q=tutspremium&callback=?',
function(data){
console.log(data);
});
but it is showing error of
jquery110205044063129462302_1377238636248({"errors":[{"message":"Bad
Authentication data","code":215}]});
how to pass the oauth data to it so that it can authenticate
properly?please help

how to do i get returned data from ajax call

how to do i get returned data from ajax call

I am getting a undefined on the username from $sql which should be the
returned data from the query.
$('#userlist').on('change', function () {
var selected = $("select option:selected").text();
console.log(selected);
// use ajax to run the check
$.ajax({
url: '/php/connect/userdropdowncheck.php',
type: 'JSON',
data: selected,
success: formfill,
error: function (xhr, status, err) { console.log(xhr, status, err); }
});
function formfill($sql) {
var username = $sql['UserLogin'];
var email = $sql['UserEmail'];
var admin = $sql['admin'];
var firstname = $sql['firstname'];
var lastname = $sql['lastname'];
var title = $sql['title'];
var company = $sql['company'];
console.log(username);
if (username.length > 0) {
console.log('Found user');
console.log(username);
$('#username').html($username);
}
else {
console.log('Failed to find user');
}
}
});
<?php
session_start();
include 'anonconnect.php';
// username and password sent from form
$myusername= $_POST['username'];
$sql = $dbh->prepare("SELECT * FROM Users WHERE UserLogin= :login");
$sql->execute(array(':login' => $myusername));
$sql = $sql->fetch();
/*** close the database connection ***/
$dbh = null;
if($sql->rowCount() == 1){
echo 1;
return $sql;
else {
echo 0;
}
?>
It is pulling the text from the selected drop down just fine and passing
it but the function on the return cannot find it.

JQuery UI Mobile and Kendo UI Mobile co-existing in one project

JQuery UI Mobile and Kendo UI Mobile co-existing in one project

Has anyone tried this before in Icenium or in regular HTML 5 project? Is
there possible problem if we try to build our core project based on this
two libraries?

Is loading JPEG image in ARGB_8888 format a waste of 8 bits per pixel?

Is loading JPEG image in ARGB_8888 format a waste of 8 bits per pixel?

JPEG format of images doesn't support transparency.
So, if I load huge JPEG images as ARGB_8888, I waste 8 bits of alpha
channel on every pixel?

CSS or Javascript Solution to Horizontal Table Overflow

CSS or Javascript Solution to Horizontal Table Overflow

I have a UI problem that I can't figure out a good interactive solution
for. I have an html table node that has data that makes the table overflow
out of the body. I need the table to basically scroll horizontally and
stay within the body / viewpoint, but I'm looking for a better solution
other than a bad scroll bar with an overflow-y. If you know of any js or
css solution that isn't from the 90's that would get you 10 brownie
points.

how to extract data from subform in zendframework1

how to extract data from subform in zendframework1

i need to perform a loop on data returned from a subform in zendframework 1.
i seem to have run into a bit of trouble understanding how to extract the
information once its returned by the post.
This is the zend subform.
$e = new Zend_Form_Element('quantity');
$e
->setValue($tieredPrice->quantity)
->setDecorators($this->_tieredPriceElementDecorators);
$sub->addElement($e);
This is the returned values:
array(5) { ["comments"]=> string(19) "testing new format " [5]=> array(6)
{ ["quantity"]=> string(3) "222" ["price"]=> string(3) "220" ["rrp"]=>
string(2) "22" ["sampleId"]=> string(5) "42960" ["id"]=> string(1) "5"
["delete"]=> string(1) "0" } [6]=> array(6) { ["quantity"]=> string(4)
"7777" ["price"]=> string(4) "2022" ["rrp"]=> string(2) "22"
["sampleId"]=> string(5) "42960" ["id"]=> string(1) "6" ["delete"]=>
string(1) "0" } [7]=> array(devil) { ["quantity"]=> string(5) "23243"
["price"]=> string(2) "22" ["rrp"]=> string(2) "22" ["sampleId"]=>
string(5) "42960" ["id"]=> string(1) "7" ["delete"]=> string(1) "0" }
["submit"]=> string(4) "Save" }
this is my attempt to seek out the subform data and loop round it.
public function processTieredPriceForm(EP3D_Form_Product_ProductSample
$form, array $data, $sampleId ) { $this->_sampleId = (int)$sampleId;
if ($form->isValid($data)) { foreach($data as $tieredPrice) { $sub =
$form->getSubForm($tieredPrice['id']);
$tieredPrice['quantity'] = $sub->getValue('quantity');
$tieredPrice['price'] = $sub->getValue('price');
$tieredPrice['rrp'] = $sub->getValue('rrp');
$tieredPrice->save();
}
The error message that i received was:
Illegal string offset 'id'
i would really appreciate any advice on this matter.
warm regards
Andreea

How to Left and Right Align labels on UITableCell

How to Left and Right Align labels on UITableCell

I need a table layout like this screenshot
Screen:1
but i am getting like this
Screen:2
after scrolling the table it becomes like the first screen as required but
initially its like screen 2.
My code for this in cellForRowAtIndexPath method is
UILabel *titleLabel = (UILabel *) [cell viewWithTag:1];
titleLabel.backgroundColor =[UIColor whiteColor];
if (indexPath.row % 2) {
NSLog(@"Odd Cell");
[titleLabel setFrame:CGRectMake(100.0f, 10.0f, 200.0f, 20.0f)];
} else {
NSLog(@"Even Cell");
[titleLabel setFrame:CGRectMake(20.0f, 10.0f, 200.0f, 20.0f)];
}
titleLabel is a label on the cell through IB and having the tag:1

Wednesday, 21 August 2013

Totally independant forms in tabcontrol

Totally independant forms in tabcontrol

I'm designing an application on VB.net and I'm newbie as well. I thought
about the general architecture of the application and came up with the
following idea.
the application is made of different modules
the user can run different modules in the same time
each module will run his main form in a different tab in tabcontrol
each module has his own modal forms, modeless windows, messages, ... etc.
Before going through much development details, I started first with trying
this design. Though, I couldn't first embed dynamically a form in tab
during run time and even after some workarounds, I couldn't make the
modules run perfectly in parallel. For example when I have a modal window
displayed in a module, the whole application freezes while I expect only
the related tab to freeze and be able to switch to the others to do some
work.
Does anyone know how to make the tab contents completely separate and not
have one freezes the other ?
Thank you.

Shadow not showing google maps marker

Shadow not showing google maps marker

Having a problem, I'm trying to add a custom shadow but somehow it is not
showing. I checked for bugs using firebug but nothing wrong, the path is
also correct. I have no idea why it's not working. code below.
var marker = new google.maps.Marker({
map: map,
position: latlngset,
shadow: 'codes/icon/shadow.png',
icon: baseicon+icon
});

Is it possible to bypass CSP when injecting js in the page from a Firefox plugin?

Is it possible to bypass CSP when injecting js in the page from a Firefox
plugin?

I have a firefox plugin that used to interact with github's web app by
injeting some javascript in the page (by creating a element under the head
element, and setting its innerHTML value to the javascript to be
executed).
However, it just stopped working lately. I then saw the following warning:
Timestamp: 8/21/13 5:45:42 PM
Warning: CSP WARN: Directive inline script base restriction violated
Source File: https://github.com/login
Line: 0
Source Code:
myjscode();...
Github returns the following header:
X-Content-Security-Policy: default-src *; script-src 'self'
https://github.global.ssl.fastly.net https://jobs.github.com
https://ssl.google-analytics.com https://collector.githubapp.com
https://analytics.githubapp.com; style-src 'self' 'unsafe-inline'
https://github.global.ssl.fastly.net; object-src 'self'
https://github.global.ssl.fastly.net
I was aware that Firefox started supporting CSP through the
X-Content-Security-Policy header, but I thought some mechanism would be in
place to prevent code injection from plugins to brake.
Does anyone know if the extension API has any specific mechanism for
injecting javascript in the page in a and bypass the CSP settings?
Rationale is - if the user has the plugin installed, he/she trusts it, and
there should be a way to bypass CSP.

keep getting the nullpointerException? i am trying to print out an image

keep getting the nullpointerException? i am trying to print out an image

here is the main class
public class testing extends JFrame{
private static final long serialVersionUID = 1L;
public testing(){
setContentPane(new Canvas());
setSize(800,600);
setVisible(true);
setLocationRelativeTo(null);
}
public static void main(String[] args0){
new testing();
}
}
and the error occurs in the Canvas class, the drawImage method. I've made
a res folder where i put my images and use it as source folder.
public class Canvas extends JPanel{
BufferedImage image;
Graphics2D g;
private static final long serialVersionUID = 1L;
public Canvas(){
setPreferredSize(new Dimension(800,600));
loadImage("/space.png");
PaintComponents(g);
}
public void PaintComponents(Graphics2D g){
g.drawImage(image, 0,0,null);
}
public void loadImage(String path){
try {
image = ImageIO.read(
getClass().getResourceAsStream(path)
);
}
catch(Exception e) {
e.printStackTrace();
System.out.println("image loading error");
}
}
}
Thank you for the help.

Persistence for cookies

Persistence for cookies

I am working with python mechanize on making a login script. I have read
that the mechanize's Browser() object will handle with cookies
automatically for further requests. How can i make this cookie persistent
ie save into a file so that I can load from that file later. My script is
currently logging-in(using mechanize/HTML forms) to the website with
Browser() object every time it is run.

SUM(ROUND function Gives Error "invalid use og group function"

SUM(ROUND function Gives Error "invalid use og group function"

SELECT sale_time as sale_date,
CONCAT(ospos_people.first_name, ' ' ,ospos_people.last_name ) AS
CustomerName, ospos_sales_items.sale_id,
comment,payment_type,
customer_id,
employee_id,
ospos_items.item_id,
supplier_id,
quantity_purchased,
item_cost_price,
item_unit_price,
percent as item_tax_percent,
discount_percent,
SUM(item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)
as subtotal,
ospos_sales_items.line as line,
serialnumber,ospos_sales_items.description as description,
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*
(1+(SUM(percent)/100)),2) as total, SUM(
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*(SUM(percent)/100),2))
as tax,
SUM((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)
- (item_cost_price*quantity_purchased)) as profit
FROM ospos_sales_items
INNER JOIN ospos_sales ON ospos_sales_items.sale_id=ospos_sales.sale_id
INNER JOIN ospos_items ON ospos_sales_items.item_id=ospos_items.item_id
LEFT OUTER JOIN ospos_suppliers ON
ospos_items.supplier_id=ospos_suppliers.person_id
LEFT OUTER JOIN ospos_sales_items_taxes ON
ospos_sales_items.sale_id=ospos_sales_items_taxes.sale_id and
ospos_sales_items.item_id=ospos_sales_items_taxes.item_id and
ospos_sales_items.line=ospos_sales_items_taxes.line
INNER JOIN ospos_people ON customer_id = ospos_people.person_id
GROUP BY customer_id

What is the use of Hashing except for HashMap?

What is the use of Hashing except for HashMap?

Is hashing used only in HashMap?What about other collection?For example
Hashtable also uses key value pair,for storing but I had never seen in any
practical examples hashing been used in hashtable.

Tuesday, 20 August 2013

How delegate call differ from normal method call

How delegate call differ from normal method call

Whenever I wanted to inform something to parent class I have used delegate
instead of calling directly parent's functions. I have implemented like...
eg:
CustomClass *custom = [[CustomClass alloc] init];
// assign delegate
custom.delegate = self;
[custom helloDelegate];
In custom class, I have intimated parent like below....
-(void)helloDelegate
{
// send message the message to the delegate
[_delegate sayHello:self];
}
So my doubts , how it differs from direct call?. Setting delegate variable
with self is somewhat equal to giving the parent instance to child and let
the child call the function whenever required, how protocols helps here or
why we need protocols? what is the advantage?
thanx

Multiple Render Targets in Three.js

Multiple Render Targets in Three.js

Is multiple render targets supported in Three.js? I mean, using one single
fragment shader to write to different render targets.
I have a fragment shader that calculates several things and I need to
output them separately into different textures for further manipulations.

MS Access dropdown list over columns

MS Access dropdown list over columns

I am building a canned response database. I conduct assessments of sites
based on 14 separate categories. Each site I visit designate their main
assets (up to 15 separate pieces). Each of these assets I can grade them
with my 14 separate categories. I rate and then give a narrative of
commendables, vulnerabilities, and then options for consideration.
Example: Site_Name1 has 7 assets. However, I will eventually have many
Site_Name(s) each with multiple assets but each asset can be graded
individually. I am trying to create pull downs to signify which narratives
match the Site and asset. I have figured out the first indicator
(site_name) pull down. But I am trying to then pull down the asset to then
write my narrative.
Is this an answer for cascading drop downs? Or is it a querry I am looking
for? I currently have a table that has all my site_names along with their
assets in a row across columns under one ID line. eg> ID / Site_name /
Asset1 / Asset2 / Asset3 / etc.
The "site_name" above is a look-up from the main site_name table.

fnmatch and recursive path match with `**`

fnmatch and recursive path match with `**`

Is there any built-in or straightforward way to match paths recursively
with double asterisk, e.g. like zsh does?
For example, with
path = 'foo/bar/ham/spam/eggs.py'
I can use fnmatch to test it with
fnmatch(path, 'foo/bar/ham/*/*.py'
Although, I would like to be able to do:
fnmatch(path, 'foo/**/*.py')
I know that fnmatch maps its pattern to regex, so in the words case I can
roll my own fnmatch with additional ** pattern, but maybe there is an
easier way

Media Query Image Rule?

Media Query Image Rule?

I have been experimenting with the CSS Media Query for image substitution
on ultra hi-res displays, and they seem to work well for single images
defined in the CSS. But, I'm struggling to create intellegent rules as my
command of CSS is limited.
Is it possible to use CSS Media Queries to create rule which will
substitute any image with an @2x version if one is available? I know there
is a jscript that can do this (retina.js) but, it works retrospectively
and won't work on images that are rendered dynamically. I thought it would
be better to define them in the CSS some how so that they load the correct
image first time. Or, am I completely barking up the wrong tree with CSS?

Determine vectors similarity weighing the vectors lengths

Determine vectors similarity weighing the vectors lengths

I have many vector couples, for which I would like to assign a single
number (for each couple) that signify their similarity. I am running a
minimization algorithm on the whole group of vector couples so the
relative 'similarity grade' between couples is important.
If they were all at the same length, cosine similarity would be my obvious
choice. However, the vectors are not of same length and I would like to
take their size differences into account.
My intuition of vectors similarity are :
Vectors with the same direction (d) but of different sizes (s1,s2) are
more similar than vectors with same sizes (s1,s2) but of different
directions (d1,d2).
Vectors of the same size (Sshort) with different directions (d1,d2) are
more similar than the vectors of sam direction (d1,d2) with a larger size
((Slong).
In my context, this makes sense as (somewhat abstractly) if I wanted to
align the 2 vectors I would have needed less "energy" to rotate the
shorter ones.
Is there a standard method that determines vectors similarity along these
lines?
Thanks!

pcre not matching utf8 characters

pcre not matching utf8 characters

I'm compiling a pcre pattern with utf8 flag enabled and am trying to match
a utf8 char* string against it, but it is not matching and pcre_exec
returns negative. I'm passing the subject length as 65 to pcre_exec which
is the number of characters in the string. I believe it expects the number
of bytes so I have tried with increasing the argument till 70 but still
get the same result. I don't know what else is making the match fail.
Please help before I shoot myself.
(If I try without the flag PCRE_UTF8 however, it matches but the offset
vector[1] is 30 which is index of the character just before a unicode
character in my input string)
#include "stdafx.h"
#include "pcre.h"
#include <pcre.h> /* PCRE lib NONE */
#include <stdio.h> /* I/O lib C89 */
#include <stdlib.h> /* Standard Lib C89 */
#include <string.h> /* Strings C89 */
#include <iostream>
int main(int argc, char *argv[])
{
pcre *reCompiled;
int pcreExecRet;
int subStrVec[30];
const char *pcreErrorStr;
int pcreErrorOffset;
char* aStrRegex =
"(\\?\\w+\\?\\s*=)?\\s*(call|exec|execute)\\s+(?<spName>\\w+)("
// params can be an empty pair of
paranthesis or have parameters inside
them as well.
"\\(\\s*(?<params>[?\\w,]+)\\s*\\)"
// paramList along with its
paranthesis is optional below so a SP
call can be just "exec sp_name" for a
stored proc call without any
parameters.
")?";
reCompiled = pcre_compile(aStrRegex, 0, &pcreErrorStr,
&pcreErrorOffset, NULL);
if(reCompiled == NULL) {
printf("ERROR: Could not compile '%s': %s\n", aStrRegex, pcreErrorStr);
exit(1);
}
char* line = "?rt?=call
SqlTxFunctionTesting(?înFîéld?,?outField?,?inOutField?)";
pcreExecRet = pcre_exec(reCompiled,
NULL,
line,
65, // length of string
0, // Start looking at
this point
0, // OPTIONS
subStrVec,
30); // Length of subStrVec
printf("\nret=%d",pcreExecRet);
//int substrLen = pcre_get_substring(line, subStrVec, pcreExecRet, 1,
&mantissa);
}

Monday, 19 August 2013

Loading image from MAC system using NSBundle and plist

Loading image from MAC system using NSBundle and plist

Trying to Display the load the image from the folder present on MAC
desktop using path like (/Users/sai/Desktop/images/aaa.jpg) Which is
created in plist file called Data.plist at item0. As im using NSBundle it
is diaplying the image path but not loading the image from the desktop .I
have done a lots of research still couldn't find the solution .Plz help me
.Here is the code
NSString *path=[[NSBundle mainBundle]pathForResource:@"Data"
ofType:@"plist"];
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:path];
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization
propertyListFromData:plistXML
mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format
errorDescription:&errorDesc];
NSArray *array=[NSArray arrayWithArray:[temp objectForKey:@"images"]];
NSString *object=[array objectAtIndex:0];
NSLog(@"object at index i %@",[object lastPathComponent]);
NSString *image=[object lastPathComponent];
mImageView.image=[UIImage imageNamed:image];
[self.view addSubview:mImageView];
Here is the screen shot of Data.plist

drag and drop anumate shadow back to original position if not dropped to target

drag and drop anumate shadow back to original position if not dropped to
target

I have made the functionality of drag and drop using ondraglistener. Its
working fine But my problem is the shadow which is made does not go back
to original image if the view is not dropped at the target. how to animate
going of shadow from the position to original position.

causes top and left properties to be ignored in production environment

causes top and left properties to be ignored in production environment

I have a positioning style that has a .top and .left property that is
being ignored on my production server on some pages and not others.
.logoPosition {position: absolute; left: 10; top: 4;}
The behavior is consistent between browsers and I have flushed the cache
in every case. Everything displays as expected when viewed locally, but
some pages on the production server ignore the top and left attributes.
When I use the IE Developer tools, it confirms that the span element has
the position attribute of the style class, but not the left/top.
So the first problem appears to be definition. The non-working pages have
this definition, while the working pages do not. As I recall, I originally
included this to get hover working in IE, so removing it doesn't work (and
is probably not advised). Are the top/left properties not supported with
this doctype or is there some other issue that causes this behavior.
The next problem is this issue didn't appear until it went to production.
I have read that the rendering mode may be adjusted in the safe zone and
that this may be causing this difference. How can I ensure that my prod
and dev environments render the same.

Using SQL "In" instead of "Like" using %wildcards% in Linq

Using SQL "In" instead of "Like" using %wildcards% in Linq

If I search within a description field using Linq I receive different
results when searching with these two queries. First by this %MODULE%ALLEN
BRADLEY% and then second by this query %ALLEN BRADLEY%MODULE%. I would
like these search queries to give me a result where these words appear in
any place of the description field.
I read about sql that using LIKE searches for pattern in string in a
correct order, for instance searching for %MODULE%ALLEN BRADLEY% would
force the result to be in that particular order within the string. However
using the keyword "In" searches for the wildcards anywhere within the
string.
How would I achieve that in Linq?
This is my Linq method:
public List<Item> SearchItems(string itemid, string description)
{
return (from allitems in _dbc.Items
where SqlMethods.Like(allitems.Number, itemid)
&& SqlMethods.Like(allitems.DESCRIPTION, description)
select allitems);
}

Something missing in my C# custom config implementation

Something missing in my C# custom config implementation

I've tried to write an application with custom config implementation - for
this purpose I had written down a small dummy app which I could later
follow. But, I'm just not able to load the config. Any ideas on what I'm
missing here would be of real help.
Config File
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- Configuration section-handler declaration area. -->
<configSections>
<sectionGroup name="SecuritySettingsGroup">
<section name="SecuritySettings"
type="ConfigSecHandler.ServicesSection, ConfigSecHandler"/>
</sectionGroup>
<!-- Other <section> and <sectionGroup> elements. -->
</configSections>
<!-- Configuration section settings area. -->
<SecuritySettingsGroup>
<SecuritySettings>
<ServiceSecuritySettings>
<Service svcName="xStore" svcUser="user1"
svcPermissions="pemission1"/>
<Service svcName="xStore" svcUser="user2"
svcPermissions="pemission3"/>
</ServiceSecuritySettings>
</SecuritySettings>
</SecuritySettingsGroup>
</configuration>
Classes
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Xml;
namespace ServicesConfigSection {
public class ServicesSection : ConfigurationSection {
[ConfigurationProperty("ServiceSecuritySettings",
IsDefaultCollection = false)]
[ConfigurationCollection(typeof(ServiceCollection),
AddItemName = "Service")]
public ServiceCollection Services {
get { return
(ServiceCollection)this["ServiceSecuritySettings"]; }
set { this["ServiceSecuritySettings"] = value; }
}
public static ServicesSection GetConfiguration() {
return
GetConfiguration("SecuritySettingsGroup/SecuritySettings");
}
public static ServicesSection GetConfiguration(string section) {
return ConfigurationManager.GetSection(section) as
ServicesSection;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace ServicesConfigSection {
public class ServiceCollection : ConfigurationElementCollection {
protected override ConfigurationElement CreateNewElement() {
return new ServiceElement();
}
protected override object GetElementKey(ConfigurationElement
element) {
return ((ServiceElement)element).SvcName;
}
public override ConfigurationElementCollectionType CollectionType {
get { return
ConfigurationElementCollectionType.AddRemoveClearMap; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace ServicesConfigSection {
public class ServiceElement : ConfigurationElement {
[ConfigurationProperty("svcName", DefaultValue = "", IsRequired =
true)]
public String SvcName {
get { return (String)this["svcName"]; }
set { this["svcName"] = value; }
}
[ConfigurationProperty("svcUser", DefaultValue = "", IsRequired =
true)]
public String SvcUser {
get { return (String)this["svcUser"]; }
set { this["svcUser"] = value; }
}
[ConfigurationProperty("svcPermissions", DefaultValue = "",
IsRequired = true)]
public String SvcPermissions {
get { return (String)this["svcPermissions"]; }
set { this["svcPermissions"] = value; }
}
}
}
Main
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using ServicesConfigSection;
namespace TestApp {
class Program {
static void Main(string[] args) {
ServicesSection svcConfig = ServicesSection.GetConfiguration();
foreach (ServiceElement thisConfig in svcConfig.Services) {
Console.WriteLine(thisConfig.SvcName);
}
}
}
}
Error Faced during loading the XML
System.Configuration.ConfigurationErrorsException was unhandled Message=An
error occurred creating the configuration section handler for
SecuritySettingsGroup/SecuritySettings: Could not load type
'ConfigSecHandler.ServicesSection' from assembly 'ConfigSecHandler'.
(######\TestApp\bin\Debug\TestApp.vshost.exe.config line 6)

Sunday, 18 August 2013

How to retrieve CC email address from MS outlook 2010?

How to retrieve CC email address from MS outlook 2010?

I am using below code to retrieve the different mail parameter from MS
outlook 2010. but I am not able to get CC email address. CC property of
MailItem class is returning Name, not email address.
NameSpace _nameSpace;
ApplicationClass _app;
_app = new ApplicationClass();
_nameSpace = _app.GetNamespace("MAPI");
object o = _nameSpace.GetItemFromID(EntryIDCollection);
MailItem Item = (MailItem)o;
string HTMLbpdyTest = Item.HTMLBody;
CreationTime = Convert.ToString(Item.CreationTime);
strEmailSenderEmailIdMAPI =
Convert.ToString(Item.SenderEmailAddress);
strEmailSenderName = Item.SenderName;
Subject = Item.Subject;
string CCEmailAddress = Item.CC;
Please suggest, how can I get CC email addresses?

What am I trying to ask?

What am I trying to ask?

I will apologize in advance if this appears vague. The problem I am having
is that I am not certain how to properly articulate what I want to achieve
into the correct question. I will try to describe my goal.
This is for a windows 8 tablet app. Imagine a set of rectangles across the
top of the screen, much like piano keys. The user will drag a key down a
little (I can do this). Then touching the top end of the rectangle they
will drag their finger in a circle around it, as they do so the rectangle
will fan out into an actual circle. Then when finished they would drag the
top around the opposite way closing it. Sort of like one of those Japanese
hand fans.
What do I search for or how do I phrase this in such a way that will point
me in the right direction.
Thanks in advance, its maddening not being able figure out what I need
search for.

Component, controller and context: wrong controller inside the component?

Component, controller and context: wrong controller inside the component?

I'm using ember.js 1.0.RC6
I have created a component (options-carousel) and I would like to render
content inside this component.
The first {{controller}}{{test}} is displaying the correct value for test
from the controller.
The second {{controller}}{{test}} is displaying the
OptionsCarouselComponent for the controller and nothing for the test
(because it seems a bad reference to the controller).

<div class="active item">
{{controller}}{{test}}
</div>
{{/options-carousel}}

Regex to extract lines after the last occurence

Regex to extract lines after the last occurence

Hi I have a paragraph like this :
output 123
Deepak everywhere
Deepak where are
output 123
Ankur Everywhere
Deepak where are
last
Deepak everywhere
Deepak where are
I want to extract after last occurrence of "output 123" to "last" . This
is what I expect :
Ankur Everywhere
Deepak where are
last
I use this RegEx pattern - (?<=(output))([^\\n]*)last . But using this,
what I get is :
output 123
Deepak everywhere
Deepak where are
output 123
Ankur Everywhere
Deepak where are
last
Can anyone help ? I use this tool - http://regexr.com?360e5

Django - Accessing model from django.contrib's User class via ManyToManyKey

Django - Accessing model from django.contrib's User class via ManyToManyKey

I am making a Hacker News Clone in Django as taught in a Tuts+ Course [Git
Repo]
In views.py file, for vote view, I tried using this code to increase
security by checking if user has liked the story already.
@login_required
def vote(request):
story = get_object_or_404(Story, pk=request.POST.get('story'))
user = request.user
if user.is_authenticated() and story not in user.liked_stories:
story.points += 1
story.save()
user.liked_stories.add(story)
user.save()
return HttpResponse()
But it gives me this Error:
NameError: global name 'liked_stories' is not defined
[18/Aug/2013 19:26:43] "POST /vote/ HTTP/1.1" 500 11148
I am able to use user.liked_stories in index view so why not in vote view?