Monday, 30 September 2013

Extracting a zip file in my machne givs me CRC error?

Extracting a zip file in my machne givs me CRC error?

I have a large zip that contain hundreds of file. I've unzip'ed it in more
than one machine and didn't have any problem before. However, for this
particular machine (Ubuntu Server 12.04) I keep getting CRC error for some
of the files inside my zip. I've unzip'ed the same file it on anther
machine just to and its fine.
Any clue?

Slave SQL Thread not running

Slave SQL Thread not running

My replication suddenly went offline. SHOW SLAVE STATUS shows me that I/O
Thread is running, while SQL thread is not.
I have error message:
Fatal error: Found table map event mapping table id 0 which was already
mapped but with different settings.
I haven't been able to find a solution for this using Google.
Stop/Start slave doesn't help much.

jQuery css transition toggle fix

jQuery css transition toggle fix

I have a little problem with jquery toggle function. Sometimes i can fix
it very fast but now im totally crazy about this. Im using jquery transit
plugin to animate a DIV
The code:
$(".grid-1").toggle( function() {
$(this).transition({ perspective: '170px', rotateY: '180deg' },
function() {
$(this).transition({ perspective: '170px', rotateY: '0deg' });
});
});
If i refresh the page this DIV (.grid-1) just disappear... where i make a
mistake ?
Thank you!

generating true random number

generating true random number

I want to simulate a random deliver of 52 standard cards without using
rand/srand urandom etc...
this is my random number function
int rand2(int lim)
{
static int a = 34; // could be made the seed value
a = (a * 32719 + 3) % 32749;
return ((a % lim) + 1);
}
the struct where i will know if a card have already popped ( 0 = NO, 1 yes )
typedef struct s_game
{
int *cards;
int state;
unsigned int dat_rand;
} t_game;
int main()
{
t_game game;
int i;
int rd;
i = 0;
game.cards = malloc(sizeof(*game.cards) * 52);
while(i < 52)
{
rd = rand2(52);
if(game.cards[rd] == 0)
{
game.cards[rd] = 1;
printf("i:%d\n rd: %d\n", i, rd);
i++;
}
}
}
But my output is always the same, each cards is delivered at the same time
so im searching fo a better random function or a different way to fill my
deliver

Sunday, 29 September 2013

If the events $\{E_n\}$ satisfy a certain property show that $P(\cap_{i=1}^k E_i) > 0$

If the events $\{E_n\}$ satisfy a certain property show that
$P(\cap_{i=1}^k E_i) > 0$

Let $\{E_n\}$ be events such that $\sum_{i=1}^kP(E_i) > k - 1$ then we
want to show that $P(\cap_{i=1}^k E_i) > 0$.
My approach for this problem is by contradiction. Suppose $P(\cap_{i=1}^k
E_i) = 0$ and then try and arrive at a contradiction. But we are not told
if the events are independent. I am not sure how from knowing
$P(\cap_{i=1}^k E_i) = 0$ to go to making conclusions about
$\sum_{i=1}^kP(E_i)$.

Splashscreen not showing Android PhoneGap

Splashscreen not showing Android PhoneGap

I am using PhoneGap 2.9.0 (cordova 2.7.0) to make an Android App. I want a
splashscreen in the application. I have followed all the steps mentioned
on:
http://docs.phonegap.com/en/2.9.0/cordova_splashscreen_splashscreen.md.html#Splashscreen
for setting up splashscreen. Still mentioning. I have added splash.png in
res/drawable-hdpi,res/drawable-xhdpi and so on...
I have the following code in my MainActivity.java file:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 10000);
I have the following code in index.html to hide the Splashscreen once the
document is loaded:
function onLoad(){
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
navigator.splashscreen.hide();
}
Still the Splashscreen Image doesn't show up when I run the app. Instead
when I load the application a BLANK BLACK SCREEN shows up for round about
10 seconds.
(P.S. The PNG image is a 9-Patch image. So no problem there too..
Moreover, I have tried uninstalling and reinstalling the app to make sure
there's no problem due to caching. Still no results)
Please help

Selenium (Python): How to insert value on a hidden input?

Selenium (Python): How to insert value on a hidden input?

I'm using Selenium's WebDriver and coding in Python.
There's a hidden input field in which I'm trying to insert a specific date
value. The field originally produces a calendar, from which a user can
select an appropriate date, but that seems like a more complicated
endeavour to emulate than inserting the appropriate date value directly.
The page's source code looks like this:
<div class="dijitReset dijitInputField">
<input id="form_date_DateTextBox_0" class="dijitReset" type="text"
autocomplete="off" dojoattachpoint="textbox,focusNode" tabindex="0"
aria-required="true"/>
<input type="hidden" value="2013-11-26" sliceindex="0"/>
where value="2013-11-26" is the field I'm trying to inject a value (it's
originally empty, ie: value="".
I understand that WebDriver is not able to insert a value into a hidden
input, because regular users would not be able to do that in a browser,
but a workaround is to use Javascript. Unfortunately that's a language I'm
not familiar with. Would anyone know what would work?

CREATE TABLE Query not working

CREATE TABLE Query not working

$con->query("CREATE TABLE jobs
(
ID INT AUTO_INCREMENT,
Title VARCHAR(32),
Company VARCHAR(32),
Country VARCHAR(32),
City VARCHAR(32),
Email VARCHAR(32),
Website VARCHAR(32),
Description VARCHAR(1000)
);");
Does anyone know why it does not work?
Thanks in advance

Saturday, 28 September 2013

Problem about indexing files between partitions

Problem about indexing files between partitions

I'm here for talking to you about a problem. First of all sorry for being
noobish but I just installed Ubuntu this night. Anyhow, here's the
problem: I have my PC with a double boot Ubuntu+Windows 8 and I installed
Ubuntu in a secondary partition in my 500gb hard drive. In the other
partition there are my files such as music, downloads etc for my windows
hard drive ( I have an SSD where is stored 8 and an hard drive where I
have my files and Ubuntu). So now I'm trying to use my music with
banshee's library system and at the first time that I used that library I
got no problems. Now that I reboot Ubuntu when I try to play the music the
software just says that he can't find the file ( I suppose that Ubuntu
gets some time before loading files from other partitions but dunno... ).
And the same thing happens with my Dropbox folder withc is in the same
partition of the music one. So, Is there a way to fix this annoying
problem or it's just something that I should ignore ? Anyhow, Ubuntu 13.04
is installed on ext4 and my file partition on ntfs. For better
understanding here a little graphic explanation about my partitions:
C: -> Windows 8 D: -> Ubuntu partition (E:) My files Basically the file
hard drive has two partitions Sorry for my English mistackes but I'm
Italian
Thank you for the attention given to me and have a nice day

Android - How to test onResume()?

Android - How to test onResume()?

I'd like a way to easily take an app and put it into a saved state mode
(on an actual device) so that I can resume the app and thus test the
onResume function. On android devices, when one exists an app, it does not
instantly save its state; instead, it keeps the app running for quite a
while in case you decide to return to it shortly. This causes the onResume
function to not actually be called. Instead of having to wait that long
period of time with the app out of focus before the OS decides to save its
state, I'd like a way to quickly tell the OS to do this. Any suggestions?

Uncaught TypeError: Object [object Object] has no method 'multipleSelect'

Uncaught TypeError: Object [object Object] has no method 'multipleSelect'

I have used the ajax function when calling this function with
multipleSelect like this. suppose that I have a function that called again
in ajax load page
I have included jquery and jquery.multiselect.js include file also
$('#demo3').multipleSelect({
placeholder: "Select Country",
filter:true
});
});
$("#button").click(function(){
$.ajax({
url:"http:localhost/mydata",
success:function(data){
$('#demo4').multiSelect({
placeholder: "Select Country",
filter:true
});
},
});
});
demo3 has successfully generate multiselect function. But when I have
pressed button the code in demo4 has error that multiselect function has
not been registered in a page?
The error code said.. Uncaught TypeError: Object [object Object] has no
method 'multipleSelect'
How I can solve this ? Thanks

Java Logger with Log4j

Java Logger with Log4j

Am processing files using java , there are 2 or 3 Java components to
process files.My requirement is for file must have a log file and its
processing details will be logged in relevant log file.

Problem is for single file it works well but with multiple file am getting
problem. When multiple files are getting processed logger is logging log
detail of file1.txt logs to file2.log instead of file1.log...
public Class FileProcessComponent1
{
public void process()
{
Logger Log = Logg.getLogger1("file1",this.getClass());
log.info("file1 logging");
}
}
public Class FileProcessComponent2
{
public void process()
{
Logger Log = Logg.getLogger1("file1",this.getClass());
log.info("file1 logging");
}
}
public Class Logg
{
public static Logger getLogger1(String fileName,Class clazz) throws
Exception
{
if(fileName == null || "".equals(fileName.trim()))
throw new Exception("File Name or Map for File Name is Null");
fileName = "/home/logs/"+fileName+".log";
Logger logger =
Logger.getLogger(clazz.getCanonicalName()+":"+System.nanoTime());
logger.setAdditivity(false);
FileAppender appender = new DailyRollingFileAppender(new
PatternLayout("%d{ISO8601}\t%p\t%c\t%m%n"), fileName,
"'.'yyyy-MM-dd");
logger.addAppender(appender);
logger.setLevel(Level.DEBUG);
return logger;
}
}

