Skip to content

Instantly share code, notes, and snippets.

View MostafaEzzelden's full-sized avatar
🏠
Working from home

Mostafa Ezz MostafaEzzelden

🏠
Working from home
View GitHub Profile
@MostafaEzzelden
MostafaEzzelden / ftp_download.php
Created September 14, 2020 09:56 — forked from staatzstreich/ftp_download.php
Download a directory from an FTP Server
<?php
// ftp_sync - copy directory and file structure
// based on http://www.php.net/manual/es/function.ftp-get.php#90910
// main function witch is called recursivly
function ftp_sync($dir, $conn_id) {
if ($dir !== '.') {
if (ftp_chdir($conn_id, $dir) === FALSE) {
echo 'Change dir failed: ' . $dir . PHP_EOL;
return;
@MostafaEzzelden
MostafaEzzelden / mongo_dump_restore.md
Last active May 16, 2020 17:49 — forked from saggiyogesh/mongo_dump_restore.md
Mongodb dump and restore from mlab
  • install mongodb on local machine (mongodump & mongorestore) commands are required.
  • command dumping. to dump locally

mongodump -d dbname -o dumpname -u username -p password

  • command dumping to dump mlab database

mongodump -h xxx11.mlab.com:11 -u user -p password --authenticationDatabase release-db -d release-db -o /home/dumps

**Options** `-h`: mlab host:port, `-u`: db user, `-p`: db user password, `--authenticationDatabase` `-d`: mlab dbname, `-o`: path to store backupfiles
  • restore command, to restore locally

> mongorestore --db dname /home/dumps

root@desktop:~# sudo -su
root@desktop:~# apt update
root@desktop:~# apt install nginx
root@desktop:~# apt install mysql-server-5.7
root@desktop:~# mysql_secure_installation
# to login in your mysql type
root@desktop:~# mysql -uroot -p
# to change authentication plugin for root password
root@desktop:~# mysql
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class RepositoriesServiceProvider extends ServiceProvider
{
/**
* Repositories Name Space
/*
SELECTION SORT
*** Description
Iterate over array and grow a sorted array behind current element.
For each position, find the smallest element in unsorted subarray starting at that position,
and swap elements so that smallest element is at the beginning of unsorted subarray.
*/
@MostafaEzzelden
MostafaEzzelden / custom-paginator.md
Created March 2, 2020 10:09 — forked from paulofreitas/custom-paginator.md
Custom Google-like length-aware paginator for Laravel 5.4+
  • Save the helpers.php file in your app directory
  • Edit your composer.json manifest file to auloload this file:
    "autoload": {
        "files": [
            "app/helpers.php"
        ],
    // ...
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Redirect To HTTPS
server {
listen 80 default_server;
server_name _;
@MostafaEzzelden
MostafaEzzelden / ID.js
Created October 30, 2019 09:42
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@MostafaEzzelden
MostafaEzzelden / portscanner.c
Created August 30, 2019 17:55 — forked from fffaraz/portscanner.c
Port scanner code in c
#include "stdio.h"
#include "sys/socket.h"
#include "errno.h"
#include "netdb.h"
#include "string.h"
#include "stdlib.h"
int main(int argc , char **argv)
{
struct hostent *host;
@MostafaEzzelden
MostafaEzzelden / perms.md
Last active July 23, 2019 19:26 — forked from stefanbc/perms.md
Set proper permissions on /var/www/

HOWTO

To set up permissions on /var/www where your files are served from by default:

sudo addgroup webmasters
sudo adduser $USER webmasters
sudo chown -R root:webmasters /var/www/html
sudo find /var/www/html -type f -exec chmod 664 {} \;
sudo find /var/www/html -type d -exec chmod 775 {} \;