Skip to main content

Posts

Showing posts from February, 2017

Pattern program

i/p: 3 o/p :          1                 232               45654 c program # include < stdio.h > int main ( ) { int i , m , j , temp = 0 , n ; scanf ( " %d " , & n ) ; for ( i = 1 ; i < = n ; i + + ) { //to print space printf ( " %*s " , ( n - i ) , " " ) ; //to print increment order for ( j = 1 ; j < = i ; j + + ) { printf ( " %d " , + + temp ) ; } //to print decrement order for ( j = 1 ; j < i ; j + + ) printf ( " %d " , temp - j ) ; printf ( " \n " ) ; } return 0 ; }

Dynamically create and access workspaces in i3WM Linux

You can do not have to define a shortcut for every single workspace, you can just create them on the fly by sending a workspace NEW_WS to i3 , for example with the i3-msg program: i3-msg workspace NEW_WS  i3-msg move container to workspace NEW_WS i3 also comes with the i3-input command, which opens a small input field then runs a command with the given input as parameter i3-input -F 'workspace %s' -P 'go to workspace: ' i3-input -F 'move container to workspace %s' -P 'move to workspace: '   Bind these these two commands to shortcuts and you can access an arbitrary number of workspaces by just pressing the shortcut and then entering the name (or number) of the workspace you want. (If you only work with numbered workspaces, you might want to use workspace number %s instead of just workspace %? )

How many user process can you create in linux?

Check the Max User Processes thrid line from bottom so i can create 15430 process WOW!!!! Resources: http://unix.stackexchange.com/questions/343296/what-is-a-limit-for-number-of-threads

sleep sort program in c

# include < stdlib.h > # include < unistd.h > # include < sys/types.h > # include < sys/wait.h > // This program works well in linux // or use gcc compiler int main ( int c , char * * v ) { /*fork is used to create a child process        and make the process to sleep for given        milli seconds and atlast the process        with minimum sleep get printed using        this we can sort the array             Note: This is fun program               cannot be used in productive environment        Time complexity is high for big numbers */ while ( - - c > 1 & & ! fork ( ) ) ; sleep ( c = atoi ( v [ c ] ) ) ; wait ( 0 ) ; return 0 ; }

Dynamic allocation of variable using malloc

int main ( ) { int * h = malloc ( sizeof ( int ) * 26 ) ; // using malloc to allocate array of integers for ( int h_i = 0 ; h_i < 26 ; h_i + + ) { scanf ( " %d " , & h [ h_i ] ) ; } char * word = ( char * ) malloc ( 512000 * sizeof ( char ) ) ; // using malloc to allocate string scanf ( " %s " , word ) ; return 0 ; }