Skip to content

Instantly share code, notes, and snippets.

View StanleyMasinde's full-sized avatar
🎯
Focusing

Stanley Masinde StanleyMasinde

🎯
Focusing
View GitHub Profile
@StanleyMasinde
StanleyMasinde / xmlhttp.js
Created January 19, 2024 15:48
XMLHTTP Request
const req = new XMLHttpRequest()
req.addEventListener('load', (event) => {
console.log(event.target.response)
})
req.open('https://jsonplaceholder.typicode.com/posts')
req.send()
@StanleyMasinde
StanleyMasinde / promises.js
Created October 28, 2023 13:22
A simple test on Promise.all()
// Promises without dates
(async function main() {
const promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Promise 1')
}, 5000)
})
const promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
name: Deploy
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
@StanleyMasinde
StanleyMasinde / perms.md
Last active June 16, 2023 22:36 — 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  # If you have multiple users that need to manage the server.
sudo adduser $USER webmasters # Add your current user to the webmasters group
sudo chown -R root:webmasters /var/www
sudo find /var/www -type f -exec chmod 664 {} \;
sudo find /var/www -type d -exec chmod 775 {} \;
@StanleyMasinde
StanleyMasinde / deploy.sh
Last active June 4, 2022 19:16
A shell script to help in application deployment
#!/bin/sh
## Set error handling
set -e
## Set debug mode
#set -x
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
@StanleyMasinde
StanleyMasinde / smart-commit.sh
Created February 20, 2021 12:47 — forked from am-kantox/smart-commit.sh
Bash script that prefixes commits with a JIRA (CO-400)
#!/usr/bin/env bash
# based on https://github.com/sbimochan/smart-commit/blob/master/commit
# am@aleksei  feature/CO-400-some-branch-name$ ./smart-commit.sh "Foo bar."
# → [feature/CO-400-some-branch-name f70ebbf167] CO-400: Foo bar.
set -euo pipefail
if [ -z "${1:-}" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
@StanleyMasinde
StanleyMasinde / HandlePutFormData.php
Last active July 20, 2020 10:24 — forked from Stunext/HandlePutFormData.php
Laravel: Middleware to support multipart/form-data in PUT, PATH and DELETE requests
<?php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* @author https://github.com/Stunext
*
#!/bin/bash
echo "Starting the process"
sudo apt update && sudo apt upgrade
echo "Echo installing php"
sudo apt install php
echo "Done installing php and apache2"
#!/bin/bash
# Update the server with the latest changes
# Put the application in maintenance mode
php artisan down
echo "The Application in in maintenance mode"
# Git pull from remote
echo "Starting the update"
@StanleyMasinde
StanleyMasinde / gist:9d114c7c864182b46af96ce3dabe33cf
Created December 5, 2019 12:45 — forked from lgalaz/gist:aec80abd40350161ff63
Server sent events with Laravel
Using nginx version: nginx/1.6.2 and Laravel 5
In the controller:
use Symfony\Component\HttpFoundation\StreamedResponse;
- - - - - - Some method - - - - - - - - -
$response = new StreamedResponse();
$response->headers->set('Content-Type', 'text/event-stream');
$response->headers->set('Cache-Control', 'no-cache');
$response->setCallback(
function() {