Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Convert



  Be careful about printing error as string in GoLang

In GoLang, we can format and produce string using fmt.Printf(), just like C, GoLang also supports format verbs like %s, %d which can be placeholder for different types of values. But please pay attention when printing error as string so that you will not fall into some trap. Let's first take an example code snippet and see what trap we are talking about. package main import "fmt" type A string func (a A) Error() string { return fmt.Sprintf("%s is an error", a) } func main() { a := A("hello...

   STACKOVERFLOW,GOLANG,FMT     2019-01-23 09:17:15

  Get associated file icon with only extension name using C++ on Windows

I have searched on Google for a few examples on how to get associated file icon with only file extension name using C++ on Windows. There are some useful information provided on MSDN which explains the use of SHGetFileInfo() function.It also gives an example code, but it doesn't say how to do it with only the extension name.  Here I give an example code on how to achieve this after I gathered and summarized some  useful information from Internet. I have tested the code on my PC, it w...

   File icon,Windows,Association,Extension name,C++     2012-03-26 09:55:20

  Convert number to string in C++

Prior to C++11, there is no built-in function in C++ standard library which can be used to convert numbers such as interger and double number to string.  There are many ways which can convert number to string. Since C++ is C compatible, we can use itoa() function to convert an integer to C style string. But this one can only convert integer to string, not double. For different types of numbers, we need to use different functions. string s = string(itoa(a)); Actually, we can also use strings...

   C++,conversion,number,string     2012-08-14 15:52:48

  JSON in JavaScript

When sending an AJAX request to the server, the response can have two formats : XMLHttpRequest.responseXML to access data with XML format and XMLHttpRequest.responseText to access data with string format. XML is the standard data transfer format, but one weakness is it's troublesome to parse and retrieve the data. JSON(JavaScript Object Notation) is a light weight data interchange format, we call it the JavaScript object representation. The advantage of using JSON as the data format is itself is...

   JSON,JavaScript     2013-05-04 23:25:57

  Use progressive JPEG to improve user experience

JPEG image files can have two different save types : Baseline JPEG and Progressive JPEG. Both of them have the same extension name but with different display effect. Baseline JPEG This type of JPEG files are scanned from top to bottom consecutively, each line of the image data will be saved sequentially. When opening this kind of images, data will be displayed with the save order line by line until all the data are read. If the image size is very large or network speed is very slow, the image wi...

   USER EXPERIENCE,PROGRESSIVE JPEG,BASELINE JPEG     2013-07-25 08:11:50

  Dates in PHP and MySQL

I see a lot of people on forums and on my training courses asking about the best way (or any way) to manage dates stored in a MySQL database and used in PHP. Three options follow, but first the problem.PHP uses unix timestamps for all its date functionality. It has methods to convert these timestamps into pretty much any text format you could want but internally it uses the timestamp format. A timestamp is simply an integer. Specifically, it’s the number of seconds that have ela...

   PHP,MySQL,Date format,Date,Comparison,Date compare     2011-10-17 14:00:57

  A strange behavior of printing struct with nested struct in GoLang

Normally when trying to print a struct , we would use %v to show all data of the struct. It will print the default format for each field in the struct. %v the value in a default format when printing structs, the plus flag (%+v) adds field names But recently we observed a strange behavior when printing a struct with nested struct which has a String() string implemented, the %v format prints an 'unexpected' output per our understanding.   Let's see the example snippet first. pa...

   PROGRAMMING,GOLANG     2018-10-29 09:59:49

  Never ever touch a programmer

This is a technical license plate block example. We don't know whether it is working or not, however, the idea is very good. When you drive through some of the junctions, the camera captures the license number and convert it into text with OCR, and then insert them into the database. Therefore, this license plate on the car becomes a SQL injection. This picture tells us -- never trust user input.Author : 陈皓 Source : http://coolshell.cn/articles/6639.html#more-6639...

   Programmer,SQL injection     2012-04-21 01:19:48

  Why you should be careful about optimizations

In one of my current javascript projects, I have to deal with 3D voxel coordinates. And, sometimes, I have floating points coordinates which must be converted to integers in order to convert them into proper array index. Javascript is a wonderful language, really. However, implementations are sometimes weird, and the way to do something can sometimes have very huge impacts on the performances. Worse, sometimes the classical way is more expensive than the tricky one. So, some peo...

   JavaScript,Bitwise,Floor,Trick,Optimization     2012-05-02 11:29:20

  Noteworthy Aspects of PSD to Markup Conversion

Are you a great designer but can't code to turn your pixel-perfect design into a mark-up language? You will certainly begin scrolling the web to seek out an expert PSD to mark-up conversion service provider. But before venturing out for a credible service partner, it's very important to decide the right platform for your website. Especially, when you're thinking about converting your photoshop document into a CMS (content management system), you will get a plenty of choices. However, WordPress, ...

   PSD to WordPress, Convert PSD to Wordpress, Convert PSD to Wordpress Theme, PSD to Wordpress Service     2014-08-04 08:46:36