if (!rtrId.isPresent()) {
            ...
        } else if (identityId.isPresent() && rtrId.isPresent()) {
            ...
        }
        

A treasured knife protects

By Dunia, 2018-09-18 10:34:19

return IsActive == true ? true : false;
By Anonymous, 2018-09-12 18:01:20
product = None
for key in dictionary.keys():
	if product is None:
		product = dictionary[key]
	else:
		product = itertools.product(product, dictionary[key])

product = "{0}".format(list(product))
product = re.sub(r"\), \(+", "], [", product)
product = re.sub(r"\(+", "[", product)
product = product.replace(")]", "]]").replace(")", "")
product = ast.literal_eval(product)

Ok, I have a weird array of objects as output of itertools and I need an array of strings... 1 - Convert the array to string 2 - Clean it up with regex and replace 3 - Convert the string to array 4 - Problem solved

By AnonimaPitoni, 2018-09-06 00:27:34
# Weird list cleanup
product = "{0}".format(list(product))
product = re.sub(r"\), \(+", "], [", product)
product = re.sub(r"\(+", "[", product)
product = product.replace(")]", "]]").replace(")", "")
product = ast.literal_eval(product)

I don't know why I get this strange fomat for this array of objects... Ok let's do it fast: 1 - Convert array in string 2 - Clean up string 3 - Convert string in array

By Anonymous, 2018-09-05 23:51:16
var div = '<div class="imgdiv" '+(user[5] ? 'style="display: flex; flex-direction: column; padding: 10px; justify-content: flex-end; background-image: url(\''+user[5]+'\');"' : '')+'>'
        + (usersVideos[userId] && <?= ($authuser ? 'true' : 'false') ?> ? '<i class="f7-icons icon-acc" onclick="videoShow('+user[uID]+')" style="color: white; font-size: 50px; margin-bottom: 5px; cursor: pointer; text-align: left;">play_round</i>' : '')
        + (iam && page=='home' ? '<div> <input id="video-input" onchange="uploadVideo(files)" type="file" accept="video/*" style="display: none; width: 80%; height: 100px; margin: auto; padding-top: 20px;"/> </div> <p class="action_cont" style="padding: 0; padding-top: 12;"> <a class="act_btn" onmousedown=document.getElementById("video-input").click() href="javascript:void(0)" style="text-decoration: none; margin: auto; width: calc(100% - 26px); text-align: center;"> ' + (myMods['video'] ? 'Загрузить новое видео' : 'Добавить видео-превью' ) + ' </a> </p>' : '')
+ '</div>'

JS + CSS + PHP + HTML

