Feb29
Yea, sometimes it’s acceptable and you will need to do this.
1
2
| $s = "Don't you love this ☂?";
$s = preg_replace('/[^(\x20-\x7F)]*/','', $s); |
The string becomes
Thanks Ryan for figuring this out!
Feb29
Say in implementation the jeditable textile you don’t want any OK nor Cancel buttons, kinda like making your textarea an Excel cell, how to do that?
The key is to use onblur, then comment out submit and cancel. Now when you press ESC, it’s a cancel. Clicking somewhere else is an OK, or submit.
1
2
3
4
5
6
7
8
9
10
11
12
| $('.editable_textile').editable('save.php', {
indicator : '<img src=\"images/indicator.gif\">',
loadurl : 'load.php',
type : 'textarea',
onblur : 'submit',
//submit : 'OK',
//cancel : 'Cancel',
callback: function(value, settings) {
var retval = value.replace(/\\n/gi, \"<br>\\n\");
$(this).html(retval);
},
}); |
See more examples at http://unrealideas.net/examples/05_onblur.php
Feb28
Sometimes when I open up a new terminal I see the following, notifying me there are new mails in my system mail box.
1
2
| Last login: Tue Feb 28 18:57:43 on ttys006
You have new mail. |
Just how to read those emails?
You can use “mailx”.
1
| my_osx_box:~ birdchan$ mailx |
This is a very linux like mail program, so don’t expect fancy controls. Below are some commands that are enough to get you through.
- h: lists the current emails in your mailbox, notice there is an ID before each email.
- NUMBER: Just type in the email ID and press enter, you will enter the reading mode. Then ENTER gets you to the next line, SPACE next page. Just like in MORE.
- d <num>: deletes the corresponding email.
- ?: Shows you all the commands
Feb28
This took me a while to debug, one div and one fieldset both are set to 100%, but in close examination they are off by a few pixels. Below is a stripped down example.
1
2
3
4
5
6
7
| <div style='width: 100%;'>
This is the menu bar, with some buttons
</div>
<fieldset class='section-field-set ui-corner-all' style='width: 100%;'>
Some text
</fieldset> |
So, I was like, perhaps some of these jquery-ui classes gave margin values, so I manually set the margins to all zeros. I also then set all the border sizes to zeroes.
However, still off by two pixels…
I then went through all the css attributes in the chrome debugging tool, it turns out the following unheard of attributes are set by fieldset by default.
1
2
3
4
5
6
| -webkit-margin-start: 2px;
-webkit-margin-end: 2px;
-webkit-padding-before: 0.35em;
-webkit-padding-start: 0.75em;
-webkit-padding-end: 0.75em;
-webkit-padding-after: 0.625em; |
Apparently -webkit-margin-start and -webkit-margin-end will override the margin values… See more info here: http://css-infos.net/property/-webkit-margin-start
And in fact, I was off by 2 pixels on each side, haha.
So I explicitly set these two to zeroes, then yup, I got both the div and the fieldset aligned. I am happy!
Feb28
CSS really made adding shadow easy and fun!
hello
All you are adding is the following style code. Then assign the my_shadow class to your box.
1
2
3
4
5
6
7
| <style>
.my_shadow {
-moz-box-shadow: 0 0 5px 5px #888;
-webkit-box-shadow: 0 0 5px 5px#888;
box-shadow: 0 0 5px 5px #888;
}
</style> |
I remember back in the days it was painful to use images surrounding the box… haha, we have come a long way…
For more info, visit http://www.css3.info/preview/box-shadow/
Feb27

I think I found the easiest way ever in my whole history of using osx to free up ram. Well, of course I am talking about using a free app.
Here it is. It’s rightfully called FreeMemory and you can download it from the Mac App Store.
With it, you no longer need to manually check your Activity Monitor, close apps, relaunch… Once you launch the app, it will display your current free memory amount on your top bar. When you need to free up some memory, just click on the app on the top bar, then click “free memory”. That’s it!
Hope you find it useful as well!
Feb24
If you have ever played with jeditable, eventually you will get to this issue, which is dealing with the textarea. The Textile renderer on the official jeditable demo page works perfectly fine, but when I tried it I experienced quite some difficulty.
Basically the text I enter would NOT be what I see after pressing the ok button, due to the html rendering of the newline character. I found a lot of people sharing their pain all over the internet:
http://stackoverflow.com/questions/5277800/jeditable-handling-output-that-has-line-breaks
http://forum.jquery.com/topic/jeditable-jquery-question-regarding-textarea
After quite some time hacking around (especially on that demo page and its source), I finally got it working that way it’s supposed to be. Here is my solution.
First, your save and load scripts should be doing what they have been doing. No change at all. Just make sure you have clean data in the database.
Second, call a string replace function to change all substring “\n” to “<br>\n”. If you are using php, then below is the code. It will make sure you will have good initial values rendered correctly by your browser.
1
| $s = str_replace("\n", "<br>\n", $s); |
Third, add the following callback to your .editable attribute list. Basically, on the client side it renders the line breaks for you.
1
2
3
4
| callback: function(value, settings) {
var retval = value.replace(/\n/gi, "<br>\n");
$(this).html(retval);
} |
So it looks something like the following:
1
2
3
4
5
6
7
8
9
10
11
| $('.editable_textile').editable('save.php', {
indicator : '<img src=\"images/indicator.gif\">',
loadurl : 'load.php',
type : 'textarea',
submit : 'OK',
callback: function(value, settings) {
var retval = value.replace(/\n/gi, "<br>\n");
$(this).html(retval);
},
cancel : 'Cancel',
}); |
Then you are done! Hope this can save you some time.
Feb21
After much research, at least at this point there is no way to include html tags in the mailto body. If a particular email client plays nice then you are in luck, otherwise there is no standard, or cross email client way to include html tags in the mailto body.
During my research (just googling around…), I found this nice tool that can help construct the mailto link. You simply need to fill in the to, cc, subject, and body, then the mailto link will be generated for you. Check it out at http://jscode.com/generators/mailto_generator.shtml