Use jQuery select an option from dropdown
Self note
<select id="target"> <option selected>--- blank</option> <option value="21">test1</option> <option value="12">test2</option> <option value="30">test3</option> </select>
Using index:
$('#target>option:eq(1)').attr('selected', true);
// test1 will be select
Or select by value:
$(#target>option[value=30]').attr('selected', true);
// test3 will be select
Yii overwrite accessRules in base class
Suppose you defined a base class Controller with basic accessRules
class Controller extends CController
{
public function filters()
{
return array(
'accessControl',
'postOnly + delete',
);
}
public function accessRules() {
return array(
// allow authenticated user to perform 'create' and 'update' actions
array('allow', 'actions'=>; array('index', 'view'), 'users' => '@'),
// deny all users
array('deny', 'users'=>'*'),
);
}
}
and you want to add (overwrite) rules in derived class, using array_merge here how you do it:
class Site extends Controller
{
public function accessRules()
{
return array_merge(
// allow all user to perform 'help' actions
array( array('allow', 'actions'=> array('help'), 'users' => '*') ),
// parent go last
parent::accessRules()
);
}
}
As best practice your base class default access rule is deny all by default.
Play!
Out of my boredom I usually tune in some random Khmer Oldies Songs just to remind myself the glorious era where sound of the music would flew into the deepest of my heart and cheer me up. What I did in the pass was collect all my favorite songs and classified it manually and sometime after clean up my station I let iTune screw up my collection a big pain in the a^^ and as my habit of trying out new os release like Ubuntu every 6 months I got to remind myself backup the music collection before I do something silly. That works out quiet well until I am get lazy and decided not to waste my time move back and force I truth the Internet to play me my favorite songs :) which mean I optimize my money Internet expend when I am not using it for some secrecy works ;)
How it works out for me? YouTube! Yeah, what can’t be find on YouTube right? Except that streaming video on my connection is damn slow and like chopping my head every time the buffer loading. So I tried something lighter pure sound and that tons of site offer free mp3 and I do enjoy using those site which some of you may already know and love. But I am just too demand I want some control over what I want to listen, I want to be able to easily share my playlist with my close friends so they can rejoice in hearing the songs. It turn out that a few site does offer these ability, why am I still not happy? Because the site need to know about me want me to become a member and I kind of like what the f???ck. It like I have to tell my radio who I am before it play me the song kind of thing.
So enough is enough, I thought to myself “look geek if it doesn’t work out, do it yourself” ah huh, that was what I use to talk with my dest friend (sad he’d gone) why don’t we do something about it, It’d be fun. Now that I am bored it justified enough that I block sometime to deliver our plan and so I start prototype the project #sidekick and show it to a few friends get their feedback some -/+ and finally I got it out of the door “JolJET Hits” or should I call it “JolJET Hits Online Music Player” still have an issue of naming it properly but here how it looks:
A typic music player portable as it should be since it developed using HTML 5 and Sencha ExtJS technology blah blah blah not so interesting for an engineer to talk about tools. But hey it’s not bad for the cost of home stay during Khmer New Year instead of enjoying myself sight seeing Thansur Bokor Resort and weeks after to stabilize. But as the passion fill up I glad I spend my time develop this little product so that what I can do now:
- On first visit to the site the app will load up default playlist fill with about 250 songs enough if you want to just hear some noise the whole day
- If you so obsess about what you want to hear then Clear all and start adding your favorite songs from: a) Library b) Artist Collection or c) Blind search
- when you found it select it (multiple select is supported) and click on Add to playlist to append selected song to your current playlist
- or if you so want to hear the song immediately just double click it and you got it
- Not just that if your like to listen to the music during your work hours (I usually did :D) close your browser as soon as your boss walk to your desk, and revisit the site after he/she gone nice trick yeah ;) who never cheat. But I had implemented is the app will remember not only your selected song but it remember your last play song and resume it for you (Thanks Sothy Chanty for his suggestion)
- But how about I want my friend to listen to a song. NO NOT 1 songs my collection, well we got you covered from Now Playing tab you find a menu call Sharing just select your favorite sharing technical twitter/facebook and you done
Now that more like an ado why don’t you jump to the site and experience it yourself? Here the link http://play.joljet.net as always I love to hear your comments/suggestions you can do it here or post on facebook page http://www.facebook.com/play.joljet.net
Hope you enjoy the sound LIKE if you LIKED for sharing is caring and have a great weekend ;)
[mac os x lion] Reset a user’s password in single user mode
- Boot into single user mode (press Command-S at power on)
- Type fsck -fy
- Type mount -uw /
- Type launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
- Type dscl . -passwd /Users/username password, replacing username with the targeted user and password with the desired password. Ignore the error message!
- Reboot
Build monodevelop on ubuntu 11.10
Again? yes but this time I don’t have to built mono runtine Ubuntu 11.10 packed with mono 2.10.5 which good enough since what I am after is dynamic.
However monodevelop I got from Ubuntu Software Center (USC) is 2.6 and the official release is 2.8.x so I take my on my gut to try and built me an IDE ;)
This time it much easier what I have to do is get latest copy of the source code from github.com
> git clone git://github.com/mono/monodevelop.git
Then install build dependent by issuing this command
> sudo apt-get build-dep monodevelop
I don’t know why mono-gmcs was not install as part of the previous command (if you know why please comment) for now I have to install another package
> sudo apt-get install mono-gmcs
and then I’m ready to
> ./configure
> sudo make && make run
> monodevelop
BOOM !
MonoDevelop 2.8.2 Installation UUID: b220bfc2-57c6-4b94-840e-ff6c6477632d Runtime: Mono 2.10.5 (Debian 2.10.5-1) (64-bit) GTK 2.24.6 GTK# (2.12.0.0) Build information: Git revision: e047f99f6df7b5c801102c03f903d4dd722b2989-dirty Build date: 2011-11-11 15:03:47+0000 Thanks to mono packaging team, you guy rock!
LINQ 101 .NET Reflection
In this post I am going over three points listed bellow:
What is .NET Reflection? Cut short it refer to a set of API built-in .NET Framework, which give you a greate power to load and manipulate type within assembly (.dll) one of the most favor use is to support late binding. There a whole lot of explaination available through google! but that all I care for now.
How about LINQ? stand for .NET Language-Integrated Query,
a set of general purpose standard query operators that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET-based programming language. The standard query operators allow queries to be applied to any IEnumerable<T>-based information source.
What it mean to me?
Assume that I had ITrap interface and a bunch of Trap implementation as show in the code bellow:
interface ITrap{
void Setup();
int OrderNr { get; };
}
class LevelOneTrap: ITrap{
public void Setup(){
Console.WriteLine("LevelOne Setup First");
}
public int OrderNr {
get { return 1; }
}
}
class LevelTwoTrap: ITrap{
public void Setup(){
Console.WriteLine("LevelTwo Setup Next");
}
public int OrderNr {
get { return 2; }
}
}
Now I want to Setup all trap by respecting it OrderNr which mean LevelOneTrap.Setup() must execute before LevelTwoTrap.Setup() so far so good? Let see how many lines of code needed:
var trapInterface = typeof(ITrap);
var trapImplementations = ( from t in trapInterface.Assembly.GetTypes()
where t.IsClass && t.GetInterfaces().Any(x => x == trapInterface)
select (ITrap)Activator.CreateInstance(t)
).OrderBy(k=>k.OrderNr);
// time to play ;)
foreach( var trap in trapImplementations ) {
trap.Setup();
}
// LevelOne Setup First
// LevelTwo Setup Next
Cool isn’t it? Life is short so our code!


