Skip to content

Instantly share code, notes, and snippets.

@IvanRybakov
IvanRybakov / Cors.php
Created August 25, 2019 21:12 — forked from drewjoh/Cors.php
Laravel CORS Middleware
<?php // /app/Http/Middleware/Cors.php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
return $next($request)
@IvanRybakov
IvanRybakov / grumphp.yml
Last active May 16, 2019 17:56
grumphp.yml for Magento 2 project (in magento subfolder of git repo) with installed Magento2 coding standard
parameters:
git_dir: .
bin_dir: magento/vendor/bin
ascii:
failed:
- grumphp-grumpy.txt
- nopecat.txt
succeeded:
- grumphp-happy.txt
- me-gusta.txt
@IvanRybakov
IvanRybakov / pre-commit
Created April 9, 2019 15:05
Pre-commit hook for git with phpcs and phpcbf (auto-correct obvious violations)
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
@IvanRybakov
IvanRybakov / dirty_passwd_adjust_cow.c
Created October 25, 2016 19:21 — forked from ngaro/dirty_passwd_adjust_cow.c
A dirty cow exploit that automatically finds the current user in passwd and changes it's uid to 0
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
@IvanRybakov
IvanRybakov / xml.py
Created September 19, 2016 23:20 — forked from chrisguitarguy/xml.py
Parse an XML sitemap with Python, requests and BeautifulSoup
from __future__ import with_statement # we'll use this later, has to be here
from argparse import ArgumentParser
import requests
from BeautifulSoup import BeautifulStoneSoup as Soup
def parse_sitemap(url):
resp = requests.get(url)
# we didn't get a valid response, bail
@IvanRybakov
IvanRybakov / validate_m2_package.php
Created February 15, 2016 10:39 — forked from alankent/validate_m2_package.php
Magento Marketplace beta Composer package ZIP file validator script.
#!/usr/bin/php
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See https://github.com/magento/magento2/blob/develop/COPYING.txt for license details.
*/
/**
* validate_m2_package.php - a script that checks a given M2 zip package to ensure
* it is structured correctly and has all the required files.
@IvanRybakov
IvanRybakov / customers.sql
Created February 12, 2016 11:54 — forked from leek/_Magento1_DeleteTestData.md
Magento - Delete All Test Data
SET FOREIGN_KEY_CHECKS=0;
-- Customers
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;