By Anon, 2018-08-24 18:30:12

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }

        fileObjectDAO = new FileObjectDAO(this);
        iv = (ImageView)findViewById(R.id.imageView);
        tv = (TextView)findViewById(R.id.textView);
        centerImageView = (ImageButton)findViewById(R.id.imageButton);
        leftText = (TextView)findViewById(R.id.textView2);
        rightText = (TextView)findViewById(R.id.textView3);
        leftArrow = (TextView)findViewById(R.id.textView4);
        rightArrow =  (TextView)findViewById(R.id.textView9);
        leftCancel = (ImageButton)findViewById(R.id.imageButton2);
        displayWelcome1  = (TextView)findViewById(R.id.textView5);
        displayWelcome2  = (TextView)findViewById(R.id.textView6);
        rightCancel = (ImageButton)findViewById(R.id.imageButton3);

        seatButton = (ImageButton)findViewById(R.id.imageButton4);
        waitButton = (ImageButton)findViewById(R.id.imageButton5);
        clearButton = (ImageButton)findViewById(R.id.imageButton6);
        enityButton = (ImageButton)findViewById(R.id.imageButton7);
        bookButton = (ImageButton)findViewById(R.id.imageButton8);
        settingButton = (ImageButton)findViewById(R.id.imageButton9);

        displatSeat = (TextView)findViewById(R.id.textView7);
        displatSeatNumber = (TextView)findViewById(R.id.textView8);
        isClearing = false;
        hidenAll();
        key1 = 0;
        key2 = 0;
        key3 = 0;

        isError = false;
        isWaiting = false;

        myTTS = new TapiaTTS(this);
        myhandler = new Tapiahandler();
        mySTT = new TapiaSTT(this,myhandler,false);
        isResume = false;
        tapiaAnimation = new TapiaAnimation(this);

        liveData.add("愛媛");
        liveData.add("松山");
        liveData.add("今治");
        liveData.add("高知");
        liveData.add("福岡");
        liveData.add("北九州");
        liveData.add("佐賀");
        liveData.add("長崎");
        liveData.add("熊本");
        liveData.add("大分");
        liveData.add("別府");
        liveData.add("宮崎");
        liveData.add("高千穂");
        liveData.add("鹿児島");
        liveData.add("奄美大島");
        liveData.add("屋久島");
        liveData.add("沖縄");
        liveData.add("那覇");
        liveData.add("北海道");
        liveData.add("札幌");
        liveData.add("函館");
        liveData.add("室蘭");
        liveData.add("浦河");
        liveData.add("旭川");
        liveData.add("留萌");
        liveData.add("稚内");
        liveData.add("網走");
        liveData.add("帯広");
        liveData.add("登別");
        liveData.add("知床");
        liveData.add("釧路");
        liveData.add("根室");
        liveData.add("青森");
        liveData.add("岩手");
        liveData.add("盛岡");
        liveData.add("秋田");
        liveData.add("宮城");
        liveData.add("仙台");
        liveData.add("松島");
        liveData.add("泉");
        liveData.add("登米");
        liveData.add("佐沼");
        liveData.add("山形");
        liveData.add("福島");
        liveData.add("郡山");
        liveData.add("茨城");
        liveData.add("水戸");
        liveData.add("栃木");
        liveData.add("日光");
        liveData.add("宇都宮");
        liveData.add("群馬");
        liveData.add("前橋");
        liveData.add("高崎");
        liveData.add("埼玉");
        liveData.add("千葉");
        liveData.add("成田");
        liveData.add("木更津");
        liveData.add("船橋");
        liveData.add("松戸");
        liveData.add("東京");
        liveData.add("銀座");
        liveData.add("浅草");
        liveData.add("池袋");
        liveData.add("上野");
        liveData.add("新宿");
        liveData.add("渋谷");
        liveData.add("品川");
        liveData.add("巣鴨");
        liveData.add("八王子");
        liveData.add("神奈川");
        liveData.add("横浜");
        liveData.add("川崎");
        liveData.add("横須賀");
        liveData.add("相模原");
        liveData.add("山梨");
        liveData.add("甲府");
        liveData.add("新潟");
        liveData.add("佐渡");
        liveData.add("富山");
        liveData.add("石川");
        liveData.add("金沢");
        liveData.add("福井");
        liveData.add("長野");
        liveData.add("軽井沢");
        liveData.add("松本");
        liveData.add("岐阜");
        liveData.add("飛騨高山");
        liveData.add("静岡");
        liveData.add("富士");
        liveData.add("浜松");
        liveData.add("愛知");
        liveData.add("名古屋");
        liveData.add("三重");
        liveData.add("伊勢");
        liveData.add("津");
        liveData.add("滋賀");
        liveData.add("大津");
        liveData.add("京都");
        liveData.add("大阪");
        liveData.add("堺");
        liveData.add("東大阪");
        liveData.add("兵庫");
        liveData.add("神戸");
        liveData.add("姫路");
        liveData.add("奈良");
        liveData.add("和歌山");
        liveData.add("鳥取");
        liveData.add("島根");
        liveData.add("出雲");
        liveData.add("松江");
        liveData.add("岡山");
        liveData.add("広島");
        liveData.add("福山");
        liveData.add("山口");
        liveData.add("下関");
        liveData.add("徳島");
        liveData.add("香川");
        liveData.add("高松");
        try {
            SN = getSerialNumber();
        }catch (Exception e){
            SN = "mji123456";
        }
