/// <summary>
/// Method that checks if an object is not null
/// </summary>
/// <param name="obj">extend type of <see cref="Object"/></param>
/// <returns>true if object is not null</returns>
public static bool NotNull(this Object obj)
{
    return obj != null;
}


[TestMethod]
public void Test_Something()
{
    // test
    var result = DoSomething();
    
    // assert
    Assert.IsTrue(result.NotNull());
}
By Anonymous, 2017-12-21 15:42:20
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
$_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}'";
By Carlos Correa, 2016-09-16 22:11:38

string date = user.RegistrationDate.ToShortDateString().ToString();
By Anonymous, 2019-02-13 14:51:41
int minimum(int a, int b, int c){
  int mini =a*b*c;
  int iterator=0;
  int test[3];
  test[0]=a;
  test[1]=b;
  test[2]=c;
  for (iterator=0;iterator<3;iterator++){
    if (test[iterator]<mini){
      mini=test[iterator];
    }
  }
  return mini;
}

I hope that your 3 numbers aren't larger than 1290!

By Another random student of algorithms., 2017-12-14 01:28:18
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 uploadimg(file) {
    var ext = file.value.split('.').pop().toLowerCase();
    var size = document.getElementById("uploadpic").files.item(0).size;

    if (size > 3145728) {
        $.messager.alert({
            title: "Error",
            msg: " image to large",
            icon: "error"
        });
        return true;
    }

    return false;
}

var reader = new FileReader();
$("#uploadpic").change(function() {
    var pdfcheck = this;
    var ext = pdfcheck.value.split('.').pop().toLowerCase();
    if (!($.inArray(ext, ['pdf']) == -1)) {
        console.log('upload pdf start');
        if (uploadPdf(pdfcheck)) {
            $("#preview_img").attr("src", "");
            $("#preview_img2").attr("src", "");
            $("#uploadpic").prop("file", "");
            $("#uploadpic").val("");
        }
    } else {
        if (uploadimg(pdfcheck)) {//dude, I think the image you upload to check is your dick, only small enough you would rather keep going producing shitcode.
            return false;
        }
        var upload_file = $("#uploadpic")[0].files[0];
        if (upload_file != null) {
            var chimgarr = ["image/png", "image/PNG", "image/jpg", "image/JPG", "image/jpeg", "image/JPEG", "image/gif", "image/GIF", "image/bmp", "image/BMP"];
            if (chimgarr.indexOf(upload_file.type) != "-1") {
                reader.readAsDataURL(upload_file);
                reader.onload = function(e) {
                    $("#preview_img").attr("src", e.target.result);
                    $("#preview_img2").attr("src", e.target.result);
                    $("#pdf-contents").hide();
                    $("#pdf_name").val("");
                    $("#btn_pdf_view").hide();
                    $("#pic_name").val("");
                }
            } else {
                $.messager.alert("Image format does not match");
                $("#preview_img").attr("src", "");
                $("#preview_img2").attr("src", "");
                $("#uploadpic").prop("file", "");
                $("#uploadpic").val("");
            }
        } else {
            $("#preview_img").attr("src", "");
            $("#preview_img2").attr("src", "");
        }
    }
});

The moment an important image ready to be uploaded It's really important that should be checked again and again.

By shitcode master's friend, 2018-04-20 11:03:15
from itertools import combinations as comb
from functools import reduce
  
def all_arrangements(k):
	m=k*(k+1)/2
	m_bits_on=set([tuple(reduce(lambda x,y:x[:y]+[1]+x[y+1:],c,[0]*(2*m+1))) for c in comb(range(2*m+1),m)])
	return set([tuple(sorted(filter(lambda i:i>0,reduce(lambda x,y: x+[y] if y==0 else x[:-1]+[x[-1]+1,],p,[0])))) for p in m_bits_on])

Returns all arrangements in the Bulgarian solitaire game with k piles https://en.wikipedia.org/wiki/Bulgarian_solitaire

By Uri Goren, 2017-12-13 11:48:22
i++;
i++;
i++;
i++;
Console.WriteLine(i);

He doesn't know what is " i+=4 " :||||

By Manoochehr Mojgani, 2017-12-13 21:46:04
.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
#1344 PHP +34
$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
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
[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
class {
    public State state;
    //enums cant take double values...
    public struct State
    {
        public const float IDLE = 0f;
        public const float WALKING = 0.5f;
        public const float RUNNING = 1f;
    }
    protected void Stop()
    {
        SetSpeed(State.IDLE);
    }
    protected void SetSpeed(float f)
    {
        agent.speed = f;
        if (agent.speed > 1f && agent.speed < 5f)
        {
            f = State.WALKING;
            agent.Resume();
        }
        else if (agent.speed > 5f)
        {
            f = State.RUNNING;
            agent.Resume();
        }
        else
        {
            f = State.IDLE;
            agent.Stop();
        }
    }
}

Who needs static float when you can have a constant in a nested struct, as a bonus State state has 0 references in the project

By SwagridOfficial, 2018-01-05 13:39:24