var doc = (Parent as Doc);
doc.Name = (doc != null) ? "" : doc.Name
By MSx, 2020-01-16 12:39:39
$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
  ));
}
By Anonymous, 2018-01-16 10:56:13
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;
        }
    }
}
By Anonymous, 2015-09-14 05:52:20
var None = null;

if ({{ post.pk }} == None) {
    // reset to draft
    $("#id_status")[0].value = 1;
}
By Anonymous, 2016-11-18 19:08:07
[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

By Anonymous, 2019-09-17 21:48:29
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
'use strict'

// exports //

module.exports = Math.sqrt
By Igor, 2021-09-01 21:28:26
const handleBoolean = value => {
        switch (value) {
            case "true":
                return true;
            case true:
                return "true";
            case "false":
                return false;
            case false:
                return "false"
            default:
                return null;
        }
    }
By Anonymous, 2021-09-29 11:53:22
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.

By Anonymous, 2023-02-02 21:29:11
	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

By Nitor, 2017-05-06 19:59:30
.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;
}
By Anonymous, 2021-08-11 11:24:55
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
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

string date = user.RegistrationDate.ToShortDateString().ToString();
By Anonymous, 2019-02-13 14:51:41
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 !!

By fotogena.co sonickseven, 2019-10-13 00:10:25