//
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
                myHandaling(paramThread, paramThrowable);
            }
        });
        
        
        connectFtp();

        tapiaGet = new TapiaGetJson();
        setWalkpaper();

//        longPressRunnable = new Runnable() {
//            public void run() {
//                if(currentMode.equalsIgnoreCase("talk")){
//                    myTTS.stopSpeak();
//                    mySTT.stop();
//                    checkHandler98_BLUE.removeCallbacks(checkRunnable98_BLUE);
//                    isListen = false;
//                    tapiaAnimation.playColor1(1);
//                    String [] SpeakArray = {"またあとでね", "またね", "あとでね", "ちょっとひとやすみ", "休憩するね"};
//                    Random ran = new Random();
//                    int index = ran.nextInt(SpeakArray.length);
//                    String toSpeak = SpeakArray[index];
//                    //Toast.makeText(getApplicationContext(), toSpeak,Toast.LENGTH_SHORT).show();
//                    myTTS.TapiaSpeak(toSpeak);
//                    //iv.setImageResource(R.drawable.black);
//                    myTTS.player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
//
//                        @Override
//                        public void onCompletion(MediaPlayer mp) {
////                                Intent intent = new Intent(context, StartActivity.class);
////                                startActivity(intent);
//                            count98 =0;
//                            checkStateHander.postDelayed(checkStateRunnable,5000);
//                            handler98.postDelayed(runnable98,800);
//                            setSleepMode();
//                        }
//
//                    });
//                }else if(currentMode.equalsIgnoreCase("sleep")){
//                    setTalkingMode();
//                    checkStateHander.removeCallbacks(checkStateRunnable);
//                    handler98.removeCallbacks(runnable98);
//                    needForHelp("なにかご用ですか?");
//                }
//            }
//        };
//

        createDirIfNotExists("/sdcard/TapiaData/Send/");
        createDirIfNotExists("/sdcard/TapiaData/Receive/");
 public void run() {

                Log.d("Tapia","Check 98");

                if(count98==0){


                    boolean check = false;
                    boolean check2 = false;
                    String path = "/Tapia/"+seatNumber+"/";
                    allFileName = ftpPrintFilesList(path);
                    if(allFileName.size()==0){


                    }else{
                        for(String filename :allFileName){

                            if(filename.endsWith("98.trg")){

                                if(!fileObjectDAO.checkFileExit(filename)){
                                    fileObjectDAO.addFile(filename);
                                    isDelete = true;
                                    check = true;
                                    Log.e("checking","98");
                                    ftpDownload(path + filename, "/sdcard/TapiaData/Receive/" + filename);
                                    break;
                                }
                            }
                        }

                    }

                    if(!check){
                        path = "/Tapia/ALL/";
                        allFileName = ftpPrintFilesList(path);
                        if(allFileName.size()==0){


                        }else{
                            for(String filename :allFileName){

                                if(filename.endsWith("98.trg")){

                                    if(!fileObjectDAO.checkFileExit(filename)){
                                        fileObjectDAO.addFile(filename);
                                        isDelete = true;
                                        check2 = true;
                                        ftpDownload(path+filename,"/sdcard/TapiaData/Receive/"+filename);
                                        break;
                                    }
                                }
                            }

                        }


                    }
                        count98++;
                        handler98.postDelayed(this, 1000);

                }else{
                    count98++;
                    if(count98==10)count98=0;
                    handler98.postDelayed(this, 1000);
                }

            }
        };


Trust me it works!!!

PS. This is 300 out of 3000 lines from one Class

By SIMON WONG , 2018-08-20 10:19:44
Entity veh = World->NewVehicle(type);
...
World->AddAnimal(veh); // insert vehicle to both landscape and world

Code for creating CAMERA object in one big AAA game engine.

By Anonymous, 2018-08-19 01:33:34
value unless value.select! { |v| v != "0" }.nil?

I don't not know no why not no one of my "predecessor" committed this shit.

