on-internet

One liner for If string is not null or empty else

I usually use something like this for various reasons throughout an application: if (String.IsNullOrEmpty(strFoo)) { FooTextBox.Text = "0"; } else { FooTextBox.Text = strFoo; } If I'm going to be using it a lot I will create a method that returns the desired string. For example: public string NonBlankValueOf(string strTestString) { if (String.IsNullOrEmpty(strTestString)) return "0"; else return strTestString; } and use it like: FooTextBox.Text = NonBlankValueOf(strFoo); I always wondered if there was something that was part of C# that would do this for me. Something that could be called like:

Join the discussion →

How should one go about organising a skiing/snowboarding holiday for a large group of people?

I try to go skiing every year with my university, however this year I want to do something a little different. I know a lot of people, and in turn they know some others, who want to go skiing this year. So I'm interested in arranging my own trip with lets say a group of 15-30 people. What are the things I need to consider? What is the best time to get the bookings and such finalised? And what is the best way of going about organising this trip, both logistically and financially? Sorry I forgot quite a lot of information that's useful. We're all UK based & British, the trip itself is likely to

Join the discussion →

SSRS 2008 R2- Format Parameter to DD/MM/YYYY

I have SSRS 2008 R2 and am working on reports for the UK. My report has a Date/Time data type parameter. When user opens the report the default date format is MM/DD/YYYY, but I would like to have DD/MM/YYYY format (same if user pick date from Calender drop-down date selection). I have changed the Language settings on the reports to UK and it formats the dates within the dataset, not the parameter. I have also tried using a cdate expression but that does not work either. One work around is just changing it to nvarchar in my SQL code however, I have a few scripts that use a > @eomdate so the nva

Join the discussion →

Line colour of 3D parametric curve in python's matplotlib.pyplot

I've been googling quite some time with no success ... maybe my keywords are just lousy. Anyway, suppose I have three 1D numpy.ndarrays of the same length I'd like to plot them in 3D as a trajectory. Moreover, I'd like to be able to do either of the following things: Change the colour of the line as a function of z Change the colour of the line as a function of time (i.e. the index in the arrays) This demo has an example of making such a curve: import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = fig.gca(pro

Join the discussion →

'The server was unable to process the request due to an internal error'. WCF Service, when deployed on IIS

I'm trying to consume a service, that I created, the service consumes perfectly when its deployed on the localhost. But when I try to consume the same service after deploying it on the server(IIS). I get the following error The server was unable to process the request due to an internal error.For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK document

Join the discussion →

Execution time, high- vs. low-level programming language [closed]

When talking about execution time between high- and low-level programming languages I often hear that low-level languages performs a bit better than high-level. Of course a low level can perform worse than a high-level depending on the programmer and algorithms. But if we use the very minimal code needed to do different tasks. Will there most often be differences in execution time due to the abstraction level of different languages? And also, does anyone know any good books about these kind of topic?

Join the discussion →

How to fetch rows with a whole nominated number in a column of comma-separated values with CodeIgniter's query builder [duplicate]

I have the followings examples in be_user_profiles.subject. These are subject ids which each teacher teaches. 1// English 1,2 // English and Math etc 1,2,14 2,4,114 12,24,34 15, 23 I want to select where be_user_profiles.subject has 1. When I use the following, it outputs all which has 1 in it. So it will outputs all. I tried HAVING but it picks up only exact matches. So it shows only the first one. How can I pick up data which has the be_user_profiles.subject? $this->db->select('*'); $this->db->from('be_user_profiles'); $this->db->join('be_users', 'be_users.id = be_user_profiles.user_id'); $t

Join the discussion →

"Fatal error: Allowed memory size [...] exhausted" when autoloading a custom CodeIgniter library defined as an extension of CI_Controller [duplicate]

I've custom library class Test extends CI_Controller { public function __construct() { parent::__construct(); } public function abc() { // some code } } When I add this library to autoload, I get the following error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in C:\xampp\htdocs...\system\core\Loader.php on line 495

Join the discussion →

Bluetooth communication between Arduino and PyBluez

I am trying to establish bluetooth communication between an Arduino Uno board (with a bluetooth shield) and my Linux OS, using Python PyBluez. I've successfully paired my laptop to the Uno. I'm able to connect to the board, however the board is not reading the data being sent nor is it able to send data. Here is the Arduino Sketch #include <SoftwareSerial.h> #define RxD 0 //receive data on digital 0 #define TxD 1 //transmit on digital 1 SoftwareSerial blueToothSerial(RxD, TxD); int counter = 0; int incoming; void setup(void){ Serial.begin(9600); //pinMode(RxD,INPUT); //pinMode(TxD,OUTPUT); set

Join the discussion →

How can I debug a Microsoft Store application using WinDbg?

