w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Why the python threads is so frustrating?
Python threads use Global Interpretor Lock (GIL) to synchronize access of Python interpretor state. Compared to other threads like POSIX threads, usage of GIL can make Python threads significantly slower, especially when dealing with multiple cores. This is well-known. Here is a really good presentation on the same: www.dabeaz.com/python/UnderstandingGIL.pdf‎

Categories : Python

Frustrating issue with NSTask and NSTaskDidTerminateNotification
The problem is that myObj is being deallocated after applicationDidFinishLaunching goes out of scope. Create a strong property, myObj, and then it should work properly. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.myObj = [[TestObj alloc] init]; [self.myObj executeTheTaskWithObj:self]; }

Categories : IOS

Extremely frustrating behavior with Internet Explorer, Bootstrap and Respond.js
Racket uses S-expressions to represent XML and I must use them to build my site. Have you looked at templates? http://docs.racket-lang.org/web-server/templates.html?q=template

Categories : PHP

How to map simple database with doctrine
First you should do a quick read on how Doctrine works, here's a nice tutorial: https://github.com/doctrine/orm-documentation/blob/master/en/tutorials/in-ten-quick-steps.rst The 5th step will show you how to properly configure your database access options. In Doctrine, you can either write your Entities in a PHP file (xml and yaml are also supported) or you can map an existing database into Entities, using the command line for a reverse engineering. Here's an explanation about this step: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/tools.html#reverse-engineering You can read this presentation on Doctrine 2 ORM's basics too: http://marco-pivetta.com/doctrine2-orm-tutorial/

Categories : PHP

Simple relational database planning suggestions
The first approach (with 5 tables) is more normalized. I'd suggest sticking with that unless you have a specific reason to denormalize. The following SQL will get all the distinct page ids for a given user: select DISTINCT GP.page_id from GroupUser GU join GroupPage GP on GU.group_id = GP.group_id where GU.user_id = ?

Categories : Mysql

Fast relational Database for simple use with Python
If speed is the main criteria, then i would suggest to go with a in-memory database. Take a look at http://docs.python.org/2/library/sqlite3.html it can be used as a normal database too, for the in-memory mode use the below and the db should get created in the RAM itself and hence much faster run-time access. import sqlite3 conn = sqlite3.connect(':memory:')

Categories : Python

I can only store numbers in the database, a simple shoutbox in php
See if this helps: function postMessage($message){ mysqli_query(connectdb(), "INSERT INTO messages (message) VALUES ("'".mysqli_real_escape_string($message)."'")"); } // connectdb(); // this is probably not needed since this function // is called in postMessage function if (isset($_POST['message'])){ postMessage($_POST['message']); }

Categories : PHP

Do I have to initialize the database for simple membership or not? MVC contradictiving itself?
Yes, it's actually quite simple. You are using some code that requires simple membership PRIOR to where you are normally doing your initialization. So, you get the error message and you add a call to do the initialization, so now your new code works.. but then it gets to the old code which.. initializes the database again and it throws the error. The problem is basically that you are trying to access the data too early in the pipeline. Initialization must occur once each time the App Domain is created (ie, when the app is first started, or after the app is restarted from being shut down by IIS for inactivity). This is why you should wrap it in a call to WebSecurity.Initialized

Categories : Dotnet

Simple show database data in JTable
Anyone who is so foolish as to include an empty catch block is sure to struggle: } catch (SQLException ex) { } This is a very bad idea. You should log or print the stack trace at minimum OR add a throws clause to the method signature and handle it elsewhere. Your code style is poor, too. Readability matters. Develop a single coherent style and stick to it.

Categories : Java

Optimal storage engine for simple key/value database
MySQL probably wouldn't be considered the "best fit" for this. Check out this wikipedia article on databases meant to be used as key-value stores. Some of the more popular ones it mentions are: Apache Cassandra Project Voldemort Riak BigTable MemcacheDB MongoDB (though I thought this was a document store not a KV store...) Berkeley DB

Categories : Java

Simple form not submitting to database PHP MySQL
You're missing the name attribute for your submit button so there's no schcreate key in $_POST and your query doesn't run. You can eliminate the need for the name attribute by checking $_SERVER['REQUEST_METHOD'] to get the request type, also you should use isset in each of your post values, so you could rewrite your code like this: <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { error_reporting(E_ALL); include_once("../php_includes/db_connect.php"); $name = isset($_POST['schname']) ? $_POST['schname'] : ''; $location = isset($_POST['schlocation']) ? $_POST['schlocation'] : ''; $daystart = isset($_POST['schday']) ? $_POST['schday'] : ''; $shiftcount = isset($_POST['schshiftcount']) ? $_POST['schshiftcount'] : ''; $st

