Sunday 1 September 2013

Using HTML5 and CSS display 2 images level with each other, and each with a list below

Using HTML5 and CSS display 2 images level with each other, and each with
a list below

I'm new to CSS. I want to code a page in HTML5 that has 2 rather large
images of equal size and level with each other and with space between
them. I also want a left-margin between the left image and the left edge
of the page.
Directly below each image there will be an unnumbered list of 6 or so
items. Would someone be so kind as to draft the code for this? I know one
way to use CSS for spacing the images:
img { margin-right: 38px; margin-left: 50px; }
But what to do about the lists?
Thanks

Saturday 31 August 2013

C# event listener using lock() still throws exceptions

C# event listener using lock() still throws exceptions

im making an xna game, the problem involves the following classes:
Game class - this class listens to the event listeners of the two classes
below
Player class - this class launches a Fire() event, telling the game that
the player fires a bullet
Bullet class - this class launches a SelfDestruct() event(after a certain
traveled distance), telling the game that the instance has to be removed

The game class has a list of bullets, in the update method it does a
foreach on this list
The event listener for Fire() adds a new bullet to the bullet list The
event listener for SelfDestruct() removes the sender from the list(by
casting to bullet)
both events, as well as the update method locks the list for thread
safety. but it still throws an exception, telling that the list was
modified during the foreach.
how do i solve this; since i do lock on the list.. but that doesnt work:
Update:
public void Update(GameTime gameTime)
{
player.Update(GameTime gameTime);//can throw fire event
lock(Bullets)//Lock the list for thread safett
{
foreach(Bullet b in Bullets)//Throws exception when bullet is
added/removed
b.Update(gameTime);//can throw selfdestruct event
}
}
Fire listener:
void listen_fire(object sender, EventArgs e)
{
Player p = (Player)sender;/used to get coordinates and rotation stored
in the player
lock(Bullets)
{
Bullets.Add(new Bullet(p.Position,p.Rotation));
}
}
Self destruct listener:
void listen_selfdestruct(object sender, EventArgs e)
{
lock(Bullets)
{
Bullets.Remove((Bullet)sender);
}
}
I figured that this solution may fail because the event is thrown inside a
thread that has the list locked by itself already
any solutions are welcome, thanks for reading my question

How to avoid force close if there is no data to fetch in db

How to avoid force close if there is no data to fetch in db

I'm having some problem in avoiding force stop of my application. When I
click my load button it is supposed to load all data present in my
database. However, if there is no data present in my database, I want to
display a toast saying that there is no data to fetch in the db.
save.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
db.addContact(new PlayerData(name,score));
Log.d("Insert: ", "Inserting ..");
}
});
load.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
List<PlayerData> contacts = db.getAllContacts();
//check to ensure there are users
if(contacts.size()==0)
try {
throw new Exception();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
PlayerData player = contacts.get(0);
String showName = player.getName();
int showScore = player.getscore();
Log.d("Getting:", showName);
Log.d("Getting:", Integer.toString(showScore));
saved.setText("Player Name: "+showName+" Player Score:
"+showScore);
}
});

How can I get the base address of the target process after DLL injection?

How can I get the base address of the target process after DLL injection?

After I've successfully injected my dll into my target process, say
"target.exe", how can I get the base address of "target.exe"?
I've tried GetModuleHandle(0) and GetModuleHandle("target.exe") but it
doesn't seem to be right and I'm not sure how to debug. I've tried to
print it like this:
//retrive target's base address
DWORD EXEBaseAddr = (DWORD) GetModuleHandle((LPCWSTR)"target.exe");
std::stringstream sstr;
sstr << EXEBaseAddr;
std::string str = sstr.str();
String^ str3 = gcnew String(str.c_str());
baseAddressLBL->Text = str3;
I had to cast it at the end again because I'm using a Windows Form (not
sure if that's what it's called) to print the address in my interface.

django middleware redirect doesn't render page

django middleware redirect doesn't render page

I am writing custom middlware that I want to redirect to another page if a
condition is met. My code looks like this:
class SettingHandler(object):
def process_view(self, request, view_func, view_args, view_kwargs):
if request.setting:
return view_func(request, *view_args, **view_kwargs)
else:
return HttpResponseRedirect(reverse('setting'))
When the redirect condition is reached, the page doesn't render. The
output in the console looks like this:
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
"GET /setting/ HTTP/1.1" 302 0
How can I redirect to the desired page?

Adding up numbers in custom fields on a monthly basis

Adding up numbers in custom fields on a monthly basis

Every time i help out a client with a request i make a new post on my
wordpress-site. I write a little text about what the problem was, assign
the post to the clients own specific category and i fill inn the number of
minutes it took me to accomplish the request. The number of minutes i
insert in a custom field (using the advanced custom field plugin).
Then, i bill my client on a monthly basis according to how long time i
have spent solving request.
I have accomplished to query out the number of minutes for each
request/post and add up the total number of minutes. But here comes my
problem:
I would like the query to check out which month the post was published in,
and add up totals on a monthly basis. So lets say i helped a client like
this:
JANUARY
request took me 60 minutes
request took me 30 minutes
FEBRUARY
request took me 45 minutes
request took me 15 minutes
Then i would like to query out two seperate boxes saying You spent 90
minutes on requests in january You spent 60 minutes on requests in
february
Anyone able to solve this problem for me?
Anders

Copy only records that do not exist in the target table

Copy only records that do not exist in the target table

Having two tables (the source and target) intend to copy only the records
from the source table that do not exist in the target table (making the
comparison with the value of a specific cell in each record). I thought to
do it using arrays, but as I am new in this area, needed help.
Examples:
Source Table
ID Date Description
115 01-Ago Description1
120 05-Ago Description2
130 03-Ago Description5
110 08-Ago Description4
105 06-Ago Description6
Destination Table
ID Date Description
130 03-Ago Description5
110 08-Ago Description4
I want to add in the target table records from the source table that do
not exist in the target table (ID's 115,120,105 in this example). Thank
you!