Here, I was able to setup Huawei E1552 SMS Gateway in Raspbian using SMSTools3.
- Install/Burn Raspbian to your microsd card. Instructions here.
- After burning/installing the image to your SD card. Install it to your Raspberry PI and configure it so you can SSH into it properly. Sadly, SSH daemon is not automatically configured to start on boot.
- To Enable SSH to autostart on boot… do
:> update-rc.d ssh defaults
:> update-rc.d ssh enable
- Restart and try to login remotely
- If you can not login, sshd may be configured to deny any remote root connection
- Got to /etc/ssh/ and edit sshd_config
- Look for this line…
- And change it to…
Had a problem after an update that when I force a restart or a shutdown on my server, it hangs on the last part of the process.
To fix my problem, I had to edit the /etc/default/grub config file and added acpi=force apm=power_off to the config line, between the double quotation marks…
do a update-grub after saving then reboot one more time.. ( force sa restart when it hangs )
After the restart, try another reboot, it should work now without hanging.
Source of the fix is from Here
Memory problem.. the thorn of web apps… I have to connect to my remote server to monitor its memory usage and produce a heap dump.
Bellow is the steps I had to configure the server to allow me to connect a remote monitor tool.
Requirement: VisualVM app, download here
- Access your catalina.sh file.
- Look for JAVA_OPTS, if none found, you can add your own.
- Add …
to the line if found, if not, you can do
JAVA_OPTS="JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump/folder/"
The above code will force a heamp dump when the server encounter a out-of-mem exception.
- Next, to enable remote memory monitoring, add these commands after the line above, within the quotation mark, add proper spacing after each command…
- Now, run VisualVM and create a new JMX remote connection, under the CONNECTION field, add host_ip_address:port_num
Congrats! You should now be able to connect to your server and monitor your memory usage!
I wanted to connect to a remote server and setup a tunnel for my MariaDB replication ( yes I migrated to MariaDB ),
the only problem was that sometimes the net is erratic and can’t connect right away on boot time.
Found a code online to check for ping reply, if it does, continue with the tunneling.
I modified this to suit my needs.
In summary, the script checks for a ping reply from Google infinitely. Once it receives a response, it then creates the tunnel.
Source for the code here
((count = 0))
while [[ $count -ne 1 ]] ; do
ping -c 1 126.96.36.199
if [[ $rc -eq 0 ]] ; then
((count = 1)) # If okay, flag to exit loop.
if [[ $rc -eq 0 ]] ; then # Make final determination.
screen -dm -S tunnel autossh -M 0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -p <PORT> <IP_ADDRESS> -L <LOCAL_TUNNEL_PORT>:localhost:<MYSQL_PORT>
echo `date` >> log.txt
echo "Tunnel Timeout...." `date` >> log.txt
Had a problem with a fresh install of MySQL 5.7 using more than normal memory.
Researching around the net, one feature that was added (5.6?) that fixed my problem was performance schema ( performance_schema ).
Disabling is easy enough as adding performance_schema=0 in my.cnf config file.
Thanks to Joel Abraham for the fix.
I had a problem connecting to a remote server that has its ports blocked by the ISP. So technically, I can’t port forward my way into the server. The only way around this is to SSH connect from my remote server to my main server and access the remote server via reverse SSH tunneling. This tutorial will show the steps on how I connected to my database server on the remote server via port forwarding on my PC and reverse SSH tunneling on my main server.
- Connect from the remote server (B) to the main server (A).
- #> screen autossh -R22222:localhost:22 your_remote_IP_address
- screen – new terminal so you can disconnect and work on other stuffs
- autossh – reconnects if ssh is broken or is disconnected
- -R -> tells the client that the remote port to open for the reverse tunnel
- 22222 -> of course, the port to be used on the other end
- localhost:22 -> anything attached on port 22222 will reach localhost port 22
- your_remote_IP_address – not much explaining needed
- Now on the main server ( A ), to connect to remote server via the SSH tunnel created.
- #> ssh -p 22222 username@localhost -L 4406:localhost:3306
- -p 22222 -> instructs the SSH client to connect to localhost via port 22222
- -L 4406:localhost:3306 -> this tells the client to forward all packets that is sent on port 4406 to localhost and target port 3306. That’s if the connection succeeds, will be on the remote server already.
- On my dev machine, I setup my SSH client ( putty ) to bind to port 99999 and forward it to the main server on port 4406.
- I then have my DB Client attach to port 99999 on connect
Image shown below….
Sencha ( formerly ExtJS ) has a cool paging toolbar at the bottom of their Grid List component. There are sometimes scenarios that I want to pass values, lets say ID or search terms, for the next/previous page to retrieve. Sadly the buttons ( First, Previous, Next, Last and Refresh ) does not have any onClick event handlers to initialize the parameters before sending to the database. The only thing close to handling this requirement that I found is that you have to set a listener for the beforechange event under Ext.PagingToolbar to initialize the parameters and values before the component sends the data to the server. This way any variables can be set before sending.
The variables that are sent to the server is normally start and limit, what if I want to add a filter to the query? One way is adding baseParams to your data store and change their value using setBaseParam when the beforechange event is fired.
Sample code below.
I had a problem in using a string-comma-separated-value returned from a query in an “IN” statement. I used the IDs from one table, concat them into a comma separated value and insert them into another table. Baaaad idea… Now when I query that value, I can’t use it directly into an “IN” statement to retrieve their real values since its a string being returned from the query, the “IN” statement will not compare all the values inside as a set, but it will compare it as a string.
SELECT value FROM my_table WHERE my_id IN (‘1, 2, 3’) is NOT equivalent to SELECT value FROM my_table WHERE my_id IN (‘1’, ‘2’, ‘3’)
So, if you have a table containing values 1 to 3, the first query will return only 1 while the second query will return all values; 1, 2 and 3.
I Googled around and found out that MySQL does not have a native equivalent of PHP’s explode() function. Crap… I had to do it the hard war and create a MySQL stored function to ‘explode’ the values from its delimiter, query the right value from the other table using the exploded IDs, concat them back together and return them as a string.
Below is the function I was able to patch together from different codes I found in the MySQL forum. I added comments below as to make things clearer. I named the function splitAndTranslate since that’s what I was really trying to implement. You can make up your own modifications and function name.
DROP FUNCTION IF EXISTS `splitAndTranslate` //
CREATE FUNCTION splitAndTranslate(str TEXT, delim VARCHAR(124))
DECLARE i INT DEFAULT 0; -- total number of delimiters
DECLARE ctr INT DEFAULT 0; -- counter for the loop
DECLARE str_len INT; -- string length,self explanatory
DECLARE out_str text DEFAULT ''; -- return string holder
DECLARE temp_str text DEFAULT ''; -- temporary string holder
DECLARE temp_val VARCHAR(255) DEFAULT ''; -- temporary string holder for query
-- get length
SET i = (LENGTH(str)-LENGTH(REPLACE(str, delim, '')))/LENGTH(delim) + 1;
-- get total number delimeters and add 1
-- add 1 since total separated values are 1 more than the number of delimiters
-- start of while loop
-- add 1 to the counter, which will also be used to get the value of the string
-- get value separated by delimiter using ctr as the index
SET temp_str = REPLACE(SUBSTRING(SUBSTRING_INDEX(str, delim, ctr), LENGTH(SUBSTRING_INDEX(str, delim,ctr - 1)) + 1), delim, '');
-- query real value and insert into temporary value holder, temp_str contains the exploded ID
SELECT <real_value_column> INTO temp_val FROM <my_table> WHERE <table_id>=temp_str;
-- concat real value into output string separated by delimiter
SET out_str=CONCAT(out_str, temp_val, ',');
-- end of while loop
-- trim delimiter from end of string
SET out_str=TRIM(TRAILING delim FROM out_str);
RETURN(out_str); -- return
After creating the stored function, you can now use it normally like any MySQL function inside a query. So what I now do with the new function is…
SELECT splitAndTranslate( g.comma_separated_ids ) real_values FROM my_group_table g;
Thanks to Chris Stubben in the MySQL Forum, I used and modified his code to fit my need.
Well, seems like a problem crept into a friend’s Friendster account. Everything in her page disappeared, or so it seems. The problem lay inside the shoutbox. A rouge script has inserted a small CSS script inside and made every “Div” element invisible. How? I dont know. I made this script for her to run under greasemonkey. This will rewrite what’s inside the shoutbox and let her rewrite whats inside back to normal.
The greasemonkey script can be found under the script page or here.