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 / multi-git.md
Last active April 15, 2018 11:28 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer.

Setting up github and bitbucket on the same computer

Github will be the main account and bitbucket the secondary.

Create SSH Keys

ssh-keygen -t rsa -C "github email"

Enter passphrase when prompted. If you see an option to save the passphrase in your keychain, do it for an easier life.

@joemccann
joemccann / redis.conf
Created December 6, 2011 21:51
Standard Redis Conf with Authentication
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@paulofreitas
paulofreitas / custom-paginator.md
Last active March 2, 2020 10:09
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"
        ],
    // ...
function hostReachable() {
// Handle IE and more capable browsers
var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" );
var status;
// Open new request as a HEAD to the root hostname with a random param to bust the cache
xhr.open( "HEAD", "//" + window.location.hostname + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000), false );
// Issue request and handle response
@twhitney11
twhitney11 / find-replace.php
Created September 29, 2012 05:14
Simple Recursive Find and Replace PHP CLI Script
<?php
/**
* Tyler Whitney
*
* PHP Command line script that recursively finds and replaces a string within files of directories.
*
* Useage: php script.php DIRECTORY SEARCH-STRING REPLACE-STRING (PARTIAL-FILE-NAME-MATCH)
*
* The script will replace all strings matching SEARCH-STRING within all files inside of DIRECTORY and its sub-directories with REPLACE-STRING.
* If you provide the option PARTIAL-FILE-NAME-MATCH it will only replace occurences in files that their filenames contain the partail search.
@saggiyogesh
saggiyogesh / mongo_dump_restore.md
Last active December 3, 2020 18:26
Mongodb dump and restore from mlab
  • install mongodb on local machine (mongodump & mongorestore) commands are required.
  • command dumping

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

Otherwise to restore in mlab, create a new db and replace the options

@magnetikonline
magnetikonline / example.php
Last active February 10, 2021 21:01
PHP reading of sub directories for files using recursion and generators.
<?php
// using generators (yield) to recursively read files from a source path
// more: http://www.php.net/manual/en/language.generators.php
foreach (readFileSubDir('~/testdir') as $fileItem) {
echo($fileItem . "\n");
}
function readFileSubDir($scanDir) {
@mitchellrj
mitchellrj / tree.html
Created October 28, 2011 00:09
HTML & CSS vertical tree layout
<html>
<head>
<title>HTML &amp; CSS tree</title>
<!-- tree -->
<style type="text/css">
ul.tree {
overflow-x: auto;
white-space: nowrap;
}
@staatzstreich
staatzstreich / ftp_download.php
Created November 30, 2012 12:45
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;
@Aymkdn
Aymkdn / loadExt.js
Last active December 31, 2022 04:32
To load JS and CSS files with vanilla JavaScript
// long version
function loadExt(files, after) {
var _this=this;
_this.files = files;
_this.js = [];
_this.head = document.getElementsByTagName("head")[0];
_this.after = after || function(){};
_this.loadStyle = function(file) {
var link = document.createElement("link");
link.rel = "stylesheet";