Monday, March 9, 2015

How to give Subdomain path in Jbimages plugin in tinymce

recently i got some website project that use subdomain for it's image or something like CDN for serving images, and i got some serious problem when i try to upload an image using tinymce plugin called Jbimages.

the problem is image not showing in the editor because it's relative url like '../cdn_public_html/uploads/filename.jpg', I solve this problem by editing this 2 files

tinymce/plugins/jbimages/ci/application/controllers/uploader.php
tinymce/plugins/jbimages/config.php


by adding some configuration ($conf['base_image_url']) and setting that to the controller (function upload), so the output (ajax) is prepended with your sub domain or your CDN url.
see my Gist below for how to do this

Wednesday, December 24, 2014

Configuring smsd gammu 1.33.0 with MySQL and ODBC on Mac OS X Mavericks 10.9.5


2 days ago i got frustated why i CAN'T connecting gammu to mysql, after so many research then I have find solution about how to configure SMSD gammu 1.33.0 with MySQL using ODBC MySQL Connector on Mac OS X Mavericks 10.9.5

this is what I'm trying to configure on below step:
- Gammu 1.33.0
- MySQL 5.6
- MySQL ODBC Connector
- unixodbc

so if you have one of this installed before, please remove/backup it first.

and here's how I solved this problem:

1. configure modem first with gammu, if you don't know how, you can read my other post here about Step by step to easy install gammu on Mac OS X 10.9 Mavericks

2. install MySQL using homebrew. but before install this if you have MySQL installed before WITHOUT USING HOMEBREW please remove/backup it first,  especially MAMP, I got serious [ERROR] No database Selected problem occured that keep me puzzled for 2 days because ODBC MySQL Connector installing MySQL as their depedency, but if you have installed MySQL using homebrew in the first, i think you won't have problem like mine.  to install MySQL with homebrew type this command:

$ brew install mysql

3. install ODBC MySQL Connector using homebrew

$ brew install mysql-connector-odbc

4. check unixodbc on /usr/local/Cellar/ is there or not, if yes then you can go to step 5, if not, you must install it with:

$ brew install unixodbc

5. make sure your MySQL is up and running correctly

6. create database with name smsdb or whatever you want on your MySQL, and import mysql.sql file from gammu you've install before usually located on 
/usr/local/Cellar/gammu/1.33.0/share/doc/gammu/examples/sql/mysql.sql to your database

7. open your favorite text editor, and input this configuration and change to your need, then save with whatever name and wherever path you want, example: ~/smsdrc (saved on root like me)

[gammu]
device = /dev/tty.HUAWEIMobile-Modem
connection = at115200

[smsd]
logfile = smsd.log
phoneid = SMSServer1
PIN = 12345

Service = SQL
Driver = odbc
SQL = mysql

Host = my_local_odbc_mysql
User = root
Password = 
Database = smsdb


8. create/or open file .odbc.ini on ~/ folder

$ mate ~/.odbc.ini --> I'm using TextMate command line syntax here

9. input this configuration to .odbc.ini files and change to your need

[ODBC]
Trace         = 1
TraceAutoStop = 0
TraceFile     = ~/odbc_log.txt
TraceLibrary  = 

[my_local_odbc_mysql] # this must be same as on Host setting on smsdrc file
Driver      = /usr/local/Cellar/mysql-connector-odbc/5.3.2_1/lib/libmyodbc5a.so # path to ODBC Driver you installed, version maybe different from mine, 5a.so for ANSI 5w.so for Unicode, choose one to your need
SERVER      = localhost
PORT        = 3306
USER        = root
PASSWORD    =
DATABASE    = smsdb


10. test unixodbc config you just create

$ isql my_local_odbc_mysql

11. if you have this console, then you success connect to your mysql server, try some mysql command

+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+

SQL>

SQL> show databases;
+-----------------------------------------------------------------+
| Database                                                        |
+-----------------------------------------------------------------+
| information_schema                                              |
| mysql                                                           |
| performance_schema                                              |
| phpmyadmin                                                      |
| test                                                            |
| smsdb                                                         |
+-----------------------------------------------------------------+
SQLRowCount returns 6
6 rows fetched
SQL>

