var doc = (Parent as Doc);
doc.Name = (doc != null) ? "" : doc.Name
$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
));
}
public event EventHandler<Cles_graph_doivent_etre_redessines> les_graph_doivent_etre_redessines;
public void remove_event()
{
if (this.les_graph_doivent_etre_redessines != null)
{
foreach (EventHandler<Cles_graph_doivent_etre_redessines> F_les_graph_doivent_etre_redessines in this.les_graph_doivent_etre_redessines.GetInvocationList())
{
this.les_graph_doivent_etre_redessines -= F_les_graph_doivent_etre_redessines;
}
}
}
var None = null;
if ({{ post.pk }} == None) {
// reset to draft
$("#id_status")[0].value = 1;
}
[HttpPost]
[Route("validaPrepacks")]
public IHttpActionResult ValidaPrepacks(ValidaPrepackVO validacion)
{
try
{
return Ok();
}
catch (Exception e)
{
return Ok(e.Message);
}
}
A code that "validate" a pack in the backend
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.
'use strict'
// exports //
module.exports = Math.sqrt
const handleBoolean = value => {
switch (value) {
case "true":
return true;
case true:
return "true";
case "false":
return false;
case false:
return "false"
default:
return null;
}
}
typedef signed int sint;
#define N 100
static int n = N;
inline int f(const int n, int& i, int* j, int t[2], int p=11)
{
i*=i;
(*j)--;
if ( n<=0 )
{
cout << ::n << ">\n";
return t[0];
}
else return f(n-1, i, j, t) + t[n];
}
int main()
{
int n = 4;
int x = 1U;
sint y = 10;
int (*fptr)(const int, int&, int*, int*, int) = f;
int* t = new int[n];
int& r = *(t+3);
(*t) = 1;
*(t+1) = 2;
t[2] = 3;
r = 4;
int z = (*fptr)(5, x, &y, t, 12);
for(int i = 0; i < 2*n; i++)
{
if( i == n )
continue;
if( i > n )
break;
cout << t[i] << "\n";
};
cout << x << ", " << y << ", " << z << "\n";
delete[] t;
}
This is what my professor gave as part of the final exam. The purpose of giving us this code was to get us used to seeing different ways the C++ syntax can be used and figure out what the output is.
public showOrHideLegends(seriesList: any[]) {
if (seriesList.length === 0)
return false;
else
return true;
}
more code lines => more money; that's how our contractor company thinks
.stepper a{
}
.stepper>div>div>div>div>a{
color: transparent !important;
}
stepper>div>div>div>div>span{
color: transparent !important;
}
.stepper>div>div>div:nth-child(1)>div>a:after, .stepper>div>div>div:nth-child(1)>div>span:after{
color: rgb(52, 58, 64);
content: '4' !important;
margin-left: -10px;
}
.stepper>div>div>div:nth-child(2)>div>a:after{
color: rgb(52, 58, 64);
content: '3' !important;
margin-left: -10px;
}
.stepper>div>div>div:nth-child(3)>div>a:after{
color: rgb(52, 58, 64);
content: '2' !important;
margin-left: -10px;
}
.stepper>div>div>div:nth-child(4)>div>a:after{
color: rgb(52, 58, 64);
content: '1' !important;
margin-left: -10px;
}
.stepper>div>div>div:nth-child(4)>div>span:after{
color: rgb(52, 58, 64);
background-color: rgb(108, 117, 125);
content: '1' !important;
margin-left: -10px;
}
.stepper>div>div>div:nth-child(3)>div>span:after{
color: rgb(52, 58, 64);
background-color: rgb(108, 117, 125);
content: '2' !important;
margin-left: -10px;
}
.stepper>div>div>div:nth-child(2)>div>span:after{
color: rgb(52, 58, 64);
background-color: rgb(108, 117, 125);
content: '3' !important;
margin-left: -10px;
}
.stepper>div>div>div:nth-child(1)>div>span:after{
color: rgb(52, 58, 64);
background-color: rgb(108, 117, 125);
content: '4' !important;
margin-left: -10px;
}
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.
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:
string date = user.RegistrationDate.ToShortDateString().ToString();
function downScaleCanvas(a, b) {
var c = Math.ceil,
d = Math.floor;
if (!(1 > b) || !(0 < b)) throw "scale must be a positive number <1 ";
var e = b * b,
f = a.width,
g = a.height,
h = d(f * b),
i = d(g * b),
j = 0,
k = 0,
l = 0,
m = 0,
n = 0,
o = 0,
p = 0,
q = 0,
r = 0,
s = 0,
t = 0,
u = 0,
v = 0,
x = 0,
y = 0,
z = !1,
A = !1,
B = a.getContext("2d").getImageData(0, 0, f, g).data,
C = new Float32Array(3 * h * i),
D = 0,
E = 0,
F = 0;
for (k = 0; k < g; k++)
for (n = k * b, r = 0 | n, o = 3 * r * h, A = r != (0 | n + b), A && (x = r + 1 - n, y = n + b - r - 1), j = 0; j < f; j++, l += 4) m = j * b, q = 0 | m, p = o + 3 * q, z = q != (0 | m + b), z && (u = q + 1 - m, v = m + b - q - 1), D = B[l], E = B[l + 1], F = B[l + 2], z || A ? z && !A ? (s = u * b, C[p] += D * s, C[p + 1] += E * s, C[p + 2] += F * s, t = v * b, C[p + 3] += D * t, C[p + 4] += E * t, C[p + 5] += F * t) : A && !z ? (s = x * b, C[p] += D * s, C[p + 1] += E * s, C[p + 2] += F * s, t = y * b, C[p + 3 * h] += D * t, C[p + 3 * h + 1] += E * t, C[p + 3 * h + 2] += F * t) : (s = u * x, C[p] += D * s, C[p + 1] += E * s, C[p + 2] += F * s, t = v * x, C[p + 3] += D * t, C[p + 4] += E * t, C[p + 5] += F * t, t = u * y, C[p + 3 * h] += D * t, C[p + 3 * h + 1] += E * t, C[p + 3 * h + 2] += F * t, t = v * y, C[p + 3 * h + 3] += D * t, C[p + 3 * h + 4] += E * t, C[p + 3 * h + 5] += F * t) : (C[p] += D * e, C[p + 1] += E * e, C[p + 2] += F * e);
var G = document.createElement("canvas");
G.width = h, G.height = i;
var H = G.getContext("2d"),
I = H.getImageData(0, 0, h, i),
J = I.data,
K = 0;
for (l = 0, p = 0; K < h * i; l += 3, p += 4, K++) J[p] = c(C[l]), J[p + 1] = c(C[l + 1]), J[p + 2] = c(C[l + 2]), J[p + 3] = 255;
return H.putImageData(I, 0, 0), G
}
dohhhhhh !!