Skip to content

Instantly share code, notes, and snippets.

View hamidhaghdoost's full-sized avatar
🎯
Focusing

Hamid Haghdoost hamidhaghdoost

🎯
Focusing
View GitHub Profile
@hamidhaghdoost
hamidhaghdoost / docker-debian.sh
Last active September 11, 2023 07:42
Install Docker and Docker Compose with one command, and run it without sudo :)
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done &&
sudo apt-get update &&
sudo apt-get install ca-certificates curl gnupg &&
sudo install -m 0755 -d /etc/apt/keyrings &&
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg &&
sudo chmod a+r /etc/apt/keyrings/docker.gpg &&
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
@hamidhaghdoost
hamidhaghdoost / scatter_gather.cpp
Last active January 19, 2018 10:38
scatter and gather simple example in c
#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;
#include "mpi.h"
#pragma comment(lib, "msmpi.lib")
void main(int argc, char *argv[])
@hamidhaghdoost
hamidhaghdoost / mpi_scatter_example_in_c.cpp
Last active November 9, 2022 14:22
MPI_Scatter example in c
// This code creates an array as count as our processes count and send every value of array to coresponding process and prints it in process...
#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;
#include "mpi.h"
#pragma comment(lib, "msmpi.lib")
@hamidhaghdoost
hamidhaghdoost / file_get_contents_curl.php
Created January 16, 2017 20:05
php file_get_contents() with curl
<?php
function file_get_contents_curl( $url ) {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_AUTOREFERER, TRUE );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_URL, $url );
@hamidhaghdoost
hamidhaghdoost / times.php
Last active December 14, 2016 12:54
بخش بندی بازه زمانی بر اساس روز - ماه - سال - دقیقه و ثانیه در کاربن / divide time period according to days , month , year and others...
<?php
public function index()
{
$start = '1992-5-7 11:25:17';
var_dump($this->times(20 , 'Year' , $start , false));
}
function times($number , $type = 'Day' , $start = null , $floor = true)
{
@hamidhaghdoost
hamidhaghdoost / last_days.php
Created December 14, 2016 10:58
Get et last n days in Carbon
<?php
public function index()
{
var_dump($this->last_days(5));
}
function last_days($number)
{
$days = [];
@hamidhaghdoost
hamidhaghdoost / Search.php
Last active February 27, 2023 01:52
get google results about a keyword
<?php
// Search $title in Google search engine
public function google($title)
{
$keyword = urlencode($title);
$url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=$keyword";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'HTTP://YOURSITE.COM');