12. type control + C to exit

13. it's time to test our gammu-smsd

$ gammu-smsd -c ~/smsdrc 
Log filename is "smsdlog"

if you have that message, then you success on configuring smsd gammu 1.33.0 with MySQL and ODBC on Mac OS X Mavericks 10.9.5

Congratulation !!! 

if your have an error like this

$ gammu-smsd -c smsdrc 
Log filename is "smsdlog"
gammu-smsd[78488]: SQLExecDirect failed, Code = -1, ODBC diagnostics:
gammu-smsd[78488]: 3D000:1:1046:[MySQL][ODBC 5.3(a) Driver][mysqld-5.6.22]No database selected

I think you install MySQL manually or not from homebrew, and the odbc is connected to that MySQL one, to see if you have MySQL running type this command:


$ ps ax | grep mysql

next time I will try share some simple web base sms management using PHP, MySQL and Gammu on Mac OS X.

thanks for reading, don't hestitate to comment here, if you have some problem.

Saturday, June 21, 2014

Step by step to easy install gammu on Mac OS X 10.9 Mavericks

Right now, I'm trying to create a SMS Gateway for my friend, who need it for his business. And as usual, I write here is just for a reminder, if sometime I need it again, I can find it easily, so this is how to installing gammu on Mac OS X 10.9 Mavericks.

First of all, you must install your modem driver, I'm using Huawei E 173 here, the driver can be download from huawei website

be sure to install MobilePartner.app and your modem can send sms or make a phone call, that's how we know that our modem is working perfectly.

and the important ingredient is installing CMake before installing gammu, because gammu is build using cmake

gammu is available on Homebrew packages, so you can install it on last version, right now is 1.33.0
Homebrew is already on Mavericks, so you don't need to install it again.

1. disconnect modem
2. open terminal and type this command to install Cmake

$ brew install cmake

3. after it finish, now type this command to install gammu

$ brew install gammu

4. after success and no error happen, connect your modem now, and type this command

$ ls -la /dev

5. find Modem TTY for your modem, or like mine with this command

$ ls -la /dev | grep HUAWEI

crw-rw-rw-   1 root        wheel      18,  19 Jun 22 01:40 cu.HUAWEIMobile-Diag
crw-rw-rw-   1 root        wheel      18,  17 Jun 22 01:40 cu.HUAWEIMobile-Modem
crw-rw-rw-   1 root        wheel      18,  21 Jun 22 01:40 cu.HUAWEIMobile-Pcui
crw-rw-rw-   1 root        wheel      18,  18 Jun 22 01:40 tty.HUAWEIMobile-Diag
crw-rw-rw-   1 root        wheel      18,  16 Jun 22 01:40 tty.HUAWEIMobile-Modem

crw-rw-rw-   1 root        wheel      18,  20 Jun 22 01:40 tty.HUAWEIMobile-Pcui

6. my Modem TTY is tty.HUAWEIMobile-Modem
you will need this, so remember or copy it on text editor for next step

7. create gammu configuration file

$ touch ~/.gammurc
$ vi ~/.gammurc

8. type A to insert, and type configuration like this

[gammu]
device = /dev/tty.HUAWEIMobile-Modem
connection = at115200

9. change device value to your Modem TTY, and type Esc then :wq to save and quit from vi editor
or you can use nano command instead vi like me :D

10. make sure your configuration is fine

$ cat ~/.gammurc

11. lastly type this command for check that your gammu is ready to fight :)

$ gammu --identify

if you have some info like this, then you can start building your own SMS Gateway Application

Device               : /dev/tty.HUAWEIMobile-Modem
Manufacturer         : Huawei
Model                : E173 (E173)
Firmware             : 11.126.25.00.76
IMEI                 : 8xxxxxxxxxxxxxx6
SIM IMSI             : 5xxxxxxxxxxxxxx3

if you got an error, just comment here, maybe I can help you

thanks for reading