Skip to content

Instantly share code, notes, and snippets.

View FernE97's full-sized avatar

Eric Fernandez FernE97

View GitHub Profile
@FernE97
FernE97 / rails-laravel-notes.md
Last active April 9, 2021 21:56
Rails & Laravel comparisons

Rails & Laravel comparisons

Start console

# rails

bundle exec rails c
@FernE97
FernE97 / ssh.md
Last active August 29, 2015 13:57
SSH site transfer commands
ssh username@<host-1>

cd path/to/directory

tar cvzf content.tgz ./

host-1 send to host-2

@FernE97
FernE97 / file-path.php
Created March 4, 2014 00:27
Server file path
<?php
$dir = dirname(__FILE__);
echo "<p>" . $dir . "</p>";
@FernE97
FernE97 / zip-extractor.php
Created February 7, 2014 22:20
Extract zip files from server
<?php
if ( $_GET['file'] ) {
exec( 'unzip '.$_GET['file'] );
}
else {
echo 'Please pass the filename you would like to extract. ex: '.$_SERVER['SCRIPT_URL'].'?file=content.zip';
}
// www.example.com/tgz_extractor.php?file=content.tgz
@FernE97
FernE97 / wp_url.sql
Last active January 6, 2016 23:17
Useful for changing over WordPress urls
-- Avoid updating serialized strings with "NOT LIKE '%{%'"
UPDATE wp_options SET option_value = REPLACE(option_value, '//olddomain.com', '//newdomain.com') WHERE option_value NOT LIKE '%{%';
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '//olddomain.com', '//newdomain.com') WHERE meta_value NOT LIKE '%{%';
UPDATE wp_posts SET post_content = REPLACE(post_content, '//olddomain.com', '//newdomain.com') WHERE post_content NOT LIKE '%{%';
UPDATE wp_posts SET guid = REPLACE(guid, '//olddomain.com', '//newdomain.com') WHERE post_type = 'attachment';
-- File paths
UPDATE wp_options SET option_value = REPLACE(option_value, '/home/old/path', '/home/new/path') WHERE option_value NOT LIKE '%{%';
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '/home/old/path', '/home/new/path') WHERE meta_value NOT LIKE '%{%';
@FernE97
FernE97 / wp_roles.php
Last active December 22, 2015 10:09
WordPress: Display roles and remove by name
<?php
$wp_roles = new WP_Roles();
$names = $wp_roles->get_names();
print_r($names);
$wp_roles->remove_role('role_name');
@FernE97
FernE97 / tarball.bash
Last active December 18, 2015 04:38
Reminders for creating a tgz file
## Disable mac ._ hidden files
$ export COPYFILE_DISABLE=true
$ cd directory-name
## Filename then path to folder
$ tar -cvzf filename.tgz folder-name
## Period will zip all files from current directory
$ tar -cvzf filename.tgz .
@FernE97
FernE97 / excerpt.php
Created May 22, 2013 22:32
PHP: WordPress - Custom Excerpt Length Template Part
<?php
/**
* Custom Excerpt
*
* Needs $word_count set from the template it's being called from
*
* Template Usage:
*
* $word_count = 60;
* get_template_part( 'parts/excerpt' );
@FernE97
FernE97 / typekit-enqueue.php
Last active April 20, 2019 01:46
PHP: WordPress Typekit wp_enqueue
<?php
function h5bs_enqueue_scripts() {
wp_enqueue_script( 'typekit', '//use.typekit.net/xxxxxxx.js' );
}
add_action( 'wp_enqueue_scripts', 'h5bs_enqueue_scripts' );
function h5bs_typekit_inline() {