if(typeof(sortOrder) != "boolean"){
return items;
}
filtered.sort(function (a, b) {
if(sortOrder == true){
return (CustomOrder(a.status) > CustomOrder(b.status) ? 1 : -1);
}
else if(sortOrder == false){
return (CustomOrder(a.status) < CustomOrder(b.status) ? 1 : -1);
}
});
The status
property is a string ("Started", "Running", "Failed", "Finished", etc.), and CustomOrder
is a function with a switch that just returns a predefined integer for each string. I switched CustomOrder to just be a simple lookup table object, and the sort call was changed to filtered.sort((a, b) => CustomOrder[a.status] - CustomOrder[b.status]);
if "[trait]" in lines[i]:
in_trait = True
elif "[/trait]" in lines[i]:
in_trait = False
elif "[object]" in lines[i]:
in_object = True
elif "[/object]" in lines[i]:
in_object = False
elif "[stage]" in lines[i]:
in_stage = True
elif "[/stage]" in lines[i]:
in_stage = False
elif "[cfg]" in lines[i]:
in_cfg = True
elif "[/cfg]" in lines[i]:
in_cfg = False
elif "[goal]" in lines[i]:
in_goal = True
elif "[/goal]" in lines[i]:
in_goal = False
#... 150 more lines of this
Basically, linting a config file with a DOM tree, using Python
if (!recruiters
.stream().map(UserData::getUserName).collect(Collectors.toList())
.contains(recruiter.getUserData().getUserName())) {
}
if (!response ||
!response.data ||
!response.data.success ||
response.data.success == false ) {
//process stuff
}
Not talking about the '===' warning, here
const configs = {
employeeObject: {
// tab 0
firstName: "",
middleName: "",
nickname: "",
lastName: "",
gender: "",
race: "",
title: "",
dob: "",
employeeIDNo: "",
// tab 1
userName: "",
permissionRole: 0,
employeeNo: "",
phoneExt: "",
startDate: "",
company: "",
division: "",
jobDescription: "",
businessUnit: "",
regionId: "",
participantStatus: "",
costCentre: "",
personType: "",
comments: "",
// tab 2
phone1: "",
phone2: "",
phone3: "",
address1: "",
address2: "",
address3: "",
address4: "",
postalCode: "",
email: "",
},
Why add another object with a title when you can just add a comment saying... well... nothing really...
func runAnsible(c *cli.Context) {
runAnsibleCmd1(c.String("command"), c.StringSlice("var-file"), c.StringSlice("var"))
}
func runAnsibleCmd1(cmd string, varfiles []string, varstrs []string) {
runAnsibleCmd2(cmd, util.ToVars(varfiles, varstrs))
}
func runAnsibleCmd2(cmd string, vars map[string]interface{}) {
err := exec.SyscallExecute(cmd, vars)
log.Error("Error running ansible command.", "err", err.Error())
}
try
{
len = readBufferSize(reader);
}
catch (IOException xcp)
{
throw xcp;
}
I swear I didn't omit a single symbol (except for tabs at the beginning)
public class CustomBoolean {
private Container<java.lang.Boolean> booleanContainer;
public CustomBoolean(Container<Boolean> booleanContainer) {
CustomBoolean custom_boolean = getThis();
custom_boolean.booleanContainer = booleanContainer;
}
private <T extends Object> T getThis() {
return (T) (Object) (T) this;
}
public Container<Boolean> getBooleanContainer() {
return booleanContainer;
}
public static CustomBoolean create(Boolean value) {
return new CustomBoolean(Container.builder().setValue(true).build());
}
public static void main(String[] args) {
System.out.println(CustomBoolean.create(Boolean.TRUE).getBooleanContainer().getObject());
}
public static class Container<T extends Object> {
private T object = null;
private Container(T object) {
Container<T> _this = getThis();
_this.object = (T) (Object) object;
}
private <T extends Object> T getThis() {
return (T) (Object) (T) this;
}
public static Builder builder() {
return new Builder();
}
public T getObject() {
return object;
}
public static class Builder<T extends Object> {
private T value;
public Builder<T> setValue(T value) {
Container<T> _this = getThis();
_this.object = (T) (Object) value;
return this;
}
private <T extends Object> T getThis() {
return (T) (Object) (T) this;
}
public Container build() {
return new Container(value);
}
}
}
} // Dort#0001
trolled
val weekEnd = DateTime.now.withDayOfWeek(5).plusDays(2)
$url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22https%3A%2F%2Fwww.google.com%2Ffinance%3Fq%3D' . $stock_identifier . '%26fstype%3Dii%26ei%3DCFrdWImFNdiGe_atlegC%22%20and%20compat%3D%22html5%22%20and%20xpath%3D' . "'%2F%2Ftable%5Bcontains(%40class%2C%22gf-table%20rgt%22)%5D'" . '&format=json&diagnostics=true&callback=';
$json = json_decode($this->getJsonFromYql($url), true);
$json = $json["query"]["results"]["table"];
//If the value is red, that means there is an additional span class which needs to be checked through.
$response["revanueValue"] = empty($json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"];
$response["costofRevanue"] = $json["1"]["tbody"]["tr"]["3"]["td"]["1"]["content"];
$response["operatingIncome"] = empty($json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"];
$response["netIncome"] = empty($json["1"]["tbody"]["tr"]["24"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["24"]["td"]["1"]["span"]["content"] : $json["0"]["tbody"]["tr"]["24"]["td"]["1"]["content"];
$response["dividendsPerShare"] = $json["1"]["tbody"]["tr"]["35"]["td"]["1"]["content"];
$response["dilutedNormalizedEps"] = empty($json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"];
$response["minorityInterest"] = $json["1"]["tbody"]["tr"]["18"]["td"]["1"]["content"];
Website --> Json --> PHP Parsing Beautiful.
FOR x IN ( SELECT COUNT(*) cnt
FROM DUAL
WHERE EXISTS ( SELECT NULL FROM task
WHERE task.task_type_id = lib.task_type_check()
AND task.task_status_id = lib.task_status_open()
AND task.unit_id = in_unit_id
AND task.station_id = v_station_id
)
)
LOOP
IF( x.cnt = 1 ) THEN
v_task_exist := TRUE;
ELSE
v_task_exist := FALSE;
END IF;
END LOOP;
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
void randy(int array[] ){
int i = 0 , d = 0;
for(i = 1 ; i <= 23 ; i++){
array[i] = 1 + (rand() % 365 );
}
}
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int find (int arr[]){
int d = 0;
for(d = 1 ;d <=23 ; d++ ){
if(arr[d] == arr[d + 1]){
return 1;
}
}
return 0;
}
int main(void){
double count_birthday = 0;
int people[24];
srand(time(NULL));
int c = 0 ;
long double ip = 0;
while(ip++ <= 1000000 ){
randy(people);
qsort (people, 25, sizeof(int), compare);
if(find (people) == 1 ){
count_birthday++;
}
}
printf("%.2lf", count_birthday / 10000 );
return 0;
}
class ExampleClass {
public void DoSomething()
{
if (this != null) {
//omitted
}
}
public void DoSomething2()
{
if (this != null) {
//omitted
}
}
}
Explanation: This can't be null in C# virtual instance methods - I was so confused by the widespread use of this check that I asked this question at SO: https://stackoverflow.com/questions/31747718/can-this-be-null-in-c-sharp-virtual-methods-what-happens-with-the-rest-of-ins
Button.MouseButton1Click:Connect(function()
if TextHolder.Text == Codes.Code1 then
if Check1.Value == false then
Check1.Value = true
elseif Check1.Value == false then
TextHolder.Text = "Code Already Redeemed"
Event:FireServer("Code1")
TextHolder.Text = "Success! 500 Coins Rewarded"
elseif TextHolder.Text == Codes.Code2 then
if Check2.Value == false then
Check2.Value = true
elseif Check2.Value == false then
TextHolder.Text = "Code Already Redeemed"
Event:FireServer("Code2")
TextHolder.Text = "Success! 250 Coins Rewarded"
elseif TextHolder.Text == Codes.Code3 then
if Check3.Value == false then
Check3.Value = true
elseif Check3.Value == false then
TextHolder.Text = "Code Already Redeemed"
Event:FireServer("Code3")
TextHolder.Text = "Sucess! 100 Coins Rewarded"
else TextHolder.Text = "Invalid/Expired Code"
end
end
end
end
end)
public class NullableFloatToNullableDoubleConverter : ITypeConverter<float?, double?>
{
public double? Convert(float? source, double? destination, ResolutionContext context)
{
if (source == null)
{
return null;
}
var floatAsString = source.Value.ToString(CultureInfo.InvariantCulture);
return double.Parse(floatAsString);
}
}