I have a Microsoft Store application that needs to be debugged on one of our lab machines. The machines in the lab have WinDbg, but do not have Visual Studio. When I launch the .exe using WinDbg I get the following message: This application can be run only in the context of an app container Is there any way to get Windbg.exe to create the app container context?

Join the discussion →

OpenCart suddenly stopped working: HTTP Error 500

I use OpenCart v1.5.5.1 for the last month and a couple dozen orders came through fine. Suddenly today, I get a HTTP Error 500, when accessing www.domain.com/shop/*, but www.domain.com works fine. So far, I tried to no avail: rebooted the server cleaned out /logs/error.txt removed .htaccess The last error in the logs were: 2013-03-17 19:10:11 - PHP Notice: Error: Table 'shop_db.geo' doesn't exist<br />Error No: 1146<br />SELECT g.id,g.full_name,g.name,g.postcode,z.zone_id,z.country_id FROM geo g LEFT JOIN zone z ON g.zone_id = z.zone_id WHERE g.name LIKE '99%' AND g.postcode <> '' ORDER BY pop

Join the discussion →

SMTP server error: Verification failed for 550-No Such User Here 550 Sender verify failed

I'm using Configure SMTP plugin for wordpress, when I used it in a local server (localhost) it works properly and send me the test email which confirms that it is working. But when I used it in a hosting site (I used Hostgator) it gives me an STMP error. What is the possible cause of this error? and what is the possible solution? Thank you.

Join the discussion →

CSS transition effect makes image blurry / moves image 1px, in Chrome?

I have some CSS that on hover, a CSS transition effect will moves a div. The problem, as you can see in the example, is that the translate transition has the horrible side effect of making the image in the div move by 1px down/right (and possibly resize ever so slightly?) so that it appears out of place and out of focus... The glitch seems to apply the whole time the hover effect is applied, and from a process of trial and error I can safely say only seems to occur when the translate transition moves the div (box shadow and opacity are also applied but make no difference to the error when remo

Join the discussion →

Double quotes vs asterisk filename expansion in Bash

In the directories ~/temp/a/foo/ and ~/temp/b/foo foo/ I have some files named bar1, bar2, bar bar1, bar bar2, etc. I am trying to write a line of Bash that copies all these files in a directory containing "foo" as last part of the name to the folder above the respective "foo" folder. As long as there are no spaces in the file names, this is an easy task, but the two following commands fail when dealing with the foo foo directory: for dir in `find . -type d -name '*foo'` ; do cp $dir/* "$(echo $dir|sed 's_foo__g')" ; done (The cp command fails to see the last foo of "foo foo" as part of the sa

Join the discussion →

How can we verify what's noise and what's real data?

How can I claim that I correctly catch the "noise" in my data? To be more specific, take principal component analysis (PCA) as an example. We know that in PCA, after doing SVD, we can zero out the small singular values and reconstruct the original matrix using low-rank approximation. Then, can I claim what's been ignored is indeed noise in the data? Is there an evaluation metric for this? The only method I can come up with is simply subtract the original data from the reconstructed data. Then, try to fit a Gaussian over it, seeing if the fitness is good. Is that conventional method in a field

Join the discussion →

How can we verify what's noise what's real data?

How can I claim that I correctly catch the "noise" in my data? To be more specific, take principal component analysis (PCA) as an example. We know that in PCA, after doing SVD, we can zero out the small singular values and reconstruct the original matrix using low-rank approximation. Then, can I claim what's been ignored is indeed noise in the data? Is there an evaluation metric for this? The only method I can come up with is simply subtract the original data from the reconstructed data. Then, try to fit a Gaussian over it, seeing if the fitness is good. Is that conventional method in a field

Join the discussion →

Clearing a line in the console

How can a line in the console be cleared in C#? I know how to place the cursor at the beginning of a line: Console.SetCursorPosition(0, Console.CursorTop);

Join the discussion →

PHP/Apache: PHP Fatal error: Call to undefined function mysql_connect() [duplicate]

I have MySQL (5.5.23 Community Server), Apache (2.2), and PHP (5.3.13) running on a Fedora 15 machine (64-bit). Each works with no problem on their own. I thought that PHP was configured/compiled to work with MySQL, but when I try to load any PHP web page which makes a MySQL call then I get the above noted fatal error (in the Apache error log). PHP works okay on its own though, through Apache and at the command line. When I run php -i from the command line then sure enough it shows all the MySQL bits and pieces, but when I load a page displaying phpinfo() then there are no MySQL modules mentio

Join the discussion →

How can I prevent the cracking of Mac OS apps?

I have developed a small app for OS X and I provided it in the Mac App Store. Some weeks later I found a cracked version of my app on rapidscene.me. It seems for me the code signing of Apple is not strong enough to prevent cracks. Are there any other techniques to make the life harder for the crackers? Maybe binary checksums? How can I implement it easily?

Join the discussion →

WordPress - Custom Comments - Parent / Nested Reply

I am making a custom WordPress theme and have edited comments.php, but I'm unable to get the comments to save as a reply to another comment. I have succeeded in showing the comment parent id to show as a hidden value in the source code, but it doesn't save it accordingly in the database (instead, it always saves the comment_parent as 0). Also, the commenter IP address isn't saved either for some reason (comment_author_IP appears as "::1"). Here's the code I have so far: <?php if ( post_password_required() ) return; ?> <div id="comments" class="comments-area"> <?php // You can start editing her

Join the discussion →

Exact decimal datatype for C++?

PHP has a decimal type, which doesn't have the "inaccuracy" of floats and doubles, so that 2.5 + 2.5 = 5 and not 4.999999999978325 or something like that. So I wonder if there is such a data type implementation for C or C++?

Join the discussion →

Connect to Visual Studio Team Services from WebService

How can I provide credentials to TfsTeamProjectCollectionFactory.GetTeamProjectCollection? I am trying to develop my own WCF Service from which I will make the request to TFS. I need this WCF service because I would like to manage my TFS files from mobile in which I cannot use Microsoft.TeamFoundation.* dll I have been trying this way: Uri tpcAddress= new Uri("https://myserver.visualstudio.com/DefaultCollection"); TfsConnection tfsc = new TfsConfigurationServer(tpcAddress, new NetworkCredential("[email protected]", "password")); TfsWebClient wc = new TfsWebClient(tfsc); tfsc.Connect(ConnectOpti

Join the discussion →

Non-Object Errors using PHP PDO with MySQL [duplicate]

I've been scratching my head over this for a few days now and I've still got nowhere. I'm trying to pull a small set of values from a MySQL database via PHP PDO; I know PDO works as I am using it else where and I have based my code around te previously working code. function custom_sub_cat_list($db_details, $cat_id) { //ln21 $subcat = NULL; try { $h = new PDO("mysql:host=".$db_details['host'].";dbase=".$db_details['db'],$db_details['user'],$db_details['pass']); $h->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } catch(PDOException $ex) { return false; } try { $q = $h->prepare("SELECT catego

Join the discussion →

Android downloading file through DownloadManager not working correctly

I'm trying to download files thru DownloadManager, it works perfectly on most of the phones (Nexus family, S3, etc) but on Galaxy S2 for some reason the download works, but the name of the file is set wrong and when I try to open it (either from notification, either downloads app) it says that the file cannot be opened, even for files like jpeg, gif, png, etc. Here is the code: DownloadManager downloadManager = (DownloadManager) service .getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Request downloadReq = new DownloadManager.Request( Uri.parse(URL)); downloadReq .setAllowedNetwork

Join the discussion →

Spring how to reload the values from application.properties at runtime

In my Spring application I load application.properties file from outside the application e.g. /user/home/properties/application.properties. The values in the file are injected via @Value annotation in the beans. The new requirement I've is to be able to change values in application.properties file and reload (or reinject) the new values in the beans. Is something like this possible in Spring 3.2?

Join the discussion →

How to check if a variable is a typed array in javascript?

I'm working on a game and we make extensive use of typed arrays (Float32Arrays) for our math types. We save and load the gamestate from JSON. An example of JSON stringify output is for such an array (in Chrome) is: "{"0":0,"1":0,"2":0,"length":3,"byteLength":12,"byteOffset":0,"buffer":{"byteLength":12}}" This wastes space and causes them to be loaded as objects which is inconvenient. Ideally we could use the stringify 'replacer' function to test if a variable is a typed array, and then convert it to a bog standard array in that case. Unfortunately I'm not sure how to reliably test whether a va

Join the discussion →

How do I auto-expand a JTree when setting a new TreeModel?

I have a custom JTree and a custom JModel; I would for the JTree to "auto-expand" when I give it a new model. At the moment, it simply collapse all the nodes to the root. Here is an example: private class CustomTree extends JTree { @Override public boolean isExpanded(TreePath path) { return ((Person) path.getLastPathComponent).hasChildren(); } private class CustomTreeModel extends TreeModel { // ... omitting various implementation details @Override public boolean isLeaf(Object object) { return !((Person) object).hasChildren(); } } Model model = new Model(); Person bob = new Person(); Person al

Join the discussion →

Android - Is there is a way to remotely open and debug a given Android device?

My scenario is as follow: I'm working with an app development which a bug occurs in the app when it is in a different country than mine, and only there. The bug is related with a fail in an image download through an URL access. Right now, I haven't figured out yet what it can be. Some subjects I've already looked up are: Its not related to internationalization and/or culture, because the code does not implement this; Its not related to firewall/security access, because if the user in the other country opens the image's URL, he can look at the image; Without rooting the device, is there is a wa

Join the discussion →
Older stories