samedi 31 janvier 2015

AWS ec2 winreg not found

I'm trying to run a python app from amazon EC2 large instance. However, Its complaining in scipy because it can't find a thing called _winreg.


I don't know how to reconfigure this so its no longer an issue.



""" python2 app.py * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) * Restarting with stat import _winreg as winregTraceback (most recent call last): File "app.py", line 111, in app = create_app().run(debug=True) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 772, in run run_simple(host, port, self, **options) File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 622, in run_simple reloader_type) File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 265, in run_with_reloader reloader.run() File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 155, in run for filename in chain(_iter_module_files(), self.extra_files): File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 70, in _iter_module_files for package_path in getattr(module, 'path', ()): File "/usr/lib/python2.7/dist-packages/scipy/lib/six.py", line 116, in getattr _module = self._resolve() File "/usr/lib/python2.7/dist-packages/scipy/lib/six.py", line 105, in _resolve return _import_module(self.mod) File "/usr/lib/python2.7/dist-packages/scipy/lib/six.py", line 76, in _import_module import(name) ImportError: No module named _winreg """






Web Browser Filter

I would like to have a list of websites (each on a different line) that the web browser will check when navigated and if it is the current url then it will navigate back. Below is some code that I have currently have created and fails because it doesn't check each line of text and below that is some code that also check text with current text.



Using sr As New StreamReader("website_lists.txt")
Dim lined As String
lined = sr.ReadToEnd()
Dim scanbox As New TextBox
scanbox.Multiline = True
Dim buff As StringBuilder = New StringBuilder
For Each line In lined
If TextBox1.Text.Contains(scanbox.Text) Then
webview.GoBack()
MsgBox("Infected website! For your own sake stay away!")
End If
Next
End Using
End Sub


Some code that kinda does the same thing:



Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
Dim f As FileStream = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
f = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
md5.ComputeHash(f)
Dim hash As Byte() = md5.Hash
Dim buff As StringBuilder = New StringBuilder
Dim hashByte As Byte
For Each hashByte In hash
buff.Append(String.Format("{0:X2}", hashByte))
Next

If scanbox.Text.Contains(buff.ToString) Then


Have any suggestions or help? Thanks in advance.





how can i extract data or web scrape websites using universal web code

I would like to extract data or web scrape from any website eg google kitkat ingredients section using code for my website


I prefer php or javascript





How to add a request header in Nancyfx?

I tried adding this in the bootstrapper in the ApplicationStartup override.



pipelines.AfterRequest.AddItemToStartOfPipeline(ctx =>
{
ctx.Request.Headers["x-fcr-version"] = "1";
});


Its giving me errors.


Can anyone point me in the right direction?





Creating webpages using div (study resources)

I am newbie in web development. I have studied almost popular languages, frameworks, technologies required to build web site. I know that the best practice is to create site using div blocks.

I have read some articles,there are different approaches everywhere.

I am looking for a good article, book, course etc... , about patterns of developing web layouts. I need something to use like an example of well-designed web page. Please suggest some good example to study.





Javascript: why this line is required for functionality?

This function is to return to the main page. But I have one question: When I delete the line requestpath += options.index; why does it give me an error 'encountered error while processing GET of “/“' with response code 500? without that line wouldn't it be localhost:3000/ which would return me to index. I'm guessing it is something with fs.exist function at the end.



var return_index = function(request, response, requestpath) {

var exists_callback = function(file_exists) {
if (file_exists) {
return serve_file(request, response, requestpath);
} else {
return respond(request, response, 404);
}
}

if (requestpath.substr(-1) !== '/') {
requestpath += "/";
}
requestpath += options.index;
return fs.exists(requestpath, exists_callback);
}


Any help is appreciated


Edit: option is:



var options = {
host: 'localhost',
port: 8080,
index: 'index.html',
docroot: '.'
};


so option.index will give 'index.html'





Want to display last 3 posts on the homepage

So i have rails app where all posts are displayed on /posts, which is where I want them. There, I have 10 posts per page. But, along with this page - i would like to take the last three posts and display them in a div on the root page.


Not sure where to start.


Thanks





Should I define one class for each REST JSON Request and Response?

In my android app, I need to post JSON data to several REST APIs and get JSON data back for parsing. I want to use GSON to serialize/deserialize the data.


Each REST API has different input/output fields, should I define a separate class to hold data for each API request and response like this?



public class API1RequestData{
public String field1;
public String field2;
}


I am asking this, because if I am using python to construct the JSON request, I don't need to define classes, a dictionary will do.





html input and suggestions

How can I realize inline suggestion (for example like google, when you starts to search something, it opens new html where listed suggestion). I want to have such kind of html, which appears only after my input





Deploying Java web application on Amazon (AWS)

I am relatively new to developing Java web applications and trying to understand that best ways to deploy new applications. I am particularly interested in leveraging AWS. I have been researching some of the posts on this topic, but some good ones are a couple years old. Any updates on AWS structures to implement a Java web application? Any good alternatives?


Deploy Java Web application on Amazon Cloud @Sangram_Anand


Is the Cloud ready for an Enterprise Java web application? Seeking a Java EE hosting advice @sfussenegger





getting user_id on register

I am trying to insert user_id to my accounts_table. But I am trying to get the user_ID from the user_table upon register.


I cant get the user_id (foreign key for my accounts_table) of the last registered user in the user_table which is what i need to be inserted on my accounts_table.


but when I var_dump($userData) i get value of null. and it says mysql_fetch_array() expects parameter 1 to be resource, boolean given why?



$registerQuery = 'INSERT INTO `user`(`firstname`,`lastname`,`email_address`,`password`,`mobile_number`,`address`,`birthdate`) VALUES (
"'.ucfirst($firstname).'",
"'.$lastname.'",
"'.$emailaddress.'",
"'.$password.'",
"'.$mobile_number.'",
"'.$address.'",
"'.$birthdate.'"
);';

$qry = mysql_query($registerQuery); //INSERT TO DATABASE
//echo $getuserIDQuery = 'SELECT `user_id` FROM `users` WHERE `email_address` LIKE \'%'.$emailaddress.'%\'';;
echo $getuserIDQuery ="SELECT * FROM `users` WHERE `email_address` = '$emailaddress'";
$getuserIDResult = mysql_query($getuserIDQuery);
$userData = mysql_fetch_array($getuserIDResult) ;

echo ' </br> ';
var_dump($userData);
echo ' </br> ';
var_dump($emailaddress);
echo '</br> ';
echo $userData['user_id'];
echo $emailaddress; //validation purpose only
echo ' AND COUNT ='.count($getuserIDResult); //check if found something


$accountQuery = 'INSERT INTO `accounts`(`user_id`,`balance`) VALUES (
"'.$getuserIDResult.'",
"'.$default_amount.'"
);';

$accountQry = mysql_query($getuserIDQuery);
}




vendredi 30 janvier 2015

Can anyone suggests me the tools for web designing?I want to make my website more attractive

I want something like this Link 2Link 1





need to add all the boxes in the same div in html

I need to implement the following functionality in either JSP or HTML


For example:


I have CINEMAS MOVIES EVENTS ( top level horizontal menu)


After this I have submenus like CINEMAS has -> price, Date, etc.. submenus Once I click price it should display a text box under menu bar and similarly for all submenus.


I tried with div and frames but its not working fine. So, I want to know how to implement this functionality.


To be more clear: Menu Bar and Submenus and all the options(text boxes, labels) within a same box/div/frame without refreshing the page. After clicking the submenu the corresponding text box or label should displayed within the box.


Thank you.





How to build a website with user login, timelines with text based posts and user submitted images

I am new to web development. I have some knowledge of wordpress and I am learning Django at the moment. The reason I took up Django is because I wanted to create a website as mentioned in the title, and I thought that is the right way of doing it.


