{k: v for d in [{ key: { 0: x[0], } for key in x["name"] } for x in items] for k, v in d.items()}
By nooooooo, 2018-01-02 14:54:31
let True = true
let False = false

使用Python的 True 和 False 在javascript

By AD, 2023-01-31 10:16:17
.black {
    color: #000;
}

.not-black {
    color: #999;
}
By Anonymous, 2019-03-04 13:45:29
var doc = (Parent as Doc);
doc.Name = (doc != null) ? "" : doc.Name
By MSx, 2020-01-16 12:39:39
in_array($this->market, ["ru"])

There is an old mysterious legend, which says that those conditions are lightening fast which are using in_array($source, ["target"]) instead of just "==". Is says always that probably you never do code refactoring, and keep all shit alive

By Anonymous, 2018-03-12 14:47:24
function urlREPLACER(dtTEXTVALUE){
    
    dtTEXTVALUE.indexOf('http://') != -1 && (dtTEXTVALUE = dtTEXTVALUE.replace('http://','')) && dtTEXTVALUE.indexOf('.aspx') == -1 && (dtTEXTVALUE += '.aspx');
    
    return dtTEXTVALUE;
}
By I'm glad, 2019-02-16 13:10:54
function IsAOrB(const p_Id: string): boolean;
begin
  if ((p_Id = 'A') or (p_Id = 'B')) then begin
    Result := true;
    Exit;
  end;
  Result := false;
end;

Result := ((p_Id = 'A') or (p_Id = 'B'));

That would have been enough. But this also features Exit and an asymmetrical if.

By Anonymous, 2017-12-12 15:42:14
 public void updateCurrency() {
        LOGGER.info("Update currencies");
        var ok = false;

        try {
            getExchangeRatesMechanism(getExchangeRatesProcessor());
            ok = true;
        } catch (Exception exception) {
            LOGGER.error(exception.getMessage(), exception);
        }

        if (ok) {
            LOGGER.info("The currencies were updated successfully!");
        }
    }
By halogenUnit, 2022-09-29 13:31:58
Boolean b = new Boolean(true);
if (b == true){
    ...
}

think outside the autoboxing

By ktb, 2018-09-18 15:17:38
#1344 PHP +41
$command = 'curl -X GET -H "application/json" -H "X-Api-Key: '.$key.'" https://some-api.com/resource';
exec($command, $output);
$array = json_decode($output[0], true);

Using curl in PHP is boring. Let execute a command for

By Anonymous, 2020-07-14 20:28:49
const ITEM_COUNT = 100
let visibleItems = []
for (let i = 0; i < ITEM_COUNT; ++i) {
  visibleItems.push(false)
}

function showItem(index) {
  visibleItems = []
  for (let i = 0; i < ITEM_COUNT; ++i) {
    visibleItems.push(false)
  }
  visibleItems[index] = true
}

It was more or less like this. The guy had a collection of React components and wanted to show only one of them at a time. Instead of storing the index of the component to show at the moment, he decided that a boolean array would work much better. O(n) in runtime and space and null readability just because.

By Anonymous, 2019-12-07 11:59:58
class vggNet(nn.Module):
    def __init__(self, pretrained=True):
        super(vggNet, self).__init__()
        self.net = models.vgg16(pretrained=True).features.eval()

    def forward(self, x):


        out = []
        for i in range(len(self.net)):
            #x = self.net[i](x)
            x = self.net[i](x)
            #if i in [3, 8, 15, 22, 29]:
            #if i in [15]: #提取1,1/2,1/4的特征图
            if i in [8,15,22]: #提取1,1/2,1/4,1/8,1/16
                # print(self.net[i])
                out.append(x)
        return out

Some creepy feature extraction code I found attached to a research paper.

Features:

  • the "pretrained" parameter it's not actually used.
  • Just works (not so sure about that) with a vgg16, what if I want to use any other model?
  • They provided a spare copy of line 12, in case you lose one.
  • You can select a custom combination of layers by uncommenting the right if statement. A chinese explanation follows. Sometimes.
  • Why use pytorch hooks when you can write a 20+ lines class each time you need it?
By Baichuan Huang, 2021-05-21 19:21:58
var None = null;

if ({{ post.pk }} == None) {
    // reset to draft
    $("#id_status")[0].value = 1;
}
By Anonymous, 2016-11-18 19:08:07
doit({txs, [Tx]}) ->
    X = tx_pool_feeder:absorb(Tx),
    Y = case X of
	    ok -> hash:doit(testnet_sign:data(Tx));
	    _ -> <<"error">>
		     end,
    {ok, Y};

In my opinion api response should be as confusing as possible. This method is used for sending tx into Amoveo blockchain. It returns ["ok", ] in success, and ["ok", <base64 encoded «error» word>] I hope I inspired you to make your code totally confusing and irrational.

By Zack Hess, 2019-01-24 12:19:04
bool	vlNoExitIfZeroBytesReceived = false; //		false: can exit when receive 0 later; 	1: can not exit when receive 0 later;
By BrokenBrain, 2019-12-23 15:23:19