By Penguin, 2018-08-09 04:37:29
const setFormFlag(state){
    state.formFlag ? state.formFlag = false : state.formFlag = true;
}
By Apeiron, 2018-07-27 20:43:23
private readonly FooType _foo = new FooType();

/// <summary>
/// Gets the controller of this component
/// </summary>
private FooType Foo
{
    get
    {
        return _foo;
    }
}
By Anonymous, 2018-07-25 13:55:26

    def dow_to_dict_from_self(self):
        # res = {'name': self.name, 'enabled': self.enabled }
        res = {'sun': 0, 'mon': 0, 'tue': 0, 'wed': 0, 'thr': 0, 'fri': 0,
               'sat': 0,
               'enabled': 0, 'dow': 0, 'name': 'untitled'}

        if (int(self.days_of_week) & 0x01) == 0x01:  # sun
            res['sun'] = 1
        if (int(self.days_of_week) & 0x02) == 0x02:  # mon
            res['mon'] = 1
        if (int(self.days_of_week) & 0x04) == 0x04:  # tue
            res['tue'] = 1
        if (int(self.days_of_week) & 0x08) == 0x08:  # wed
            res['wed'] = 1
        if (int(self.days_of_week) & 0x10) == 0x10:  # thr
            res['thr'] = 1
            res['thu'] = 1  # '%a' returns thu for Thursday
        if (int(self.days_of_week) & 0x20) == 0x20:  # fri
            res['fri'] = 1
        if (int(self.days_of_week) & 0x40) == 0x40:  # sat
            res['sat'] = 1
        if (int(
                self.days_of_week) & 0x40) == 0x80:  # enabled # new enable#
            # flag -- duplicate in db
            res['enabled'] = 1

        res['enabled'] = self.enabled  # remove this
        res['dow'] = self.days_of_week
        res['name'] = self.name

        return res

kept the original comments - they're very helpful