What I want is: A site where user can login and have very basic timelines. The user can submit a drawing (let's say) in response to another's wish. This matching of a user with a wish would be random and will be stored in a database. The timeline should have a particular user's wishes or the drawings submitted.


This is the basic idea, how should I go about creating it. I have one to two months for this project to be completed (I did not want to rush any learning). If anybody can just give me an outline of the things I will have to learn and implement in order to achieving the said target.





How to pass value from change function?

I don't have Idea how to pass a value from change function, for example i have function like this :



$('pilihan').change(function(){
var amount = $('#pilihan option:selected').val();
var result = amount*12; });


I want pass value of "result" variable to other function just like this :



function add() {
var lastresult = result+56;
$('#jumlah').text(lastresult);


If I do this, then variable "result" in add function doesn't has value.


So, how to pass result variable value from change function to other function?





button does not respond in Webview

Everything in the android web app is working as expected except the html file input fields coded as <input type="file" name="filn"/> in webpage.When i click on the button supposed to load the resources in which the files can be chosen from, it does not respond. Meanwhile in google browser, it works fine. My webview android code is as follows:



public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview =(WebView)findViewById(R.id.webView1);
webview.setWebViewClient(new WebViewClient());
webview .getSettings().setJavaScriptEnabled(true);
webview.loadUrl("website");
}


What can i do to make it work?





Change URL data on page load

Hello I have a small website where data is passed between pages over URL. My question is can someone break into it and make it pass the same data always?


For example let say, when you click button one, page below is loaded.


example.com?clicked=5


Then at that page I take value 5 and get some more data from user through a form. Then pass all the data to a third page. In this page data is entered to a database. While I observe collected data I saw some unusual combinations of records. How can I verify this?





Force capitalization in iOS web page?

This should be easy to fix, but I can't find out why it's not working.


I have a web "app" that runs in Safari, and it's made for users to add to the home screen. There's a web form where the user enters a first and last name. Here's the simple code for that form.



<fieldset>
<div class="row">
<label>First Name</label>
<input type="text" name="first_name" id="pFirstName" value="" autocapitalize="on" autocorrect="off" placeholder="John" />
</div>
<div class="row">
<label>Last Name</label>
<input type="text" name="last_name" id="pLastName" value="" autocorrect="off" autocapitalize="on" placeholder="Doe" />
</div>
</fieldset>


Very simple. The problem is that the Last Name form is not capitalized when the user switches to it. I ran it directly in mobile Safari, and it worked fine. When I added to the home screen, I had the same issue...


Is this just a bug in iOS/webkit (because it used to work...)? Not sure if there's some sort of script to force the auto-capitalization? Thanks!


Edit: If I click on the field directly, it capitalizes. The problem is when I fill in text for first name, and click the "Next" arrow on the top of the keyboard.





Windows user and Linux Web Project

I would like to gather here some opinions on what development pipeline to select to efficiently develop a Linux Web Project, if I am a Windows user and developer. Here are couple of possibilities but some has its cons and pros:



  • Develop everything on Windows and then port for Linux. Disadvantage is, that porting Windows project to Linxu will cost time and resources, which might be avoided, if I would develop within Linux.

  • Install Virtual Machine. I will be still within windows, but be developing under Linux. Virtual Machine is usually a bit slower which is not very comfortable while programming

  • Install a Linux machine and develop everything there. Here, the main disadvantages are, that I have to run two physical machines, which might be unnecessary. I will miss tools which I normally use within Windows.


I would like to know from efficient developer, what is reliable and most efficient pipeline to develop web applications running on Linux (LAMP) if the developer is comfortable Within Windows OS.


I will use:



  • HTML5

  • JavaScript

  • PHP

  • CSS3

  • MySQL

  • JQuery

  • Windows: WAMP

  • Linux: LAMP


Thanks in advance.





JS.Prototype.Cannot read property 'apply' of undefined

Trying to make little module for searching some stuff.



function SearchModule() {
this.softName = "",
this.userLogin = undefined,
this.init.apply(this, arguments);
}

SearchModule.prototype = {
init: function (softname, userlogin) {
this.softName = softname;
this.userLogin = userlogin;
},
clearField: function () {
//whatever
},
searchData:function(args){
//whatever
}

}


When I try to call it I get an error



Uncaught TypeError: Cannot read property 'apply' of undefined



I use it like this



var searchObject;
function searchTestPart1() {
searchObject = SearchModule("PPC", usermail);
searchObject.getSearchData("Test");

}


Whats wrong? P.S. Maybe I making some silly mistake, sorry. But for some reason I don't understand what's wrong here





Why can I see RSS feed without logging into Facebook?

I got the url of my rss feed from this link saying RSS(circled)


enter image description here


then I used it to get notifications but even if I logged out it still showed the updated notification feed. Please tell me about it. Shall one not share his rss url.


The RSS feed url is of the form: http://ift.tt/1yfBE3O


Can anyone explain the significance of each get parameters in url.


P.S.:I have changed the key for security reasons.





Limiting the total number of HTTP requests a user can make

How does a web server limits the total number of HTTP request rate from a ip adress? How does websites like twitter and facebook does that??





PHP - MSSQL configurations cause slow performance

I have a problem in my project using PHP and MSSQL. I have the following configurations:


64 GB Ram 16 CPU Intel Xeon SQL Server 16 GB Ram 4 CPU Intel Xeon Web Server


And I have the following code:



SELECT
protokol.hekim_tc as hekim_tc,
iller.il_adi as il_adi,
SUM(protokol.taniveilacolan)as taniveilacolan,
SUM(protokol.taniolanilacolmayan) as taniolanilacolmayan,
SUM(protokol.taniveilacolan+protokol.taniolanilacolmayan) as protokolsayisi,
SUM(protokol.antibiyotik_yazilan) as antibiyotik_yazilan,
SUM(protokol.agrikesici_yazilan) as agrikesici_yazilan,
SUM(protokol.enj_yazilan) as agrikesici_yazilan,
SUM(protokol.enj_agrikesici_yazilan) as enj_agrikesici_yazilan,
SUM(protokol.antibiyotik_yazilan) as antibiyotik_yazilan,
SUM(protokol.enj_antibiyotik_yazilan) as enj_antibiyotik_yazilan,
kalem_sayisi,
kutu_sayisi,
maliyet
FROM rdp_2013_protokol_dagilimi_copy2 AS protokol
LEFT JOIN iller ON iller.il_kodu = protokol.hekim_il
LEFT JOIN (
SELECT hekim_tc,
SUM(kalem_sayisi) as kalem_sayisi,
SUM(kutu_sayisi) as kutu_sayisi,
SUM(maliyet) as maliyet
FROM rdp_2013_atc_dagilimi
GROUP BY hekim_tc
) AS atc
ON atc.hekim_tc = protokol.hekim_tc
GROUP BY
protokol.hekim_tc,
iller.il_adi,
kalem_sayisi,
kutu_sayisi,
maliyet


The problem is that the query above lasts only 6 sec. in SQL Server. But when I run the same code in PHP on IIS server, it lasts more than 5 minutes. Which configuration am I supposed to look for and change?





Call silverlight web page with one argument

Is it possible to call a silverlight web page with an argument?


I want to open the web page and send a number so that the web page can display the number and act in consequence.


something like:



http://example.html argument=1


This way the page would know that is being called as the client number 1 and would save its data to a corresponding place in a database.


The main purpose is that with a single web file, at least 10 instances of it can be called, each one knowing that it is different from the others.


Anyway if there is a better way to achieve this behaviour I want to know since I am starting with web technology.


I hope it is clear.





JQuery bind/unbind mousewheel event

I am trying to enable and disable scrolling on my page


I have this function :



function scroll_toggle(key){
if (key) {
$(window).bind('scroll', function(){
$('body').on({
'mousewheel': function(e) {
console.log("binded");
$("html body").scrollTop(0);
if (e.target.id == 'el') return;
e.preventDefault();
e.stopPropagation();
}});
});
} else {
$(window).unbind('scroll');
$('body').on({
'mousewheel': function(e) {
console.log("unbinded");
return true;

}});
}
}


When I call this function for the first time with true as parameter, the mousewheel don't work, and a I have "binded" in my console.


But when I call the function with false, the mousewheel still don't work and i have "binded" and "unbinded" alternatively.


What is wrong in my code?


Thanks for your time





Pyramid POST /login HTTP1.1 404 error

So, i am new at python, pyramid and web and i`m trying to write simple app with main page and login page. For that i have two files login.pt and main.pt. When i go to 0.0.0.0:8080 i get login page. Now, if i enter correct data(login and password) i must get to main page, but every time in console of my IDE i got this string: "127.0.0.1 - - [30/Jan/2015 14:52:59] "POST /login HTTP/1.1" 404 158" In my views.py i got method login, which checking login and pass.


Can u tell me please what am i doing wrong?





WEB - How to make an automatic diagram?

This my first post in this amazing website I been using for a long time (especially for my VBA questions).


As you can guess I have a question ... How to make an automatic diagram like the below image?


http://ift.tt/1veaW05


The data will be in a MySQL table.


I don't have much experience in web development ... I just know the basics of HTML/CSS PHP/MySQL and JavaScript.


I don't want you to give me the code to do that, I will do the research and the code myself but I need to know where to look at!


Thanks folks! :)





How to store the website url when a browser visits a site using python twisted?

How to store the website url when a browser visits a site using python twisted ? for example if i use firefox to retreive google.com,i need to store the url google.com in a string variable.





HttpModule Web Api

I'm trying to get an auth basic on my web api. I've written a simple HttpModule to check it



public class BasicAuth : IHttpModule
{
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
private const string Realm = "MyRealm";

public void Init(HttpApplication context)
{
// Register event handlers
context.AuthorizeRequest += new EventHandler(OnApplicationAuthenticateRequest);
context.EndRequest += new EventHandler(OnApplicationEndRequest);
}

private static void SetPrincipal(IPrincipal principal)
{
Thread.CurrentPrincipal = principal;
if (HttpContext.Current != null)
{
HttpContext.Current.User = principal;
}
}

private bool CheckPassword(string username, string password)
{
var parameters = new DynamicParameters();
parameters.Add("@UserName", username);
parameters.Add("@Password", password);
con.Open();
try
{
var query = //query to db to check username and password
return query.Count() == 1 ? true : false;
}
catch
{
return false;
}
finally
{
con.Close();
}
}

private bool AuthenticateUser(string credentials)
{
try
{
var encoding = Encoding.GetEncoding("iso-8859-1");
credentials = encoding.GetString(Convert.FromBase64String(credentials));

int separator = credentials.IndexOf(':');
string name = credentials.Substring(0, separator);
string password = credentials.Substring(separator + 1);

if (CheckPassword(name, password))
{
var identity = new GenericIdentity(name);
SetPrincipal(new GenericPrincipal(identity, null));

return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}

private void OnApplicationAuthenticateRequest(object sender, EventArgs e)
{
var authHeader = request.Headers["Authorization"];
if (authHeader != null)
{
var authHeaderVal = AuthenticationHeaderValue.Parse(authHeader);

// RFC 2617 sec 1.2, "scheme" name is case-insensitive
if (authHeaderVal.Scheme.Equals("basic",
StringComparison.OrdinalIgnoreCase) &&
authHeaderVal.Parameter != null)
{
if (AuthenticateUser(authHeaderVal.Parameter))
{
//user is authenticated
}
else
{
HttpContext.Current.Response.StatusCode = 401;
}
}
else
{
HttpContext.Current.Response.StatusCode = 401;
}
}
catch
{
HttpContext.Current.Response.StatusCode = 401;
}
}

private static void OnApplicationEndRequest(object sender, EventArgs e)
{
var response = HttpContext.Current.Response;
if (response.StatusCode == 401)
{
response.Headers.Add("WWW-Authenticate",
string.Format("Basic realm=\"{0}\"", Realm));
}
}

public void Dispose()
{
}
}


well, this code works pretty well, except the fact it asks for basic auth even on controller I don't put the [Authorize] tag on. And when it occurs, it gives the right data back.


Let me explain:


My HistoryController has [Authorize] attribute, to make a POST request I have to send Header auth to get data, if I don't do it, I receive 401 status code and a custom error.


My HomeController doesn't have [Authorize] attribute, if i make a get request on my homepage, the browser popups the authentication request, but if I hit Cancel it shows my home page. (The page is sent back with 401 error, checked with fiddler).


Where am I doing wrong?





Hyperlinks not working correctly when converting word doc to Web Page, Filtered

I have created a word document (MS Word 2013) with Table of Contents and their links to particular sections and all the hyperlinks works fine in the word document. But when I convert this document into Web Page, Filtered then after a specific point the hyperlinks not pointing to their respective sections instead they are pointed to the end of the page.


I have checked the page source of the HTML document and found that the table of contents have hyper links but the respective sections doesn't have the hyper link code and hence click on the a section didn't find the that section and go to the end of the document.


Please advise me how to resolve this issue.





Url Rewrite get some string on Web config

I want to get some string on web config.


For example, Entered link by the user: http://ift.tt/eIlFV0abc/def/ghi/jkl


Will redirect link: http://www.google.com/abc/def/ghi/jkl


So, I need "abc/def/ghi/jkl".


Thank you.





Git workflow for website

This already works:


I'm administrating a site via local git commits that I push to a bare remote git repository.


There is a post-receive hook which does GIT_WORK_TREE=/web git checkout -f to checkout the files to the running site.


What I would like to add to this workflow:



  • Changes via SFTP to the running site should be automatically committed and pushed (or merged)

  • Changes to files in specific folder (in this case folders with pictures and statistics) should be synced between the local repository and the working directory but not be "tracked" by Git (I don't need several versions of these files, only the latest ones and only locally and on the life site)

  • I only want the branch "Master" to be checked out to the life site. If I work on e.g. the "Dev" branch I don't want anything changed on the life site


I don't know if and how this is possible. I already looked at gitwatch and this site but I don't know if this is what I need and if there could be an even simpler way.


Also I don't know how to accomplish the other two ideas.


Any opinion, help or point in the right direction is greatly appreciated!





Custom renderer not applied on Table render handsontable

I have a custom renderer for summing the columns in my handsontable.


The values are only shown when a cell is edited, but not when the table loads with its initial data.


Is there some event to load the initial rendering? Or am I calling the renderer incorrectly?



hot = new Handsontable(container, {
data: data,
colHeaders: col_headers,
rowHeaders: row_headers,
colWidths: 110,
rowHeights: 30,
startRows: row_count,
maxRow: row_count,
maxCols: col_headers.length,
columns: column_types,
cells: function(row, col, prop){
if (row === row_count - 1) {
this.renderer = sumRenderer;
var cellProperties = {};
cellProperties.readOnly = true;
}
return cellProperties;
}
});

var sumRenderer = function (instance, td, row, col, prop, value) {
var total = 0;
for (ii = 0; ii < row; ii++) {
total += instance.getDataAtCell(ii, col);
};
value = total;

Handsontable.renderers.NumericRenderer.apply(this, arguments);
};




Proper way to detect user's leaving page

I am building a WebApp (ERP) and I need to display the people currently logged in and active on the page. I managed to get something pretty accurate by listening on the mouse/keyboard events and periodically reporting to the DB.


I don't know how to mark people offline when they close the page. I tried using onbeforeunload, but it obviously fires when the user simply changes pages (click a link inside the ERP, that point to another page in the ERP).


I then tried to use WebSockets, but the problem is the same : everytime the page is realoded, the WebSockets connection is closed.


So I can think of two ways:




  • Use WebSockets indeed, and replace all links by a call to a javascript function that would somehow tell the server that the user is going to change page (so that the server doesn't mark it as offline). But that doesn't feel right, semantically speaking, links should be links, it simply points to another location.




  • Use either WebSockets or AJAX and never actually change page: links are replaces by a function that will call for the content, and display it on screen (updating the DOM with Javascript). But again, it doesn't feel right either, because semantically speaking the page would have no meaning and the URL would never change, so the user can't "copy paste" the link of the page to refer to it, right ?




So, is there a proper, clean way of doing this? Thanks for your help.





jeudi 29 janvier 2015

Looking for someone to point me in the right direction for starting a website

Im looking for someone to give me like a general explanation I've how I'd start to build the site I'm thinking about. Basically, its an eBay clone, where you can buy/sell items in the form of auctions.


I understand how to do a good majority of it, however im pretty lost when it comes to this. What i'm mainly confused about is how I'll have the actual auction created, and while that auction is live people visit it. Visually I picture it as like an instance being made, and other people visiting that instance, but I dont know how I would get around to that in code. Any advice or suggestions are much appreciated!





%HEXADECIMAL% is decoding (%7445% as input results in t445% in PHP)

I am handling a scenario in PhP where the input is in %XXXXX% format, where XXXXX can be any number of characters/numbers. The input will be sent to sql for processing (the main intention is to send the input that contains %TEXT% to sql).


What I understand from the scenario is that the input text is being encoded as %257445D%25 and later it is decoded to t445D%. Here the value of ‘%74’ is ‘t’ and in this case any hexa decimal number followed by % gives the decoded form. Here is the ASCII encoding for reference " http://ift.tt/1iJoiug "


The ultimate goal is to get the output same as input. I dont want the input to be encoded and decoded.


Here is the piece of code: form:


\ (ex:%7445% or %anything) \


Getting value: $ss= $_GET['name_1'];


Please help me in getting raw data without encoding and decoding the value. I have tried using many scenario’s including the decoded version of htmlentities, utf8_encode, rawurlencode, using regex and replacing strings and many more.


The actual code contains more text boxes and other functions, if one thing works i can replicate the same and make it work for others.


Thank you!





What is the form of the request put into a queue for a multithreaded web server?

I'm building a multithreaded (using a thread pool) web server from scratch in Java. I know I need to create a queue to hold the requests coming in and then notify threads currently in the blocked status to process the requests in the queue.


My question is: what exactly should be put into the request queue? Does the queue hold the client connection and the handler threads use the client to get the HTTP request headers? Or does the daemon thread get the HTTP request header and put that in the queue for the handler to parse? Or does the queue hold both the client and the HTTP request headers?





How can I log into a simple web access login using Python?

I'm trying to create a little Python script that'll log into a web access authentication page for me automatically for the purposes of convenience (the login appears each time the computer is disconnected from the network).


login


My attempt so far has been to use the module mechanize, but running this doesn't result in the login vanishing from my standard browser:



import mechanize
browser = mechanize.Browser()
browser.addheaders = [("User-agent","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13")]
browser.open("http://ift.tt/S0UJZD")
browser.select_form(name="logonForm")
browser["login"] = "myUsername"
browser["password"] = "myPasscode"
browser.submit()
print browser.title()


How can I get this login to work in Python?


Here's what I think is the relevant section of the HTML of the login page:



<form name="logonForm" style="display:none">
<!-- Logon Form -->
<div id="logonForm_subscriptionChoice_top_title_block" class="subtitle">
<span id="logonForm_subscriptionChoice_top_title_text">YOU ALREADY HAVE YOUR LOGIN</span>
</div>
<div id="logonForm_auth_modes_block" style="display:none">
<table class="hoverLink"><tr>
<td>
<div id="logonForm_shibboleth_authentication_button">
<img src="./resources/_images/shibboleth.png" height="30px"><br><span id="logonForm_shibboleth_text">Utilisez vos identifiants institutionnels</span>
</div>
</td>
<td>
<div id="logonForm_standard_authentication_button">
<img src="./resources/_images/ticket.png" height="30px"><br><span id="logonForm_ticket_text">Utilisez un ticket de connexion</span>
</div>
</td>
</tr></table>
</div>
<div id="logonForm_logon_block">
<table>
<tr id="logonForm_logon_block_credentials">
<td class="label">
<span id="logonForm_login_text">LOGIN</span><br><input type="text" name="login" autocomplete="on">
</td>
<td class="label">
<span id="logonForm_password_text">PASSWORD</span><br><input type="password" name="password" autocomplete="on">
</td>
<td>
<button type="submit" id="logonForm_connect_button"><span><img src="./resources/_images/auth_button.png" height="35px"></span></button>
</td>
</tr>
<tr id="logonForm_policy_block">
<!-- Check Box Confirm (Visible status depends on configuration option) --><td colspan="3">
<br><input type="checkbox" name="policy_accept">&nbsp;
<span id="logonForm_policy_text"></span>
</td>
</tr>
</table>
</div>
<br><button type="button" id="logonForm_authentication_form_back_button" style="display:none">Retour</button>
<div id="logonForm_subscriptionChoice_block">
<br><div class="subtitle">
<span id="logonForm_subcribe_bottom_title_text">NOT A LOGIN YET ?</span>
</div>
<br><div id="logonForm_subscriptionChoice_first_double_insert_block">
<table class="hoverLink"><tr>
<td></td>
<td></td>
</tr></table>
</div>
<div id="logonForm_subscriptionChoice_second_double_insert_block">
<table class="hoverLink"><tr>
<td></td>
<td></td>
</tr></table>
</div>
<div id="logonForm_subscriptionChoice_single_insert_block">
<table class="hoverLink"><tr><td></td></tr></table>
</div>
</div>
</form>




AppWeb server with MVC on Ubuntu not working as expected

Disclaimer: I'm a linux noob


That being stated, after following the instructions on how to install AppWeb on Ubuntu (http://ift.tt/1CQAQrI) I did the following:



  1. Changed directory to where I installed AppWeb :

    [my_username@ubuntu]:$ cd ~/apps/appweb

  2. Changed directory to one of the samples provided by the isntallation (MVC related)

    [my_username@ubuntu]:~/apps/appweb$ cd samples/esp-hosted

  3. Started AppWeb at that location:

    [my_username@ubuntu]:~/apps/appweb/samples/esp-hosted$ appweb

    This gave me the following info:

    01/29/15 12:41:47 2 appweb, Configuration for Embedthis Appweb

    01/29/15 12:41:47 2 appweb, ----------------------------------

    01/29/15 12:41:47 2 appweb, Version: 5.3.0

    01/29/15 12:41:47 2 appweb, BuildType: Debug

    01/29/15 12:41:47 2 appweb, CPU: x86

    01/29/15 12:41:47 2 appweb, OS: linux

    01/29/15 12:41:47 2 appweb, Host: ubuntu

    01/29/15 12:41:47 2 appweb, Configure: me -d -q -platform linux-x86-default -configure . -with openssl -gen make

    01/29/15 12:41:47 2 appweb, ----------------------------------

    01/29/15 12:41:47 0 info http, Started HTTP service on *:4000

  4. I then went to firefox and typed "http://localhost:4000" in the address bar

    This showed me a static page with static info asexpected


The problem I'm having is that this sample is touted to display a basic blog with which one can interact. Well, the blog is not available because whenever a blog related web address (MVC pattern) is entered, the server responds with a "file not found" response. The appweb.config file provided by the sample is described below:



#
# appweb.conf -- Appweb configuration for ${UAPP} (esp-html-mvc)
#

ErrorLog stdout level=2 append

Listen 4000

LoadModule espHandler libmod_esp

#
# SSL/TLS configuration
#
# LoadModule sslModule libmod_ssl
# ListenSecure 443
#
# SECURITY NOTE: you must generate the server.crt and server.key.pem.
# Use a decrypted key here so it won't prompt for the password.
#
# SSLCertificateFile "server.crt"
# SSLCertificateKeyFile "server.key.pem"

#
# Define the application
<EspApp name="blog" routes="esp-html-mvc">
#
# EspResource NAME
# EspResourceGroup
#
# <Route /upload-uri>
# AddInputFilter uploadFilter
# UploadDir /tmp
# UploadAutoDelete on
# LimitUpload 200MB
# </Route>
</EspApp>

# LogRoutes


So, If I were to type http://localhost:4000/post/list (local to my computer), then I should expect a page like the one at the following link (http://ift.tt/1CQAQrK) under the "Scaffolds" section, but instead I get the "Access Error: 404 -- Not Found" message from the server


I know my way around the MVC paradigm so I think I'm doing this correctly (since I followed the instructions), but it's possible I may have missed a step, but I just can't see it because of my linux noobiness.


Any suggestions?





Enlarging web content, zooming, makes some elements invisible

I have some simple html css js website, but the case is, that if someone in for example firefox, zoom page, some elements overlap and becomes invsible. How to avoid it? Its also the case when someone has really low screen resolution.





building a web based interface for a database

One of the task on my project is to design and build a web based interface for my database such that it can update,query and add new rows of data. How can i approach this problem? Is there any examples ?





Request disabling browser features from the server. Doctypes, metatags, modes?

I think it would be nice for security and performance reasons, if a server could tell the browser, in it's response:



Look browser: I'm a simple website, all I need is html and css, so please disable javascript when you show my page. Or at least disable this APIs which I don't need.



Then the browser could render that page much faster and safer because it knows it won't have to do a bunch of things. I know that certain doctypes trigger certain rendering modes, and that some metatags change browser behavior. Is there any mechanism intended for this purpose?





Any ideas on what simple features that could be added to this Offline application? JavaScript only [on hold]

This application works offline, it stores food inside a database, and the details on each food, such as servings, and calories, it's a work in progress. So i want to add a few more final touches to this application, a few features that are JavaScript related only, any suggestions.


(http://ift.tt/18z2zli)


Web App works best on phone





Convert Lighttpd rewrite to Nginx [new]

I've seen lots people asking about converting Lighttpd to Nginx but haven't seen my example in it's total form. If anyone could help, please!


I want to convert:



url.rewrite = (
"^/includes/(.*)$" => "/includes/$1",
"^/templates/(.*)$" => "/templates/$1",
"^/css/(.*)$" => "/css/$1",
"^/classes/(.*)$" => "/classes/$1",
"" => "/index.php/$1"
)


I tried using:



location / {
try_files $uri $uri/ /index.php?$args;
}


But if I link directly to a resource, it displays it instead of rewriting back to index.php


I also wondered if this might work, but it doesn't seem to:



rewrite ^/includes/(.*)$ /includes/$1 break;
rewrite ^/classes/(.*)$ /classes/$1 break;


Any suggestions would be greatly appreciated.


Thanks, E





C++ iWebBroser2 Navigate

I have a problem where I navigate to a temp html file inject some html and when i hover hover a certain element i see a tooltip which is correct. howver if i click else where and hover again there is no tool tip.



  1. What I currently do is that i navigate to a temp html file

  2. inject some html inside my html file which holds the string for the tool tip

  3. click else where window then close and DOM is destroyed.

  4. click back to open the window hover and then there is no tooltip.


could this be because I dont call navigate again? i have checked the title attribute and there is a valid string?


any help would be great.





GET http://ift.tt/1v90HKj ... error in console

Hi I am getting this error GET http://ift.tt/1v90HKl 403 (Forbidden)


this error in browsers console in all of my nodejs app. I don't know where is this coming from since I have not added any get route for this. What is causing this? I did find in folder using sublime for this and there is no result for cl4appf in my code base. It is even giving me an error of mixed content and breaking my entire site.


Any help would be appriciated.





Call server side python script from webpage

I am a hobbyist and have learnt most of what i know about coding by trawling these forums.


I have a network of Raspberry Pi computers that are programmed to take a photo when the server sends a multicast message. this is all working and implemented in Python.


I would like to setup a webpage to act as a GUI to send the multicast message including some parameters which are passed to the python script when it is executed. I would be happy for a button which launched the script and go from there.


I have setup apache and have been able to launch php and python simple scripts directly.


The scripts that i have created so far are only 'hello world' style scripts, anything more than printing to html seems to fail without any feedback So far i have been searching for a few weeks, i have done tutorials for HTML CSS Javascript and Jquery and am no closer. I have also considered running the whole thing from a python web framework but didnt have much luck with that either. Ideally, i would like to have a webpage that can run a script when the buttons are pressed.


I understand that this is probably too many words with out any code but i am quite lost at the moment. It seems like a task that i should be able to find tutorials for but i have had no luck. Any help would be appreciated.





Refreshing a JSP form resubmits the data

I have a jsp page called patient.jsp with a Form which is a pop-up. This form is submitted using post method. Once this form reached the servlet, something like below take place.



request.setAttribute("id",id);
RequestDispatcher dispatch = getServletContect().getRequestDispatcher("/patient.jsp");
dispatch.forward(request,response);


There is a big problem. Once this is forwarded back to the patient.jsp, if the user refresh the web page, everything he previously entered into the forms will be resubmitted and saved in the database.


We used RequestDispatcher because we have to pass an attribute from Request scope. Any idea how to solve this?





Problems with html selects in firefox

I have a problem with html select, at the time that I view with firefox, it's like I broke the css styles.


The button associated with the select, shown divided into two different colors halved. A dark black and light black.


Here is the css code:



select{
background:url("data:image/svg+xml;utf8,<svg xmlns='http://ift.tt/nvqhV5' width='50px' height='50px'><polyline points='46.139,15.518 25.166,36.49 4.193,15.519'/></svg>");
background-repeat: no-repeat;
background-position: right 10px top 15px;
background-size: 16px 16px;
color: #000000;
padding: 12px;
width: auto;
font-family: arial,tahoma;
font-size: 16px;
/* font-weight: bold; */
text-align: center;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
border-radius: 3px;
-webkit-border-radius: 3px;
-webkit-appearance: none;
-moz-appearance: -moz-win-media-toolbox;
border: 0;
outline: 0;
-webkit-transition: 0.3s ease all;
-moz-transition: 0.3s ease all;
-ms-transition: 0.3s ease all;
-o-transition: 0.3s ease all;
transition: 0.3s ease all;
background-color: #a7a59e;
}




How can I check if time period is already exist or between a specific period in database?

I have this query in my php. What i need to do is. i have example.


8:30 am to 10:00 am. so i want this time start and time end to be checked if it already exist in the database or it is between a time period.



input: 8:30 am to 10:00 am == database: 8:30 am to 10:am. -> already exist


input: 8:30 am to 11:30 am == database: 8:30 am to 10:am. -> already exist between


input: 9:30 am to 11:30 am == database: 8:30 am to 10:am. -> already exist between


input: 7:00 am to 11:30 am == database: 8:30 am to 10:am. -> already exist between


input: 7:00 am to 10:00 am == database: 8:30 am to 10:am. -> already exist between


input: 7:00 am to 9:30 am == database: 8:30 am to 10:am. -> already exist between



the code below works except that if the time start or time end is between the existing periods.. it still continues and doesn't tell me that it is already existing in between a period. i don't know what im lacking. thanks!



$Query = mysqli_query($Connection->con(),"SELECT
*
FROM room_schedules
INNER JOIN rooms
ON room_schedules.Room_ID = rooms.Room_ID
WHERE ((('" . htmlspecialchars($_POST['starts']) . "'
BETWEEN room_schedules.Starts
AND room_schedules.Ends)
AND ('" . htmlspecialchars($_POST['ends']) . "'
BETWEEN room_schedules.Starts
AND room_schedules.Ends))
OR ((room_schedules.Starts
BETWEEN '" . htmlspecialchars($_POST['starts']) . "'
AND '" . htmlspecialchars($_POST['ends']) . "')
AND (room_schedules.Ends
BETWEEN '" . htmlspecialchars($_POST['starts']) . "'
AND '" . htmlspecialchars($_POST['ends']) . "'))))




mercredi 28 janvier 2015

Hiberbate query for the product search based it's category id

I have a schema which consist of the following table. 1)TABLE category_type. Basically we have 4 category_type a)Groceries b)Pharma c)Baby Products d) Sports item



CREATE TABLE `category_type` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(45) NOT NULL,
`image` varchar(128) NOT NULL,
`creation_date` datetime NOT NULL,
`last_updated_date` datetime NOT NULL,
`created_by` int(11) DEFAULT NULL,
`last_updated_by` int(11) NOT NULL,
`object_version_number` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8


2) TABLE category. Table's description as follows. The category_type and category are different. Category Type is the higher level as explain earlier. The category table consist of the next level of categorization. Ex) Staples,Personal Care,Biscuit and Beverages is the 2nd level of category which come under the main category_type Groceries. All the next level of the categorization is been done in the same category table itself. Suppose rice and pulses,flour and suji,spices,salt and sugar are the 3rd level of categorization with comes under staples category.So,all the 3rd level of the categorization refer to the 2nd level of categories using the "parent_category_id" field in the same table.If the staples have id=53 there sub categories will have there "parent_category_id"=53 in the same table.



CREATE TABLE `category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`creation_date` datetime NOT NULL,
`last_updated_date` datetime NOT NULL,
`created_by` int(11) NOT NULL,
`last_updated_by` int(11) NOT NULL,
`object_version_number` int(11) NOT NULL,
`image` varchar(128) DEFAULT NULL,
`category_type_id` int(11) NOT NULL,
`parent_category_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_category_categorytype_id` (`category_type_id`),
KEY `FK_parent_category_id` (`parent_category_id`),
CONSTRAINT `FK_category_categorytype_id` FOREIGN KEY (`category_type_id`) REFERENCES `category_type` (`id`),
CONSTRAINT `FK_parent_category_id` FOREIGN KEY (`parent_category_id`) REFERENCES `category` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1011 DEFAULT CHARSET=utf8


3)TABLE product.Now ultimately the product table come.It has category_id field which references to the id field in table category



