Skip to content

Instantly share code, notes, and snippets.

@Khalefa
Khalefa / Dockerfile
Created December 22, 2021 03:14
Docker for postgres
# syntax=docker/dockerfile:1
FROM ubuntu:16.04
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
@Khalefa
Khalefa / db.sql
Last active December 12, 2020 02:02
drop database project2;
create database Project2;
use Project2;
Create table item(
Item_id int primary key,
Item_name char(100),
category char(100),
price decimal(5,2)
);
//g++ -march=native --std=c++17 -O3 gaps.cpp -o gaps
//sysctl -a | grep machdep.cpu.features
//sysctl -n machdep.cpu.brand_string
//https://www.cs.virginia.edu/~cr4bd/3330/F2018/simdref.html
#include <unistd.h>
#include <chrono>
#include <cstdlib>
@Khalefa
Khalefa / version1.cc
Created November 29, 2018 00:34
SpellChecker.c
#include <iostream>
#include <fstream>
#include<unordered_map>
#include <string>
using namespace std;
;
vector<string> exchange_two_chars(string &s);
vector<string> add_one_char(string &s);
void printTree2(BinaryNode * r) {
if(r==nullptr) return;
else {
queue<BinaryNode*> q;
q.push(r);
while (!q.empty()){
BinaryNode *n=q.back();
q.pop();
#include <iostream>
#include <queue>
using namespace std;
template<typename Comparable>
class BinarySearchTree
{
public:
BinarySearchTree()
{
@Khalefa
Khalefa / problem3.cc
Created September 25, 2018 02:35
C++ hw1 solution
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;
struct point {
float x, y;
point(float xx, float yy) :x{ xx }, y{ yy } {}
};
ostream& operator <<(ostream &os, const point &p) {
os << "(";
#include <algorithm>
#include <iostream>
#include<random>
using namespace std;
template <int size>
struct record_int {
int x;
char P[size - sizeof(int)];
bool operator<(const record_int<size> & rhs) {
template <int size>
struct record_int {
int x;
char P[size - sizeof(x)];
};
template <int size>
struct record_float {
#include <vector>
#include <iostream>
#include <string>
using namespace std;
vector< vector<string>> params;
void all_permutation(vector<vector<string>> &p, string &&x, int i) {
if (i >= p.size()) {
cout << x << endl;
return;
}