Posted by Christian Pelczarski in
Saturday, November 14. 2009
To fix:
After that you will be a happy camper.
Posted by Christian Pelczarski in
Wednesday, October 21. 2009
The Prototype.js get-fresh crew created a new sizzle branch.
Quick install Guide:
I am using it in development and soon will release in production. I am looking forward to the boost in IE especially. That said I can't wait to plug in NWMatcher and this is why.
Posted by Christian Pelczarski in
Saturday, August 15. 2009
The use case for doing a modal inside a modal comes up often. In Prototype UI you can do a modal inside a modal like this.
var ui_win = new UI.Window({
id: 'movePostWindow',
maximize: false,
minimize: false,
width: 580,
height: 160
}).setHeader('Move Post(s)' )
.setContent(html.join(''))
.center()
.show(true).focus();
The html.join('') code is missing from this example; however, the above code renders like this
I am going to hit the "Move" button and receive back some validation in a modal inside of the current modal.
The code below is for creating this.
// Make sure wm2 is global -- no var in front of it
wm2 = new UI.WindowManager({ container: $('movePostWindow') });
var w = new UI.Window({id: "insideWindow", shadow: false, resizable: false, close: false,
width: 200, height: 50, windowManager: wm2});
w.setContent('<p><a href="#" onclick="destroy_all_pui_windows(wm2);">Close</a></p>');
w.center({auto: true}).show(true).focus();
function destroy_all_pui_windows(){
var winObj = arguments[0] || UI.defaultWM;
winObj.windows().invoke('destroy');
}
However, when clicking the close link this is what you get (Fig. 3). The style overflow gets set to "auto".
Figure 3:
The fix for this is to add this line of code wm2.container.style.overflow = 'hidden'; . Below is the final code.
// Make sure wm2 is global -- no var in front of it
wm2 = new UI.WindowManager({ container: $('movePostWindow') });
var w = new UI.Window({id: "insideWindow", shadow: false, resizable: false, close: false,
width: 200, height: 50, windowManager: wm2});
w.setContent('<p><a href="#" onclick="destroy_all_pui_windows(wm2);">Close</a></p>');
w.center({auto: true}).show(true).focus();
wm2.container.style.overflow = 'hidden';
function destroy_all_pui_windows(){
var winObj = arguments[0] || UI.defaultWM;
winObj.windows().invoke('destroy');
}
Posted by Christian Pelczarski in
Monday, August 10. 2009
Before:
var dialog = new UI.Dialog({
width:400,
height:150,
id: 'deleteDialog',
buttons: button
}).center()
.setHeader('Delete issue #{ref}'.interpolate({ ref: ref }))
.setContent(content)
.show(true);
Pict 1: If you want to size the dialog box yourself ( hence the 400 x 150 in the options ) then this is how it looks
After:
.setContent(content)
.show(true);
// Add these two commands for better rendering when you want to control the size.
dialog.dialogContent.style.width = '100%';
dialog.dialogContent.style.height = '';
Pict. 2: Adding the above two lines after the UI.Dialog call will render the dialog as such.
Posted by Christian Pelczarski in
Tuesday, July 7. 2009
My side project is in Rails and the below bash file is what I use to search the code base.
# contents of fart.sh
[ -n "$2" ] && files=$2 || files="rb|rhtml|html|erb|css|js|rjs|rake"
file_regex="^.*\.($files)$"
cmd=$( cat <<EOT
find app/ public/ lib/ script/ config/ \
-regextype 'posix-egrep' -regex '$file_regex' \
-not -name "firebug-lite-compressed.js" -not -name "AJS.*" \
-exec grep -Hn "$1" {} \;
EOT
)
eval $cmd
Installation:
Copy the above into /bin/fart.sh and do a chmod +x /bin/fart.sh
Usage:
cd /var/www/project_code // Only searches current directory so you must switch fart.sh "def str_to_camel" fart.sh "function open_window" js // this will only search javascript files fart.sh "function open_window" "js|erb" // this will only search javascript files and .erb files fart.sh "func.*open_" // pass in a regex
The above code is a simple and fast find script for *nix systems. It is fast because you determine which file types or not to search through. Just using a "find . -name "*.*" exec grep " type of search is quite slow in my experience.
You will have to change the "-not -name" line to fit your personal project needs. This line is for excluding searching certain files. For example in the above code I don't want to search files that start with "AJS" or Firebug.
Posted by Christian Pelczarski in
Monday, July 6. 2009
# contents of jart.sh
[ -n "$2" ] && files=$2 || files="php|css|js|inc|htc"
file_regex="^.*\.($files)$"
cmd=$( cat <<EOT
find . -regextype 'posix-egrep' -regex '$file_regex' \
-not -name "_*.js" -not -name "firebug*" \
-exec grep -Hn "$1" {} \;
EOT
)
eval $cmd
Installation:
Copy the above into /bin/jart.sh and do a chmod +x /bin/jart.sh
Usage:
cd /var/www/project_code // Only searches current directory so you must switch jart.sh "function str_to_camel" jart.sh "function open_window" js // this will only search javascript files jart.sh "function open_window" "js|htc" // this will only search javascript files and .htc files jart.sh "func.*open_" // pass in a regex
The above code is a simple and fast find script for *nix systems. It is fast because you determine which file types or not to search through. Just using a "find . -name "*.*" exec grep " type of search is quite slow in my experience.
You will have to change the "-not -name" line to fit your personal project needs. This line is for excluding searching certain files. For example in the above code I don't want to search files that start with "_" and end with .js. This is because in our project we combine our javascript into a single file for deployment using this naming convention. Likewise, I don't want to search thru third party libraries such as firebug.
Posted by Christian Pelczarski in
Thursday, January 8. 2009
On Apache's page for mod_deflate they have a sample configuration titled "Compress everything except images". In this configuration it has an exception for Internet Explorer to only compress the mime type of text/html because IE 6 and below doesn't properly compress some other mime types ( javascript,css,xml,etc). However, I have found this configuration to be faulty by careful packet inspection using fiddler. I found by having the "!" in front of both no-gzip and gzip-only-text/html that everything ( js and css ) still was getting compressed in IE 6. By only having the "!" in front of the no-gzip text/html was compressed and not js or css. Internet Explorer 7 compressed everything as expected.
This configuration works at enabling compression of only text/html for Internet Explorer 6 ( IE 7 and 8 work fine with compression of most types of files ). Also, note that I don't have a browser match for Netscape and IE 5.5 and below because our web application doesn't allow them.
SetOutputFilter DEFLATE #Highest 9 - Lowest 1 DeflateCompressionLevel 9 # IE 6 can only gzip text/html mime type. # Must have a ! in front of no-gzip but NOT in front of gzip-only-text/html BrowserMatch \bMSIE\s6 !no-gzip gzip-only-text/html SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
Posted by Christian Pelczarski in
Friday, October 10. 2008
Invoke is a fantastic mixin within Prototype.js; however, whether you are looking at the bungee book or the Prototype.js API using invoke in a "custom" way is not explained. Meaning, all the examples are for either built-in Javascript methods(substring) or Prototype methods (toUpperCase). What if you wanted to use a user-defined function with invoke?
function expandTagHelper(element){
ne = element.next();
ne.toggle();
if( element.innerHTML == '+' ){
element.update('-');
}else{
element.update('+');
}
}
el = el.select('span.tag_excerpt_show');
el.invoke('expandTagHelper')
This will not work.
What you must do is add this function to the Element object
// My personal Element methods
Element.addMethods( {
expandTagHelper: function(element){
ne = element.next();
ne.toggle();
if( element.innerHTML == '+' ){
element.update('-');
}else{
element.update('+');
}
}
});
el = el.select('span.tag_excerpt_show');
el.invoke('expandTagHelper')
This will work.
Posted by Christian Pelczarski in
Tuesday, August 19. 2008
Are you a business shipping from Canada to the U.S.? N.G. Jensen has an easy way to automate this process. See here.
Posted by Christian Pelczarski in
Friday, October 5. 2007
ssh -D 7777 user@sshserver.com
Proxy request sent, awaiting response... No data received.and
Connection refusedSame with wget, though the errors where different. Let me tell you, I tried everything! I did all the stuff suggested when googling around like messing with /etc/ssh/sshd_config settings like AllowTcpForwarding and others. Moreover, I have three different servers to test on.
Save yourself the headache and set up Apache as the proxy. First edit httpd.conf as such:
Listen 7777 # Of course mod_proxy needs to be enable -- it is with most distros ProxyRequests On ProxyVia On <Proxy *:7777> Order deny,allow Deny from all Allow from localhost </Proxy>
Next, do a /etc/init.d/httpd graceful.
Then, on your local machine do this:
# -C is to compress the data thru the tunnel
ssh user@sshserver.com -C -L 7777:localhost:7777
I spent three hours trying to get ssh -D working; Apache proxy with ssh -L took 5 minutes.
Posted by Christian Pelczarski in
Thursday, May 17. 2007
JD is up to his hypocrisy again.
Consider this post where he again accuses of Flash bashing. He turns right around and bashes himself.
"do something to fix the awful problems of browser disparity"
We wrote an RIA in XHTML/CSS/Javascript using the Prototype library and it even works in Konqueror ( which, by the way, there is no way to get flash working -- in Konqueror ). John, how many times have you used ( or eluded to in subtle way ) that false argument? Cross browser application development is not rocket science! The proof is in the pudding -- how else do you explained the explosion of these type of (cross browser) web applications. Although, cross browser compatibility is more important than in years past you can still just target IE if you are in a small vertical market. Flash as presentation run-time ( Volkswagen website,YouTube ) needs to run on all modern OS's( because VW wants to reach as many as possible -- marketing wise ); however, applications are different. Consider that Adobe doesn't make a Linux version of Photoshop. Textmate only runs on OSX. It is tolerated that applications that do something valuable aren't available everywhere.
I guess my point is that for a long time Flash has held up this false-argument that cross platform ( I am talking about for applications not presentations ) is a key feature. It is a feature but it is not key one. Remember Oddpost in 2003? They didn't listen to the dogmatism of cross platform ( they released a Win/IE only web app. ) and they were sold for 30 million to Yahoo.
"and molasses-like evolution"
Webkit and Gecko are evolving fast and IE 8 is already in the works. Moreover, as a developer I like that the (X)HTML/CSS/JS environment is more sane than the MS ( .NET 1,1.2,2,3 ) and Adobe ( AS, AS1,AS2,AS3,Flex 1,2,3,Flash MX,8,9,CS3 ) circus that they want you to play. I live in San Diego and I like to go to the Beach(there is my bias)! Granted that molasses-like needs to be further defined; however, I hold that this is not true ( even by today's standard of software development ).
Posted by Christian Pelczarski in
Linux
Friday, May 4. 2007
Here is the situation: You want to move to Linux as your full time desktop but you can't live without the iSiloX plugin for IE. Sure, you can install a virtual PC with VirtualBox or VMWare; however, that is such a pain you never end up iSilo'ing anything. Also, do you waste an hour every month Googling around to see if anyone made a iSilo plugin for Firefox yet?
Does this describe you?
Ok, here is a solution.
Posted by Christian Pelczarski in
Saturday, January 27. 2007
Posted by Christian Pelczarski in
Wednesday, October 4. 2006
Can be found at here
Posted by Christian Pelczarski in
Monday, July 3. 2006
RHTML, Ruby, and RXML in Homesite 4.5 and above! Got to love it.
Get it here.