CREATE TABLE `product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`category_id` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
`manufacturer` varchar(45) DEFAULT NULL,
`unique_name` varchar(45) DEFAULT NULL,
`barcode` varchar(45) DEFAULT NULL,
`search_code` varchar(45) DEFAULT NULL,
`active` int(1) NOT NULL DEFAULT '1',
`image` varchar(128) DEFAULT NULL,
`creation_date` datetime NOT NULL,
`last_updated_date` datetime NOT NULL,
`created_by` int(11) NOT NULL,
`last_updated_by` int(11) NOT NULL,
`object_version_number` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UNQ_product_unique_name` (`manufacturer`,`name`,`category_id`),
KEY `FK_product_category_id` (`category_id`),
CONSTRAINT `FK_product_category_id` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1834 DEFAULT CHARSET=utf8


The POJO class of the able tables are as follows: 1)Table "category_type"



@Entity
public class CategoryType implements java.io.Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;
private int id;
private String name;
private Date creationDate;
private Date lastUpdatedDate;
private int createdBy;
private int lastUpdatedBy;
private String image;
@Version
private int objectVersionNumber;

public CategoryType() {
}

public CategoryType(String name, Date creationDate, Date lastUpdatedDate,
int createdBy, int lastUpdatedBy, int objectVersionNumber) {
this.name = name;
this.creationDate = creationDate;
this.lastUpdatedDate = lastUpdatedDate;
this.createdBy = createdBy;
this.lastUpdatedBy = lastUpdatedBy;
this.objectVersionNumber = objectVersionNumber;
}

