Skip to content

Instantly share code, notes, and snippets.

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

Marcel Djaman mdjaman

🏠
Working from home
View GitHub Profile
@mdjaman
mdjaman / Setting-Up-Mac.md
Created October 22, 2021 10:34 — forked from andytung/Setting-Up-Mac.md
The steps I took to configure a new mac

#Mac Setup

These are the steps I go to setup a new macbook.

  1. Install homebrew

    http://brew.sh/

    Packages to install: ack android-sdk bash bash-completion brew-rmtree calc colordiff cowsay docker fish git git-lfs go gradle hh htop mongodb node python python3 ruby tree unrar zsh zsh-completions fzf ngrok ctags tmux neovim

@mdjaman
mdjaman / slugify.js
Created November 14, 2020 19:32 — forked from codeguy/slugify.js
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@mdjaman
mdjaman / git-deployment.md
Created September 29, 2020 15:58 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@mdjaman
mdjaman / Foo.php
Created August 30, 2019 09:31 — forked from grizzm0/Foo.php
Best practice form/input-filter setup for ZF3
<?php
namespace Application\Entity;
/**
* Class Foo
*
* @package Application\Entity
*/
class Foo
{
@mdjaman
mdjaman / manage-etc-hosts.sh
Created August 19, 2019 11:59 — forked from irazasyed/manage-etc-hosts.sh
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1

#MongoDB 3.2.x Sharding Sharding is used when the database is too large to run on a single server and you need to spread the load across multiple servers. The name itself refers to the breaking (sharding) of the data into seperate groups of data which will reside on different servers.

##Configuration Server Start the server on your server (myserver0)

mongod --configsvr --dbpath /data

On myserver1 start the shard giving the configuration server as the --configdb option

@mdjaman
mdjaman / openssl_encrypt_decrypt.php
Created November 5, 2018 15:55 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@mdjaman
mdjaman / parseFunction.js
Created October 23, 2018 20:39 — forked from lamberta/parseFunction.js
Parse a JavaScript string function definition and return a function object. Does not use eval.
/* Parse a string function definition and return a function object. Does not use eval.
* @param {string} str
* @return {function}
*
* Example:
* var f = function (x, y) { return x * y; };
* var g = parseFunction(f.toString());
* g(33, 3); //=> 99
*/
function parseFunction (str) {
@mdjaman
mdjaman / OrderDetails.php
Created August 14, 2018 23:29
Update storeProduct level after an order
<?php
/**
* This file is part of the Inventory project
* Copyright (c) 2016
* @author Marcel Djaman <marceldjaman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Organization name: leexij@gmail.com
Serial Key: eNrzzU/OLi0odswsqslJTa3IzHJIz03MzNFLzs+tMTQyNrcwsTQyAIEa5xpDAIFxDy8k