Skip to content

Instantly share code, notes, and snippets.

View cosmomathieu's full-sized avatar
🎯
Focusing

Cosmo Mathieu cosmomathieu

🎯
Focusing
View GitHub Profile
@cosmomathieu
cosmomathieu / README.md
Last active June 5, 2020 01:23
Creating GitHub packages

Publishing to GitHub Packages

Login

npm login --registry=https://npm.pkg.github.com --scope=@pagestudiocms

Username: 
Password: <gitHub access token>
Email (optional):
@cosmomathieu
cosmomathieu / css.php
Last active May 28, 2020 15:41
Adding styles directly into the page template from the controller
<?php
// An example of how to generate inpage css for body
// Typically saved in a database OR in theme folder as style.custom.css
$encodedStyles = json_encode([
'body' => [
'font-family' => '"NeutraText-Book"',
'font-size' => '14px',
'background-color' => 'rgba(255, 255, 255, 1)',
#!/bin/bash
### Set Language
TEXTDOMAIN=virtualhost
### Set default parameters
action=$1
domain=$2
rootDir=$3
owner=$(who am i | awk '{print $1}')
apacheUser=$(ps -ef | egrep '(httpd|apache2|apache)' | grep -v root | head -n1 | awk '{print $1}')
@cosmomathieu
cosmomathieu / FileManager.php
Last active April 8, 2023 02:58
Using FlySystem with Digital Oceans Spaces
<?php
class FileManager
{
const USER_FOLDER = siteData()->userFolder;
protected $adapter;
public function __construct($adapter)
{
@cosmomathieu
cosmomathieu / JavaScriptClassWithEventsListener.js
Last active August 7, 2019 12:59
An implementation of a JavaScript module with an event emitter/listener system
/**
* @see https://jsfiddle.net/cosmointeractive/ukb8Lpm1/
*/
const events = (function() {
'use strict'
var _triggers = {};
const on = function(event, callback) {
@cosmomathieu
cosmomathieu / README.md
Last active September 2, 2021 13:42
A collection of helpful bash commands

Bash Scripts and Commands

A collection of helpful bash scripts.

List

File Name Description
mkdirandmove.sh Creates a new folder in the current directory and then moves everything into that folder
@cosmomathieu
cosmomathieu / common.php
Last active August 16, 2019 13:28
A set of procedual functions to handle common text manipulation tasks in PHP
<?php
/**
* Return the current server date and time to the caller
*
* @param $format Date format
* @return datetime Formated date and time
*/
if( ! function_exists('datetime')){
function datetime($format = 'Y-m-d H:i:s') {
<?php
$file = $file['temp']['file'];
$image = new Image($file);
$image->save(${filename}, [optional]${quality}); // Use this when moving a file from one location to another. Especially in the case when we upload a file to the server.
$image->resize(${width}, ${height}, [optional]${crop}, [optional]${replace});
$image->createThumb(${width}, ${height}, [optional] ${save_path});
$image->getWidth();
$image->getHeight();
@cosmomathieu
cosmomathieu / README.md
Last active March 11, 2020 13:24
VirtualHost site creation script

VirtualHost site creation script

Create a VirtualHost via PHP CLI script

Usage

# sudo ./sitegen/cli ${siteName} ${webRoot}
sudo ./sitegen/cli mywebsitename.local /var/www