public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public Date getCreationDate() {
return this.creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

public Date getLastUpdatedDate() {
return this.lastUpdatedDate;
}

public void setLastUpdatedDate(Date lastUpdatedDate) {
this.lastUpdatedDate = lastUpdatedDate;
}

public int getCreatedBy() {
return this.createdBy;
}

public void setCreatedBy(int createdBy) {
this.createdBy = createdBy;
}

public int getLastUpdatedBy() {
return this.lastUpdatedBy;
}

public void setLastUpdatedBy(int lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy;
}

public int getObjectVersionNumber() {
return this.objectVersionNumber;
}

public void setObjectVersionNumber(int objectVersionNumber) {
this.objectVersionNumber = objectVersionNumber;
}

public String getImage() {
return this.image;
}

public void setImage(String image) {
this.image = image;
}

public static void initializeXStream(XStream xstreamObj) {
xstreamObj.alias("", java.sql.Timestamp.class, java.util.Date.class);
}
}


2)Table "category"



@XStreamAlias("category")
@Entity
public class Category implements java.io.Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;
private int id;
private String name;
private Date creationDate;
private Date lastUpdatedDate;
private int createdBy;
private int lastUpdatedBy;
private String image;
@XStreamOmitField
@JsonIgnore
private CategoryType categoryType;
@XStreamOmitField
@JsonIgnore
private Category parentCategory;
@Version
private int objectVersionNumber;
@XStreamOmitField
@JsonIgnore
private Set<Product> products = new HashSet<Product>(0);
@XStreamOmitField
@JsonIgnore
private Set<RetailerCategory> retailerCategories = new HashSet<RetailerCategory>(
0);
@XStreamOmitField
@JsonIgnore
private Set<CategoryType> categoryTypes = new HashSet<CategoryType>(0);