By Anonymous, 2018-07-11 19:40:44
SELECT 
	tblPosts.idPost,
	tblPosts.postTitle, 
	tblPosts.postCode, 
	tblPostsStatus.scsTitle, 
	concat(code, '<br>', pTitle) AS pTitle, (CASE WHEN postResult = 1 THEN 'yes' ELSE 'no' END) AS postResult , 
	concat(date_format(postStartedDate, '%d.%m.%Y'), '<br>', date_format(postStartedDate, '%H:%i')) AS dateStart, 
	date_format(tblPosts.updated_at, '%d.%m.%Y %H:%i') AS dtUpdated, tblPerson.mobile, tblPerson.mail, tblPerson.isoLang, tblPostsReason.surname, 
	concat(coalesce(clientFName, ''), ' ', coalesce(clientName, '')) AS client, 
	concat(coalesce(concat(tblGender.gender, ' '), ''), coalesce(eFName, ''), ' ', coalesce(eName, '')) AS pers, 
	(CASE WHEN tblPosts.idCollab is NULLTHEN '' ELSE concat(coalesce(tblCol.cFName, ''), ' ', coalesce(tblCol.cName, '')) END) AS starter, 
	concat("<img src='img/status_", tblPosts.status, ".png' height='12px' border='1' />") AS displaystat,
	concat("<a href='index.php?arg=posts&id=", tblPosts.idPost, "&idAccess=", coalesce(tblAccess.idAccess, ''), "' title='Prepare Interface'><img src='../DG/styles/flat/images/edit.gif' style='height:14px; width:32px;' border='0'></a>") AS elink, 
	concat("<a href='email.php?frame=1&idPost=", tblPosts.idPost, "&source=PERS&idSrc=", tblPerson.idPerson, "&lang=", tblPerson.isoLang, "&from=", ";;SENDER", "&to=", tblPerson.persMail, "&idTperslate=CLI_diff_joindre_can,PERS_demande_contact,PERS_demande_CV&title=", replace(replace(replace(coalesce(pTitle, ''), "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(persName, ''), ' ', coalesce(persFname, '')), "' class='fancybox fancybox.iframe'><img src='img/email.png' height='12px' border='1' title='Messages' ></a>") AS mailink, 
	concat("<a href='post_email.php?frame=1&op=resend&idPosts=", tblPosts.idPost, "&idPerson=", tblPerson.idPerson, "&lang=", tblPerson.isoLang, "&idAccess=", coalesce(tblAccess.idAccess, ''), "&title=", replace(replace(replace(coalesce(pTitle, ''), "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(perName, ''), ' ', coalesce(perFName, '')), "' class='fancybox fancybox.iframe'><img src='img/emailNew.png' height='12px' border=1 title='New Posts' ></a>") AS newlink, 
	concat("<a href='comment.php?idPosts=", tblPosts.idPost, "&idPostsElem=-1&idClient=", tblPosts.idClient, "&frame=1&title=", replace(replace(replace(pTitle, "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(persName, ''), ' ', coalesce(persFName, '')), "' class='fancyboxstepreload fancybox.iframe'><div id='divBadgeComm", tblPosts.idPost, "' class='divBadge'>", (select count(*) from tblComment where idPosts=tblPosts.idPost and idElem is NULLand visibleClient=1), "</div><img src='img/comment.png' height='12px' border='1' title='Comments' /></a>") AS comments, 
	concat("<a href='docs.php?frame=1&idPosts=", tblPosts.idPost, "&title=", replace(replace(replace(pTitle, "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(persName, ''), ' ', coalesce(persFname, '')), "' class='fancyboxstep fancybox.iframe'><div id='divBadgeDocument", tblPosts.idPost, "' class='divBadge'>", (select count(*) from tblDocs where idPosts=tblPosts.idPost and docFileName <> '' and status=1), "</div><img src='img/dir.png' height='12px' border='1' title='Docs' /></a>") AS documents, 
FROM tblPosts
-- lots of LEFT JOIN
WHERE 1;

Maybe he didn't know how to do it in PHP ?

By Not a real programmer, 2018-07-10 11:03:17
<div class="scrollContent">
	{foreach $animations as $index => $a}
		{if $index > 2}
			{if $a.filename == '9_1447691013_3726.png'}
			{else}
				{if $a.filename == '9_1423150010_6441.png'}
				{else}
					{if $a.filename == '9_1423149959_5909.png'}
					{else}
						{if $a.filename == '9_1423149908_5874.png'}
						{else}
							{if $a.filename == '9_1528213223_6374.jpg'}
							{else}
								{if $a.filename == '9_1527670984_3732.jpg'}
								{else}

							<div class="spotlightFrame frame{$index+1} contains1" data-index="{$index}">
								{if $a.link}<a href="{$a.link}">{/if}
								<img src="/upload/{$a.filename}" alt="{$a.title}" />
								{if $a.link}</a>{/if}
							</div>

								{/if}
							{/if}
						{/if}
					{/if}
				{/if}
			{/if}
		{/if}
	{/foreach}
</div>

Handovers are great.

By Anonymous, 2018-07-09 14:50:36
switch (kafkaStreams.state()) {
                case RUNNING: {
                    if (kafkaStreams.state().isRunning()) {
                        countDownLatch.countDown();
                    }
                }
                break;
By Anonymous, 2018-07-05 18:05:59
if((substr($onefile, -4) == ".Mp3") OR 
    (substr($onefile, -4) == ".ogg") OR 
    (substr($onefile, -4) == ".OGG") OR 
    (substr($onefile, -4) == ".oGG") OR 
    (substr($onefile, -4) == ".OGg") OR 
    (substr($onefile, -4) == ".Ogg") OR 
    (substr($onefile, -4) == ".OgG") OR 
    (substr($onefile, -4) == ".mP3") OR 
    (substr($onefile, -4) == ".MP3") OR 
    (substr($onefile, -4) == ".mp3")){
    
    // do stuff
} 

gotta make sure you account for capitalization

By Kyuunex, 2018-07-02 04:58:09