Previously in ASP.NET when you wanted to output html directly on the aspx page, you would do something like:
<%= myString %>
In ASP.NET 4, there is a new shorthand which also html encodes your output string:
<%: myString %>
enjoy!
Previously in ASP.NET when you wanted to output html directly on the aspx page, you would do something like:
<%= myString %>
In ASP.NET 4, there is a new shorthand which also html encodes your output string:
<%: myString %>
enjoy!
I’ve been helping a friend with his site, www.thehardwareproject.org, for the past couple of months. It was a good chance to rework a lot of my php CMS and one thing I noticed was that there were a lot of pages where all I was doing was displaying information via a list of divs. Different pages might have the lists formatted differently, but rather than write page-specific backend code to format the lists, why not output all lists uniformly to the page and then have client-side code manage the display?
Listerine has 2 modes. One is “columns” which basically creates a user-set number of columns on the page and then evenly distributes the list items between columns. The other mode is “grid” which is more of a tile-like display.
simple columns example:
$('.manufacturer_list_container').listerine({
cols: 3,
transform: 'columns'
});
This little registry hack will disable javascript debugging in Visual Web Developer 2010 Express. You should really be using something like Chrome Dev Tools or Firebug when debugging javascript anyways.
reg add HKLM\SOFTWARE\Microsoft\VWDExpress\10.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f
Just published a plugin that extends jquery to give access to querystring params easily. For the longest time, I was just copy/pasting one function into all my projects to do this, but finally decided to make it a jquery plugin for future use. Here’s how to use it:
$.querystring(param_name_here);
example:
var q = $.querystring('q');
Ezmode. get the code here: https://github.com/gehsekky/jquery-querystring
I used to use eggdrops back in the day when we would idle in IRC channels for counterstrike and used to write custom TCL scripts to do all that annoying IRC bot stuff (like listing scrim availabilities, cs clan rosters, etc). So while I’m learning Python, I figured I’d try and write my own bot to see if I could do it. I first started off with this example that builds the core of the bot in less than 30 lines of code. While that was fantastic, I then came across this example which uses the Twisted lib and makes it much more robust. I didn’t implement the markov chains, but I wrote up some quick code that can handle saving and displaying IRC quotes. This version of the bot is now just under 180 lines.
You can view the code here.
To use it, you have to change this section at the bottom of the file.
if __name__ == "__main__":
reactor.connectTCP("YOUR_IRC_SERVER_HOST",
IRC_SERVER_HOST_PORT,
ShibalBotFactory("YOUR_IRC_CHANNEL",
"YOUR_IRCBOT_NICK",
True, False))
reactor.run()
Just change the parameters to your own IRC server address, server port, IRC channel, and bot nickname and you’re good to go. Some Todo’s include adding some code to fetch the titles of url’s pasted in the channel, making it modular so you can just drop in scripts instead of having to change the main file, and updating the quotes module to not load the entire quotes file at once (in case the file becomes huge).
While teaching myself Python, I wanted to try and write something that I would actually use. Since I have multiple reddit accounts, a script that would sync settings across them seemed like it would be useful. So far, the only thing being synced is friends, but I’ll soon have something that also syncs subscribed subreddits as well (hopefully).
The script is being hosted on github and the link is here.
I developed the script using Python 2.7.2 so I don’t even know if it is compatible with Python 3.x. Using the script is fairly easy. Just edit the top of the file above the line that says “DO NOT MODIFY BELOW THIS LINE”.
Example: login_info = [ ["user1", "pass1"], ["user2", "pass2"], ["user3", "pass3"] ] add_self_to_friends should be either "True" or "False" (without quotations)
I think I’ll add in some logic to do interactive input if no settings are detected in the file. I’m also going to change the script to do dom parsing as opposed to regex because the regex could run into some weird issues (I know I’ve said dom parsing is a hassle before, but the goal here is to learn as much Python as possible so I’ll try attacking problems from all angles to learn everything).
Finally decided to do something with my Github account and actually set up a repository for some reddit utility scripts. This is really just a way for me to learn and improve my python skills for the future. Pro tip: Git is really meant to be used on linux. Using it in Windows 7 just doesn’t feel right for some reason…
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger W.Dijkstra
This quote ran through my head today after I realized (after 5 minutes of head scratching) why this line was throwing an exception in javascript:
var sHeading = oInput(0);
Parenthesis for array indexing? Damn you VB!
Jeff Atwood wrote a really good blog post about the perils of abusing regular expressions a while back which you can read here. The basic gist was that you shouldn’t rely on using regexes for the solution to every problem (which languages like perl encourage you to do). I agree with this, however, there are some cases where regular expressions are simply the most expedient (but perhaps not the most efficient) solution where you just cannot ignore the simplicity and convenience they offer.
One of the things we do at work is analyze html from news sites. Lots of it. We need to be able to look at a page of html and extract certain sections for information gathering/processing. Among the programming purists, they will tell you that you MUST write a proper html parser with a lexer and tokenizer, because there exists some input that will break your regex. That’s fine and dandy for something with a broad input spectrum (blogs, forums, etc), but we deal with the output from mainly news CMS systems. In fact, many news organizations use similar CMS systems which make this job a lot easier. You just have to see the CMS output pattern/template and write a regex to extract the info you need.
What are the advantages to this? Fast turnaround time. In an industry that’s fast paced and constantly changing, you can roll out changes and keep up with any news site that decides to change their article structure every few months. Instead of retooling a dom-based parser where you’d have to probably change a complicated document definition for every source, you can just simply adjust a client-specific regex and be rolling in a matter of minutes.
What are the disadvantages? Efficiency. Regexes aren’t known for being the fastest tool in the programmer’s toolbox. While your regex is being evaluated, there are hundreds, if not thousands of computations going on as well as regex trees being built to see if there’s a match.
In the end, researching a non-regex based solution to this problem isn’t exactly a waste of time. But you simply cannot ignore the simplicity this solution offers in this type of industry-specific situation. Most of the arguments I’ve seen against regex-based parsing of html revolve around hypothetical input scenarios, but I’ve rarely seen anything that I couldn’t write a regex for. Even something as bad as this (which was lifted from one of the biggest news sources around):
<span class="focusParagraph"><p> <span class="articleLocatio</span>n">
Today’s daily funny comes to you thanks to eclipse and the android sdk.