public Category() {
}

public Category(String name, Date creationDate, Date lastUpdatedDate,
int createdBy, int lastUpdatedBy, int objectVersionNumber) {
this.name = name;
this.creationDate = creationDate;
this.lastUpdatedDate = lastUpdatedDate;
this.createdBy = createdBy;
this.lastUpdatedBy = lastUpdatedBy;
this.objectVersionNumber = objectVersionNumber;
}

public Category(String name, Date creationDate, Date lastUpdatedDate,
int createdBy, int lastUpdatedBy, int objectVersionNumber, String image,
Set<Product> products, Set<RetailerCategory> retailerCategories) {
this.name = name;
this.creationDate = creationDate;
this.lastUpdatedDate = lastUpdatedDate;
this.createdBy = createdBy;
this.lastUpdatedBy = lastUpdatedBy;
this.objectVersionNumber = objectVersionNumber;
this.image = image;
this.products = products;
this.retailerCategories = retailerCategories;
}

public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public Date getCreationDate() {
return this.creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

public Date getLastUpdatedDate() {
return this.lastUpdatedDate;
}

public void setLastUpdatedDate(Date lastUpdatedDate) {
this.lastUpdatedDate = lastUpdatedDate;
}

public int getCreatedBy() {
return this.createdBy;
}

public void setCreatedBy(int createdBy) {
this.createdBy = createdBy;
}

public int getLastUpdatedBy() {
return this.lastUpdatedBy;
}

public void setLastUpdatedBy(int lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy;
}

public int getObjectVersionNumber() {
return this.objectVersionNumber;
}

public void setObjectVersionNumber(int objectVersionNumber) {
this.objectVersionNumber = objectVersionNumber;
}

public String getImage() {
return this.image;
}

public void setImage(String image) {
this.image = image;
}

public Set<Product> getProducts() {
return this.products;
}

public void setProducts(Set<Product> products) {
this.products = products;
}

public Set<RetailerCategory> getRetailerCategories() {
return this.retailerCategories;
}

public void setRetailerCategories(Set<RetailerCategory> retailerCategories) {
this.retailerCategories = retailerCategories;
}
public Set<CategoryType> getCategoryTypes() {
return categoryTypes;
}

public void setCategoryTypes(Set<CategoryType> categoryTypes) {
this.categoryTypes = categoryTypes;
}
public CategoryType getCategoryType() {
return categoryType;
}

public void setCategoryType(CategoryType categoryType) {
this.categoryType = categoryType;
}



public Category getParentCategory() {
return parentCategory;
}

public void setParentCategory(Category parentCategory) {
this.parentCategory = parentCategory;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Category [id=");
builder.append(id);
builder.append(", name=");
builder.append(name);
builder.append(", creationDate=");
builder.append(creationDate);
builder.append(", lastUpdatedDate=");
builder.append(lastUpdatedDate);
builder.append(", createdBy=");
builder.append(createdBy);
builder.append(", lastUpdatedBy=");
builder.append(lastUpdatedBy);
builder.append(", objectVersionNumber=");
builder.append(objectVersionNumber);
builder.append("]");
return builder.toString();
}

public static void initializeXStream(XStream xstreamObj) {
xstreamObj.alias("", java.sql.Timestamp.class, java.util.Date.class);
}
}


3) Table product



