{k: v for d in [{ key: { 0: x[0], } for key in x["name"] } for x in items] for k, v in d.items()}
let True = true
let False = false
使用Python的 True 和 False 在javascript
.black {
color: #000;
}
.not-black {
color: #999;
}
var doc = (Parent as Doc);
doc.Name = (doc != null) ? "" : doc.Name
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
function urlREPLACER(dtTEXTVALUE){
dtTEXTVALUE.indexOf('http://') != -1 && (dtTEXTVALUE = dtTEXTVALUE.replace('http://','')) && dtTEXTVALUE.indexOf('.aspx') == -1 && (dtTEXTVALUE += '.aspx');
return dtTEXTVALUE;
}
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.
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!");
}
}
Boolean b = new Boolean(true);
if (b == true){
...
}
think outside the autoboxing
$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
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.
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:
var None = null;
if ({{ post.pk }} == None) {
// reset to draft
$("#id_status")[0].value = 1;
}
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",
bool vlNoExitIfZeroBytesReceived = false; // false: can exit when receive 0 later; 1: can not exit when receive 0 later;