- 1
- 2
- 3
- 4
- 5
- 6
$(function() {
   ...
   $(document).ready(function() {
      ...
   }
}Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+155
$(function() {
   ...
   $(document).ready(function() {
      ...
   }
}
+146
function close() {
	return(true);
}
+150
(получаем каждый $array из $all_arr){
for ($i=0; $i<=7; $i++){
switch("value".$i){
case "value0":
echo $array['value0'];
break;
case "value5":
echo $array['value5'];
break;
}
}
}
            Имеем массив $all_arr, где каждый элемент имеет значение:
$array = array(
 "value0" => "sometext0",
 "value1" => "sometext1",
 "value2" => "sometext2",
 "value3" => "sometext3",
 "value4" => "sometext4",
 "value5" => "sometext5"
);
Необходимо, вывести заданные значения из каждого элемента $all_arr.
Спустя пару недель, пересматривая код, сократил.
        
+126
...
{else}
    {assign var=count value=0}
    {foreach from=$item.child item=item2 key=key2}
        {if $item2.virtual != 1}
            {assign var=count value=$count+1}
        {/if}
    {/foreach}
    {if $count > 0}
...Smarty. Выдранный кусок из шаблона сайта.
+75
if(batchControlImpl.startJobActivity(JobStatusType.STARTED));
            К проекту подключили активированных активных индусов.http://tinyurl.com/cvwefek
+74
public class FSMSmilesMatcher {
	private Callback mCallback;
	private State mStartState;
	
	public interface Callback {
		public void onMatch(int matchStart, int matchEnd, int matchId);
	}
	
	//matching whole leading substring cause it's easier to build that way
	private class State {
		protected HashMap<String, State> substates; //substring which led to this state + next symbol
		protected String whole; //whole match
		protected int matchId;
		
		//result = symbols to skip before starting next match
		protected int process(String input, int matchStart, int matchEnd) {
			if(matchStart >= input.length() || matchStart >= matchEnd)
				return 0;
			if(substates == null) {
				if(whole == null || whole.length() == 0) {
					return 0; //shouldn't happen
				} else if(input.length() >= matchStart + whole.length() && input.substring(matchStart, matchStart + whole.length()).equals(whole)) {
					mCallback.onMatch(matchStart, matchStart + whole.length(), matchId);
					return whole.length()> 1 ? whole.length() - 1: 0;
				}
			} else if(matchEnd <= input.length()) {
				State nextState = substates.get(input.substring(matchStart, matchEnd));
				if(nextState != null)
					return nextState.process(input, matchStart, matchEnd + 1);
			}
			return 0;
		}
	}
	
	//checks only next symbol
	//removes long tails (into single 'whole' match)
	private class OptimizedState extends State{
		private OptimizedState(State inState) {			
			if(inState.substates != null) {
				this.substates = new HashMap<String, State>();
				for(String key : inState.substates.keySet()) {
					this.substates.put(key.substring(key.length()-1, key.length()).toLowerCase(), new OptimizedState(inState.substates.get(key)));
				}				
				if(this.substates.size() == 1) {
					State subState = this.substates.values().iterator().next();
					if(subState.substates == null) {
						this.substates = null;
						this.whole = subState.whole;
						this.matchId = subState.matchId;
					}
				}
			} else {
				this.whole = inState.whole;
				this.matchId = inState.matchId;
			}
		}
		
		@Override
		protected int process(String input, int matchStart, int matchEnd) {
			if(matchStart >= input.length() || matchStart >= matchEnd)
				return 0;
			if(substates == null) {
				if(whole == null || whole.length() == 0) {
					return 0; //shouldn't happen
				} else if(input.length() >= matchStart + whole.length() && input.substring(matchStart, matchStart + whole.length()).equalsIgnoreCase(whole)) {
					mCallback.onMatch(matchStart, matchStart + whole.length(), matchId);
					return whole.length()> 1 ? whole.length() - 1: 0;
				}
			} else if(matchEnd <= input.length()) {
				State nextState = substates.get(input.substring(matchEnd - 1, matchEnd).toLowerCase());
				if(nextState != null)
					return nextState.process(input, matchStart, matchEnd + 1);
			}
			return 0;
		}
	}
	...	
	private HashMap<String, State> generateSubstates(List<ImageMatchElement> matches, String lead) {
		List<String> variants = new ArrayList<String>();
		HashMap<String, Integer> completeMatches = new HashMap<String, Integer>();
		
		...		
		if(variants.size() == 0) {
			return null;
		} else {
			HashMap<String, State> substates = new HashMap<String, State>();
			for(String variant: variants) {
				State state = new State();
				if(completeMatches.containsKey(variant)) {
					state.whole = variant;
					state.matchId = completeMatches.get(variant);
				} else {
					state.substates = generateSubstates(matches, variant);
				}
				substates.put(variant, state);
			}
		...Требовалось заменить коды смайликов в текстовом сообщении заменить на соответствующие картинки (типа ":* привет :-p ^_^" заменить на "[картинка] привет [картинка] [картинка]".
+75
program pr8;
uses crt;
var
a:array [1..32] of char;
b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r:integer;
a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,n1,o1,p1: integer;
begin
a[1]:=' ';
a[2]:='Ў';
a[3]:='ў';
a[4]:='Ј';
a[5]:='¤';
a[6]:='Ґ';
a[7]:='¦';
a[8]:='§';
a[9]:='Ё';
a[10]:='©';
a[11]:='Є';
a[12]:='«';
a[13]:='¬';
a[14]:='';
a[15]:='®';
a[16]:='Ї';
a[17]:='а';
a[18]:='б';
a[19]:='в';
a[20]:='г';
a[21]:='д';
a[22]:='е';
a[23]:='ж';
a[24]:='з';
a[25]:='и';
a[26]:='й';
a[27]:='к';
a[28]:='л';
a[29]:='м';
a[30]:='н';
a[31]:='о';
a[32]:='п';
b:=21;
c:=24;
d:=6;
e:=13;
f:=15;
g:=19;
h:=18;
i:=20;
j:=10;
k:=21;
l:=10;
m:=10;
n:=14;
o:=9;
p:=10;
q:=18;
for r:=1 to 32 do
begin
a1:=b+r;
if a1>32 then a1:=a1-32;
b1:=c+r;
if b1>32 then b1:=b1-32;
c1:=d+r;
if c1>32 then c1:=c1-32;
d1:=e+r;
if d1>32 then d1:=d1-32;
e1:=f+r;
if e1>32 then e1:=e1-32;
f1:=g+r;
if f1>32 then f1:=f1-32;
g1:=h+r;
if g1>32 then g1:=g1-32;
h1:=i+r;
if h1>32 then h1:=h1-32;
i1:=j+r;
if i1>32 then i1:=i1-32;
j1:=k+r;
if j1>32 then j1:=j1-32;
k1:=l+r;
if k1>32 then k1:=k1-32;
l1:=n+r;
if l1>32 then l1:=l1-32;
m1:=m+r;
if m1>32 then m1:=m1-32;
n1:=o+r;
if n1>32 then n1:=n1-32;
o1:=p+r;
if o1>32 then o1:=o1-32;
p1:=q+r;
if p1>32 then p1:=p1-32;
writeln(a[a1],a[b1],a[c1],a[d1],a[e1],a[f1],a[g1],'  ',a[h1],a[i1],a[j1],a[k1],a[l1],a[m1],a[n1],a[o1],a[p1]);
end;
readln;
CLRSCR
end.Парниша пытался написать шифр Цезаря... :)
+155
n = 1;
			sel_images[n] = new Array();
			sel_images[n]['images'] = new Array(<?=$t ?>);
			sel_images[n]['images_numb'] = new Array(<?=$t_del ?>);
			sel_images[n]['maxcount'] = 2;
			sel_images[n]['blockid'] = 'imgbl2';
			sel_images[n]['type'] = 'one';
			
			sel_images[n]['tmp_names'] = 'image2[]';
			sel_images[n]['tmp_blockid'] = 'tmp_imgbl2';
			sel_images[n]['tmp_images'] = new Array();
				
			imagetmp_input(n);
			imageselection_input(n);
            Итак, на каждый инпут файлов, пхп кодеры пишут вот такой участок кода.
Китайский код везде и всюду.
        
+155
interface SQLDriver
{
	...
	public function __construct() {
		...
	}
	...
}Испытатель...
+119
using System;
namespace IPGuard
{
	class Program
	{
		public static void Main(string[] args)
		{
			System.Net.IPAddress IPAdress = null;
			System.Net.NetworkInformation.Ping Ping = null;
			for (int IP1 = 1; IP1 < 255; IP1++)
			{
				for (int IP2 = 0; IP2 < 255; IP2++) 
				{
					for (int IP3 = 0; IP3 < 255; IP3++) 
					{
						for (int IP4 = 0; IP4 < 255; IP4++) 
						{
							IPAdress = System.Net.IPAddress.Parse(Convert.ToString(IP1) + "." + Convert.ToString(IP2) + "." + Convert.ToString(IP3) + "." + Convert.ToString(IP4));
							Ping = new System.Net.NetworkInformation.Ping();
							if (Ping.Send(IPAdress).Status == System.Net.NetworkInformation.IPStatus.Success) 
							{
								Console.WriteLine(IPAdress);
							} 
						}
					}
				}
			}
		}
	}
}Программа для поиска всех доступных IP адрессов.