@XStreamAlias("product")
@Entity
public class Product implements java.io.Serializable,Comparable<Product> {
/**
*
*/
private static final long serialVersionUID = -1399060577555793322L;
private int id;
@XStreamOmitField
@JsonIgnore
private Category category;
private String name;
private String uniqueName;
private String barcode;
private String searchCode;
private int active = 1;
private String manufacturer;
private String image;
private Date creationDate;
private Date lastUpdatedDate;
private int createdBy;
private int lastUpdatedBy;
@Version
private int objectVersionNumber;
@XStreamOmitField
@JsonIgnore
private Set<OrderLines> orderLineses = new HashSet<OrderLines>(0);
@XStreamOmitField
//@JsonIgnore
private Set<RetailerSnapshot> retailerSnapshots = new HashSet<RetailerSnapshot>(0);
@XStreamOmitField
@JsonIgnore
private Set brandedProducts = new HashSet(0);

public Product() {
}

public Product(Category category, String name, String uniqueName,
int active, Date creationDate, Date lastUpdatedDate, int createdBy,
int lastUpdatedBy,int objectVersionNumber) {
this.category = category;
this.name = name;
this.uniqueName = uniqueName;
this.active = active;
this.creationDate = creationDate;
this.lastUpdatedDate = lastUpdatedDate;
this.createdBy = createdBy;
this.lastUpdatedBy = lastUpdatedBy;
this.objectVersionNumber = objectVersionNumber;
}

public Product(Category category, String name, String uniqueName,
String barcode, String searchCode, int active, String image,
Date creationDate, Date lastUpdatedDate, int createdBy,
int lastUpdatedBy, int objectVersionNumber, Set<OrderLines> orderLineses,
Set<RetailerSnapshot> retailerSnapshots) {
this.category = category;
this.name = name;
this.uniqueName = uniqueName;
this.barcode = barcode;
this.searchCode = searchCode;
this.active = active;
this.image = image;
this.creationDate = creationDate;
this.lastUpdatedDate = lastUpdatedDate;
this.createdBy = createdBy;
this.lastUpdatedBy = lastUpdatedBy;
this.objectVersionNumber = objectVersionNumber;
this.orderLineses = orderLineses;
this.retailerSnapshots = retailerSnapshots;
}

public Product( Category category, String name,
String uniqueName, String barcode, String searchCode, int active) {
this.category = category;
this.name = name;
this.uniqueName = uniqueName;
this.barcode = barcode;
this.searchCode = searchCode;
this.active = active;
}

public Product(String name, String manufacturer, Category category) {
this.name = name;
this.manufacturer = manufacturer;
this.category = category;
}

public int getId() {
return this.id;
}

public void setId(int id) {
this.id = id;
}

public int getObjectVersionNumber() {
return this.objectVersionNumber;
}

public void setObjectVersionNumber(int objectVersionNumber) {
this.objectVersionNumber = objectVersionNumber;
}

public Category getCategory() {
return this.category;
}

public void setCategory(Category category) {
this.category = category;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getUniqueName() {
return this.uniqueName;
}

public void setUniqueName(String uniqueName) {
this.uniqueName = uniqueName;
}

public String getBarcode() {
return this.barcode;
}

public void setBarcode(String barcode) {
this.barcode = barcode;
}

public String getSearchCode() {
return this.searchCode;
}

public void setSearchCode(String searchCode) {
this.searchCode = searchCode;
}

public int getActive() {
return this.active;
}

public void setActive(int active) {
this.active = active;
}

public String getImage() {
return this.image;
}

public void setImage(String image) {
this.image = image;
}

public Date getCreationDate() {
return this.creationDate;
}

public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}

public Date getLastUpdatedDate() {
return this.lastUpdatedDate;
}

public void setLastUpdatedDate(Date lastUpdatedDate) {
this.lastUpdatedDate = lastUpdatedDate;
}

public int getCreatedBy() {
return this.createdBy;
}

public void setCreatedBy(int createdBy) {
this.createdBy = createdBy;
}

public int getLastUpdatedBy() {
return this.lastUpdatedBy;
}

public void setLastUpdatedBy(int lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy;
}

public Set<OrderLines> getOrderLineses() {
return this.orderLineses;
}

public void setOrderLineses(Set<OrderLines> orderLineses) {
this.orderLineses = orderLineses;
}

public Set getBrandedProducts() {
return this.brandedProducts;
}

public void setBrandedProducts(Set brandedProducts) {
this.brandedProducts = brandedProducts;
}

public Set<RetailerSnapshot> getRetailerSnapshots() {
return this.retailerSnapshots;
}

public void setRetailerSnapshots(Set<RetailerSnapshot> retailerSnapshots) {
this.retailerSnapshots = retailerSnapshots;
}

public String getManufacturer() {
return manufacturer;
}

public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Product [id=");
builder.append(id);
builder.append(", category=");
builder.append(category);
builder.append(", name=");
builder.append(name);
builder.append(", uniqueName=");
builder.append(uniqueName);
builder.append(", barcode=");
builder.append(barcode);
builder.append(", searchCode=");
builder.append(searchCode);
builder.append(", active=");
builder.append(active);
builder.append(", creationDate=");
builder.append(creationDate);
builder.append(", lastUpdatedDate=");
builder.append(lastUpdatedDate);
builder.append(", createdBy=");
builder.append(createdBy);
builder.append(", lastUpdatedBy=");
builder.append(lastUpdatedBy);
builder.append(", objectVersionNumber=");
builder.append(objectVersionNumber);
builder.append("]");
return builder.toString();
}

public int compareTo(Product that) {
final int BEFORE = -1;
final int AFTER = 1;

if (that == null) {
return BEFORE;
}

Comparable<String> thisProductName = this.getCategory().getName();
Comparable<String> thatProductName = that.getCategory().getName();

if (thisProductName == null) {
return AFTER;
} else if (thatProductName == null) {
return BEFORE;
} else {
return thisProductName.compareTo(thatProductName.toString());
}
}

}