Categories : PHP

Change datetime to simple %m/%d/%Y in database with rails
Try this: Add a file to config/initializers with the following code: Date::DATE_FORMATS[:default]="%m/%d/%Y" Time::DATE_FORMATS[:default]="%m/%d/%Y %H:%M" Time::DATE_FORMATS[:db]="%m/%d/%Y" and see the railcast.

Categories : Ruby On Rails

Simple Membership Accounts not Writing to Database
The ASP.Net configuration tool is for use with the full ASP.Net membership service, not the Simple Membership tables. If you are wanting to add users to Simple Membership, you simply add the user in the tables directly using SQL Management Studio. If you modify the providers for the much more complex ASP.Net Membership service, you will render Simple Membership useless. From ASP.Net blog WSAT is built to work with ASP.NET Membership, and is not compatible with Simple Membership. There are two main options there: Use the WebSecurity and OAuthWebSecurity API to manage the users and roles. Create a web admin using the above APIs. Since SimpleMembership runs on top of your database, you can update your users as you would any other data - via EF or even in direct databa

Categories : C#

simple check box insertion into database using mysqli php
For information: If the checkbox is not selected on the form, the field is not sent in the posts array. i.e. the actual fieldname $_POST['PHP'] will not exist. You will need to change your code to something like this. $subject1 = isset($_POST['php']) ? mysqli_real_escape_string($_POST['php']) : 'DEFAULT_VALUE'; $query = "INSERT into sub(Subject1) VALUES('$subject1')"; $result = mysqli_query($query); if ( $result ) { echo 'Record Added'; } else { die('Error: ' . mysqli_error($con)); } This will insert either the value of the checkbox field or your default value if the checkbox was not selected by the user.

Categories : PHP

Android simple database adapter not working
String[] columns = new String[] { contacts_nick.KEY_ID, contacts_nick.KEY_NAME,contacts_nick.KEY_PHONE }; int[] to = new int[] { R.id.name, R.id.phone }; You are mapping out three variables but only onto two views.

Categories : Android

Android 'simple' database scenario: Is it better to close using database.close() or databaseHelper.close()?
There isn't really a huge difference. This is the whole definition of close() within SQLiteOpenHelper: /** * Close any open database object. */ public synchronized void close() { if (mIsInitializing) throw new IllegalStateException("Closed during initialization"); if (mDatabase != null && mDatabase.isOpen()) { mDatabase.close(); mDatabase = null; } } The reason both exist, is that there may be instances where developers only use SQLiteOpenHelper for interfacing with their database and want the close() method as a convenience to directly access the DB, or vice versa if developers don't choose to use the OpenHelper at all.

Categories : Android

I am creating a simple database that controls my company's stock
You might want to look into materialized views of your data structure. Save off the snapshots each month in the format of your choice for reporting purposes. This would give you a performance boost while maintaining the data structure you desire.

Categories : SQL

How to create a simple document in a CouchDB database from Android?
Ok so I managed to make it work. Here is the code I've used: public static String createDocument(String hostUrl, String databaseName, JSONObject jsonDoc) { try { HttpPut httpPutRequest = new HttpPut(hostUrl + databaseName); StringEntity body = new StringEntity(jsonDoc.toString(), "utf8"); httpPutRequest.setEntity(body); httpPutRequest.setHeader("Accept", "application/json"); httpPutRequest.setHeader("Content-type", "application/json"); // timeout params HttpParams params = httpPutRequest.getParams(); params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Integer.valueOf(1000)); param

Categories : Android

Why am I getting this type compatibility error with Database.PostgreSQL.Simple?
The PostgreSQL count() functions returns a Bigint type, see http://www.postgresql.org/docs/9.2/static/functions-aggregate.html Bigint are 8 bytes see http://www.postgresql.org/docs/9.2/static/datatype-numeric.html Haskell int is ~ 2**29 which implies it a 4 byte integer. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Int.html Then its normal that PostgreSQL or its API will not do an implicit downwards conversion in precision. So use a Haskell int64 type or cast count(*) to integer.

Categories : Postgresql

