-
+151
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
/**
* Magic method __get()
* @param string $name The name of the payment options properties
* @return string
*/
public function &__get($name)
{
if (isset($this->_properties[$name]) && is_scalar($this->_properties[$name]))
{
$property = $this->_properties[$name];
}
else
{
$property = &$this->_properties[$name];
}
return $property;
}
dimkich,
28 Августа 2013
-
+155
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
<?php
class Json_Encode {
public function Encode($obj) {
$str = "";
$type = gettype($obj);
if ($type == "array") {
$fst = 1;
if (array_keys($obj) !== range(0, count($obj) - 1)) {
$str .= "{";
foreach($obj as $id=>$el) {
if ($fst) {
$fst = 0;
} else {
$str .= ",";
}
$str .= "\"$id\":";
$str .= $this->Encode($el);
}
$str .= "}";
} else {
$str .= "[";
foreach($obj as $el) {
if ($fst) {
$fst = 0;
} else {
$str .= ",";
}
$str .= $this->Encode($el);
}
$str .= "]";
}
} else if ($type == "string") {
$str .= "\"$obj\"";
} else if ($obj == null) {
$str .= "null";
} else {
$str .= "$obj";
}
return $str;
}
}
Листинг файла json_encode.php
От души посмеялся.
businessduck,
28 Августа 2013
-
+15
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
#include <cstdio>
#include <cstdlib>
#include <fstream>
// #include <cstring>
#include <string>
using namespace std;
string exec = "\"c:\\Program Files (x86)\\GnuWin32\\bin\\wget.exe\"";
string root = "http://techno.org/electronic-music-guide/";
const char* flist = "list.txt";
void getFile(string name)
{
string command = exec + " " + root + name;
system(command.c_str());
}
int main(int argc, char* argv[])
{
ifstream fin(flist);
string name = "";
while(true)
{
if (fin.eof()) break;
getline(fin, name);
getFile(name);
}
return 0;
}
Суть такова: ваш покорный слуга копался в исходниках этого: http://techno.org/electronic-music-guide/ -- ради музыкальных лупов на рингтон. Узнал, что это реализовано swf-модулями, список которых он добыл после объединения кучи скриптов и сортировки в NPP. Осталось лишь найти способ загрузить эти файлы по списку.
Но искать было лень, поэтому реализовано подручными средствами: мозгом, компилятором и случайно попавшимся wget'ом (FTW).
ckopo,
28 Августа 2013
-
+120
- 1
- 2
- 3
Раз уж у нас пошла мода на анальные уроки - выложу, пожалуй, еще одну ссылку:
http://avtuh.ru/2010/04/09/delphi-dopolnitelnyj-potok-v-programme.html
На видео анальный учитель с сайта avpetuh.r доходчиво объясняет, как нужно обращаться из потока к компонентам формы.
Долой синхронизацию!!!
Stertor,
27 Августа 2013
-
+152
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
public function actionAddnumber()
{
$model = $this->loadUser();
if(!$model->profile->mobile1) {$model->profile->mobile1=$_POST['number'];
}elseif(!$model->profile->mobile2){$model->profile->mobile2=$_POST['number'];
}elseif(!$model->profile->mobile3){$model->profile->mobile3=$_POST['number'];
}elseif(!$model->profile->mobile4){$model->profile->mobile4=$_POST['number'];
}elseif(!$model->profile->mobile5){$model->profile->mobile5=$_POST['number'];
}elseif(!$model->profile->mobile6){$model->profile->mobile6=$_POST['number'];
}else{ echo "Больше нет свободны номеров"; yii::app()->end(); }
echo " Сохранено";
$model->profile->save();
yii::app()->end();
}
Yii
flashbag,
27 Августа 2013
-
+149
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
$finalTimeNews = '';
$timeNews = strftime('%#d %B', strtotime($article->created));
if($language->language === 'ru')
{
$months_pattern = explode('|', 'Январь|Февраль|Март|Апрель|Май|Июнь|Июль|Август|Сентябрь|Октябрь|Ноябрь|Декабрь');
$months_grammar = explode('|', 'Января|Февраля|Марта|Апреля|Мая|Июня|Июля|Августа|Сентября|Октября|Ноября|Декабря');
for($i = 0; $i <= 11; $i++)
{
//$months_grammar[0];
}
$art_date = explode(' ', $timeNews);
for($i = 0; $i <= 11; $i++)
{
if($art_date[1] === $months_pattern[$i])
{
$finalTimeNews = $art_date[0] . ' ' . $months_grammar[$i];
break;
}
}
unset($months_pattern, $months_grammar, $art_date);
}
Новобраней постарался
Edd,
27 Августа 2013
-
+126
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
import Data.Char
import Data.List
digitRangeToRegex :: Integer -> Integer -> String
digitRangeToRegex min max
| min == max = digit min : ""
-- uncomment if you want \d instead of [0-9]
-- | min == 0 && max == 9 = "\\d"
| min >= 10 || max <= 9 = "[" ++ rangeToStr (digit min) (digit max) ++ "]"
| otherwise = "[" ++ rangeToStr (digit min) '9' ++ rangeToStr 'a' (digit max) ++ "]"
where
rangeToStr min max
| min == max = min : ""
| otherwise = min : '-' : max : ""
digit d
| d >= 0 && d <= 9 = chr (ord '0' + fromIntegral d)
| d < 36 = chr (ord 'a' + fromIntegral d - 10)
numberRangeToRegex :: Integer -> Integer -> Integer -> String
numberRangeToRegex base min max
| min == 0 && max == 0 = "0"
| cmin == cmax = intercalate "|" $ map formatRanges $ step dmin dmax
| otherwise = intercalate "|" $
(map formatRanges $ step dmin (replicate cmin (base-1))) ++
(if cmin + 1 < cmax then [digitRangeToRegex 1 (base - 1) ++ digitRangeToRegex 0 (base-1) ++ formatCount cmin (cmax-2)] else []) ++
(map formatRanges $ step (1 : replicate (cmax-1) 0) dmax)
where
digits 0 = [0]
digits n = reverse $ map (`mod` base) $ takeWhile (>0) $ iterate (`div` base) n
dmin = digits min
dmax = digits max
cmin = length dmin
cmax = length dmax
step [] [] = [[]]
step (a:as) (b:bs) =
if a == b then
prepend a $ step as bs
else
(if zeroHead then [] else prepend a $ step as nines) ++
(if na > nb then [] else [(na, nb) : replicate (length as) (0, base-1)]) ++
(if nineTail then [] else prepend b $ step zeros bs)
where
suffixLen = length as
zeroHead = all (== 0) as
nineTail = all (== base-1) bs
na = if zeroHead then a else a+1
nb = if nineTail then b else b-1
zeros = replicate suffixLen 0
nines = replicate suffixLen (base-1)
prepend x = map ((x, x):)
formatRanges = concatMap formatGroup . group . dropWhile (== (0,0)) where
formatGroup [(min, max)] = digitRangeToRegex min max
formatGroup xs@((min, max) : _)
| min == max = concat $ replicate (length xs) $ digitRangeToRegex min max
| otherwise = digitRangeToRegex min max ++ "{" ++ show (length xs) ++ "}"
formatCount min max
| min == 1 && max == 1 = ""
| min == max = "{" ++ show min ++ "}"
| otherwise = "{" ++ show min ++ "," ++ show max ++ "}"
Генератор реджексов, проверяющих диапазон чисел. Говнецо то еще, причем не только в реализации и выхлопе, но и в самой идее :)
Пример: http://ideone.com/FzAmYd
bormand,
27 Августа 2013
-
+152
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
<? if(Yii::app()->controller->getCurrentModelName()!=="Home") { ?>
<div id="nav"><?php
$this->widget(
'Breadcrumbs',
array(
'links' => $this->breadcrumbs,
'homeLink' => false,
'separator' => ' » ',
)
);
?></div>
<h1 class="title">
<? if(Yii::app()->controller->getCurrentModelName()!=="Home") {?>
<? echo $this->getCurrentModel()->name ?>
<?
}
?>
<? if( $this->getCurrentModelName() === 'Product') {?>
<a href="javascript:window.print()" class="icon_print"></a>
<? } ?>
</h1>
<? } ?>
Фреймворки способствуют написанию хорошего кода, ага.
Tairesh,
27 Августа 2013
-
−158
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
sub get_number_from_possible_b64
{
my $s = shift;
my $rv = $s;
if( $s =~ /^\d+$/ )
{
$rv = int( $s );
} elsif( $s =~ /=$/ )
{
$rv = decode_base64( $rv );
}
return $rv;
}
Где-то есть что-то, что либо цифорка, либо строка, оканчивающаяся на знак равенства.
kainwinterheart,
27 Августа 2013
-
+147
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
<?php
// semantic schema
$s_path = 'http://schema.org/';
// [1] : global
$s_schema = $s_path . 'WebPage';
$base_schema = 'prefix="og: http://ogp.me/ns#"';
$body_schema = 'itemtype="'. $s_schema .'"' . ' itemscope';
// [2] : section
$b_schema = ( $is_front ) ? $s_path . 'Blog' : $s_path . 'Article';
$section_schema = 'itemtype="'. $b_schema .'"' . ' itemscope';
$canonical = ( $is_front ) ? 'http://www.domain.in' : 'http://www.domain.out' . $_SERVER['REQUEST_URI'];
// jquery
$libs = array(
'jQuery 1.4.2' => '...',
'jQuery Form' => '...'
);
// spider detect
$spider = ( is_robot() ) ? true : false;
$metter = ( arg(0) != 'admin' && !$is_admin && !$spider ) ? true : false;
$adm = ( arg(0) != 'admin' && !$is_admin ) ? true : false;
?>
индуcтриальненько … семантический шаблонизатор
Stealth,
26 Августа 2013