Skip to content

Instantly share code, notes, and snippets.

View byjujohn's full-sized avatar

Byju John byjujohn

View GitHub Profile

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@pbojinov
pbojinov / parseAnalyticsCookie.js
Last active August 8, 2019 09:32
Parse Google Analytics __utmz cookie
// inspiration from http://stackoverflow.com/questions/1688657/how-do-i-extract-google-analytics-campaign-data-from-their-cookie-with-javascript
// readCookie is from // http://www.quirksmode.org/js/cookies.html
// utmcsr = utm_source
// utmccn = utm_campaign
// utmcmd = utm_medium
// utmctr = utm_term
// utmcct = utm_content
var parseAnalyticsCookie = function() {
var values = {};
@dsanson
dsanson / any2pandoc.sh
Created August 30, 2011 17:52
any2pandoc.sh: script that tries to convert documents thrown at it to pandoc's extended markdown
#!/bin/sh
# any2pandoc.sh
#
# A shell script that tries its best to convert documents thrown at it
# to pandoc's extended markdown.
#
# https://gist.github.com/1181510
#
# Depends on:
@learncodeacademy
learncodeacademy / deployUser.md
Last active October 8, 2022 18:56
Adding a deploy user in Linux

(wherever it says url.com, use your server's domain or IP)

Login to new server as root, then add a deploy user

sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy

And Update the new password

Best Practices for Azure Redis

Below are a set of best practices that I recommend for most customers. This information is based on my experience helping hundreds of Azure Redis customers investigate various issues.

Configuration and Concepts

  1. Use Standard or Premium Tier for Production systems. The Basic Tier is a single node system with no data replication and no SLA. Also, use at least a C1 cache. C0 caches are really meant for simple dev/test scenarios since they have a shared CPU core, very little memory, are prone to "noisy neighbor", etc.
  2. Remember that Redis is an In-Memory data store. Read this article so that you are aware of scenarios where data loss can occur.
  3. Configure your client library to use a "connect timeout" of at least 10 to 15 seconds, giving the system time to connect even under higher CPU conditions. If your client or server tend to be under high load
<?php
namespace App\Forms\Components;
use Closure;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Field;
use Illuminate\Support\Arr;
/** @see https://gist.github.com/awcodes/2d54ac60139fbb66acb34fc10bbb9fc5 */
@dopiaza
dopiaza / slackpost
Created September 5, 2013 12:33
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@lastguest
lastguest / Chainable.class.php
Last active March 17, 2023 09:46
PHP Class Chainable.Wrapper for convenient chaining methods.
<?php
/**
* Class Chainable
* Wrapper for convenient chaining methods
*
* @author Stefano Azzolini <lastguest@gmail.com>
*/
class Chainable {
private $instance = null;
@dukeofharen
dukeofharen / gist:e2c60b4478408b53d743
Last active June 18, 2023 19:20
WordPress like shortcode parser for PHP
<?php
//The content which should be parsed
$content = '<p>Hello, my name is John an my age is [calc-age day="4" month="10" year="1991"].</p>';
$content .= '<p>Hello, my name is Carol an my age is [calc-age day="26" month="11" year="1996"].</p>';
//The array with all the shortcode handlers. This is just a regular associative array with anonymous functions as values. A very cool new feature in PHP, just like callbacks in JavaScript or delegates in C#.
$shortcodes = array(
"calc-age" => function($data){
$content = "";
//Calculate the age
@anchetaWern
anchetaWern / laravel-ums.markdown
Created December 6, 2012 11:14
Building a User Management System in Laravel

There's no shortage of good resources for learning laravel. So instead of the usual introductory tutorial were just gonna learn Laravel by building a project from scratch and that's gonna be a User Management System.

I don't know if my definition of a User Management System is correct but here's my idea of what's it's capable of doing:

  • Register Roles
  • Register Users
  • Update Users