shorten

How to convert an integer to the shortest url-safe string in Python?

I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the cleanest way to con...

url shortening service

I want to write a url shorten service. I trying to think of scenarios that would be dangerous. one I thought of was if a submitted url is from my own website, it would create an inifinite redirection loop. can you guys think of any other situations? (security holes, bugs...) ...

Create Tinyurl style hash

does anyone know of an algorithm that generates hashes that look like tinyurl hashes from a string (url) I think the requirements would be case sensitive short numbers and alphabets only anything else? ...

How to code a URL shortener?

I want to create a URL shortener service where you can write a long URL into an input field and the service shortens the URL to "http://www.example.org/abcdef". Instead of "abcdef" there can be any other string with six characters containing a-z, A-Z and 0-9. That makes 56 trillion possible strings. My approach: I have a database table...

Shorten a text and only keep important sentences

Hello! The German website nandoo.net offers the possibility to shorten a news article. If you change the percentage value with a slider, the text changes and some sentences are left out. You can see that in action here: http://www.nandoo.net/read/article/299925/ The news article is on the left side and tags are marked. The slider...

Shorten Zend Framework Route Definitions

Hi! How can I shorten the definition of my custom routes in Zend Framework? I currently have this as definition: $route = new Zend_Controller_Router_Route( ":module/:id", array( "controller" => "index", "action" => "index" ), array("id" => "\d+") ); self::$frontController->getRouter()->addRoute('shortcutOne', $route); $route =...

smart way to shorten long strings with javascript

Does anyone have a more sophisticated solution/library for shortening strings with JavaScript, than the obvious one: if(string.length > 25) { string = string.substring(0,24)+"..."; } ...

Using wildcard for classpath?

G'day everybody, I have been using so many 3rd party libraries(jar files) that my CLASSPATH is completely messed up as i have to include the path for every single jar file that i use. I've been wondering if there is a way to include all the jar files in a folder using wildcard(*) operator (like *.jar). But it seems to be...

Obtaining a referring short URL using a widget.

Hi, I'd like to create a client-side javascript widget on a blog that obtains the shortened URL from which a visitor used to come to the blog. While the widget can get the Referrer, such would only be the referring page URL, not the shortened URL that was placed on the site that had to be clicked. I know shortener sites use either 301 or...

Shorten commands?

Is it possible to shorten commands, such as... this.ExampleCommand1.ExampleCommand2.1; this.ExampleCommand1.ExampleCommand2.2; this.ExampleCommand1.ExampleCommand2.3; to ExampleShorten = "this.ExampleCommand1.ExampleCommand2"; ExampleShorten.1; ExampleShorten.2; ExampleShorten.3; ? ...

Adding ArrayList elements efficiently

How would I shorten this? int[] a1 = {2, 0, 1, 4, 3}; int[] a2 = {3, 1, 2, 0, 4}; int[] a3 = {4, 2, 3, 1, 0}; int[] a4 = {0, 3, 4, 2, 1}; int[] a5 = {1, 4, 0, 3, 2}; ArrayList<int[]> array = new ArrayList<int[]>(); array.add(a1); array.add(a2); array.add(a3); array.add(a4); array.add(a5); ...

Shortening/Rehashing UUIDs

Hi, first of all, I want to assure that I'm aware of the fact, that rehashing is a sensible topic. However I'd like to hear some opions of you, what approach you would take here. I'm building a distribured application, where nodes remotely create entities identified by a UUID. Eventually, all entities should be gathered at a dedicated ...

shorten a word in a block of text

I have a block of text which occasionally has a really long word/web address which breaks out of my site's layout. What is the best way to go through this block of text and shorten the words? EXAMPLE: this is some text and this a long word appears like this fkdfjdksodifjdisosdidjsosdifosdfiosdfoisjdfoijsdfoijsdfoijsdfoijsdfoijsdfoisj...

jQuery: shorten string length to fit a set width.

Hello there, I have a table, and in each cell I want to place strings, but they are much wider than the cell width. To prevent line break, I would like to shorten the strings to fit the cell, and append '...' at end to indicate that the string is much longer. The table has about 40 rows and has to be done to each cell, so its important...

Shorten array length once element is remove in Java.

Note: Following is my homework/assignment, feel free not to answer if you will. I want to delete/remove an element from an String array(Set) basic, I'm not allowed to use Collections..etc. Now I have this: void remove(String newValue) { for ( int i = 0; i < setElements.length; i++) { if ( setElements[i] =...

javascript/php - shorten string to fit into a certain # of lines

Hi I have a string that must fit into a box, and must be at most 3 lines long. To shorten it, I plan to truncate it and end it with '...'. I could shorten it to a certain # of characters but if i make it look good with "wwwwwwwww [...] wwww" it won't look right with "iiiiiiiiiii [...] iiii". Is there some way I can shorten it by how mu...

Ruby: Multiply many variables with the same name

Hi. I'm new to ruby. Is there any way how can I shorten this code? Thanks plans.each do |plan| total = plan.landline.to_f * @landline.to_f total += plan.vpn.to_f * @vpn.to_f total += plan.other_networks.to_f * @other_networks.to_f total += plan.gprs.to_f * @gprs.to_f total += plan.sms.to_f * @sms.to_f total += plan.mms.to_...

jQuery: shorten code

Hello, Can this code be shorten in some way? I've tried several ways to compact it, but I can't get it to work: //Customer info $('input#state-field-a, input#state-field-b').hide(); $('select#country-a').change(function(){ if ($(this).val() === "United States" || $(this).val() === "Canada" ||$(this).val() === "null") { ...

shorten echo in php 5.3 with Closures

I really liked PHPs <?= $out ?> to echo something. In PHP 5.3 this is deprecated as we know. So i thought about using something like that: $_ = function($name) use ($tpl_vars) { echo $tpl_vars[$name]; } In $tpl_vars all my template variables are stored. Now i can use <?php $_['name']; ?> instead of: <?php echo $tpl_vars['name']...