postgresql-simple: get a list of table names in a database
as already answered in a comment above (due to lack of privileges): don't use postgresql-simple at all, but plain SQL on the internal postgresql tables: select schemaname, tablename from pg_tables; sorry for the noise.

Categories : Database

A simple file for saving a class of vectors or a SQL database
A relational SQL database can handle this just well. Use PostGreSQL You can use ODBC from C, that way you can change the database should the need arise. If your data is not really relational, you can also use redis. http://code.google.com/p/credis/

Categories : C++

Store meta information as a simple Enum or in database?
IMO, you should not choose one over the other, but instead have both. The enum will help keep your Java code clean, and the table will help keep that data organized. It would be good to have a separate (master) table for that type of information. And the other tables can reference it as a foreign key. With that you will have a central location for possible values. You wouldn't have to go every where looking for all the possible values. You can create an enum representing that (master) table. And it can be used as field type if you create entities for other tables. You can see this for an example. Also (optionally) you could valid the enum with table content at application start, to make sure the enum stays in sync with the table, in case new values or added or some existing ones are upd

Categories : Java

Moq simple example required- database connection and file handling
First of all, Moq does not support mocking concrete classes. Only abstract classes and interfaces can be mocked. However, this is not as hard as it sounds. Let's take your log file handling as an example. Say you start with the following concrete logging class: public class Log { public void WriteToLog(string message) { ... } } We have another classes that uses this Log class to do its logging: public class LogGenerator { public void Foo() { ... var log = new Log(); log.WriteToLog("my log message"); } } The problem with unit testing the Foo method is that you have no control over the creation of the Log class. The first step is to apply inversion of control, where the caller gets to decide what instances are used: public clas

Categories : C#

Posted values not being entered into database with simple PDO query
You are missing a comma between :rid and :cmt. $stmt = $dbh->prepare("INSERT INTO `post_comments` (`user_id`,`post_id`,`reply_id`,`comment`,`date`) VALUES (:uid, :pid, :rid, :cmt, :date)");

Categories : PHP

