Skip to content

Instantly share code, notes, and snippets.

View magefast's full-sized avatar
🥶

Alex S magefast

🥶
View GitHub Profile
@gglnx
gglnx / gist:1391586
Created November 24, 2011 15:30
Add or remove trailing slash of the current URL
<?php
/**
* Add or remove trailing slash of the current URL
*/
function correctTrailingSlash($base = "/", $trainlingSlash = false) {
// Load the URI data
$redirect = false;
$requestUri = $_SERVER["REQUEST_URI"];
$queryString = $_SERVER["QUERY_STRING"];
$serverName = $_SERVER["SERVER_NAME"];
@miped
miped / magento
Created March 8, 2013 12:28
nginx + php-fpm magento setup
# /etc/nginx/sites-enabled/magento
server {
listen 80;
server_name ec2-184-72-68-219.compute-1.amazonaws.com;
root /var/www/magento/;
access_log /var/log/nginx/magento-access_log;
error_log /var/log/nginx/magento-error_log;
location / {
@mkdizajn
mkdizajn / magento transactional email insert cms static blocks
Last active November 18, 2021 15:02
magento transactional email insert cms static blocks
magento transaction email insert block
cms/content.phtml == just returt cms block content!
{{block type="cms/block" block_id="blockIdHere" template="cms/content.phtml"}}
<?php
$filename= "test.jpg";
list($w, $h, $type, $attr) = getimagesize($filename);
$src_im = imagecreatefromjpeg($filename);
$src_x = '0'; // начальная позиция x
$src_y = '0'; // начальная позиция y
$src_w = '100'; // ширина
$src_h = '100'; // высота
@peihsinsu
peihsinsu / gce-snapshot.sh
Created September 19, 2014 13:38
GCE daily scheduling snapshot backup
#!/bin/bash
# Environments
export PATH=/root/google-cloud-sdk/bin:$PATH
# Daily create snapshot for "backup_path" listed disks
# And remove snapshot 1 week old before
# Create snap date
export DT=`date +%Y%m%d`
@irazasyed
irazasyed / block-robots.php
Created February 12, 2015 13:14
PHP: Block Robots using Headers in PHP.
<?php
@header('X-Robots-Tag: "none, noindex, nofollow, noarchive, nosnippet, noodp, notranslate, noimageindex"');
@joashp
joashp / openssl_encrypt_decrypt.php
Created September 4, 2015 15:59
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@0xjac
0xjac / private_fork.md
Last active October 2, 2025 14:22
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@elalemanyo
elalemanyo / ampify_img.php
Last active August 27, 2021 12:33
Make img AMP-ready
<?php
/**
* Replace img tag with amp-img
*
* <amp-img src="[src]"
* width="[width]"
* height="[height]"
* layout="responsive"
* alt="[alt]">
* </amp-img>
@timneutkens
timneutkens / README.md
Last active April 15, 2021 12:10
Magento2 | Execute data-mage-init and x-magento-init in dynamic content (ajax request)

Execute data-mage-init and x-magento-init in dynamic content (ajax response)

Trigger .trigger('contentUpdated') on the element where dynamic content is injected.

$.ajax({
    url: 'https://www.example.com',
    method: 'POST',
    data: {
 id: '1'