Skip to content

Instantly share code, notes, and snippets.

Walter Lee Davis walterdavis

Block or report user

Report or block walterdavis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View test_mail.php
header('Content-type: text/plain');
ini_set('display_errors', true);
$from = '';
$to = '';
if(mail($to, 'test message from PHP', phpinfo(), array("From: $from"), "-f$from")){
print('Mail sent successfully');
walterdavis / .git-autocomplete.bash
Last active May 29, 2019
Auto-complete for git commands and branches. "Install" by adding `. ~/.git-autocomplete.bash` (without back-ticks) to your .bash_profile.
View .git-autocomplete.bash
# bash/zsh completion support for core Git.
# Copyright (C) 2006,2007 Shawn O. Pearce <>
# Conceptually based on gitcompletion (
# Distributed under the GNU General Public License, version 2.0.
# The contained completion routines provide support for completing:
# *) local and remote branch names
# *) local and remote tag names
View show-more.js
// find all the divs with the class name 'more', and hide them
// "listen" for clicks on any link with the class name 'more', and respond...
$(document).on('click', 'a.more', function(evt, elm){
// first, stop any normal reaction, like scrolling back to the top of the browser window
// starting from the link that was clicked, look up to its containing element...
// then select the following div with the class name 'more', and if it's hidden, show it, or vice-versa
// toggle the text inside the link that was clicked
View read-more.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Read more...</title>
<script src="//"></script>
body, html {
width: 100%;
height: 100%;
View nokogiri_example.rb
require 'nokogiri'
require 'json'
html = <<-HTML
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
View example.html
<link rel=”stylesheet” type=”text/css” href=”Resources/seasonal.php” />
<link rel="stylesheet" type="text/css" href="Resources/seasonal.php" />
View sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="">
View sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="">
View document.rb

Refactoring a view with partials

Rails gives you a lot of functionality for free if you know how to name things and where to place them in the file tree.

For example, look at the following stages of refactoring a list of child elements to the parent element, in the #show page.

Stage 1

class Article < ActiveRecord::Base
You can’t perform that action at this time.