Skip to content

Instantly share code, notes, and snippets.

@ammardev
ammardev / multi-processing-demo.php
Created February 13, 2023 05:04
Multi Processing Using PHP
<?php
class ProcessManager
{
private array $processes = [];
public function run($callback): void
{
$pid = pcntl_fork();
@ammardev
ammardev / deployment.yml
Last active January 14, 2023 21:30
مثال بسيط Github Actions + Laravel Envoy
name: Deployment
run-name: Deployment
on:
push:
branches:
- 'master' # انا مهتم بالرفع فقط عند دمج أي شيء على الفرع الرئيسي
jobs:
stage:
runs-on: ubuntu-latest
<script type="text/ecmascript">
import _ from 'lodash';
import moment from 'moment';
export default {
props: ['value', 'options', 'optionId', 'optionText'],
data() {
return {
searchTerm: '',
@ammardev
ammardev / cssh-tmux.sh
Last active November 17, 2021 15:01
tmux cluster ssh
#!/bin/bash
tmux new-session -d -s mySession -n myWindow
tmux send-keys -t mySession:myWindow "ssh $1" Enter
shift
for var in "$@"
do
tmux split-window -h
tmux send-keys -t mySession:myWindow "ssh ${var}" Enter
function changeTab(tabName) {
$('.tabstest .pmtab').removeClass('active');
$('.tabcontent').removeClass('active');
$('.tabstest .pmtab[data-tab='+ tabName + ']').addClass('active');
$("#"+tabName).addClass('active');
localStorage.setItem('current', tabName);
}
$(document).ready(function(){
var current = localStorage.getItem('current');
<?php
# Problem 1:
# Functions:
function previousPosition(int $current, int $shift, int $length) {
return ($amount = $current - $shift) < 0 ? $length + $amount : $amount;
}
function rotatePrevious(array $list, int $shift, $startFrom, $replaceWith, $startRoot) {
<?php
# Problem 2:
# Function:
function mergeSortedSequences(array $list1, array $list2) : array {
$l1pointer = 0;
$l2pointer = 0;
$result = [];
while ($l1pointer < count($list1) && $l2pointer < count($list2)) {
<?php
# Problem 2:
# Function:
function listFramer(array $list): string {
$longestWord = 0;
foreach($list as $item)
if(($itemLength = strlen($item)) > $longestWord)
$longestWord = $itemLength;
function dce()
{
docker-compose exec "$1" bash
}
function _dce()
{
services=$(docker-compose config --services 2>/dev/null)
if [ -z $services ]; then
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
/**
* Created on 11/30/17
*
* @author <a href="mailto:3mmar.g97@gmail.com">Ammar Al-khawaldeh</a>
*/