- 1
- 2
int lastletter = MathUtils.random(0, 32);
letter = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ".substring(lastletter,lastletter+1);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+5
int lastletter = MathUtils.random(0, 32);
letter = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ".substring(lastletter,lastletter+1);
всё просто и наглядно.
+3
void CRenderer::renderToTexture(CTexture &dest, CTexture &src, TRANSFORM tr)
{
int w = src.width();
Concurrency::parallel_for(0, w, [&] (int i)
{
int h = src.height();
for(int j = 0; j < h; j++)
{
COLOR temp = src.pixel(i, j);
if(temp == TRANSPARENT_COLOR) continue;
//scale
float dx = (i-(w/2) + 0.5f)*tr.scale[0];
float dy = (j-(h/2) + 0.5f)*tr.scale[1];
//rotate
float dx2 = dx*tr.cosRot - dy*tr.sinRot;
float dy2 = dx*tr.sinRot + dy*tr.cosRot;
//translate
dx2 += tr.trans[0];
dy2 += tr.trans[1];
//update pixels
float xMin = dx2 - 0.5f*tr.scale[0] + w/2; if(xMin < 0) xMin = 0;
float yMin = dy2 - 0.5f*tr.scale[1] + w/2; if(yMin < 0) yMin = 0;
float xMax = xMin + tr.scale[0]; if(xMax-(int)xMax > 0) xMax++; if(xMax >= dest.width()) xMax = dest.width()-1;
float yMax = yMin + tr.scale[1]; if(yMax-(int)yMax > 0) yMax++; if(yMax >= dest.height()) yMax = dest.height()-1;
for(float ki = xMin; ki <= xMax; ki++) for(float kj = yMin; kj <= yMax; kj++) dest.pixel(ki, kj) = temp;
}
});
}
Писал ручками трансформацию картинок в 2д, вышло без искажений пропорций, но с дырками, уродливо, и просадило фпс в самую жопень!
+4
while($r=mysql_fetch_array($q)){
$buf[$r['id']]['image_file']=$r['file'];
$r=null;
$r['id']=null;
}
return $buf;
+3
class TM
{
function TM()
{
$this->startBuffering();
register_shutdown_function(array($this, 'endBuffering'));
}
public function startBuffering()
{
ob_start();
}
public function endBuffering()
{
if(ob_get_level() > 1)
{
$data = ob_get_contents();
ob_end_clean();
$this->insertBufferedContent($data);
echo $data;
}
}
function insertBufferedContent(&$data)
{
if(!empty($this->buffered))
{
foreach($this->buffered as $contentID => $contentData)
{
$search[] = ' <!--'.$contentID.'--> ';
}
$data = str_replace($search, $this->buffered, $data);
}
}
function showBuffered($contentID)
{
if(ob_get_level() > 1)
{
echo '<!--'.$contentID.'-->';
}
}
function setBuffered($contentID, $data)
{
$this->buffered[$contentID] = $data;
}
}
$tm = new TM();
даже комментировать не хочется
Взято отсюда:
http://blog.kpitv.net/article/how-to-set-title/
Автор:
http://govnokod.ru/user/13961
+1
string tempFolder = DateTime.Now.Year.ToString("0000")
+ DateTime.Now.Month.ToString("00")
+ DateTime.Now.Day.ToString("00")
+ "-" + DateTime.Now.Hour.ToString("00")
+ DateTime.Now.Minute.ToString("00")
+ DateTime.Now.Second.ToString("00");
+5
private string GetMinutes()
{
string minute = (DateTime.Now.Minute < 10) ? "0" + DateTime.Now.Minute.ToString() : DateTime.Now.Minute.ToString();
return minute;
}
private string LogPath(string minute)
{
string logPath = Param.directory + @"\log(" + DateTime.Now.ToShortDateString() + " "
+ DateTime.Now.Hour.ToString() + "." + minute + ").txt";
return logPath;
}
string minute = GetMinutes(); //Минуты формата "мм" для имени файла ЛОГа.
return LogPath(minute); //Путь файла ЛОГа
−3
{ "destination_addresses" : [ "Seattle, Washington, USA" ], "origin_addresses" : [ "Vancouver, Britisch-Kolumbien, Kanada" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "229 km", "value" : 229112 }, "duration" : { "text" : "2 Stunden, 35 Minuten", "value" : 9311 }, "status" : "OK" } ] } ], "status" : "OK" }
+5
//Collisions
static float collisionradius;
if(numplayers>1)
for(k=0;k<numplayers;k++){
for(i=k;i<numplayers;i++){
if(i==k)i++;
if(i<numplayers)
if((animation[player[i].targetanimation].attack!=reversed&&animation[player[i].targetanimation].attack!=reversal&&animation[player[k].targetanimation].attack!=reversed&&animation[player[k].targetanimation].attack!=reversal)||(i!=0&&k!=0))
if((animation[player[i].currentanimation].attack!=reversed&&animation[player[i].currentanimation].attack!=reversal&&animation[player[k].currentanimation].attack!=reversed&&animation[player[k].currentanimation].attack!=reversal)||(i!=0&&k!=0))
if(player[i].howactive<=typesleeping&&player[k].howactive<=typesleeping)
if(player[i].howactive!=typesittingwall&&player[k].howactive!=typesittingwall)
if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz&&player[k].skeleton.oldfree==player[k].skeleton.free&&player[i].skeleton.oldfree==player[i].skeleton.free&&player[i].targetanimation!=climbanim&&player[i].targetanimation!=hanganim&&player[k].targetanimation!=climbanim&&player[k].targetanimation!=hanganim)
if(player[i].coords.y>player[k].coords.y-3)
if(player[i].coords.y<player[k].coords.y+3)
if(player[i].coords.x>player[k].coords.x-3)
if(player[i].coords.x<player[k].coords.x+3)
if(player[i].coords.z>player[k].coords.z-3)
if(player[i].coords.z<player[k].coords.z+3){
if(findDistancefast(&player[i].coords,&player[k].coords)<3*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
if(player[i].onfire||player[k].onfire){
if(!player[i].onfire)player[i].CatchFire();
if(!player[k].onfire)player[k].CatchFire();
}
}
...
http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/GameTick.cpp#l7276
−1
handleNewConfigRuleLoaded: function(
this.handleConfigRuleLoaded0({rule: event.configRule}, true, false);
},
handleConfigRuleLoaded: function(event) {
this.handleConfigRuleLoaded0(event.configRule, false, false);
},
Старый добрый бэкбон и не знания карринга
0
$.get( '/scripts/ajax/popup/add_to_favorite.php', { id: productID, ajax_call: 'Y' }, function ( data ) {
data = JSON.parse( data );
$.getJSON
http://www.sapato.ru/js/ajax/widgets/baseAjaxes.js?bust=208