Posts

Install zeromq on Yosemite with php PECL

brew install zeromq Building php extension via PEAR sudo pecl install zmq-beta You will have to add the extension to your php.ini with this line: extension=zmq.so Find the php.ini File Location from the Command Line php -i | grep php.ini You can, of course, always put a new php file in your web server root directory and add in the following: phpinfo();

MySQL: Group Concatenation

One of those small thing that are not essential but yet very helpful - GROUP_CONCAT which returns grupped rows as one string with selected separator (comma by default). EG: SELECT GROUP_CONCAT(ID), type FROM `User` GROUP BY type; This will return something like: 1,2,4,12 | admin 3,5,6,7,8,9,10,11 | user SELECT GROUP_CONCAT(DISTINCT County ORDER BY Country SEPARATOR '; '), type FROM `User` GROUP BY type; The result may be like this: Ukraine; Russia; USA | admin Russia; Canada; USA | user Referenced from : http://www.soel.org.ua/programming/databases/mysql-group-concatenation

Druid: The Database Manager

Image
The druid is a tools that allows users to create databases in a graphical way. The user can add tables, fields, folders to group tables and can modify most of the database options that follow the SQL-92 standard. In addition to sql options, the user can document each table and each field with HTML information. Once the database is created, the druid can generate: HTML documentation: for all tables, with browsing facilities PDF documentation: for all tables Java classes: (one class for each table) that contain tables' constants (such as fields size) plus java code added by the user A data dictionary that contains all tables and fields present in the database SQL script which contains all table definitions that can be piped to the DBMS http://druid.sourceforge.net/

How to create unicode files using VBA?

Image
Using the Scripting Runtime library you can create a unicode text file and write to it like: Sub test() 'set reference to Microsoft Scripting Runtime lib Dim strFile As String, strRange1 As String, strRange2 As String Dim fso As FileSystemObject Dim txtStrm As TextStream strFile = "Y:\Work\MyFile.htm" 'amend as appropriate strRange1 = Range("A1").Value strRange2 = Range("A2").Value Set fso = New FileSystemObject Set txtStrm = fso.CreateTextFile(strFile, Overwrite:=True, Unicode:=True) With txtStrm .WriteLine strRange1 .WriteLine strRange2 .Close End With End Sub You must set a reference within the VBE via Tools>References to the Microsoft Scripting Runtime lib.

Reading a unicode Excel file in PHP

Image
It's easy to save an Excel file as CSV and read it in PHP with the fgetcsv function but this may not work so well if the file contains non-English characters. Excel uses a non-standard character encoding for csv files. You can save an Excel file as 'unicode' text however there are several unicode systems - Windows uses UTF-16, and PHP uses UTF-8. To open the 'unicode text' file in PHP you have to convert it, in addition you may want to be able to open UTF-8 files that may be created by other systems. PHP has an encoding detection function - but it can't detect UTF-16. I've solved the problem with the following function which detects from several encodings, adds an appropriate filter, and returns a filehandle which reads as UTF-8. function fopen_utf8 ( $filename ){ $encoding = '' ; $handle = fopen ( $filename , 'r' ); $bom = fread ( $handle , 2 ); // fclose($handle); rewind ( $handle ); if( $bom === chr ( 0xff ). chr ( 0xfe

JAVA: Set filename using setHeader()

Image
Using the response.setHeader() method you can easy set the filename and extention as you like. response.setContentType("image/jpeg"); response.setHeader( "Content-Disposition", "attachment;filename=MyFilename.jpg;" ); If you are serving other fileformats, remember to change the content type.

Redhat / CentOS / Fedora Linux Open port using ip table

Image
By default iptables firewall stores its configuration at /etc/sysconfig/iptables file. You need to edit this file and add rules to open port number. This file only avilable under Red Hat Enterprise Linux 3 / 4 / 5 and above => Old Red hat Linux version => CentOS 4 and above => Fedora Linux We will use port 80 as example. Open port 80 Open flle /etc/sysconfig/iptables: # vi /etc/sysconfig/iptables Append rule as follows: -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT Save and close the file. Restart iptables: # /etc/init.d/iptables restart Restart iptables service Type the following command: # service iptables restart Verify that port is open Run following command: netstat -tulpn | less Make sure iptables is allowing port 80 connections: iptables -L -n Refer to iptables man page for more information about iptables usage and syntax: man iptables Referenced from : http://www.cyberciti.biz/faq/howto-rhel-linux-open-port-using-iptables/