var doc = (Parent as Doc);
doc.Name = (doc != null) ? "" : doc.Name
contracts = Contract.objects.filter(staff=staff).filter(active=True)
if contracts.__len__() > 0:
ind = contracts.__len__() - 1
dic[‘active_contract_id’] = contracts[ind].id
else:
dic[‘active_contract_id’] = contracts[0].id
Get last object of queryset in django
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
const errorHandler = () => {
throw new Error();
};
int min(int a,int b,int c) //Function to return the minimum.
{
if(a < b)
{
if(a < c)return a;
else if(a > c)return c;
else return a;
}
else if(a > b)
{
if(b < c)return b;
else if(b > c)return c;
else return b;
}
else
{
if(a < c) return a;
else if(a > c) return c;
else return a;
}
}
This kind of things make me hate my work.
function isAllowSearchLength(text) {
return text.length > isNaN(parseInt(text, 10)) ? 1 : 0;
}
private boolean isToRemove(byte b) {
byte[] toRemoveB = { -106 };
for(byte c : toRemoveB) {
if(b == c) {
return true;
}
}
return false;
}
it goes without saying...
@media only screen and (-webkit-min-device-pixel-ratio:2) and (max-width:768px) and (min-width:321px),not all,only screen and (max-width:768px) and (-webkit-min-device-pixel-ratio:2) and (min-width:321px),only screen and (max-width:768px) and (min-resolution:192dpi) and (min-width:321px),only screen and (max-width:768px) and (min-resolution:2dppx) and (min-width:321px){
/*some code here*/
}
function getJSType(cppType: string) {
let typeMap = new Map<string, string>([
["Bool", "boolean"],
["Int32", "number"],
["UInt32", "number"],
["Int64", "number"],
["UInt64", "number"],
["Double", "number"],
["String", "string"],
["Object", "any"]
]);
if (typeMap.get(cppType) === undefined) {
console.error("Invalid type in getJavascriptType: " + cppType);
process.exit(1);
}
return typeMap.get(cppType);
}
const handleBoolean = value => {
switch (value) {
case "true":
return true;
case true:
return "true";
case "false":
return false;
case false:
return "false"
default:
return null;
}
}
$config = Config::getConfig('common');
$contract_carriers = $config[$market . "_" . $clearing . '_contract_carriers']; // f**ing php array
$interline_carriers = $config[$market . "_" . $clearing . '_interline_carriers']; // another f**ing array
// $marketing_carriers - is also array
$sets = [];
foreach ($marketing_carriers as $mc) {
$sets[] = array_unique(array_intersect(
array_merge(
[$mc],
array_intersect(
isset(self::$interlines[$mc]) ? self::$interlines[$mc] : [],
array_merge(
$marketing_carriers,
$interline_carriers
)
)
),
$contract_carriers
));
}
CREATE FUNCTION [dbo].[get_number_of_workers]
(
@number_of_workers varchar(10)
)
RETURNS int
AS
BEGIN
set @number_of_workers = replace(replace(replace(replace(LTRIM(RTRIM(@number_of_workers)), char(9), ''), char(10), ''), char(13),''), char(13)+char(10), '')
DECLARE @temp varchar(10)
SELECT
@temp = number_of_workers
FROM
(SELECT LTRIM(RTRIM(@number_of_workers)) as number_of_workers) as temp
WHERE
number_of_workers like '[0-9]'
or number_of_workers like '[0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
or number_of_workers like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
RETURN CONVERT(INT, @temp)
END
value unless value.select! { |v| v != "0" }.nil?
I don't not know no why not no one of my "predecessor" committed this shit.
> var x = 3;
> '5' + x - x
50
> '5' - x + x
5 // Because fuck math
JS is simply. Oh, wait...
$_POST = $this->db->mres($_POST);
$_SESSION['post'] = $_POST;
$sql = "SELECT id, documento, nombre1, nombre2, apellido1, apellido2 "
. "FROM usuarios "
. "WHERE " .
"REPLACE(" .
"REPLACE(" .
"REPLACE(" .
"REPLACE(telefono,' ','')," .
"'(','')," .
"')','')," .
"'-','') LIKE '%{$searchTel}'";