View example.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule OtpConceptsProcesses do | |
use GenServer | |
def start_link() do | |
GenServer.start_link(__MODULE__, :ok, []) | |
end | |
def init(:ok) do | |
{:ok, %{}} | |
end |
View filter_for_tasks_for_criteria.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enum.reduce(params, dynamic(true), fn | |
{"workspace_id", workspace_id}, dynamic_query -> | |
dynamic( | |
[task, project, user_task, time_track], | |
^dynamic_query and project.workspace_id == ^workspace_id | |
) | |
{"user_ids", user_ids}, dynamic_query -> | |
user_ids = Enum.map(String.split(user_ids, ","), fn x -> String.to_integer(x) end) |
View example.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = | |
Task | |
|> join(:inner, [task], project in Project, on: project.id == task.project_id) | |
|> join(:inner, [task], user_task in UserTask, on: task.id == user_task.task_id) | |
|> join(:left, [task], time_track in TimeTracking, on: time_track.task_id == task.id) | |
|> where(^filter_for_tasks_for_criteria(params)) |
View scope.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
{ | |
int x = 10, y = 20; | |
{ | |
// The outer block contains declaration of x and y, so | |
// following statement is valid and prints 10 and 20 | |
printf("x = %d, y = %d\n", x, y); | |
{ | |
// y is declared again, so outer block y is not accessible |
View IPCserver.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> //strlen | |
#include <stdlib.h> //strlen | |
#include <sys/socket.h> | |
#include <arpa/inet.h> //inet_addr | |
#include <unistd.h> //write | |
#include <pthread.h> //for threading , link with lpthread | |
#define MAX 10000 | |
//the thread function |
View http-server.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <netdb.h> //bzero() | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <sys/socket.h> //socket() | |
#include <arpa/inet.h> //inet_addr | |
#include <unistd.h> //write | |
#include <pthread.h> //for threading , link with lpthread | |
#define MAX 10000 |
View client.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> //for printf() and scanf() | |
#include <sys/types.h> | |
#include <sys/socket.h>//for socket connect send and recieve | |
#include <netinet/in.h> | |
#include <unistd.h>//for close() | |
#include <netdb.h> | |
#include <fcntl.h> | |
#include <stdlib.h>//for atoi() | |
#include <string.h>//for memeset |
View server.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
#include<netinet/in.h> | |
#include<sys/socket.h> | |
#include<sys/types.h> | |
int main(void) | |
{ | |
char server_response[256]="you have reached the server"; | |
int server_socket; | |
server_socket=socket(AF_INET,SOCK_STREAM,0); |
View client.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h>//for using printf and scanf function | |
#include<stdlib.h>//for using atoi() function | |
#include<sys/types.h> | |
#include<sys/socket.h>//API conatins function like connect socket send rev | |
#include<netinet/in.h>//contains the structure sockaddr_in | |
#include<string.h>//for memset | |
#include<fcntl.h> | |
#include<netdb.h>//for using structure hostnet and for getting the host by name | |
#define MAX_BUFF 1024 |
View header.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
# :- ask the compiler to pre-process things written after it whether header file or macros before compiling the code | |
include : ask for inclusion of all the function in stdio header file | |
<> : stdio.h header file will be searched in the standard compiler include path | |
"" : stdio.h header file will be searched in the compiler include path as well as in current directory |