Skip to content

Instantly share code, notes, and snippets.

@khalefa-phd
khalefa-phd / fork1.c
Created February 6, 2020 21:47
fork1.c
#include <stdio.h>
#include <unistd.h>
int main() {
pid_t ChildID;
ChildID = fork(); // check for Fork
if (ChildID >= 0) // fork sucess
{
if (ChildID == 0) // Code Of Child which the value will be 0 in
// case of Child code
{
#include <stdio.h>
#include <unistd.h>
int globalVraiable ;
int main() {
pid_t ChildID;
int localVraiable =0 ;
ChildID = fork(); // check for Fork
if (ChildID >= 0) // fork sucess
{
if (ChildID == 0) // Code Of Child which the value will be 0 in
@khalefa-phd
khalefa-phd / Server.java
Created February 10, 2020 18:20
Socket IP example 1
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
public class Server {
public static void main(String[] args) throws IOException {
//Wait on port
try (ServerSocket listener = new ServerSocket(1090)) {
#include <stdio.h>
#include <unistd.h>
int main() {
pid_t ChildID;
ChildID = fork(); // check for Fork
if (ChildID >= 0) // fork sucess
{
if (ChildID == 0) // Code Of Child which the value will be 0 in
// case of Child code
{
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
@khalefa-phd
khalefa-phd / q6.sql
Last active February 22, 2021 22:08
Problem no 6
-- correct but not for mysql
SELECT s.sid,s.lname, s.fname
FROM course c, student s, enrolled e
where c.cid=e.cid and e.sid=s.sid and c.`name`='network'
Intersect (
SELECT s.sid,s.lname, s.fname
FROM course c, student s, enrolled e
where c.cid=e.cid and e.sid=s.sid and c.`name`='database');
-- version 1
@khalefa-phd
khalefa-phd / Readme.md
Created March 29, 2021 18:02
Testing udf

test udf functions

PG_FUNCTION_INFO_V1(addTen);
Datum addTen(PG_FUNCTION_ARGS) {
int32 i;
FuncCallContext *funcctx;
int call_cntr;
int max_calls;
// Code executed only on first call of the function
if (SRF_IS_FIRSTCALL()) {
MemoryContext oldcontext;
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
static unordered_map<string, int> lookup;
// Function to find the length of the longest common subsequence of
@khalefa-phd
khalefa-phd / a.sql
Created April 7, 2021 20:25
Triggers Mysql
CREATE TABLE Students
(sid CHAR(20),
name CHAR(20) NOT NULL,
login CHAR(10),
age INTEGER,
gpa REAL Default 0,
Constraint pk Primary Key (sid),
Constraint u1 Unique (login),
Constraint gpaMax check (gpa <= 4.0) );