I whipped this up to remove all spans and/or divs in an HTML. Don’t ask why. Here’s the regex:
< ?(span|div)[a-zA-Z0-9'" =]+>
Did I mention I love regex?
Enjoy.
I whipped this up to remove all spans and/or divs in an HTML. Don’t ask why. Here’s the regex:
< ?(span|div)[a-zA-Z0-9'" =]+>
Did I mention I love regex?
Enjoy.
When needing to perform a String.replace() with some regex and globally replace text. You must remember to put the “g” argument like so:
var str = “‘http://www.com/123/123′”
str.replace(/’/g,”")
Spent a few minutes banging my head on this one. So remember the “g”!
Jquery makes a lot of things really easy. This one, not so much. Take this Select as an example:
SOURCE:
<select id="sort_by" name="sort_by"><option value="F%3Dlistingid%3A1%7Csmallphotos%3A1%7Clistingseopath%3A1%7Cpropertyname%3A1%7Cpropertycity%3A1%7Cpropertystate%3A1%7Clistingpricelow%3A1%7Clistingpricehigh%3A1%7Clistingbedlow%3A1%7Clistingbedhigh%3A1%7Cwebtollfree%3A1%7Clatitude%3A1%7Clongitude%3A1%7Cgeocode%3A1%7Ccityseopath%3A1%7Cfrontcover%3A1%7Cmsa_code%3A1%26N%3D5875%26Nao%3D0%26Nf%3Dgeocode%7CGCLT+48.803100%2C-102.245600+5%26Ns%3Dsortpropertyname%7C1%26Ntk%3Dshowapartment%26Ntt%3D1%26Nu%3Dlistingid%26Ns%3Dsortorder%7C0">Best Match</option> <option value="F%3Dlistingid%3A1%7Csmallphotos%3A1%7Clistingseopath%3A1%7Cpropertyname%3A1%7Cpropertycity%3A1%7Cpropertystate%3A1%7Clistingpricelow%3A1%7Clistingpricehigh%3A1%7Clistingbedlow%3A1%7Clistingbedhigh%3A1%7Cwebtollfree%3A1%7Clatitude%3A1%7Clongitude%3A1%7Cgeocode%3A1%7Ccityseopath%3A1%7Cfrontcover%3A1%7Cmsa_code%3A1%26N%3D5875%26Nao%3D0%26Nf%3Dgeocode%7CGCLT+48.803100%2C-102.245600+5%26Ns%3Dsortpropertyname%7C1%26Ntk%3Dshowapartment%26Ntt%3D1%26Nu%3Dlistingid%26Ns%3Dsortpropertyname%7C0">Property Name A to Z</option> </select>
When you perform a selection and want to do some onclick magic, how to get the current selected option text? Like this:
$('#sort_by')[0].options[$('#sort_by')[0].selectedIndex].text
Told it wasn’t pretty. Thanks Troy for helping.
wget -r -p -U Mozilla http://www.modrails.com/documentation/Users%20guide.html
Goals:
You’ll have to follow other sites on installing gems, etc. This Site has some very useful info, namely you need to symlink mongrel_cluster_ctl and ruby to /usr/bin/ (you’ll have to do a find / -name mongrel_cluster_ctl). Mine was here: /usr/local/ruby/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/bin/mongrel_cluster_ctl
So I linked into /etc/init.d/ like so:
ln -s /usr/local/ruby/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/bin/mongrel_cluster_ctl /etc/init.d/
chkconfig is not installed on westhost, so you have to do the init.d link/scrips the old fashioned way:
ln -s /etc/init.d/mongrel_cluster_ctl /etc/rc.d/rc3.d/S81mongrel_cluster
ln -s /etc/init.d/mongrel_cluster_ctl /etc/rc.d/rc3.d/K19mongrel_cluster
K = Kill, the number means the order
S= Start, “”
This all came up b/c I wanted to write a shared mixin module to have attachment_fu ready actions for all my controllers that have attachments. No need to put that crap in every controller. So in a mixin module when you want to do some fun reflection/introspection like so:
…
@this_obj = self.controller_name.classify.constantize.find_safe (id,logged_in_user.id)
…
In Dev this worked great. Tests were good, my mostly view/template developer partner, approved. Deploy to test and WHAMMO!
…
"NameError ("Blogs | ListAll" is not a valid constant name!):
…”
What gives? Mmm, seems when you include a mixin, that is included in a controller. The self.controller_name will report incorrectly in Test and Prod. So I had to adjust the code a little using a new method:
@this_obj = self.this_controller_name.classify.constantize.find_safe( id,logged_in_user.id)
Below is the method(which is basically David’s code for controller_name).
###############################
#This method is here b/c it is apparent that Rails #ActionController.controller_name
# is unreliable in Test and Production for some reason.
# attachment_symbol_name: Blogs | List_all_attachments
# attachment_model ERROR: "Blogs | ListAllAttachment" #is not a valid constant name
###############################
def this_controller_name
self_class = self.class.to_s.sub(/Controller$/, '').underscore
end
In a model or util class, parse number to determine the telecom provider (example: http://www.notepage.net/smtp.htm). Create an email message to the respective email @ address for that provider.
Issues:
SMTP is not as time sensitive.
But for a small web app, is this ok?
Simplified Internet and its interaction, enjoy
A) USER LAYER :: normal usage, browsers
1.Computer
2.Operating System (Windows OSX)
3.Browser (Internet Explorer / Safari)
4.Internet (Comcast, Verizon)
B) The network :: NETWORK LAYER
Probably the area we control the LEAST. We can’t MAKE routers talk faster OR make Sprint love us!!!
C) Website/Hosting/Servers :: SERVER LAYER
1.Server(s) (which is a fancy name for computer) ie. Dell
2.Database (where information is stored) ie Oracle, DB2, SQL Server, MySQL
3.Basic HTML files and images( STATIC CONTENT)
-> HTML, CSS, JPG, Javascript, Flash
D) Website base language/framework (does the heavy lifting, most of work***) :: APPLICATION_LAYER
This requires (B)
-> From Microsoft, Open Source, 3rd party.
E) Our code. :: CODE_LAYER
Our programs: (this is where I/we work most of the time, you MUST understand A-D though)
*we write code in the Base/fundamental programming languages from D
*we implement Extra modules/libraries other people write
DONE with A,B,C,D
***************************
***************************
***************************
Web Pages are really akin yelling across canyon!!!!
Internet Applications in the real world(web pages)
——————–
STEPS FOR ONE WEB REQUEST:
1. User A) Users —> give me a page |NETWORK B) —> |SERVER C) Joe user want to look at ‘XYZ web page’.
2. SERVER C) Send ‘XYZ web page’ to user |NETWORK B) —-> traverse network |USER A) User receives response. Views ‘XYZ web page.’
The above is TRUE even for just an image or buying a widget!
*** In the old days of the internet. All web pages were just layer C. They were simple files served up by the server. This harkens back to the days of the home page internet, when everyone had an internet home page like so: “www.mindspring.com~hbeaver” which I DID!.