Friday, 27 September 2013

how to find average of value by using php

how to find average of value by using php

am very new in php am skacking on this, please can any one help me on how
to get average of this values of v01 from table "Marks" by using php. Note
v01 or v02 is student idnumber,thank you in advanced.
And this is Marks table with the following fields.
Idnumber Math Geography English
v01 95 100 80
v02 70 90 70

Deploy web project in ClassInitialize

Deploy web project in ClassInitialize

I have a separate project for running Selenium based UI tests. These hit
my local IIS (my MVC app is bound to my local IIS)
I use MSUnit to execute these tests.
My problem is the tests run against the code base I last published, not
against the latest version. To run tests against the latest version I need
to publish my project again.
I think I want to deploy my web site in the ClassInitialize method. How
can I do this or otherwise solve my problem.

Can you open a ServerSocket from Tomcat?

Can you open a ServerSocket from Tomcat?

I need to stream binary data in real time through a socket from Tomcat.
Can you open a ServerSocket on Tomcat at startup? If so, where do you do
that?

Best way to make if statements

Best way to make if statements

Basically I am getting values from checkboxes (i.e. how many check boxes
checked in a form). What I need to happen is echo a price for a certain
number values. Here is what I was thinking but not sure if its the correct
way to do it:
$clubTotal = array(
$driversChecked,
$hybridsChecked,
$woodsChecked,
$boxesChecked,
$wedgesChecked,
);
$numberOfclubs = array_sum($total)
if ($numberOfclubs > 6)
echo "price";
if ($numberOfclubs == 6)
echo "price";
if($numberOfclubs > 6 && $numberOfclubs < 9)
echo "price";
I am sure that will work the way I need, just not sure if there is a
shorthand or better way to write it. Thanks.

Collision detection in tile-base game only applies to the file tile in the array

Collision detection in tile-base game only applies to the file tile in the
array

I've written a prototype in java that employs a movable character and
tile-based graphics and game logic. The layout of each level is stored in
a 10x10 2D array. When I use the following code to detect whether or not
the player is colliding with a '1' (empty) tile, it only returns positive
when the player is colliding with the final '1' tile in the array, why is
this? I understand this method is incredibly inefficient.
for(int r = 0; r < levArray.length; r++) {
for(int c = 0; c < levArray[0].length; c++) {
if(levArray[r][c] == 1) {
if(px >= r*64-9 && px <= (r+1)*64+11 && py >= c*64-30 &&
py <= (c+1)*64+30) {
isColliding = true;
} else {
isColliding = false;
}
}
}
}

has no method 'focus' on ui-bootstrap datepicker

has no method 'focus' on ui-bootstrap datepicker

I'm getting this error:
TypeError: Object [object Object] has no method 'focus'
when I do click on datepicker input. I'm using:
angular v1.0.8
angular-bootstrap v0.5
This plunker shows that error

high performance site with lots of image in asp.net

high performance site with lots of image in asp.net

Recently i create a website in ASP.NET with c#.Its media site so having
lots of high resolution images and dynamic controls. And its degrade and
slow the site performance. Give me some solution to solve this problem.

Thursday, 26 September 2013

Find the size of a an image sent from Java to PHP as a byte array.

Find the size of a an image sent from Java to PHP as a byte array.

I am very new to PHP, Java is my domain. I have a specific problem that
when I upload a picture from my client side to be stored in the database,
before saving it I want to calculate the file size and it should be less
than 3mb. I am sending this file from Java as a byte array. I Googled
around and found that
$result_array = getimagesize($file);
can give me the file size, however it takes an argument which has to be a
file. How do I do it for a byte array? do I have to convert it first. I
beg pardon, this might be a naive question but consider my being new to
PHP.
So far my PHP looks like this:
<?php
require 'DbConnect.php';
$IMG= $_POST["Image"];
$IMG2= $_POST["Image2"];
$IMG3= $_POST["Image3"];
$IMG4= $_POST["Image4"];
$ID = $_POST["Seller_ID"];
$query2 = "INSERT INTO used_cars (Img, Img2, Img3, Img4) VALUES ('$IMG',
'$IMG2', '$IMG3', '$IMG4')";
mysql_query($query2) or die(mysql_error())
?>

Wednesday, 25 September 2013

Filter File based on directory

Filter File based on directory

I have directory which contain multiple sub directory and each sub
directory also contain multiple directory.I have file which present in all
sub directory and need to pick file based on sub directory.Can I get some
input.
like <cell 1> <cell 2> <cell 3>
each cell1
<job 1> <job 2> < job 3>
each job contain sample. txt
similar cell2 and cell 3. So I want to extract sample.txt from each
cell/job1 directory. and written following program. just modify program
after fix issue . Can we done more better way
#!/usr/bin/py
import os
def find_all(name, path):
result = []
for root, dir, files in os.walk(path):
print "root %s dir %s" %(root, dir)
if "job1" in root:
print "\n"
if name in files:
result.append(os.path.join(root, name))
return result
name = "sample.txt"
path = "."
data = find_all(name, path)
print data
~

Thursday, 19 September 2013

Prevent showing table array if database table is empty?

Prevent showing table array if database table is empty?

How do I add an if statement to not display this table if the database
table filmInfo is empty?
$quary="SELECT filmTitle, filmRole, filmDirector, idfilm FROM filmInfo,
actorsInfo
WHERE (actorsInfo.id = filmInfo.id_actor) AND email = '$_SESSION[email]'";
$result = mysql_query($quary);
$count=mysql_numrows($result);
echo "<table>";
echo "<table border='1' style='border-collapse: collapse;border-color:
silver;'>";
echo "<tr style='font-weight: bold;'>";
echo "
<td width='20' align='center'>#</td>
<td width='200' align='center'>TITLE</td>
<td width='200' align='center'>ROLE</td>
<td width='200' align='center'>DIRECTOR</td>";
echo "</tr>";
$row_number = 1;
while ($row = mysql_fetch_array($result)) {
$id_actor= $row["id_actor"];
$idfilm= $row["idfilm"];
$filmTitle= $row["filmTitle"];
$filmRole= $row["filmRole"];
$filmDirector= $row["filmDirector"];
echo"<tr>";
echo '<td><input name="checkbox[]" value="'.$idfilm.'" type="checkbox"
id="checkbox'.$row_number.'" /></td>';
for ($i=0; $i<3; $i++) {
echo"<td> $row[$i]</td>";
}
echo"</tr>";
$row_number++;
}
echo"</table>";

how to create a vertical datatable

how to create a vertical datatable

Í´ve got a regular datatable in primefaces, but I want it to display data
in a vertical way. When you create a datatable; you get something like:
id user 1 aa 2 bb
But I need to show it like this:
id 1 2 user a bb
This is the code of a regular table:
<h:form>
<p:dataTable var="car" value="#{tableBean.carsSmall}">
<p:column headerText="Model">
<h:outputText value="#{car.model}" />
</p:column>
<p:column headerText="Year">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Manufacturer">
<h:outputText value="#{car.manufacturer}" />
</p:column>
<p:column headerText="Color">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
</h:form>
What do I need to change in the code so I can have a vertical table.
Thanks in advance.

Echo out 16.97 without the decimal place

Echo out 16.97 without the decimal place

So just like the title says, I have the need to echo out 16.97
16.97 is actually an example of a calculation done with php
I am using Stripe as my payment processor and the charge amount needs to
be passed without decimal places. So 16.97 for example needs to display as
1697
Right now this is what I have and it shoots out 17 rather than 1697, I
assume it is rounding.
data-amount="<?php echo number_format($grandTotal);?>"
$grandTotal is a value set up in my php like so:
$grandTotal = $get_row['price']*$value+$get_row['shipping'];
All of these have decimal places but when I get to sending information to
stripe, it doesn't need the decimal place.
I have tried multiple solutions from stackoverflow as well google and
nothing worked.
So my question is what do I need to do to:
data-amount="<?php echo number_format($grandTotal);?>"
or more specifically just number_format($grandTotal); to receive a number
with no decimal places. I've read that number_format always rounds, so is
there another way to do this? I hope this makes sense. If not ask
questions in comments!

you tube api is this url valid or not - json url in end of html to get feeds

you tube api is this url valid or not - json url in end of html to get feeds

you tube api is this url valid or not - json url in end of html to get
feeds? if is valid if insert in browser address bar must get the feeds ? I
do not get any either in javascript code, anyway is it valid or...?
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&max-results=30&category=Villalobos&callback=listVideos

Subscripting into an empty matrix is not supported matrix coder

Subscripting into an empty matrix is not supported matrix coder

I have a matlab file, working fine,
I am trying to conver it using auto coder, however I get an error,
??? Subscripting into an empty matrix is not supported.
ct = 0;
while i <= 1800
[xx, cc, vv] = doSomething(x, somevalue, Param1, dt);
%things happening ...
if something
flowDt(ct+1) = vv;
ct = ct + 1;
end
end
I tried then to declare it before the loop because I got an error: ???
Undefined function or variable 'flowDt'.'
flowDt = [];
ct = 0;
while i <= 1800
[xx, cc, vv] = doSomething(x, somevalue, Param1, dt);
%things happening ...
if something
flowDt(ct+1) = vv;
ct = ct + 1;
end
end
now I am stuck not knowing what is causing this issue: ??? Subscripting
into an empty matrix is not supported.