I am implementing a product filter based on the category been clicked. The code written at the front end are as follows:



<ul class="megamenu skyblue">
<!--1st level of categories -->
<li><a onclick="getCategorySearchAjaxResults('Staples','53')" class="color1" href="#">Staples</a></li>
<li><a onclick="getCategorySearchAjaxResults('HouseHold','54')" class="color1" href="#">HouseHold</a></li>
<li><a onclick="getCategorySearchAjaxResults('Wash nd Clean','55')" class="color1" href="#">Wash nd Clean</a></li>
<li><a onclick="getCategorySearchAjaxResults('Biscuit and Beverages','56')" class="color1" href="#">Biscuit and Beverages</a></li>
</ul>


When user click on any of the hyperlink in the list. The getCategorySearchAjaxResults(par1,par2) function is been called with the Category name and the Category id passed to it.


The implementation of the above function is shown below



function getCategorySearchAjaxResults(category) {
$
.ajax({
url : "${pageContext.request.contextPath}/customer/category_search.shx",
data : 'category=' + category,

success : function(data) {
var obj = JSON.parse( data);
$("#prod_list").html(buildProduct(obj.searchedProducts));
},
error : function(data, status, er) {
alert("Error occured while searching the category.");
}
});
}


The important thing to note here is the return searchedProducts is shoppingCart object is been replaced in the div with id=prod_list.


In the controller of the above the following code is been written



@RequestMapping(value = "/customer/category_search",method = RequestMethod.GET, headers="Accept=*/*")
public @ResponseBody String getcategorySearchResults(Model model,HttpSession session,
@ModelAttribute("shoppingCart") ShoppingCart shoppingCart,
@RequestParam("category") String category) throws IOException{
shoppingCart.setCategory(category);
List<Product> rs = productManager.findByCriteria(shoppingCart.getRetailer().getId(),category,shoppingCart);
model.addAttribute("shoppingCart", shoppingCart);
String json = JSONUtil.createJsonString(shoppingCart);//create the json of the shoppingCart object of ShoppingCart type
System.out.println(json);
return json;
}


BTW shoppingCart is simply the bean class used to the store the data to be displayed on the front end. It is converted to json and forward it to jsp page when ajax called is been made. The implementation of the findByCriteria is show below



public List<Product> findByCriteria(Integer orgaId, String categoryName,ShoppingCart shoppingCart) {
List<Product> rs = findByCriteria(orgaId, categoryName);
shoppingCart.setSearchedProducts(rs);
return rs;
}


The implementation of the findByCriteria(2parameters) is show below



public List<Product> findByCriteria(Integer orgaId, String categoryName){
return productDAO.findByCriteria(orgaId, categoryName);
}


The implementation of the findByCriteria(2parameters) in productDAO is shown below:



public List<Product> findByCriteria(Integer orgaId, String categoryName) {
List<Product> rs = null;
Query query = null;
Category category = null;
StringBuilder hql = new StringBuilder();
try{
String categoryHql=(categoryName!=null)?" and category.id=:category_id ":" ";
hql.append(" from Product product ");
hql.append(" left join fetch product.category category ");
hql.append(" left join fetch product.retailerSnapshots retailerSnapshot ");
hql.append(" where retailerSnapshot.organization.id=:org_id");
hql.append(categoryHql);
rs = getProducts("category_id",orgaId, categoryName, hql);
}catch(Exception e){
//if (sessionFactory.getCurrentSession().getTransaction() != null) sessionFactory.getCurrentSession().getTransaction().rollback();
e.printStackTrace();
}finally{
//sessionFactory.getCurrentSession().close();
}
return rs;
}


As we see above that when the user clicks on the particular link. It category id is been passed to the function. For Example if Staples with id=53 is been clicked then it's product with category_id=53 will be displayed. But the problem is that product doesn't refer to any category id of the 1st level of the categorization.It refers to the last level of the categorization. In short if staples is been been clicked it's last level of the category are Dates,cashews,edible oil etc. Product with category id of last level of category should be displayed. So when i click on staples no product is been displayed. How to i solve this problem? On the click the last level of the category_id should be searched and the respective product should be displayed. I hope the question is been understood. If not please leave a comment.





Errors and unknown classes from bootstrap CDN

I'm getting a lot of errors showing in the developer console, but they're all listed as coming from http://ift.tt/1r529cJ


Here are some of the errors listed:



Unknown pseudo-class or pseudo-element '-webkit-inner-spin-button'. Ruleset ignored due to bad selector.
Unknown pseudo-class or pseudo-element '-webkit-search-cancel-button'. Ruleset ignored due to bad selector.
Expected end of value but found '\9 '. Error in parsing value for 'width'. Declaration dropped.
Expected end of value but found '\9 '. Error in parsing value for 'margin-top'. Declaration dropped.
Unknown pseudo-class or pseudo-element '-ms-input-placeholder'. Ruleset ignored due to bad selector.
Unknown pseudo-class or pseudo-element '-webkit-input-placeholder'. Ruleset ignored due to bad selector.
Expected end of value but found '�'. Error in parsing value for 'line-height'. Declaration dropped.
Unknown property 'user-select'. Declaration dropped.


It's a personal site targeted to potential employers, so I don't want them to think I have errors in my website. Does anyone know why I'm getting these and how I can get rid of them?





Add to Home Screen Icon HTML5

How can we add an Icon for Home Screen in HTML5 when we browse a webpage in chrome app and in option we choose Add To Home Screen. then theres an Icon Shortcut placed on your Home Screen.


I used:



<link rel="apple-touch-icon-precomposed" href="...\icon.png">

<link rel="apple-touch-icon" href="...\icon.png">


nothing happens it display again a default icon.! Just Like the AmStalker Home Screen Iconenter image description here


What is the best way to do it?





HTML-Reloading web page takes me to main page

I am creating a website and hosting it myself via IIS. I am trying to traverse pages but it's not really working.


This is my code that will go to my "serivices" page. However, when on this page the URL does not change and when pressing reload I am taking back to the home page.


<a href="..\html\services.html">Our Services</a>


Here's my file structure:


F:\Website\ (base directory for website) F:\Website\html\ (where all the HTML is)


If I try to go to the services.html file any other way I get a 404 error.


Any ideas?





CSS "background-position: bottom" Imperfect on Mobile Browsers




body
{
background-color: #000000;
background-image: url('http://ift.tt/15VJ8lx');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center bottom;
background-size: cover;
}