Simple function to pull field data from a database table
please try with the following ,check your connection variables are correct. <?php function fetch_data(){ $user="root"; $pass=""; $dsn='mysql:dbname=mydata;host=localhost;'; try{ $db =new PDO($dsn,$user,$pass); } catch(PDOException $e){ echo "connection failed ".$e->getMessage(); } //replace the code block from $user to end of catch statement because that might be within //your included file connect.php $query=$db->prepare("SELECT Value FROM settings WHERE Name = ?"); $name="SiteSlogan";//or SiteTitle $query->bindParam(1,$name, PDO::PARAM_STR); $query->execute(); $query->bindColumn("Value",$value); $query->fetch(); echo $value; // or you can add more columns in bincolumn like //$query->bindColumn("id",$id); //echo $id; } fetch_data(); ?>

Categories : PHP

Get simple html text field to post to mysql database
You need the name="blahblah" attribute when submitting forms. On the PHP side, the name is how PHP receives the variable's "key" (var name) and then the field contents are the variable's value. On the HTML side: <input type="text" id="comment" name="myvarname" /> On the PHP side: <?php $comment = $_POST['myvarname'];

Categories : PHP

No errors or results when executing simple query on SQL Server database
The function getdate() actually returns a datetime. Try converting it to a date: AND SessionDate = cast(getdate() as date) The time component is probably the problem -- preventing a match between the date and the datetime.

Categories : C#

Set GeoServer to access a Postgresql database, Simple or Snapshot schema, populated by Osmosis
This is a case for using TRIGGERs to manage the integration. The two programs use two different schemas. You can CREATE TRIGGERs in the database which ensure that data written to one application is made available to another. Another option is you can set one or both to use VIEWs populated in part by the other application. In PostgreSQL, a VIEW can have triggers attached so these are not really This is, in any case, a potentially large project so rather than offering sample code, I will offer a general outline of what sorts of things you need to think about. Are these generally applicable? If so do you want to start an open source integration project? Are both of these read-only workloads? Does data ever update? In general, if you are going to use views, updates pose the most con

Categories : Postgresql

HTML, PHP, JavaScript -- How to make a button for each individual record in a database? Seems simple but doesn't work
Your problem is $resultArrayImplode; is a string, so var resultArray = <?php echo $resultArrayImplode; ?> renders as: var resultArray = 1,2,3,4,5 Which is a syntax error. What you can do is use JSON. JSON syntax is JavaScript syntax, so all you need to do is: var arrayEntries = <?php echo json_encode($resultArray); ?>; This should render as something like: var arrayEntries = [1,2,3,4,5]; Which is perfect JavaScript syntax. Then the rest of your code should work.

Categories : PHP

What is the best way to store a field that supports markdown in my database when I need to render both HTML and "simple text" views?
You need to store your data in a canonical format. That is, in one true format within your database. It sounds like this format should be a text column that contains markdown. That answers the database-design part of your question. Then, depending on what format you need to export, you should take the canonical format and convert it to the required output format. This might be just outputting the markdown text, or running it through some sort of parser to remove the markdown or convert it to HTML.

Categories : Javascript

Flowplayer question mark
A question mark URL encodes as %3F. But you should use a proper encoder for the whole thing rather than manually encoding a specific character. Depending on the server-side technology you're using to build the Urls, tyhere should be a function like UrlEncode() which should handle all this for you. Failing that, Javascript has encodeUriComponent()

Categories : Misc

How to match a question mark?
Use quotemeta for the regex pattern. use warnings; use strict; my $search = quotemeta 'http://shorturl.com/detail.cfm?color=blue'; my $replace = 'http://shorturl.com/detaila.aspx?color=red'; my $file = '<a href="http://shorturl.com/detail.cfm?color=blue" class="news">HI</a>'; $file =~ s/$search/$replace/gis; print $file; __END__ <a href="http://shorturl.com/detaila.aspx?color=red" class="news">HI</a>

Categories : Regex

MySQL - question marks
Your database table column should be created with proper charset and collation. You can define theit while creating or altering a table: col_name {CHAR | VARCHAR | TEXT} (col_length) [CHARACTER SET charset_name] [COLLATE collation_name] Here is the mysql link to help you learn more about it: http://dev.mysql.com/doc/refman/5.0/en/charset-column.html

Categories : Java

C++ spanish question mark
this character is simply not included in basic ascii. Try using wstring http://www.cplusplus.com/reference/string/wstring/

Categories : C++

how to retrieve data from database in edit text box that display simple dropdown items while typing the letters?
Basically you implement a class which extends AutoCompleteTextView. Then you use myACTV.setAdapter(myAdapter); where mActivities = new SimpleCursorAdapter(...); Have a search starting at SimpleCursorAdapter Then limit the results to the Training category on the left hand side of the web page. The Notepad Exercise should get you further.

Categories : Android

hr content shows question mark
The probable explanation is that although the HTML document is declared to be UTF-8 encoded, it actually isn’t. It might be windows-1252 encoded, and when the windows-1252 encoded representation of “§” is encountered when processing presumed UTF-8 data, it constitutes a character data error. A common, and recommended, way in which browsers indicate the error is “�” REPLACEMENT CHARACTER. To fix this, make sure the declared and actual character encoding match. It is less relevant which encoding you use, but other things being equal, it is best to use UTF-8. So you would need an editor or other authoring tool that can actually save the data as UTF-8 encoded. If you absolutely cannot fix the encoding issue, replace "§" in CSS by the escape notation "A7". Much less readable, bu

Categories : HTML

Check if last character is a question mark
if (substr(rtrim($link), -1) != "?") { // Do stuff } Giving a negative start value to substr() makes it count from the end instead of the beginning.

Categories : PHP

URLRewrite rule for a URL that only contains one value after the question mark
Try this code. Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} ^([a-z0-9-]+)$ [NC] RewriteRule ^$ /#!/videos:%1? [L,R=301,NE]

Categories : Htaccess

.htaccess rewrite URL with a question mark "?"
RewriteRule ^component/users/?view=registration$ registration.html$ [R=301,L] You need a because ? is part of a regular expression. To Use it as a string u need to escape it with a Linktip: http://ole.michelsen.dk/tools/regex.html

Categories : Htaccess

mod rewrite question mark and ampersands
I think the issue here is that in your RewriteRule you're trying to match a part of the query string, which isn't possible. If I understand your problem correctly, you want requests to http://example.com/category/general?type=pages&v=1 to be interpreted by the server as http://example.com/category.php?c=general&type=pages&query=1? To match a query string, you need to prefix your rule with a condition. The following should work: RewriteCond %{QUERY_STRING} type=([^&]+) RewriteCond %{QUERY_STRING} v=([^&]+) RewriteRule ^category/([^/]+) /category.php?c=$1&type=%1&query=%2 The first two lines are pre-conditions that state that the requested URL needs to have both type= and v= as part of the query string. The final line rewrites the request. This means that

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.