Developing a bar code scanner

Developing a bar code scanner

I am new in android development. Actually i am going to build a bar code
scanner app. So, can I have any easy ideas how to build this app. I only
want to scan the barcode image and decode it.
So, please help me in giving me easy and innovative ideas.
thanks in advance.

How to connect Java server(Glassfish) and Flash(games)

How to connect Java server(Glassfish) and Flash(games)

I would like to write game using Flash which will be communicate with my
Java server(Glassfish). My first thought was to use XMLSocket but write
the whole communication with this would be difdicult I have no experiance
with Flash so maybe better idea will be write all(comunication with
database ect.) inside Flash ? I read something about media server(red5,
Adobe Flash Media Server) but i have no idea how it would work and whether
it would be appropriate solution for me. Is there anyone who has some
experiance in connecting these two technology ?

Can not add web service reference to my project using port number

Can not add web service reference to my project using port number

I can access serverIP:7075//webservice from a web browser but I cannot add
it to Visual Studio. It throws an exception.

Wednesday, 18 September 2013

Add a value to a Text='

Add a value to a Text='

Here is my entire web form so you can see what I have done. I want to be
able to put the value of generatePassword(6) into the:
InsertCommand="INSERT INTO utcasesTest(created_by_user_id, status_id,
criticality_id, project_id, case_num, ... field in my db table.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
'Our Function generatePassword accepts one parameter 'passwordLength'
'passwordLength will obviously determine the password length.
'The aplhanumeric character set is assigned to the variable sDefaultChars
Function generatePassword(passwordLength)
'Declare variables
Dim sDefaultChars
Dim iCounter
Dim sMyPassword
Dim iPickedChar
Dim iDefaultCharactersLength
Dim iPasswordLength
'Initialize variables
sDefaultChars =
"abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789"
iPasswordLength = passwordLength
iDefaultCharactersLength = Len(sDefaultChars)
Randomize() 'initialize the random number generator
'Loop for the number of characters password is to have
For iCounter = 1 To iPasswordLength
'Next pick a number from 1 to length of character set
iPickedChar = Int((iDefaultCharactersLength * Rnd) + 1)
'Next pick a character from the character set using the random
number iPickedChar
'and Mid function
sMyPassword = sMyPassword & Mid(sDefaultChars, iPickedChar, 1)
Next
generatePassword = sMyPassword
End Function
</script>
<script runat="server" type="text/vb">
Sub FormView1_Item_Inserted(ByVal sender As Object, ByVal e As
FormViewInsertedEventArgs)
Response.Redirect("ThankYou.asp")
End Sub
Protected Sub FormView1_PageIndexChanging(sender As Object, e As
System.Web.UI.WebControls.FormViewPageEventArgs)
End Sub
Protected Sub SqlDataSource1_Selecting(sender As Object, e As
System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<!-- Input Form-->
<form id="form1" runat="server" method="post">
<div>
<asp:FormView ID="FormView1" runat="server"
DataKeyNames="case_id"
DataSourceID="SqlDataSource_OC"
DefaultMode="Insert"
OnItemInserted="formview1_Item_Inserted"
onpageindexchanging="FormView1_PageIndexChanging">
<InsertItemTemplate>
<table>
<tr>
<td>criticality_id:</td>
<td>
<asp:DropDownList ID="criticality_idTextBox"
runat="server"
Text='<%#
Bind("txt_criticality_id","{0:D}") %>'
DataSourceID="SqlDataSource_Criticality"
DataTextField="ut_value"
DataValueField="criticality_id"
AppendDataBoundItems="true">
<asp:ListItem Value="0"
Text="--Select Level--"
Selected="True" />
</asp:DropDownList>
<br />
</td>
</tr>
<tr>
<td>case_num:</td>
<td>
<asp:TextBox Name="txt_case_num"
ID="case_numTextBox"
runat="server"
Text='<%# Bind("txt_case_num") %>' /> **<------
This is the textbox the value needs to go into.
It will be hidden so the user wont see it**
<br />
</td>
</tr>
<tr>
<td>title:</td>
<td>
<asp:TextBox ID="titleTextBox"
runat="server"
Text='<%# Bind("txt_title") %>' />
<br />
</td>
</tr>
<tr>
<td>description:</td>
<td>
<asp:TextBox ID="descriptionTextBox"
runat="server"
Text='<%# Bind("txt_description") %>'
TextMode="MultiLine" />
<br />
</td>
</tr>
<tr>
<td>external_email_address:</td>
<td>
<asp:TextBox ID="external_email_addressTextBox"
runat="server"
Text='<%# Bind("txt_external_email_address")
%>' />
<br />
</td>
</tr>
</table>
<asp:LinkButton ID="InsertButton"
runat="server"
CausesValidation="True"
CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton"
runat="server"
CausesValidation="False"
CommandName="Cancel"
Text="Cancel" />
</InsertItemTemplate>
</asp:FormView>
<!--Datasource-->
<asp:SqlDataSource ID="SqlDataSource_OC"
runat="server"
ConnectionString="<%$
ConnectionStrings:OC_ConnectionString %>"
InsertCommand="INSERT INTO
utcasesTest(created_by_user_id, status_id,
criticality_id, project_id, case_num, is_active,
description, title, created_by_timestamp,
modified_by_timestamp, modified_by_user_id,
is_external, external_email_address, object_id,
object_type_id) VALUES (@txt_created_by_user_id,
@txt_status_id, @txt_criticality_id,
@txt_project_id, @txt_case_num, @txt_case_num
**<-------This is where the value is passed to the
DB**, @txt_description, @txt_title, getdate(),
getdate(), @txt_modified_by_user_id,
@txt_is_external, @txt_external_email_address,
@txt_object_id, @txt_object_type_id)"
SelectCommand="SELECT utcasesTest.* FROM utcasesTest">
<InsertParameters>
<asp:Parameter Name="txt_created_by_user_id" DefaultValue="1" />
<asp:Parameter Name="txt_status_id" DefaultValue="1" />
<asp:Parameter Name="txt_criticality_id" />
<asp:Parameter Name="txt_project_id" DefaultValue="1" />
<asp:Parameter Name="txt_case_num" /> **<----------Paramater
Definition**
<asp:Parameter Name="txt_is_active" DefaultValue="Y" />
<asp:Parameter Name="txt_description" />
<asp:Parameter Name="txt_title" />
<asp:Parameter Name="txt_created_by_timestamp" />
<asp:Parameter Name="txt_modified_by_timestamp" />
<asp:Parameter Name="txt_modified_by_user_id" DefaultValue="1" />
<asp:Parameter Name="txt_is_external" DefaultValue="Y" />
<asp:Parameter Name="txt_external_email_address" />
<asp:Parameter Name="txt_object_id" DefaultValue="-1" />
<asp:Parameter Name="txt_object_type_id" DefaultValue="-1" />
</InsertParameters>
</asp:SqlDataSource>
<!--Data source for criticallity dropdown-->
<!--Change Project ID to select criticality from right Binder: id 3 =
GNRM-->
<asp:SqlDataSource ID="SqlDataSource_Criticality"
runat="server"
ConnectionString="<%$
ConnectionStrings:OCConnectionString_utcriticality
%>"
SelectCommand="SELECT project_id, ut_value,
criticality_id FROM utcriticality WHERE (project_id
= 3)"
onselecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
<!--End data source for criticallity dropdown-->
</div>
</form>
</body>
</html>

How to properly use hashes and salt to protect against MITM and database access?

How to properly use hashes and salt to protect against MITM and database
access?

I want to protect a website against two security threads, one is a Man in
the Middle attack and the other against unauthorized access to the
database to get passwords.
I'm aware that to protect user's password stored in the database the best
way to do it is hashing and salting the password using good hashing
algorithms like sha512.
Also that to protect the password from a Man in the Middle sniff attack
you can also hash and salt the password before is sent through the
network.
For what I've read the proper way to protect passwords against a database
intrusion is
To Store a Password
Generate a long random salt using a CSPRNG.
Prepend the salt to the password and hash it with a standard cryptographic
hash function such as SHA256.
Save both the salt and the hash in the user's database record.
To Validate a Password
Retrieve the user's salt and hash from the database.
Prepend the salt to the given password and hash it using the same hash
function.
Compare the hash of the given password with the hash from the database. If
they match, the password is correct. Otherwise, the password is incorrect.
And that to protect a password against a sniffing attack the server
provides a random salt string to the client application for it to hash it
with the password before sending it through the network back to the server
to be compared. But how can you compare the received password if the one
stored in your database has been hashed with a different salt (if the
method for protecting passwords against database access was used) ?
I'm really confused. Can these two security threads be solved by combining
these two methods if so, how? or instead of hashing and salting for the
sniffing attack the best way to protect is to use SSL?
Thanks in advance I hope all this makes sense.

Using rbenv with Docker

Using rbenv with Docker

I am trying to setup rbenv with a Dockerfile, but this just fails on rbenv
install. I do have ruby-build in there, it just doesn't seem to work.
Relevant bits of the Dockerfile (largely lifted from
https://gist.github.com/deepak/5925003):
# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
RUN echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN chmod +x /etc/profile.d/rbenv.sh
# install ruby-build
RUN mkdir /usr/local/rbenv/plugins
RUN git clone https://github.com/sstephenson/ruby-build.git
/usr/local/rbenv/plugins/ruby-build

ENV PATH
/usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Set to Ruby 2.0.0-p247
RUN rbenv install 2.0.0-p247
RUN rbenv rehash
RUN rbenv local 2.0.0-p247
Error:
Step 21 : RUN rbenv install 2.0.0-p247
---> Running in 8869fa8f0651
rbenv: no such command `install'
Error build: The command [/bin/sh -c rbenv install 2.0.0-p247] returned a
non-zero code: 1
The command [/bin/sh -c rbenv install 2.0.0-p247] returned a non-zero code: 1

Loop through arrayList to get values of an abstract method

Loop through arrayList to get values of an abstract method

Ok I have an abstract class 'Order':
public abstract class Order {
protected String location;
protected double price;
public Order(double price, String location){
this.price = price;
this.location = location;
}
public abstract double calculateBill();
public String getLocation() {
return location;
}
public double getPrice() {
return price;
}
public abstract String printOrder(String format);
}
I also have 3 classes that implement it that are similar except, of
course, that they calculateBill differently according to tax, tariff, etc.
now I am trying to create and OrderManager class to manage them. This is
what I have so far
public class OrderManager {
private ArrayList<Order> orders;
public OrderManager() {
}
public OrderManager(ArrayList<Order> orders) {
this.orders = orders;
}
public void addOrder(Order o) {
orders.add(o);
}
public ArrayList<Order> getOrdersAbove(double val) {
for (Order o : orders) {
}
}
I'm having trouble with the getOrdersAbove method which should return and
array list of orders whose bill is above val. Being the calculateBill is
abstract and implemented in each subclass of order I should just be able
to call it correct? Also if that is the case then shouldn't OrderManager
extend Order? Or just being in the same package would allow me to call
it's methods? Or am I going about it all wrong?
Thanks for any and all help!

UIView animation code working fine in iOS6 but not in iOS7

UIView animation code working fine in iOS6 but not in iOS7

I have a UIAnimation code which increases the height of a UITableview as
below
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"%f",[summaryTableview frame].size.height);
if([UIScreen mainScreen].bounds.size.height == 568)
{
[UIView animateWithDuration:0.0 delay:0
options:UIViewAnimationOptionBeginFromCurrentState animations:^{
CGRect tableviewRect = [summaryTableview frame];
[summaryTableview setFrame:CGRectMake(tableviewRect.origin.x,
tableviewRect.origin.y, tableviewRect.size.width,
tableviewRect.size.height + 80)];
} completion:^(BOOL finished) {
NSLog(@"%f",[summaryTableview frame].size.height);
}];
}
}
I am checking if the current device is iPhone5 and if so, I am increasing
the UITableview called SummaryTableview to fill in the extra height. This
piece of code works as expected in iOS6 but the tableview is not getting
extended in iOS7.
Any suggestion will be helpful.Thank you
Update: iOS 6: First NSLog logs 358 and second NSLog logs 438 iOS 7: First
NSLog logs 358 and second NSLog logs 358
As you can notice second NSLog is inside animation completion block.

Using jQuery and JavaScript, how do I distinguish between two XML levels that have the same Name attr?

Using jQuery and JavaScript, how do I distinguish between two XML levels
that have the same Name attr?

So this is an example Documentation.XML file of what I am trying to parse
using jQuery
<DocPortal Version="">
<Folder Name="Sample Drawings" User="*">
<File Type="TILES" Name="Sample1" FileName="Sample1.zip"/>
</Folder>
<Folder Name="Sample Site Information" User="*">
<Folder Name="SampleInnerFolder1" User="*">
<File Type="PDF" Name="Sample1" FileName="Sample1.pdf"/>
<File Type="PDF" Name="Sample2" FileName="Sample2.pdf"/>
</Folder>
<Folder Name="SampleInnerFolder2" User="*">
<File Type="PDF" Name="Sample1" FileName="Sample1.pdf"/>
<File Type="PDF" Name="Sample2" FileName="Sample2.pdf"/>
</Folder>
<File Type="PDF" Name="Sample1" FileName="Sample2.pdf" QR=""/>
<File Type="PDF" Name="Sample2" FileName="Sample2.pdf" QR=""/>
</Folder>
</DocPortal>
When I perform the following code, I get a list of all Folder names in
both levels
$.get(lDocumentationFilePath , function(data){
$('#content').empty();
$(data).find('Folder').each(function(){
var $Folder = $(this);
console.log($Folder.attr('Name'));
});
});
What I want is just a list of each of the top-level Folder Names. So just
"Sample Drawings" and "Sample Site Information".
Any ideas?

jquery works in chrome console not in page

jquery works in chrome console not in page

I have a simple jquery function that removes the first class. The problem
is that it wont work when I use the script in the website, but it works
fine when running the script inside the console(chrome)
Any ideas?
$(document).ready(function() {
jQuery('.instagram-placeholder:first').hide();
});
http://akvesterberg.se/

Effect of iOS 7 update on my app

Effect of iOS 7 update on my app

I have an app released on the app store and I am still working on my iOS 7
update. How will the upgrade to iOS 7 affect the version of my app that is
already out there? Will the users who have upgraded still be able to use
the existing version?

Does null condition is required while checking validation in input

Does null condition is required while checking validation in input

I am checking input box validation in java script using if condition.do we
also need to check for null. Or we can check only =''.
<script type="text/javascript">
if(txtname==null||txtname=='')
{
return false;
}
</script>

Tuesday, 17 September 2013

Assistance for understanding Qthread and Signals. (Pyside)

Assistance for understanding Qthread and Signals. (Pyside)

i am trying to understand how to do a Qthread and i have this skeletal
code. my main objective is to not let the GUI "hang" while the backend is
doing some database stuff and at the same time updating a table widget in
the GUI. background: Doing this on Windows OS. Pyside as the GUI. (I also
tried Python threading, but everytime my application crashes)
class GenericThread(QtCore.QThread):
def __init__(self, function, *args, **kwargs):
QtCore.QThread.__init__(self)
self.function = function
self.args = args
self.kwargs = kwargs
def __del__(self):
self.wait()
def run(self):
self.function(*self.args,**self.kwargs)
return
clas myMainGUI(...)
def add(self):
...
for myfiles in os.listdir(..): <--- intensive process, lots of files
column headers = [ .... ]
result = select_data_from_file(myfiles) <----- database file
processing
self.insert_table_widget ( column headers, result ) <--want
to insert to widge in "realtime" and do other stuff without
GUI getting "hang"
....
self.mythread.emit() <-- ??
def coolie(self): # some button will call this function.
if buttonclick == "add":
self.mythread = GenericThread(self.add)
self.mythread.disconnect() <------??
self.mythread.connect() <------ ??
self.mythread.start()
any idea how should my emit(), connect() or disconnect() be? thanks

apache: Complex URL redirecting

apache: Complex URL redirecting

I have url like this
http://www.mywebsiteaddress.com/id/sports/onepage/?AFF_ID=93305
and I want to redirect it into
http://sports.mywebsiteaddress.com/id-id?AFF_ID=93305
I really confuse about the regex in apache mod_rewrite rules.
can anybody help me with this?
thank you very much

Deleting duplicates in an array of annotations

Deleting duplicates in an array of annotations

I have a MKMapKit I'm populating with annotations using data I'm fetching
from an API. Each annotation has a title, description, URL, and
coordinates. I have a button I added to a navigation bar to fetch more
results and populate more annotations. The problem is when the API runs of
out new results in populates the map with duplicates of annotations that
were already fetched. I'm trying to delete duplicate annotations from an
array using an if statement but it's not working. Any suggestions? Thanks
in advance.
-(void)layAnnotations
{
if (self.annotations) {
[self.mapView removeAnnotations:self.annotations];
}
self.annotations = [NSMutableArray array];
for (Object *aObject in self.objectArray) {
CLLocationCoordinate2D coordinate;
coordinate.latitude = [aObject.latitude floatValue];
coordinate.longitude = [aObject.longitude floatValue];
Annotations *annotation = [[Annotations alloc] init];
annotation.title = aObject.objectTitle;
annotation.subtitle = aObject.description;
annotation.url = aObject.url;
annotation.coordinate = coordinate;
//attempting to filter duplicates here
if (![self.annotations containsObject:annotation]) {
[self.annotations addObject:annotation];
}
annotation = nil;
}
[self mutateCoordinatesOfClashingAnnotations:self.annotations];
[self.mapView addAnnotations:self.annotations];
}

Scala - hashCode caching for immutable collections

Scala - hashCode caching for immutable collections

It seems that immutable scala collections do not cache their hashCode
calculations (tested for immutable.HashSet), but instead re-compute it
each time. Is there any easy way to add this behaviour (for performance
reasons)?
I've thought about creating a subclass of immutable.HashSet which does the
caching, but didn't see any way to implement the + etc. functions to
return an caching object. While possible to do with delegation, that's
just seems horribly ugly.

iOS - Sending Touche Events To A DFPBannerView from a Custom ScrollView

iOS - Sending Touche Events To A DFPBannerView from a Custom ScrollView

I am trying to implement DFP ads into my iOS application within a custom
scroll view.
I have a number of view controllers within a horizontal custom
UIScrollView, and after a few pages I have a DFPBannerView the size of the
full UIScrollView frame. My custom scroll view overrides the
touchesBegan:, touchesMoved:, etc methods of the UIScrollView because of
some unique behavior I want to get out of it. My problem arises when the
user tries to click on the DFPBannerView. Instead of the banner view
receiving the touch, the scroll view does instead. Since apparently you
can't send touch events directly to a DFPBannerView I end up stuck with
nothing to do with that touch event.
Is there any way around this? Perhaps some way to disable touches (but not
swipes) on the custom UIScrollView when the view controller with the
DFPBannerView is showing?
Thank you for any help.

Adding a group to a Linux directory

Adding a group to a Linux directory

On my Linux server I have made a group called emtbackup and added user1
and user2 to it. Also user3 created a directory called dbbackup so the
path looks like this:
/var/www/vhosts/mysite.com/httpdocs/dbbackup
How do I add the group emtbackup to dbbackup directory with rw rights? The
end result should allow all 3 users to read, write to dbbackup directory.

C malloc allocated only 8 bytes for int *

C malloc allocated only 8 bytes for int *

I'm trying to create a pointer to a 6 element int in a function to return
it later, so for that purpose I'm using malloc, but it seems to be acting
not as I expected. Here's the code:
int j = 0;
for (;j < 5; j++) {
int * intBig = malloc(j * sizeof(int));
printf("sizeof intBig - %ld\n", sizeof(intBig));
}
Prints the same number 8 bytes as the sizeof(intBig) at each iteration.
Whereas I would expect a series of 4, 8, 12, 16. What am I missing in this
instance?

Sunday, 15 September 2013

Count Two Column Values Based on One Same Column in Two tables in mysql

Count Two Column Values Based on One Same Column in Two tables in mysql

Situation is like this:
Table One (sms)
id | t_id | sms_text
1 | 200 | some text here ...
2 | 201 | some text here ...
3 | 202 | some text here ...
4 | 201 | some text here ...
5 | 202 | some text here ...
6 | 202 | some text here ...
Table Two (msg)
id | t_id | msg_text
1 | 201 | some text here ...
2 | 202 | some text here ...
3 | 200 | some text here ...
4 | 200 | some text here ...
5 | 202 | some text here ...
6 | 200 | some text here ...
Now I Want Result Something Similar
Count Result (sms + msg)
t_id | count result
200 | 4
201 | 3
202 | 5
Is is possible?? If yes, how?

simplest way to echo one value of one row

simplest way to echo one value of one row

I have this simple query
$qry = "select MAX(image_id) from tpf_images";
$res = $pdo->query($qry);
the result of which is just one number. What is the quickest, simplest way
to echo that number out with php?
Thanks

jquery (e) function parameter meaning

jquery (e) function parameter meaning

I am using Dreamweaver for jQuery coding and it automatically completes
the initial jquery selection as follows:
$(document).ready(function(e) {
});
What does the "e" mean in the function definition and what is the official
documentation of this parameter? A link would be helpful to official
documentation.

Imdb Grabber Guidance

Imdb Grabber Guidance

need a bit of assistance.
I have a Imdb grabber that grabs certain details from the site for example.
This code
$ps = $dom->getElementsByTagName('p');
for($i=0;$i<$ps->length;$i++){
$itemprop = $ps->item($i)->getAttribute("itemprop");
if ($itemprop=="description"){
$tmp = explode("See full summary",$ps->item($i)->textContent);
$tmp = explode("See full synopsis",$tmp[0]);
$res['summary'] = trim($tmp[0]);
break;
}
}
Grabs the description from imdb.com from this
<p itemprop="description"> description would be here </p>
So like the description how could i get the release date from this
<span class="nobr">
<a href="/title/tt2404311/releaseinfo?ref_=tt_ov_inf " title="See all
release dates"> 13 September 2013<meta itemprop="datePublished"
content="2013-09-13">(USA)
</a>
</span>
Could some help me out please.

Does Google calendar PHP API check request domain?

Does Google calendar PHP API check request domain?

I'm in the process of migrating a PHP site to a new server.
The existing site correctly logs in to Google calendar API via PHP which
enables the PHP to create/modify events in my Google calendar as I add
events to my sites own database.
I've copied the PHP and Databse to the new server, which I am accessing
through an /~ style URL while I try to get it all up and running prior to
switching the DNS over to point at the new server.
Hitting that URL gives me an error from the Google/Zend stuff about
authentication:
Authentication with Google failed. Reason: BadAuthentication
To check the username/password I successfully logged in to Google calendar
manually via the Google website.
So I'm happy the credentials are correct. Only thing I can think of at the
moment is that it's a problem authenticating because the request comde
from the IP address instead of the domain.
I don't recall (set this up a few years back) if I needed to allow access
to the API for my Google calendar from specific domains or now, or how I
could add this IP address while setting things up...
Some code:
require_once('ZendGdata-1.11.0/library/Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
try {
$calendarService = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; //
predefined service name for calendar
$calendarClient =
Zend_Gdata_ClientLogin::getHttpClient('<email>','<pwd>',$calendarService);
$gdataCal = new Zend_Gdata_Calendar($calendarClient);
$this->db->setZendGdataCalendar($gdataCal);
} catch(Zend_Gdata_App_HttpException $e) {
$this->db->setZendGdataCalendar(null);
}
Error message refers to the line:
Zend_Gdata_ClientLogin::getHttpClient

Scrolldown not working on iPad

Scrolldown not working on iPad

Would you know why I can't scroll down my page on an iPad? Here is the
link (would be too long to put the full CSS and HTML here). That must be
something in my CSS code but can't figure out what exactly. Many thanks

How to convert absolute postioned & transformed to image map coords?

How to convert absolute postioned & transformed to image map coords?

Some size specified, position: absolute and css transformation is used as
well for rotate html element .my-square. The goal is to calculate image
map cords for this div instead of having absolute pos + css
transformation. Is it possible? Any ideas are very welcome.
.my-square {
width:150px;
height:150px;
background-color:red;
position:absolute;
transform:matrix(0.650718, 0.759319, -0.759319, 0.650718, 0, 0);
top:150px;
left:150px;
transform-origin:50% 50% 0;
}
Full example: http://jsfiddle.net/KbbwZ/

Saturday, 14 September 2013

What is the correct mime type for .min.map javascript source files?

What is the correct mime type for .min.map javascript source files?

plain/text or application/json?
I am unable to locate any mention of it, my google-fu is weak today.
It does not mention it in this Source Map Revision document that I can
see.
https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1

How to select the method at compilation time?

How to select the method at compilation time?

I remember reading some article using new C++ features to implement the
selection at compiler time but cannot figure out how to do it. For
example, I have a method doing the following
template<class T>
void foo()
{
if (std::is_abstract<T>::value)
do something;
else
do others.
}

parse my xml file and use regular expresion for doing a search javasscript

parse my xml file and use regular expresion for doing a search javasscript

I am trying to search through my xml file. It does the search, but
populates the search exactly how it is in the xml file. I am trying to do
a search where a minimum of 3 characters can be typed, regardless of it
being case sensitive. please help.
<script lang="javascript" type="text/javascript">
var StylistListXML;
var xmlDoc;
function loadXML(fileName) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome,
Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "StylistList.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
xmlDoc.async = false;
return xmlDoc;
}
function showAllStylst() {
displayDocument(false);
}
function displayDocument(search) {
var StylistListXML = loadXML("StylistList.xml");
var StylistListXML_root = StylistListXML.documentElement;
var stylistInfo_array =
StylistListXML_root.getElementsByTagName('stylistInfo');
var stlyist_ul = document.getElementById("stylist");
var search_field_div =
document.getElementById("search_field").value.replace('/^[a-zA-Z].*$/');
//console.debug("hello world");
clearStylist();
for (var i = 0 ; i < stylistInfo_array.length; i++) {
var nameElement =
stylistInfo_array[i].getElementsByTagName('Name')[0];
var CityElement =
stylistInfo_array[i].getElementsByTagName('City')[0];
var ProvinceElement =
stylistInfo_array[i].getElementsByTagName('Province')[0];
var li_element = document.createElement('li');
var h2_element = document.createElement('h2');
var h4_element = document.createElement('h4');
var h42_element = document.createElement('h4');
var name_text =
nameElement.firstChild.nodeValue.replace('/^[a-zA-Z].*$/');
var city_text =
CityElement.firstChild.nodeValue.replace('/^[a-zA-Z].*$/');
var province_text = ProvinceElement.firstChild.nodeValue
h2_element.appendChild(document.createTextNode(name_text));
li_element.appendChild(h2_element);
h4_element.appendChild(document.createTextNode(city_text));
li_element.appendChild(h4_element);
h42_element.appendChild(document.createTextNode(province_text));
li_element.appendChild(h42_element);
if (i % 2 == 1 && search == false) {
li_element.setAttribute('class', 'zebra_background');
}
if (search == true) {
if (search_field_div == name_text || search_field_div ==
city_text) {
stlyist_ul.appendChild(li_element);
}
} else {
stlyist_ul.appendChild(li_element);
}
var lis = document.getElementsByTagName('li');
if (lis.length == 0) {
var li_element = document.createElement('li');
li_element.appendChild(document.createTextNode(search_field_div
+ " not found."));
stlyist_ul.appendChild(li_element);
}
}
console.debug(name_text);
}
function clearStylist() {
var lis = document.getElementsByTagName('li');
for (var i = lis.length - 1; i >= 0; i--) {
var parent = lis[i].parentNode;
parent.removeChild(lis[i]);
}
}
function searchAStylist() {
displayDocument(true);
}
function validate() {
return false;
}
</script>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<stylistData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<stylistInfo>
<Name>Allan, Allan</Name>
<WorkPhone>999.999.999</WorkPhone>
<Address>3Allan Allan</Address>
<City>Test TEst</City>
<Province>TEster</Province>
<PostalCode>w34w5t</PostalCode>
<Country>CAN</Country>
<Email>1234@gmail.com</Email>
</stylistInfo>
<stylistInfo>
<Name>Allan, Allan</Name>
<WorkPhone>999.999.999</WorkPhone>
<Address>3Allan Allan</Address>
<City>Test TEst</City>
<Province>TEster</Province>
<PostalCode>w34w5t</PostalCode>
<Country>CAN</Country>
<Email>1234@gmail.com</Email>
</stylistInfo>
<stylistData>
Any type of help would be appreciated. I am kinda still wrapping my head
around this regular expressions, and where i would thorow it in my code

Outlook - Auto Create Appointment based on Email using VBA

Outlook - Auto Create Appointment based on Email using VBA

I'm looking to try and have outlook automatically create an appointment
based on the Subject line of an incoming email. For instance if I receive
an email with the subject line "Demo Downloaded" I want it to create an
appointment for this email that shows the body of the message as the
"Note" on the Appointment. Also, I want the appointment TIME to be 2 hours
after the date of the email was sent to me. So if I received the email at
1pm eastern i want the appointment to be automatically set for 3pm
eastern.
I know I need to use VBA and have outlook run a script, which I know how
to do all of this. However all I currently know right now is how to
manually create an appointment based off the selected email, not the email
that has been received. Plus I dont know how to have it automatically set
the time or anything fancy like that...
This is currently all I have...
Sub CreateTask(Item As Outlook.MailItem)
Dim objTask As Outlook.TaskItem
Set objTask = Application.CreateItem(olTaskItem)
With objTask
.Subject = Item.Subject
.StartDate = Item.ReceivedTime
.Body = Item.Body
.Save
End With
Set objTask = Nothing
End Sub

Setting a php variable and displaying it on another page

Setting a php variable and displaying it on another page

I am wanting to run this script to update the db and then check if it did
then in fact update and then set a variable saying so and redirect back
the the previous page and echo out wither the successful update or
unsuccessful update on that page. Currently it runs perfectly but will not
echo out the successful or unsuccessful part. What can I do to fix this?
<?php
include_once('../../../_php/connect.php');
$update_e_id = $_POST['error_id'];
//Update unresolved to resolved
mysql_query("UPDATE error SET resolution='resolved' WHERE id=" .
$update_e_id . "
AND resolution='unresolved'");
//Check if it updated
$checkE_update = "SELECT * FROM error WHERE id=" . $update_e_id . " AND
resolution='resolved'";
$results = mysql_query($checkE_update);
$nr = mysql_num_rows($results);
while($row = mysql_fetch_assoc($results)) {
$checkResolution = $row['resolution'];
}
if($checkResolution = 'resolved') {
$successfullyUpdated = "<p>The error is now resolved.</p>";
header("Location: ../lib_errors.php");
} else {
$didnotUpdateError = "<p>The update was unsuccessful.</p>";
header("Location: ../lib_errors.php");
}
?>

Searching in a Binary Search Tree

Searching in a Binary Search Tree

This code to search a value in a Binary Search Tree is not working
completely.
Here *r is a global variable of type struct node.
struct node * searchbt(struct node*bn,int x)
{ if(bn==NULL)
{printf("Element not found.\n");}
if(bn->data==x) {printf("Element found.\n"); r=bn; return r;}
if(bn->data<x) {searchbt((bn->lc),x);}
else {searchbt((bn->rc),x);}
}

May I remove Mac os x from Macbook air(intel i5 cpu) and install Windows 7?

May I remove Mac os x from Macbook air(intel i5 cpu) and install Windows 7?

Could somebody give some advises or links about this? I don't want to
install new os via boot camp, because of small SSD. Thanks!

Hibernate @JoinTable

Hibernate @JoinTable

i am trying to map associations with @JionTable annotation, i have the
following situation.
public class A {
@Id
@GeneratedValue
private long id;
//getter setter...
}
public class D {
@Id
@GeneratedValue
private long id;
//getter setter..
}
public class B extends A {
@OneToMany( cascade = {CascadeType.ALL}, fetch = FetchType.LAZY,
orphanRemoval = true)
@JoinTable(
name="JOIN-TABLE",
joinColumns = @JoinColumn( name="B_ID"),
inverseJoinColumns = @JoinColumn( name="D_ID")
)
List<D> ds = new ArrayList<D>();
//getter setter...
}
public class C extends A {
@OneToMany( cascade = {CascadeType.ALL}, fetch = FetchType.LAZY,
orphanRemoval = true)
@JoinTable(
name="JOIN-TABLE",
joinColumns = @JoinColumn( name="C_ID"),
inverseJoinColumns = @JoinColumn( name="D_ID")
)
List<D> ds = new ArrayList<D>();
}
As you can see i am trying to save both associations (in class B and C) in
the same join table "JOIN-TABLE".
Wenn i call: session.save(b) session.save(c)
b is written to Database correctly but session.save(c) throws constraint
violation exception.
By default hibernate generates two join tables, but i want to save the
associations in one tablle, is this possible ??
Thanks in advance

Friday, 13 September 2013

Sublime Text 2 - Open folders

Sublime Text 2 - Open folders

Is it possible to open multiple folders in the same window using Sublime
Text 2? Selecting File->Open Folder always opens the folder in a new
window.
Sublime Text is an excellent editor, but this issue is a bit annoying

Import into python interpreter main namespace from an import

Import into python interpreter main namespace from an import

How can I run a bunch of imports and path appends from the interpreter
with one command/import? If I import another module that runs the commands
for me the imports are not available in main namespace. Similar to running
a bash script that modifies/adds commands and variables to the current
session.
ex.
import os, ...
sys.path.append(...)

Hover Status Color Change, Avada Theme, Wordpress

Hover Status Color Change, Avada Theme, Wordpress

We are using the Avada theme on a wordpress website:
http://skybox.wearetechnology.com/
We would like to change the hover status of the links on our site, right
now they go to white and the client has requested a white background.
I have tried to change the CSS to reflect this but somewhere in the theme
settings they have the a:hover state coded into an embedded style sheet
with the !important code at the end.
I can't find anywhere in the theme settings that allow to change to hover
state color (even though you can change just about any other color).
Is there a way to override the code so that I can change the color back to
a more visible color?
Right now I am using a text shadow and a stroke but it doesn't look very
good.

Method missing error *only* Heroku

Method missing error *only* Heroku

After updating some helpers yesterday (see how to DRY this code?), I
pushed to Heroku but was met with errors:
2013-09-13T18:26:11+00:00 heroku[slug-compiler]: Slug compilation started
2013-09-13T18:27:13.840235+00:00 heroku[api]: Deploy c41f61a by ****
2013-09-13T18:27:13.876295+00:00 heroku[api]: Release v29 created by ****
2013-09-13T18:27:13.974728+00:00 heroku[web.1]: State changed from crashed
to starting
2013-09-13T18:27:15+00:00 heroku[slug-compiler]: Slug compilation finished
2013-09-13T18:27:23.440087+00:00 heroku[web.1]: Starting process with
command `bundle exec rails server -p 58965`
2013-09-13T18:27:28.455752+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-09-13T18:27:28.454577+00:00 app[web.1]: DEPRECATION WARNING: You have
Rails 2.3-style plugins in vendor/plugins! Support for these plugins will
be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or
fold them in to your app as lib/myplugin/* and
config/initializers/myplugin.rb. See the release notes for more on this:
http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /app/config/environment.rb:5)
2013-09-13T18:27:29.539124+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:29 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : To prevent
agent startup add a NEWRELIC_ENABLE=false environment variable or modify
the "production" section of your newrelic.yml.
2013-09-13T18:27:29.539124+00:00 app[web.1]: => Rails 3.2.13 application
starting in production on http://0.0.0.0:58965
2013-09-13T18:27:29.539124+00:00 app[web.1]: => Call with -d to detach
2013-09-13T18:27:29.539124+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:29 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Enabling
the Request Sampler.
2013-09-13T18:27:29.539124+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:29 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Reading
configuration from config/newrelic.yml
2013-09-13T18:27:29.539124+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-09-13T18:27:29.539312+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:29 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO :
Application: ****
2013-09-13T18:27:29.539124+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:29 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO :
Dispatcher: webrick
2013-09-13T18:27:29.539124+00:00 app[web.1]: => Booting WEBrick
2013-09-13T18:27:29.539124+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:29 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Starting
the New Relic agent in "production" environment.
2013-09-13T18:27:29.539124+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:29 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO :
Environment: production
2013-09-13T18:27:30.527353+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Installing
ActiveRecord instrumentation
2013-09-13T18:27:30.527353+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Installing
Net instrumentation
2013-09-13T18:27:30.527353+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Installing
Rails 3 Controller instrumentation
2013-09-13T18:27:30.527353+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Installing
deferred Rack instrumentation
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:260:in
`safe_constantize'
2013-09-13T18:27:30.527353+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Finished
instrumentation
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/core_ext/string/inflections.rb:66:in
`safe_constantize'
2013-09-13T18:27:30.527353+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Installing
Rails3 Error instrumentation
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:133:in
`inherited'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:436:in
`eager_load!'
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:229:in
`each'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in
`block in run_initializers'
2013-09-13T18:27:30.527353+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Installing
Rails 3.1/3.2 view instrumentation
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:152:in
`_default_wrap_model'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/railties/routes_helpers.rb:7:in
`block (2 levels) in with'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application/finisher.rb:53:in
`block in <module:Finisher>'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in
`instance_exec'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in
`run'
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:230:in
`block in constantize'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:439:in
`block (2 levels) in eager_load!'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:438:in
`each'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in
`each'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from /app/config.ru:in `new'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in
`app'
2013-09-13T18:27:30.532390+00:00 app[web.1]: from script/rails:6:in
`require'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/action_controller/railties/paths.rb:7:in
`block (2 levels) in with'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:436:in
`each'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from /app/config.ru:3:in
`require'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in
`instance_eval'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from /app/config.ru:in
`<main>'
2013-09-13T18:27:30.527353+00:00 app[web.1]: Exiting
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/app/models/goal.rb:13:in `<top (required)>'
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:169:in
`_set_wrapper_defaults'
2013-09-13T18:27:30.528978+00:00 app[web.1]: ** [NewRelic][09/13/13
18:27:30 +0000 498cb047-5d8c-4377-8c23-2d8c5aeb36cd (2)] INFO : Starting
Agent shutdown
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/app/controllers/goals_controller.rb:1:in `<top (required)>'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in
`method_missing'
2013-09-13T18:27:30.531396+00:00 app[web.1]: /app/app/models/goal.rb:14:in
`<class:Goal>': uninitialized constant Goal::Averageable (NameError)
2013-09-13T18:27:30.531396+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/inflector/methods.rb:229:in
`constantize'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:136:in
`initialize!'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in
`start'
2013-09-13T18:27:30.532390+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in
`<top (required)>'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in
`run_initializers'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in
`app'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in
`initialize'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in
`start'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from
/app/config/environment.rb:5:in `<top (required)>'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in
`eval'
2013-09-13T18:27:30.532390+00:00 app[web.1]: from script/rails:6:in
`<main>'
2013-09-13T18:27:30.531622+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:438:in
`block in eager_load!'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in
`parse_file'
2013-09-13T18:27:30.532233+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in
`wrapped_app'
2013-09-13T18:27:30.532390+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:55:in
`block in <top (required)>'
2013-09-13T18:27:30.531764+00:00 app[web.1]: from /app/config.ru:3:in
`block in <main>'
2013-09-13T18:27:30.532390+00:00 app[web.1]: from
/app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in
`tap'
2013-09-13T18:27:31.836227+00:00 heroku[web.1]: Process exited with status 1
2013-09-13T18:29:19.359735+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path=/ host=**** fwd="195.56.164.82" dyno=
connect= service= status=503 bytes=
A lot of the questions with errors similar to this that I've found on SO
stem from problems with a missing commit and/or absent code for whatever
reason, but this doesn't seem to be the case, as the application loads
flawlessly in the local environment ($ rails s) as well as the production
environment ($ rails server -e production).

Returning a value of ruby is strange

Returning a value of ruby is strange

could anyone tell me the return value of this function give the parameter
listed blew:
def sequence(*enumerables)
enumerables.each do |enumerable|
print "#{enumerable},"
end
end
a,b,c = [1,2,3],4..6,'a'..'e'
value = sequence(a,b,c)
print value
why the value is evaluated to be:
[[1,2,3],4..6,"a".."e"]

NSArray Returning String Instead of Dictionary

NSArray Returning String Instead of Dictionary

I've setup logs and checked the code and NSArray is being returned as a
string instead of a dictionary. The problem is that I'm not sure how I can
convert this particular string into a dictionary and I'm running on a
tight timeframe.
Here's the code:
NSArray* placeJson = [NSJSONSerialization JSONObjectWithData:jsonResponse
options:kNilOptions error:nil];
for (NSDictionary *placeJsons in placeJson) {
NSLog(@"%@",NSStringFromClass([placeJsons class]));
page = placeJsons[@"page"];
NSLog(@"%d",page);
if (page > 0) {
NSDictionary* pJson = placeJsons[@"data"];
for (NSDictionary *dict in pJson) {
Error in Logs and results of NSlog:
2013-09-12 19:50:55.117 GetDeal[1584:c07] __NSCFString
2013-09-12 19:50:55.118 GetDeal[1584:c07] -[__NSCFString
objectForKeyedSubscript:]: unrecognized selector sent to instance
0xac5f890
2013-09-12 19:50:55.119 GetDeal[1584:c07] *** Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString
objectForKeyedSubscript:]: unrecognized selector sent to instance
0xac5f890'
This code may be useful as well.
NSLog(@"AES:%@",aesResponse);
NSData* jsonResponse = [aesResponse
dataUsingEncoding:NSUTF8StringEncoding];
NSArray* placeJson = [NSJSONSerialization
JSONObjectWithData:jsonResponse options:kNilOptions error:nil];
Sorry. The JSON data:
http://mobapps.getdeal.me/getcoupons.php?category=art
Possible supe solution:
NSArray* placeJson = [NSJSONSerialization JSONObjectWithData:jsonResponse
options:kNilOptions error:nil];
NSDictionary *placeJsons = [NSJSONSerialization
JSONObjectWithData:[placeJson
dataUsingEncoding:NSUTF8StringEncoding]
Error Message.
No visible @interface for 'NSArray' declares the selector
'dataUsingEncoding:'
Definitely sorry... but in about 30 minutes my life is going to change
dramatically.
Answer to Martin:
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding
allowLossyConversion:NO];
NSString *postLength = [NSString stringWithFormat:@"%d", [post
length]];
**NSURL *url = [NSURL URLWithString:placeLink];**
NSMutableURLRequest *request = [NSMutableURLRequest
requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
Config.h
#define placeLink @"http://mobapps.getdeal.me/getcoupons3.php"

How to check whats the older timestamp?

How to check whats the older timestamp?

I'm too noob when it comes to Dates. Anyone can help me in order to check
which of two given unix timestamps represent an older date ? ie:
1379049923 (equivalent to - Fri, 13 Sep 2013 01:25:23)
1379049827 (equivalent to - Fri, 13 Sep 2013 01:23:47)
Thank you

Thursday, 12 September 2013

How to Create a fixed size table in itext pdf?

How to Create a fixed size table in itext pdf?

I wan't to create a fixed size table on a pdf page and if suppose the
content(s) of table is increased then create a same size table on the next
page in itext pdf.

highcharts google maps Json

highcharts google maps Json

I have a map (http://gk5tudio.cu.cc/bin/json/) and have no idea how to
incorporate highcharts.js pie chart example to the infowindow, simply
displaying the same data in the json file.

media query trying to target device-width based devices

media query trying to target device-width based devices

I'm running into some issues here. I need to make some small adjustments
with my layouts based on different device widths, but I'm running into
some issues. Here's my media query syntax:
@media only screen and (max-device-width: 960px) and
(-webkit-min-device-pixel-ratio: 2.0) and (orientation: portrait) {
some style
}
@media only screen and (max-device-width: 960px) and
(-webkit-min-device-pixel-ratio: 2.0) and (orientation: landscape) {
some style
}
@media only screen and (max-device-width: 650px) and
(-webkit-min-device-pixel-ratio: 2.0) and (orientation: portrait) {
some style
}
@media only screen and (max-device-width: 650px) and
(-webkit-min-device-pixel-ratio: 2.0) and (orientation: landscape) {
some style
}
(This is all at the bottom of my regular css code, so it's not getting
overridden by that)
When I do it this way, the two on bottom always override the two on top!
I've tried adding (min-device-width) to the media query but it doesn't
seem to work.. Any idea what I'm doing wrong? In this instance I'm
targetting the Nexus 4 (230dpi, 768x1280res) and the Nexus 7 (323dpi,
1200x1920res).
Thanks!

Tagging/Mentioning Pages or Users in Posts via Graph Api

Tagging/Mentioning Pages or Users in Posts via Graph Api

Does anybody know a legal and working way to tag / mention other Pages or
Users in a Post sent via Graph Api?
I hear it worked some time ago with [ID:USER], but this is not working
anymore.
Anybody knows how to do this?

SQL statement won't limit. Show's no results

SQL statement won't limit. Show's no results

I'm creating a web app and I'm trying to limit the number of results that
come in. When I do the query all the results come back but if I put LIMIT
5 at the end of the statement, then no results come back. Here is my code:
$query = $conn->prepare('SELECT * FROM notifications WHERE
(needs=:username OR worker=:username) ORDER BY CASE WHEN needs=:username
THEN needsread ELSE workerread END, time DESC LIMIT 5');
$query->bindParam(':username', $username);
$query->execute();
echo "<div id='notes_title' style='background-color: #333333; padding:
10px; text-align: center; font-weight: lighter; letter-spacing:
1px;'>Notes</div>";
$te = 0;
while ($rows = $query->fetch()) {
$needs = $rows['needs'];
$id = $rows['ID'];
$worker = $rows['worker'];
$title = $rows['title'];
$needsread = $rows['needsread'];
$workerread = $rows['workerread'];
$time = $rows['time'];
$type = $rows['type'];
Any clues as to why it's not working?

angular variable generating html

angular variable generating html

i am trying to make a blog page with angularJS and on the message part i
have a div like this.
<div class="post-content">
{{jsonPost.message}}
</div>
and inside the variable jsonPost.message i got a string like this
<p>paragraph 1</p>
<p>paragraph 2</p>
but instead creating 2 html paragraphs, instead i see the <p> texts on the
screen aswell like a text. Is there a way to make them html code ? and
than target them via css. Thank you, Daniel!

Is it possible to access instances of a directive from inside the directive definition?

Is it possible to access instances of a directive from inside the
directive definition?

I am trying to create a directive for drawers that can be used in my
application. What I want to do is this: When the user opens one drawer, I
need any other currently open drawers to close.
This is my current code:
Markup
<a href="javascript:;" id="my_switch">
Click me to toggle the drawer!
</a>
<drawer data-switch="#my_switch">
Content of the first drawer
</drawer>
<a href="javascript:;" id="my_other_switch">
Click me to toggle the other drawer!
</a>
<drawer>
Content of the second drawer
</drawer>
Drawer.html
<div class="drawer_container">
<div class="drawer" ng-transclude>
</div>
</div>
Directive
MyApp.directive('drawer', function(DrawerService){
return {
restrict: 'AE',
replace: true,
transclude: true,
templateUrl: 'drawer.html',
link: function(scope, element, attributes){
var drawer_switch = $(attributes.switch);
var drawer = $(element).find('.drawer');
var toggle = function(event){
drawer.toggle();
};
drawer_switch.bind('click', toggle);
}
};
});
Is it possible for the opening of one drawer to cause the rest of the
drawers to close by using only the directive?

extracting multiple substrings from string using sed

extracting multiple substrings from string using sed

I'm working on a cocos2dx project and recently we updated to the latest
version of cocos2dx, this introduced a number of warnings which I'm
cleaning up.
I have a lot of code like:
CCPoint somePoint = ccpAdd(this->getPosition(), _someRandomOffset);
The method ccpAdd is deprecated, in favour of the + operator, I want to
replace such instances. I've tried searching on google, but I can't find
out how to extract two strings using sed and build them back together.
CCPoint somePoint = this->getPosition() + _someRandomOffset;
My question is, how can I automate this replacement using some script
against my source files?
Bonus points if the sed command can handle nested ccpAdd commands, like:
CCPoint somePoint = ccpAdd(this->getPosition(), ccpAdd(one, two));
Or maybe sed is the wrong tool for the job?

Wednesday, 11 September 2013

Getting Product name and code to Contact form

Getting Product name and code to Contact form

I have added two fields in the contact form.
Product Name:
Product Code:
I have a pre-order button on the product page so all products that is 0
quantity will have this button enabled. When the user click this button
they will be redirected to the contact form.
<a
href="http://localhost/store/index.php?route=information/contact"><button>Pre-Order</button></a>
Now How do i Autofill the Product Name and Product Code input in the
Contact form when the user click on the Pre-Order button on the product
page?
Sample Scenario:
Customer is browsing on the product Lenovo Motherboard with Product code:
LV032, But he finds out that this product is out of stock and Pre-Order is
only the available option. So he clicks on the Pre-Order button then
customer is redirected to the contact form with the product name and
product code fields already filled with the Name and Code of the Product
that the customer want's to pre-order.
EDIT:
I got a working solution using sessions on the product page then using the
session on the contact form. Please advise if I'm doing a right thing.

On transactions and nested DB writes (using Scala)

On transactions and nested DB writes (using Scala)

Let's say that I have the following methods:
On a WebsitesList model:
def create(urls: List[String]) = DB.withConnection(implicit c => {
val websites = urls.map(Website.create(_))
val listId: Option[Long] = SQL("INSERT INTO LIST (created_date,
active) VALUES ({created_date}, {active})").
on('created_date -> new Date(), 'active -> true).
executeInsert()
websites.foreach(websiteId =>
SQL("INSERT INTO websites_list (list_id, website_id) VALUES
({listId}, {websiteId})").
on('listId -> listId.get, 'websiteId -> websiteId.id).executeInsert()
)
throw new Exception()
})
And on the Website model:
def create(url: String): Website = DB.withConnection {
implicit c =>
val currentDate = new Date()
val insertedId: Option[Long] = SQL("insert into websites (url,
Date_Added) values ({url}, {date})").
on('url -> url, 'date -> currentDate).
executeInsert()
Website(insertedId.get, url, currentDate)
}
As you can see, I start a transaction on the WebsitesList create method,
and said method calls the create method of the Website model.
My objective is to delete the created websites records if for some reason
the WebsitesList fails to be created. In order to test it I raise an
exception and as expected, the WebsitesList and List records are not
created. However, the websites records are not rollback'd after the
exception and stay on the database.
My theory is that the Website.create method created a new connection
instead of using the existing one. Anybody knows how I could fix this?
Thanks.

Python Regular Expression - right-to-left

Python Regular Expression - right-to-left

I am trying to use regular expressions in python to match the frame number
component of an image file in a sequence of images. I want to come up with
a solution that covers a number of different naming conventions. If I put
it into words I am trying to match the last instance of one or more
numbers between two dots (eg .0100.). Below is an example of how my
current logic falls down:
import os
import re
def sub_frame_number_for_frame_token(path, token='@'):
folder = os.path.dirname(path)
name = os.path.basename(path)
pattern = r'\.(\d+)\.'
matches = list(re.finditer(pattern, name) or [])
if not matches:
return path
# Get last match.
match = matches[-1]
frame_token = token * len(match.group(1))
start, end = match.span()
apetail_name = '%s.%s.%s' % (name[:start], frame_token, name[end:])
return os.path.join(folder, apetail_name)
# Success
eg1 = 'xx01_010_animation.0100.exr'
eg1 = sub_frame_number_for_frame_token(eg1) # result:
xx01_010_animation.@@@@.exr
# Failure
eg2 = 'xx01_010_animation.123.0100.exr'
eg2 = sub_frame_number_for_frame_token(eg2) # result:
xx01_010_animation.@@@.0100.exr
I realise there are other ways in which I can solve this issue (I have
already implemented a solution where I am splitting the path at the dot
and taking the last item which is a number) but I am taking this
opportunity to learn something about regular expressions. It appears the
regular expression creates the groups from left-to-right and cannot use
characters in the pattern more than once. Firstly is there anyway to
search the string from right-to-left? Secondly, why doesn't the pattern
find two matches in eg2 (123 and 0100)?
Cheers

Maven doxygen plugin

Maven doxygen plugin

Does anyone know if there is any Maven plugin for generating documentation
using doxygen?
I've tried to use this one from DoodleProject but it doesn't seem to exist
anymore because I can't access the repo. In addition, this one from
SoftwareEntwicklung Beratung Schulung doesn't seem to have any
documentation on how to use it.

Trying to absolute center ul (vertical and horizontal) in nav

Trying to absolute center ul (vertical and horizontal) in nav

... with the help of this tutorial at > coding.smashingmagazine.com/..
nav {
color: #fff;
background-color: #333;
position: relative;
height: 200px;
}
nav ul {
list-style: none;
overflow: auto;
width: 50%;
height: 50%;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
nav li {
display: inline-block;
margin: 0 10px;
font-size: 25px;
line-height: 100%;
}
I can't get it right. Look at my jsfiddle.
Thanks for any help.
An image ... chrome/macos x 10.8.x > is the ul v/h centered?

jQuery/PHP Post Failure

jQuery/PHP Post Failure

I've got slightly convoluted jQuery and PHP problem here. On my index.php,
a call to a javascript function getCalls() is made.
function getCalls()
{
$('#transportDiv').load('getCalls.php');
}
getCalls.php does a select from SQL database. It returns a table with the
requested data, plus a dynamically generated form for each row, plus a
dynamically generated jQuery post function for each dynamically generated
form (these are being echo()'d, by the way):
<tr>
//Static table data here
</tr>
<form id='form$id' action='update.php' method='post'>
<tr id='tr$id' style='{display: none;}'>
<td class='$tdClass'>
<input type='text' id='txt_municipality' name='municipality'
value='$municipality'>
</td>
//a lot more inputs omitted
</tr>
</form>
<script type="text/javascript">
$("#submitButton'.$id.'").click(
function()
{
$.post( $("#form'.$id.'").attr("action"),
$("#form'.$id.':input").serializeArray(),
function(info)
{
$("#responseDiv").html(info);
}
);
getCalls();
}
);
</script>
$id is a PHP variable containing the unique identifier for each row in SQL
(BTW, those '.$id.' lines are correct, they are within an echo with single
quotes). All of this shows up as expected in my #transportDiv after
getCalls() is invoked, so no problem there. When #submitButton is clicked,
it calls update.php, but there is no post data in the $_POST array:
echo $_POST['municipality'];
That's all I have it doing right now. #responseDiv is populated by the
jQuery post with "Notice: Undefined index: municipality in
C:\inetpub\wwwroot\comm\update.php on line 3". A var_dump() on $_POST
prints "array(0)"
I've been stuck on this for days.. any thoughts?
I've lurked the numerous other posts from other users with similar issues,
but their solutions haven't worked for me.