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 / _button-groups.scss
Last active August 22, 2018 13:53
Porting Bootstrap 3's btn-group-justified to Bootstrap 4 using scss (sass)
// Justified button groups - table
// ----------------------
.btn-group-justified {
display: table;
width: 100%;
table-layout: fixed;
border-collapse: separate;
.btn,
.btn-group {
@cosmomathieu
cosmomathieu / PersitanceLayer.md
Last active July 31, 2018 20:17
Models in PS

Persistence layer

Magento uses an active record pattern strategy for persistence. In this system, the model object contains a resource model that maps an object to one or more database rows. A resource model is responsible for performing functions such as:

Executing all CRUD (create, read, update, delete) requests. The resource model contains the SQL code for completing these requests.

Performing additional business logic. For example, a resource model could perform data validation, start processes before or after data is saved, or perform other database operations.

If you expect to return multiple items from a database query, then you would implement a special type of resource model known as a collection. A collection is a class that loads multiple models into an array-like structure based on a set of rules. This is similar to a SQL WHERE clause.

# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# User-friendly check for sphinx-build
@cosmomathieu
cosmomathieu / gist:6b5cf8a1ab7c3d1d38219f2966ed3858
Created July 3, 2018 17:26
Convert MySQL Insert Statements to Updates
@see https://stackoverflow.com/questions/5156679/transform-mysql-update-statements-to-insert-statements
@see https://regex101.com/r/LkyFq4/1
@cosmomathieu
cosmomathieu / module-example-2.js
Last active February 18, 2019 16:55 — forked from nathansmith/module_pattern_init.js
Init + Module Pattern JS
//
// Revealing pattern
//
var basketModule = (function() {
var basket = []; //private
return { //exposed to public
addItem: function(values) {
basket.push(values);
},
getItemCount: function() {
@cosmomathieu
cosmomathieu / filedownloader.js
Created June 6, 2018 16:57 — forked from DavidMah/filedownloader.js
File Download requests using jquery/POST request with psuedo ajax
// Takes a URL, param name, and data string
// Sends to the server.. The server can respond with binary data to download
jQuery.download = function(url, key, data){
// Build a form
var form = $('<form></form>').attr('action', url).attr('method', 'post');
// Add the one key/value
form.append($("<input></input>").attr('type', 'hidden').attr('name', key).attr('value', data));
//send request
form.appendTo('body').submit().remove();
@cosmomathieu
cosmomathieu / DependencyInjectionContainer.php
Created May 29, 2018 18:10
Playing around with PHP Dependency Injection
<?php
/**
* In these examples:
* - The Controller needs a view renderer
* - The view renderer needs a Database and a Logger
*
* Note, that the interfaces aren't being defined here, just assume they're what you'd expect.
*/
interface DatabaseInterface
@cosmomathieu
cosmomathieu / wordpress-functions.php
Last active June 28, 2018 14:09
WordPress shortcodes to show and hide text based on user authentication state
<?php
if ( ! function_exists('show_logged_in_content')) {
/**
* Display text to logged in Donation users only
*
* <code>
* [loggedin]This content will only be displayed to logged in users.[/loggedin]
* </code>
*
@cosmomathieu
cosmomathieu / upgrade-php.sh
Last active March 11, 2020 13:26
Upgrading PHP 5.5.9 to 5.6
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 php5.6-bcmath php5.6-bz2 php5.6-dba php5.6-imagick php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-soap php5.6-xml php5.6-zip
sudo a2dismod php5
sudo a2enmod php5.6
sudo service apache2 restart
@cosmomathieu
cosmomathieu / update-mysql.md
Created February 20, 2018 16:10
Upgrade MySQL 5.5 to 5.7 Ubuntu 16

Upgrade MySQL 5.5 to 5.7 Ubuntu 16

First of all , Backup All your Database.

mysqldump --all-databases > all_databases.sql

Grab the library which contains the 5.7 verson

wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb