Thursday, 8 December 2016

Adding environment from external/workspace file into the Jenkins pipeline



// Reading workspace inside pipeline script file using 'readProperties or readFile', 

def props = readProperties file: 'tempFiles/env.properties'

// Adding environment into the Jenkins:
props.each { name, val ->
   println "Exporting to Jenkins environment: " + name + "="  + val
   env."$name" = "$val"
}

Wednesday, 31 August 2016

Steganography - hiding data within JPG file

The data file must be a ZIP file ('data.zip') and image.jpeg is a image file.

# The data file must be a ZIP file ('data.zip') and 'image.jpeg' is a image file.
>> cat image.jpeg data.zip  > test.jpg

To see the content of jpg having image + data file
>> unzip -t test.jpg


To extract content from jpg having image + data file

>> unzip test.jpg

Wednesday, 28 October 2015

Defrag MYSQL database

Over a period of time, "mysql" tables usually get fragmented. It degrades the performance of "mysql-server" significantly.

You may also find it worth your while to defragment your database tables regularly if you are using VARCHAR fields: these variable-length columns are particularly prone to fragmentation.

To defragment tables manually from command-line using mysqlcheck
Run the following command by replacing USER & PASS values:

mysqlcheck -Aos -u <user> -p <password>

Parallelise your build using make

If you're running a multiprocessor system (SMP) with a moderate amount of RAM, you can usually see significant benefits by performing a parallel make when building code. Compared to doing serial builds when running make (as is the default), a parallel build is a vast improvement. To tell make to allow more than one child at a time while building, use the -j switch:


make -j4; make -j4 modules

Thursday, 27 August 2015

'C' multi-buffer tokeniser (reentrant version)


char *strtok_r(char *str, const char *delim, char **saveptr);

The strtok_r() function is a reentrant version strtok(). The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string.

strtok_r() is used almost exactly as strtok() except with additional last parameter char ** saveptr is passed. This is used internally, to save of buffer state.


#include <stdio.h>
#include <stdlib.h>
#include <strings.h>


int main() {
  char buffer1[50];
  char buffer2[50];
  char *save1, *save2, *token1, *token2;

  strcpy(buffer1, "A-B-C-D");
  strcpy(buffer2, "1:2:3:4");

  token1 = strtok_r(buffer1, "-", &save1);
  token2 = strtok_r(buffer2, ":", &save2);

  while(token1 != NULL ||
        token2 != NULL) {
     printf("[%s%s]\n", token1, token2);
     token1 = strtok_r(NULL, "-", &save1);
     token2 = strtok_r(NULL, ":", &save2);
  }
  return 0;

}


Wednesday, 26 August 2015

Writing Linux Kernel module

  lsmod – List all loaded kernel modules




Sample kernel module

hello_world.c module in 'C'
 


Compiling kernel module
 
make -C /lib/modules/<`uname -r`>/build M=<path_to_hello_world.c file> modules
 
#on successful compilation : hello_world.ko file will be generated

 Adding /inserting module 

 # loading the module
insmod hello_world.ko

# checking whether module is loaded.
dmesg |grep

# checking using lsmod
lsmod | grep hello

Wednesday, 29 April 2015

shell - Indirect variable references


KSH
       i = 10
       var_ref=variable_sequence _$i
       eval  pointer_to_val=\$$var_ref

BASH
      i = 10
       var_ref=variable_sequence _$i
       pointer_to_val=${!var_ref}

Total Pageviews

Popular Posts