Skip to content

Instantly share code, notes, and snippets.

View AndreiTelteu's full-sized avatar

Andrei Telteu AndreiTelteu

View GitHub Profile
@bhubbard
bhubbard / run-all.sql
Last active March 13, 2018 19:23
These are various SQL Queries to run to update urls within a WordPress Database. These queries assume the table prefix is the standard `wp_`, if you have a custom prefix you will need to update the queries. I also recommend changing the default urls using this method: https://codex.wordpress.org/Changing_The_Site_URL or http://codex.wordpress.or…
/* Set our Old and New URLS */
SET @oldurl := "http://www.oldsite.com";
SET @newurl := "http://www.newsite.com";
/* Replaces URL in WordPress Home and Site URL in wp_options */
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
/* Replaces URL in GUID of all posts/cpt/etc */
/* https://deliciousbrains.com/wordpress-post-guids-sometimes-update/ */
UPDATE wp_posts SET guid = replace(guid, @oldurl, @newurl);
@skadimoolam
skadimoolam / checkbox.blade.php
Last active February 8, 2020 17:03
Customizable form partials for Laravel - https://laravelcollections.com
@php
$d = $d ?? null; // default value
@endphp
<div class="form-group row">
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label>
<div class="col-md-8">
<input id="{{ $n }}" type="checkbox" class="form-control" name="{{ $n }}" value="1" @if(old($n, $d) == '1') checked @endif>
@if ($errors->has($n))
<small class="text-danger">{{ $errors->first($n) }}</small>
@roselan
roselan / jquery.observe.src.js
Created July 25, 2012 15:13
jquery observe mutations plugin
(function( $ ){
$.fn.observe = function( callback, options ) {
var settings = $.extend( {
attributes: true,
childList: true,
characterData: true
},
options );
@taktos
taktos / Log.php
Created May 22, 2012 02:15
PHP tail viewer
<?php
/**
* Require the library
*/
require 'PHPTail.php';
/**
* Initilize a new instance of PHPTail
* @var PHPTail
*/
$tail = new PHPTail("/path/to/log");
@maddisondesigns
maddisondesigns / create-wp-admin.php
Created October 4, 2017 01:10
Create a new WordPress Administrator User
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
// Original script by Joshua Winn - https://joshuawinn.com/create-a-new-wordpress-admin-user-from-php
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
@maximilianschmitt
maximilianschmitt / jobs.js
Created September 3, 2014 23:47
Automated MySQL backups to S3 with node.js
'use strict';
var mysqlBackup = require('./mysql-backup');
var schedule = require('node-schedule');
schedule.scheduleJob({ hour: 22, minute: 0 }, mysqlBackup);
@brunotdantas
brunotdantas / downloadSheet.php
Created November 22, 2018 12:16
Create a spreadsheet with phpSpreadSheet (https://github.com/PHPOffice/PhpSpreadsheet) #Excel #xls #xlsx
<?php
// requiring autoload with the pluguin
require __DIR__ . '/../../vendor/autoload.php';
// invoking needed classes
use PhpOffice\PhpSpreadsheet\Spreadsheet; //class responsible to change the spreadsheet
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; //class that write the table in .xlsx
$spreadsheet = new Spreadsheet(); //instanciando uma nova planilha
@Awea
Awea / docker-compose.yml
Created March 21, 2018 12:28
Docker compose: PHP (5.4), composer, Apache, MySQL and phpMyAdmin
version: '3'
services:
api:
image: alterway/php:5.4-apache
environment:
PHP_php5enmod: 'mysqli'
HTTPD_a2enmod: 'rewrite headers'
volumes:
# ./api contains my PHP application
- "./api:/var/www/html"
@tegansnyder
tegansnyder / opcache.ini
Last active September 2, 2022 16:24
OpCache settings for Magento on PHP 5.5.14. Store this file as /etc/php.d/opcache.ini
; Enable Zend OPcache extension module
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
; The OPcache shared memory storage size.
@jeremyharris
jeremyharris / backup.sh
Created July 10, 2012 19:41
Quick bash script to backup mysql databases as separate files similar to how MySQL Workbench does
#!/bin/bash
#
# Script to backup all mysql tables as separate files
#
# $BACKUP_PATH/<date>/<db_name>/<host>_<table_name>.gz
# MySQL settings
MYSQL_USER="root"
MYSQL_PASS=""
MYSQL_HOST="localhost"