a
{
color: #ffffff;
}



<a>Hello, world!</a>


A site I'm developing has a background-image that fills the viewport and is anchored to the bottom. It works perfectly on PC, but mobile browsers on Android anchor the background-image to the bottom of the last element if the content doesn't fill the screen, leaving a blank space below it. How can I fix this to make the background-image correctly fill the screen on Android?





Responsive Web Desgin Without Grid System

I am doing a project on Responsive Web Design (RWD). Framework like Bootstrap or Foundation or 960 is using grids system as base layout. I am specifically looking for solution (framework) beside the ones with grids system, but still achieving the responsive components.


And if there is a pro and con comparing that to grids system.


If you known of any please shoot me a link.


Thanks





Are domains with gTLD's (.ninja, .guru, .museum, etc..) bad for SEO?

Would using one of the newer gTLD's have any adverse effect on SEO?





Web Development - How to create multiple instances of a website for different users and with different settings?

I am working on a web project and I am trying to see if I can use something already existing instead of creating it on my own (if not, I would still look for suggestions on how to pull this off).


Basically, I am creating the structure of the platform and I would like to know what is the best way to create multiple instances of the same website for different/selected users and with different settings.


For instance, I want the company 'A' to use this website. They would like the background to have their colours and logo, the language to be English and to allow the users Smith, Black and Brown to access/manage it.


At the same time, company 'B' wants the same website but with different background, in Japanese and for all his 100 employees.


How do I create multiple instances of my website for each of these companies and, perhaps, being able to assign "companyA.example.com" to company A and so forth. Is there a framework already supporting this?


If not, what would be the best way to do this?


The idea is to have it scalable for as many users and instances as needed.





Web scraping nested/hierarchical data

I am trying to read film data from a page like this: http://ift.tt/1EqIOto


If I use a DOM selector to get the a > b elements, I get this list of film titles. So far so good. But I also want to get the dates for each of those films, and then the times for each of those dates.



result: [ "A Most Violent Year", "American Sniper", "Birdman", "Ex Machina", "Foxcatcher", "Into the Woods", "Kingsman: The Secret Service", "Testament of Youth", "The Imitation Game", "The Theory of Everything", "Whiplash", "Wild" ]


I then need to make another query to get the dates in small tags but only when nested within/adjacent to A most violent year. Then get the list of times adjacent to Wednesday 28th January.


I've looked at some node packages like cheerio and noodlejs, but I can't work out how I can get only matches that are within each of the original match.





Why do we design UIs with tree structures?

Why do we define an UI of a website with a tree structure - HTML node inside a HTML node - rectangle inside rectangle? I hear it is the same with iphone's and android's UIs.


Image that an artist could only paint a picture by putting layers of rectangles inside existing rectangles.


It would not make sense. Why do we do it in digital design then?


Design is a semi-lattice and not a tree after all.





Using Custom Arabic Web Fonts from fast.fonts.com

Could someone suggest me a solution for missing web font for Arabic web site? Originally, there was a link to the web font:



<link href="http://ift.tt/1tsC3TK" rel="stylesheet" type="text/css">


But, right now this resource returns 404 error, so it was deleted or replaced.


How can I deal with that? Is there any other online resource for custom Arabic fonts?


Thanks in advance for all your help.





Web crawler class not working

Recently, I began working on constructing a simple web crawler. My initial code that just iterated twice worked perfectly, but when I attempted to turn it into a class with error exception handling, it no longer compiled.



import re, urllib
class WebCrawler:
"""A Simple Web Crawler That Is Readily Extensible"""
def __init__():
size = 1
def containsAny(seq, aset):
for c in seq:
if c in aset: return True
return False

def crawlUrls(url, depth):
textfile = file('UrlMap.txt', 'wt')
urlList = [url]
size = 1
for i in range(depth):
for ee in range(size):
if containsAny(urlList[ee], "http://"):
try:
webpage = urllib.urlopen(urlList[ee]).read()
break
except:
print "Following URL failed!"
print urlList[ee]
for ee in re.findall('''href=["'](.[^"']+)["']''',webpage, re.I):
print ee
urlList.append(ee)
size+=1
textfile.write(ee+'\n')

myCrawler = WebCrawler

myCrawler.crawlUrls("http://ift.tt/1Likcor", 2)


And here is the error code generated.



Traceback (most recent call last):
File "C:/Users/Noah Huber-Feely/Desktop/Python/WebCrawlerClass", line 33, in <module>
myCrawler.crawlUrls("http://ift.tt/1Likcor", 2)
TypeError: unbound method crawlUrls() must be called with WebCrawler instance as first argument (got str instance instead)




Contact form back end language

I'm in the process of developing a site and have hit a bit of a snag. I'm trying to decide the best way to go about hooking up a contact form.


I've got the front end built out using Bootstrap, but I'm having trouble deciding on how best to approach the back end. I keep coming across PHP as the way to go, but I'm not a huge fan of the syntax so I'd like to find a good alternative.


What are some alternatives to using PHP for the back end of a contact form?





PYTHON How to search a word on a HTML Page and make a Test

hello everyone I'm searching a special sentence or word in a html page after make a webrequest


the sentence = Couldn't resolve host 'http:'


I try to code a script using pycurl with b.getvalue() but seems doesen't works


website to try http://ift.tt/18vpPjX


code :


http://ift.tt/18vpNJ7


I would like search the total sentence or just maybe the word "http" or "Couldn't"


Thanks for your help





parallax responsive website

i'm making a prallax website, and it has to be also responsive. here is my site: http://ift.tt/1yyEi3B


Any ideas how to make it responsive?


Best regards





How to run Flask app on website

I'm very new in Flask. I work on a simple searching app in dictionary which is saved in memory while the app runs. For testing this application, I use Flask framework which runs a server on a localhost when I run the *.py file. When I start the Flask script, I can see my webpage in a browser and use the application properly.



if __name__ == '__main__':
setup()
app.run()


Now, I want to put it on the Internet to have remote access. I know that just copy+paste it to a directory on some hosting which supports Python would not work. I will appreciate any advices how to make this work.


I suppose, that it should be saved somewhere on the host directory and then I should start the app - app.run(I don't know what to type here as host and port). Or is there another way?


I want just type http://[some url where my app runs] and see the html stored in flask templates file.





Every 30 minute file updated? [on hold]

Every 30 mins I have to download a file from a link abc.com to my web host. How is it possible that every 30 minute file will be updated from that link from old to new?





how to post a moment on googleplus from different website?

I am writing a method in my web api controller to post/share moment, image and video on user's google+ page using c#. I read in some post that google api doen not have this option.But these posts are from last year. is it working now?


Thanks in advance.





k5n Web Calendar?

Im using a default install of k5n Web Calendar for a client who hosts at GoDaddy. I have seen this calendar script with other web hosts as well. I have a calendar set up with appointments on every day. When I log in as ADMIN, I can see all of the appointments fine. But when I log in as a USER, it only shows the first 4 or 5 events? Any help or insight would be helpful.





how to run .exe file from smarterasp.net hosting?

I hosted a website in smarterasp.net. now i need to run .exe files from it. Even if the file is in FTP or localdisk of the computer. Is it possible? If yes, how? If no, why?


Thanks.





Is there a way to hot reload a controller into Beego following a code change?

Is there any way to configure Beego 1.4.2 to hot patch a modified controller following a code change? Out of the box it reloads the entire application following a controller edit, thus causing any session data to be lost. A comment in GG suggests that hot reload existed in Beego 1.3, but I can't find any info as to why 1.4* does not do this. IMHO Beego is a neat framework but I wouldn't use it for a large project without the ability to dynamically update controllers.





What makes a website accessible worldwide?

I am based in the US, I would like to write websites for India.


I'm looking to build websites for other countries, target these countries as a new audience.


Maybe websites are accessible worldwide. But I came across the term GeoIP


I would have to translate them right?





how to dynamically read in local files?

I made an image slideshow of sorts for a website. Right now each slideshow image is a list item stored in a unordered list and I use javascript and naming conventions to write each list item out. Example:



for (j = 0; j<imageFileLength; j++){
$('ul#Slider').append('<li><img src="'+fileName+'/0'+j+'.png" /></li>');} //write list items for each image
});


This worked for awhile but now I can't hardcode it like this anymore. Anyone needs to be able to drop files into my folder, favorably with any name, and they will automatically be added as a list item to the unordered list.


I am required to use IE 8 which is a bit of a problem. It doesn't support the HTML File API, and it also doesn't support using PHP, but I might be able to get this turned on.


Any ideas? Or, if PHP is a good way to go about it, how it would be done? Maybe java via netbeans?


thank you