I have a database encoded as utf8mb4. I connect with this database and I set utf8 charset:  $dbHandler = new PDO("mysql:host=$dbHost;dbname=$dbName;charset=utf8mb4", $dbUsername, $dbPassword);   All data is property encoded in DB. I want to fetch data and save it as CSV:  $fp = fopen('data.csv', 'w+'); foreach ($result as $row) { ...     fputcsv($fp, $csvData, ';'); }   But then all the encoding is broken: groÃ&lt;9f&gt;e,  ZubehÃ¶r.  etc.  I've tried to add BOM (didn't help) and convert array_map("utf8_encode", $csvData); (some characters are displaying correct: große, Zubehör, but some not: Kabelverl?ng, F?r). Any idea?   EDIT:  Hexdump output beginning of file:  00000000: efbb bf70 726f 6475 6374 3b61 7274 6963  ...product;artic 00000010: 6c65 3b73 6b75 3b64 6174 653b 6e61 6d65  le;sku;date;name 00000020: 0a30 3030 3239 3039 3530 3030 3b3b 3b3b  .00028151000;;;; 00000030: 2242 7265 616b 6f75 742d 626f 7820 4b70  "Breakout-box Kp 00000040: 6c2e 223b 223c 7374 726f 6e67 3e42 7265  l.";"&lt;strong&gt;Bre 00000050: 616b 6f75 742d 626f 7820 4b70 6c2e 3c2f  akout-box Kpl.&lt;/    Hexdump output of file with 1 record where we can see the issue (F..r instead of Für). By the way - original string was modified by ucwords and strtolower:  00000000: 3030 3032 3930 3936 3030 333b 3b3b 3b22  00028151000;;;;" 00000010: 4e65 747a 7465 696c 2032 3230 762f 3132  Netzteil 220v/12 00000020: 7620 46e3 9c72 2041 766c 223b 223c 7374  v F..r Avl";"&lt;st 00000030: 726f 6e67 3e4e 6574 7a74 6569 6c20 3232  rong&gt;Netzteil 22 00000040: 3076 2f31 3276 2046 e39c 7220 4176 6c3c  0v/12v F..r Avl&lt; 00000050: 2f73 7472 6f6e 673e 3c62 723e 3c62 723e  /strong&gt;&lt;br&gt;&lt;br&gt; 00000060: 4f45 4d20 4e75 6d6d 6572 3a20 3030 3032  OEM Nummer: 0002 00000070: 3930 3936 3030 3322 3b31 3038 2e34 363b  9096003";108.46; 00000080: 3030 3032 3930 3936 3030 332d 6e65 747a  00028151000-netz 00000090: 7465 696c 2d32 3230 762d 3132 762d 6675  teil-220v-12v-fu 000000a0: 722d 6176 6c3b 4875 7371 7661 726e 613b  r-avl;Husqvarna; 000000b0: 4452 4f50 444f 574e 3b59 3b4e 3b68 7474  DROPDOWN;Y;N;htt 000000c0: 7073 3a2f 2f73 7061 7265 7061 7274 7366  ps://sparepartsf 000000d0: 696e 6465 722e 6b74 6d2e 636f 6d2f 5350  inder.fha.com/SP 000000e0: 462f 496d 6167 6573 2f6d 6170 732f 3130  F/Images/maps/10 000000f0: 3030 3032 3932 302e 6769 663b 313b 4154  0002920.gif;1;AT 00000100: 3b57 6964 6765 743b 224b 544d 204f 7269  ;Ponret;"KTM Ori 00000110: 6769 6e61 6c20 4572 7361 747a 7465 696c  ginal Ersatzteil 00000120: 6522 3b22 4875 7371 7661 726e 6120 4e65  e";"Husqvarna Ne 00000130: 747a 7465 696c 2032 3230 762f 3132 7620  tzteil 220v/12v  00000140: 46e3 9c72 2041 766c 202d 204f 454d 204e  F..r Avl - OEM N 00000150: 756d 6d65 723a 2030 3030 3239 3039 3630  ummer: 000290960 00000160: 3033 223b 3b22 4b61 7566 656e 2053 6965  03";;"Kaufen Sie 00000170: 2048 7573 7176 6172 6e61 204e 6574 7a74   Husqvarna Netzt 00000180: 6569 6c20 3232 3076 2f31 3276 2046 e39c  eil 220v/12v F.. 00000190: 7220 4176 6c20 6d69 7420 4f45 4d2d 4e75  r Avl mit OEM-Nu 000001a0: 6d6d 6572 2030 3030 3239 3039 3630 3033  mmer 00028151000 000001b0: 2062 6569 2065 696e 656d 2048 7573 7176   bei einem Husqv 000001c0: 6172 6e61 2d56 6572 7472 6167 7368 c3a4  arna-Vertragsh.. 000001d0: 6e64 6c65 722e 2057 6972 2068 6162 656e  ndler. Wir haben 000001e0: 2065 696e 6520 6772 6fc3 9f65 2041 7573   eine gro..e Aus 000001f0: 7761 686c 2061 6e20 4875 7371 7661 726e  wahl an Husqvarn 00000200: 612d 4572 7361 747a 7465 696c 656e 2c20  a-Ersatzteilen,  00000210: 4163 6365 7373 6f72 6965 732c 2043 6c6f  Accessories, Clo 00000220: 7468 696e 672c 204d 5820 4265 6b6c 6569  thing, MX Beklei 00000230: 6475 6e67 2075 6e64 205a 7562 6568 c3b6  dung und Zubeh.. 00000240: 722e 220a                                r.".    file data.csv output:  data.csv: Non-ISO extended-ASCII text, with very long lines
I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.  Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL, and PHP to do this — is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur?  This is for a new Linux server, running MySQL 5, PHP, 5 and Apache 2.
I'm looking to get data such as Size/Capacity, Serial No, Model No, Heads Sectors, Manufacturer and possibly SMART data. How to format an inline source code Very large log files, what should I do? ( deals with a similar issue, but it talks about a rotated log file.)  Today I got a system message regarding very low /var space.   As usual I executed the commands in the line of sudo apt-get clean which improved the scenario only slightly. Then I deleted the rotated log files which again provided very little improvement.  Upon examination I find that some log files in the /var/log has grown up to be very huge ones. To be specific, ls -lSh /var/log gives,   total 28G -rw-r----- 1 syslog            adm      14G Aug 23 21:56 kern.log -rw-r----- 1 syslog            adm      14G Aug 23 21:56 syslog -rw-rw-r-- 1 root              utmp    390K Aug 23 21:47 wtmp -rw-r--r-- 1 root              root    287K Aug 23 21:42 dpkg.log -rw-rw-r-- 1 root              utmp    287K Aug 23 20:43 lastlog    As we can see, the first two are the offending ones. I am mildly surprised why such large files have not been rotated.  So, what should I do? Simply delete these files and then reboot? Or go for some more prudent steps?  I am using Ubuntu 14.04.  UPDATE 1  To begin with, the system is only several months old. I had to install the system from scratch couple of months back after a hard disk crash.  Now, as advised in ,  I first checked the offending log files using tail, no surprise there. Then, for deeper inspection, I executed this script from the .  for log in /var/log/{syslog,kern.log}; do    echo "${log} :"   sed -e 's/\[[^]]\+\]//' -e 's/.*[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}//' ${log} \   | sort | uniq -c | sort -hr | head -10 done   The process took several hours.  The output was in the line of,   /var/log/syslog : 71209229  Rafid-Hamiz-Dell kernel:  sda3: rw=1, want=7638104968240336200, limit=1681522688 53929977  Rafid-Hamiz-Dell kernel:  attempt to access beyond end of device 17280298  Rafid-Hamiz-Dell kernel:  attempt to access beyond end of device    1639  Rafid-Hamiz-Dell kernel:  EXT4-fs warning (device sda3): ext4_end_bio:317: I/O error -5 writing to inode 6819258 (offset 0 size 4096 starting block 54763121030042024)        &lt;snipped&gt;  /var/log/kern.log.1 : 71210257  Rafid-Hamiz-Dell kernel:  attempt to access beyond end of device 71209212  Rafid-Hamiz-Dell kernel:  sda3: rw=1, want=7638104968240336200, limit=1681522688    1639  Rafid-Hamiz-Dell kernel:  EXT4-fs warning (device sda3): ext4_end_bio:317: I/O error -5 writing to inode 6819258 (offset 0 size 4096 starting block 954763121030042024)    (/dev/sda3 is  my home directory. As we can find,   lsblk /dev/sda NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT sda      8:0    0 931.5G  0 disk  ├─sda1   8:1    0 122.1G  0 part / ├─sda2   8:2    0   7.6G  0 part [SWAP] └─sda3   8:3    0 801.8G  0 part /home    Why a process will want to write beyond the limit is actually outside the scope of my comprehension. Perhaps I will want to ask a different question in this forum if this continues even after a system update.)  Then, from  (you may want to check  for a deeper understanding), I executed,   sudo su - &gt; kern.log &gt; syslog   Now, these files have zero sizes. The system is running fine before and after a reboot.   I will watch these files (along with others) in the next few days and report back should they behave out-of-line.  As a final note, both  the offending files (kern.log and syslog), are set to be rotated, as inspection of the files (grep helped) inside  /etc/logrotate.d/ shows.  UPDATE 2  The log files are actually rotated. Looks like the large sizes were attained on a single day. Code blocks are not prettified on mobile site On Chrome on Android, code blocks on the mobile site have no syntax highlighting, are not a monospaced font, and words are wrapped.  Mobile site on mobile browser:    Desktop site on mobile browser:    Inline code has the same issue, it isn't a monospaced font.  It has been this way for as long as I can remember. Wouldn't be surprised if this is a dupe. Punctuating a quoted question within a quoted statement I'm working on a story, and I find myself faced with something of a quandary.  Specifically, I need to know the proper style for the following:     “I have thousands of them,” the commissioner answered, “but I’ll start with ‘What do you need?’.”   Is it proper form to have both the question mark and period, or should one of them be dropped? root owned program with setuid bit on Ping is a a program owned by root with the user id bit set.  $ ls -l `which ping` -rwsr-xr-x 1 root root 35752 Nov  4  2011 /bin/ping   As I understand it, if a user runs the ping process, then the effective user id will change from the real user id (i.e. the user id of the person who launched the process) to the user id root. However when I try this and look at the output of ps to see if the ping process is running as the root user, I still get the real user id showing.  ps -e -o user,ruser,euser,cmd,args | grep ping sashan   sashan   sashan   ping -i 10 -c 1000 www.goog ping -i 10 -c 1000 www.google.com Forcing linebreaks in \url This question led to a new package:      I wish to typeset some relatively long URLs in a piece of text, and when I use \url{..}, the resulting text does not respect the margin boundaries that govern the main text body, instead going all the way to the edge of the paper before wrapping around.   For reference, my preamble looks like this:  \documentclass[12pt]{article} \usepackage{mathptmx} \usepackage{fullpage} \usepackage[pdftex]{hyperref}   and example of the url I'm including is:  \begin{itemize} \item Some text  \url{very-long-url} ... \end{itemize}   I'm compiling using pdflatex, although I doubt this makes a difference. Markov's paper on insolubility of the homeorphy problem I am looking for an English translation of Markov's 1958 paper, On insolubility of the homeorphy problem, which I remember coming across on a website for a computational topology course (taught by Afra Zomorodian). Why does a neon lamp indicator on a power strip switch flicker in the dark? Neon lamp indicators embedded in power strip switches indicate whether the switch is ON or OFF. When the neon lamp is ON in a dark environment (lights of the room are off), the lamp begins flickering and it sometimes goes off for a few seconds. When I switch the lights of the room on, it stops flickering and remains bright. Even when I unlock my phone in the dark near the lamp, it stops flickering! Is the light-making-mechanism in neon lamps affected by the light intensity of the surrounding environment?  UPDATE: I captured my observations with my iPhone and uploaded it to YouTube. Here is the link of the video:  All the lights of my room were turned off. There were no plugs connected to the power strip. The only source of light was the screen of my MacBook Pro, which was not plugged in.  I increased and decreased the brightness of the computer screen during the video.  I then produced two additional light environments using my phone. For every vector space $V$ does there exist a linear functional $f$ ( a linear map from $V$ to $F$ the underlying field ) such that for some $ \vec v \in V$ , $f(\vec v) \ne 0$ ? If it does exist , can we prove the existence without the "axiom of choice " ? Is the existence equivalent to axiom of choice ? Regex to validate date format dd/mm/yyyy Detecting the system DPI/PPI from JS/CSS? I'm working on a kind of unique app which needs to generate images at specific resolutions according to the device they are displayed on. So the output is different on a regular Windows browser (96ppi), iPhone (163ppi), Android G1 (180ppi), and other devices. I'm wondering if there's a way to detect this automatically.  My initial research seems to say no. The only suggestion I've seen is to make an element whose width is specified as "1in" in CSS, then check its offsetWidth (see also ). Makes sense, but iPhone is lying to me with that technique, saying it's 96ppi.  Another approach might be to get the dimensions of the display in inches and then divide by the width in pixels, but I'm not sure how to do that either. Why does an conditionally convergent infinite series, when deranged, have a different limit? $\sum u_n = 1-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+\dots$ conditionally converges to $\log 2$; and, when deranged to $\sum u'_n = 1-\frac{1}{2}-\frac{1}{4}+\frac{1}{3}-\frac{1}{6}-\frac{1}{8}+\dots,$ converges to $\frac{1}{2}\log 2$. Why does a deranged conditionally convergent series have a different limit? First Course in Math Anal, p.93, by Burkill, explains that the sums $s_n, t_n$ of the first n terms of the two series are different functions of $n$. This reasoning is incomplete, because different functions of $n$ can converge to the same limit; for example, let $r_n$ be the first $2n$ terms of $\sum u_n$, then $s_n$ and $r_n$ are different functions; besides, by differently defining terms, i.e. clustering pieces of a series, e.g. \begin{align*} 1-\tfrac{1}{2}-\tfrac{1}{4}+\tfrac{1}{3}-\tfrac{1}{6}-\tfrac{1}{8}+\dots = \left(1-\tfrac{1}{2}-\tfrac{1}{4}\right)+\left(\tfrac{1}{3}-\tfrac{1}{6}-\tfrac{1}{8}\right)+\dots \\ = \left(1-\tfrac{1}{2}-\tfrac{1}{4}+\tfrac{1}{3}-\tfrac{1}{6}-\tfrac{1}{8}\right)+\dots,\\ 1-1+1-1+\dots = (1-1)+(1-1)+\dots \\ =(1-1+1-1)+\dots,\\ 1+1+1+1+\dots = (1+1)+(1+1)+\dots \\ = (1+1+1+1)+\dots, \end{align*} one gets the sum of first n terms as different functions, but the series's limit remains. One could view a changed limit from the perspective of the changed number of terms, Denote 'countably many', the size of natural number, as $\lvert\mathbb{N}\rvert$, then $\lvert\mathbb{N}\rvert = \lvert k\mathbb{N}\rvert = \lvert\mathbb{N}\times\mathbb{N}\rvert$. Then two series with different numbers (e.g. $\lvert \mathbb{N}\rvert$, $\lvert k\mathbb{N}\rvert$) of terms– and so having different limits– paradoxically have same number of terms–and so are possibly formed by the same terms. The paradox could be the fundamental reason. Are there other explanations? Is the use here of 'countably many' is proper? My understanding of the Stern–Gerlach experiment is that neutral (0 total charge) particles are sent through a non-homogeneous magnetic field, with the expectation that the field will push that particle's path higher or lower on a detector because of the collective spin of that particle. While the detector can detect particles in a two-dimensional surface, the results of the experiment are that particles appear in only two localized areas directly above the path of the particle stream, or directly below the path of the particle stream - spin up or spin down. The conclusions from these measurements are that the particle, when measured, will always have about the same magnitude.  Why does this not follow from classical mechanical theory related to magnetism? If you shot a magnet through a similar apparatus, I would expect the magnet to be rotated to align with the magnetic field in some way which, at high enough field strengths relative to the mass of the magnet, would cause us to measure basically the same magnitude as if the magnet entered the apparatus pre-aligned with the field.  How is my explanation incorrect? Is there an old, rarely used word which means "an archaic word"? Make Excel open some hyperlinks with non-default browser A bunch of our network/server/storage hardware uses web interfaces for their administrative portals. I'm currently using an Excel 2010 worksheet to keep track of each device. I have one column set aside to list the URL for each web interface. This makes it easy to simply click the URL to open each administrative portal.  My default browser is Firefox. However, some of the administrative portals don't play well with Firefox and require the use of IE. Until now, when I want to open a hyperlink in IE, I have to manually open IE, copy the URL from the Excel worksheet, and paste it into the IE address bar (otherwise it will open in Firefox if I simply click it). It's just an annoying extra couple of steps.  So without changing Firefox as my default browser, is there a simple way in Excel 2010 to tell it which hyperlinks to open in IE when they are clicked? I want to choose specifically which links open in which browser  (For reference I'm using Windows 7 Enterprise 64-bit) How to find the square root of a permutation Observe that  $$\begin{pmatrix} 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 \\  2 &amp; 4 &amp; 1 &amp; 5 &amp; 3 \end{pmatrix} \begin{pmatrix} 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 \\  2 &amp; 4 &amp; 1 &amp; 5 &amp; 3 \end{pmatrix} =  \begin{pmatrix} 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 \\  4 &amp; 5 &amp; 2 &amp; 3 &amp; 1 \end{pmatrix},$$  so $\begin{pmatrix} 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 \\  4 &amp; 5 &amp; 2 &amp; 3 &amp; 1 \end{pmatrix}$ is the square of a permutation. More generally, how do I check if a permutation is square and how can I find its root? I am typing to get a sale amount (by input) to be multiplied by a defined sales tax (0.08) and then have it print the total amount (sales tax times sale amount).  I run into this error. Anyone know what could be wrong or have any suggestions?   salesAmount = raw_input (["Insert sale amount here \n"]) ['Insert sale amount here \n']20.99 &gt;&gt;&gt; salesTax = 0.08 &gt;&gt;&gt; totalAmount = salesAmount * salesTax  Traceback (most recent call last):   File "&lt;pyshell#57&gt;", line 1, in &lt;module&gt;     totalAmount = salesAmount * salesTax TypeError: can't multiply sequence by non-int of type 'float' Any idea what kind of tool should I but to fix the loose left crank on my bike? I found this  but not sure if it's gonna suit. Or is it enough to buy only nut driver? I am using texlive 2013, and just ran the following command to update the packages.  sudo ./tlmgr update  -all   After it finished, I tried to compile tex documents that uses tikz package as the following MWE shows:   \documentclass{article}  \usepackage{tikz}  \begin{document}       aaaa  \end{document}   Then pdflatex complains; it said:   (/usr/local/texlive/2013/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty  (/usr/local/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex  ! I can't find file `pgfutil-common-lists.tex'.  l.556 \input pgfutil-common-lists.tex   The problem is that, pgfutil-common-lists.tex is indeed in the directory:   /usr/local/texlive/2013/texmf-dist/tex/generic/pgf/utilities/   Why is that? pdflatex should be able to find it, right? I even download the  again, and replace the pgf directory in   /usr/local/texlive/2013/texmf-dist/tex/generic/   Nothing changed at all........... Any idea? Thank you for your critics.  %=====================================================================  Then followed the comments, I type the following command in the terminal:    sudo mktexlsr gives me command not found;  mktexlsr gives me:  mktexlsr: /usr/local/texlive/2013/../texmf-local: directory not writable.     Skipping...  mktexlsr: /usr/local/texlive/2013/texmf-config: directory not writable. Skipping...  mktexlsr: /usr/local/texlive/2013/texmf-dist: directory not writable. Skipping...  mktexlsr: /usr/local/texlive/2013/texmf-var: directory not writable. Skipping... mktexlsr: Done; Forkpsewhich pgfutil-common-lists.tex, nothing pops up.