Case: After the customer sign, the system will reply to a text message to the customer and a review service link, because the link has long, SMS will be automatically truncated, so the use of short-chain way to send.The code is as follows:public string Gettinyurl (string strlongurl){Try{byte[] PostData = Encoding.UTF8.GetBytes ("url=" + strlongurl);var url = "http://dwz.cn/create.php";var client = new WebCl
A short PHP code for PHPcode lt ;? Php $ eurl = mb_convert_encoding ( quot; 1 quot;, 'utf8', 'gb2312 '); echo $ eurl ;? Gt; the goal is to solve the PHP code in a short section.
PHP code
The purpose is to convert Chinese to utf8 encoding. Why can't I
Ask for a short PHP code in 40 minutes. please enter the requirement: Take a random number from the numbers a and B to form a string of 10 characters. Requirements: 1. two adjacent letters cannot be the same (except for 0). if two consecutive letters of the same name are randomly obtained, the following letter must be converted to 0, until another different letter appears, such as the result of "abbb" after
Short web site services, may be a lot of friends are no longer unfamiliar, and now most of the microblogging, mobile mail reminders and other places have a lot of application mode, and occupy a certain market. It is estimated that many friends are using it now. Read Sina's short connection service, found behind the main 6 string composition.
Too many algorithmic things, there is no need to explore too much
+ = [J + '.' + right for J in add_dots_l (left)]
RET + = [left + '.' + J for J in add_dots_l (right)]
Return set (RET)
Because 21 lines of Python code were used to implement a spelling checker some time ago, this equivalent but harder to read version was simplified on the rise:Def add_dots (s ):
R = [s [: I] + '.' + s [I:] For I in range (1, Len (s)]
R + = [J + '.' + s [I:] For I in range (1, Len (s) for J in add_dots (s [: I])]
R + = [s [: I] + '.'
, only 6 bytes!-[1,] the principle is IE unique features, array processing the last item of the bug. With this approach, we can also compress the code further:New (-[1,]? Xmlhttprequest:activexobject) ("Microsoft.XMLHTTP")Undoubtedly, this is the shortest XMLHTTP creation code! Exactly 60 bytes. But compared to the normative and readability, it is recommended before that.In fact, using the Self object can c
Generate a short URL program The code is as follows:Copy code Function code62 ($ x ){$ Show = '';While ($ x> 0 ){$ S = $ x % 62;If ($ s> 35 ){$ S = chr ($ s + 61 );} Elseif ($ s> 9 $ s $ S = chr ($ s + 55 );}$ Show. = $ s;$ X = floor ($ x/62 );}Return $ show;}Function compute url ($ url ){$ Url = crc32 ($ url );$ Result = sprintf ("% u", $
) throws Exception {TODO auto-generated Method StubSimulate the information in the databaselistInjecting data into the listUserinfo user1 = new Userinfo ();User1.setuserid (1);User1.setusername ("Neusoft");User1.setpwd ("123");Userinfo user2 = new Userinfo ();User2.setuserid (2);User2.setusername ("Neusoft");User2.setpwd ("123");List.add (user1);List.add (User2);Modelandview Mav = new Modelandview ();Passing the value of list in ModelandviewEquivalent to implementing the Request.setattribute ("U
"produce an exception"Explain the generic code framework: The GET method requests a link that r.raise_for_status to determine whether the request is normal (that is, 200), otherwise an exception is generated. r.encoding = r.apparent_encoding This sentence is able to be our request to return the page decoding is correct, and finally return the content of the page.This framework is used to solve the problem of our visiting the webpage.Today's content i
For example, you can convert http://zuidaima.com/to Http://t.cn/zlsvWVq
The following figure:
Original is not easy, reproduced please indicate the source share Sina short chain generated Java code
Package com.zuidaima.util;
Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStream;
Import Java.io.OutputStreamWriter;
Import java.net.HttpURLConnection;
Import Java.net.URL;
Import
Used to generate a short domain name
Public function createRandCode ($ string) {$ code = ''; $ hex_code = '1qaz2wsx3edc4rfv5t-gb6yhn7ujm8ik9ol0p _ '; $ now = microtime (true) * 10000; $ strlen = strlen ($ hex_code); $ hash_code = hash ('sha256 ', $ string); // A random length is defined for the encoding, length depends on step $ step = rand (8, 16); $ count = ceil (strlen ($ hash_code)/$ step); for ($ I
enter the same characters that you need to rename the content:"); -String S1 =input.nextline (); + //Reminder to enter a field to be modified into a new file name -System. out. println ("Please enter the format you want to change"); +String s2 =input.nextline (); A //Cyclic renaming at for(inti =0; i ) { - //converting a file path to a string type -String str =file1[i].tostring (); - //determine if a string contains a field to modify -
Android asynchronous task code is very short, simple asynchronous tool encapsulation, easy to execute asynchronous tasks
It is relatively simple. There are three classes.
1. Create a single-instance thread pool to execute asynchronous tasks
package com.ferris.pool;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;public class FerrisPoolManager {private ExecutorService servic
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.