Posts

Showing posts with the label c

Create worker in rails by sidekiq and redis

Add sidekiq to your Gemfile: Add this to your Gemfile gem 'sidekiq' Run bundle install bundle install Create worker rails g sidekiq:worker Test #will create app/workers/test_worker.rb class TestWorker   include Sidekiq::Worker   def perform(id, name)     # do something   end end Call worker without any time boundation TestWorker.perform_async(5, 'rahul') //use this anywhere from your rails app(controller, model, helpers..) Call worker within particular time period TestWorker.perform_in(5.minutes, 5, 'rahul')  //use this anywhere from your rails app(controller, model, helpers..) Call worker after specific time interval once only TestWorker.perform_at(5.minutes.from_now, 5, 'rahul')  //use this anywhere from your rails app(controller, model, helpers..) Start sidekiq on development bundle exec sidekiq Start sidekiq on production bundle exec sidekiq -d //run this first if you get some error then use second one bundle exec si

DATATYPES in sql || Sql Tutorial -5

DATATYPES IN SQL  The data type represents the type of data to be entered into a column and Db engine can assign memory for thevalue entered into the column. There are 5 types of DataType in sql. String DataTypes Numeric DataTypes Date Datatypes Binary DataTypes LOB--Large Objects String Data Types These data types support sequence of character, digits and any symbol from keyboard. CHAR(size) It is used to store fixed length character strings. By default the size is 1 character, and max size is 2000 chars orbytes. Ex: student_id, email, address and so on VARCHAR2(size) It is used to store variable length character strings. No default size. we should specify size and max size is 4000 chars /bytes. Ex: emp names, addresses, descriptions, city names. LONG It is used to store variable length char data(similar to varchar2 data type) but max size is 2 GB NOTE: Only one long type column is allowed per a table. 1) NUMBER(Precision, [Scale])    It is used to store numb

Features of Sql * Plus

Features of Sql * Plus At a time only one query is allowed to execute Sql queries are not case sensitive Each query is terminated with ; ( semi colon ) SQL commands are ANSI standard ( American National standard institute )

What is sql definition(Structured query language). Sql Tutorial -2

Image
Structured query language It is a collection of pre defined commands and constructs with syntactical rules. 1. Sql is a client tool to interact with ORACLE DB /any DB 2. Sql is to be installed in to the system whenever we have installed the db software. 3. Client [Technical] requests should be submitted in the form of "Queries". 4. Queries are executed by SQL STMT EXECUTOR ( Oracle Db Engine ) 5. Queries are executed against database and output will be displayed on the Sql * plus window.

File inclusion in c

There are two ways to include a file in c # include ”filename” #include<filename> 1st one  is search in  current directory  and  specify list of directory  and  it also take full qualified file name. 2nd one  is search in  specify list of director y. But It has a advantage that is it can take  multiple file Name  at a time that is separated by semicolon ( ; ). Example- #include<file 1; file 2; file 3>

Connect to printer by C Program

#include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { FILE *fp; char ch; fp=fopen(" full qulified file name that you want to read ","r"); if(fp==NULL) { printf("can not open file\n"); exit(1); } while((ch=fgetc(fp))!=EOF) { fputc(ch,stdprn); } fclose(fp); getch(); }

Types of constants in c

There are  two  types of constants available in c language. Primary constants  - intreger constants, real constants, character constants. Secondary constants - array, pointer, structure, union, enum. etc

Exponential function in c

The exp() function computes the exponential (Euler's number) raised to the given argument. C exp() Prototype double exp(double arg); The exp(arg) takes a single argument and returns the value in type   double . — maths e^x = exp(x) [in c programming] It is defined in  <math.h> header file. EXAMPLE- #include <stdio.h> #include <math.h> int main () { double x = 12.0 , result ; result = exp ( x ); printf ( "Exponential of %.2lf = %.2lf" , x , result ); return 0 ; } Output Enter the value of x to find e ^ x : 12 Exponential of 12.00 = 162754.79

Fibonacci series without using recursion?

#include<stdio.h> #include<conio.h> void printFibonacci(int n){ static int n1=0,n2=1,n3; if(n>0){ n3 = n1 + n2; n1 = n2; n2 = n3; printf("%d ",n3); printFibonacci(n-1); } } void main(){ int n; clrscr(); printf("Enter the number of elements: "); scanf("%d",&n); printf("Fibonacci Series: "); printf("%d %d ",0,1); printFibonacci(n-2); //n-2 because 2 numbers are already printed getch(); } Enter the number of elements : 15 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

Most efficient way to store flag values?

A flag is a value used to make a decision between two or more options in the execution of a program. For instance, the /w flag on the MS-DOS dir command causes the command to display filenames in several columns across the screen instead of displaying them one per line. In which a flag is used to indicate which of two possible types is held in a union. Because a flag has a small number of values (often only two), it is tempting to save memory space by not storing each flag in its own  int  or  char . Efficiency in this case is a tradeoff between size and speed. The most memory-space efficient way to store a flag value is as single bits or groups of bits just large enough to hold all the possible values. This is because most computers cannot address individual bits in memory, so the bit or bits of interest must be extracted from the bytes that contain it. The most time-efficient way to store flag values is to keep each in its own integer variable. Unfortunately, this method can w

what is bit field

Image
Bit fields are used in Data Structure and it is partial size member variables inside a structure. When we use number programming that time we use Bit fields. Example- Decimal to Binary Conversion In the Bit fields left most bit is called sign bit.

C program to print Armstrong numbers from 1 to 1000?

  #include<stdio.h> #include<conio.h> void main() { int i=153,n,temp,num,r,sum=0; clrscr(); while(i<=1000) { n=i; temp=n; while(n>0) { r=n%10; sum=sum+(r*r*r); n=n/10; } if(temp==sum) { printf("the armstrong number is %d\n",sum); } i++; } getch(); }

my input a=12, but how do I print this in 3 digits?

There are many ways to do this. I am using the simplest way to print two digit number in three digit number. import java . util . Scanner ; class Digit { public static void main ( String [] args ) { Scanner sc = new Scanner ( System . in ); System . out . println ( "please enter any two digit number:" ); int n = sc . nextInt (); int k = 0 ; if ( n > 9 && n < 100 ) { k = n * 10 ; } else { System . out . println ( "please enter any two digit number:" ); } System . out . println ( "you entered " + n + " and three digit output of this number is " + k ); } Read More

Why do code blocks only work when installed in the C drive, and not in any other drive?

its depends on in which drive your OS and other things related to it, is installed in C drive.when we install code blocks internal process fetch the full qualified name of some file that is already install in our system. thats why we have to install it in c drive. ex—its same as the packaging in java. when we import source code of another file into a current file, when both files is in same folder we do not need to do packaging. if files are in different folder or directory then we have to called it by its full qualified name. same its done with the code blocks

How is the C language machine independent?

How is the C language machine independent? first of all c is  machine dependent  language, means we can not run a c program on another machine except in which it is programmed. machine independent  means source code of language can execute on any machine. ex java. View More

Why are header files needed in C?

Why are header files needed in C? Header file in any programming language used for including the library functions to that particular programming language. ex- stdio.h, conio.h, io.h and many more header files in c are used for including the library functions.