This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
home = 'http://your-blog.com' | |
sitemap_file = File.open('sitemap.xml', 'wb') | |
sitemap_file.puts('<?xml version="1.0" encoding="UTF-8"?> | |
<urlset | |
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Collapsible Tree Example</title> | |
<style> | |
.node circle { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gibbon = Gibbon::API.new | |
view = ActionView::Base.new('app/views/', {instance_variable_for_templates: 5324}, ActionController::Base.new) | |
campaign = gibbon.campaigns.create( | |
type: "regular", | |
options: { | |
list_id: 'xxxy', | |
from_email: 'you@example.com', | |
from_name: 'Your From', | |
subject: "the subject", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login to your server as root | |
# Stop ghost service to prevent database corruption | |
service ghost stop | |
# Do some manual backups | |
cd /var/www | |
CURRENT_GHOST_TAR=/var/www/ghost-$(date +"%Y-%m-%d").tar | |
tar cvf $CURRENT_GHOST_TAR /var/www/ghost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assumes gem install 'roo' has been done | |
require 'roo' | |
# Spreadsheet filename I want to read | |
file_path = ENV["CONTACT_PATH"] | |
puts "Importing data from " + file_path | |
# Opening the file using roo | |
spreadsheet = case File.extname(file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remove osxfuse if installed via homebrew: | |
> brew uninstall osxfuse | |
Install osxfuse binary and choose to install the MacFUSE compatibility layer: | |
http://sourceforge.net/projects/osxfuse/files/latest/download?source=files | |
Reboot (optional but recommended by osxfuse) | |
Install ntfs-3g via homebrew: | |
> brew update && brew install ntfs-3g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/http" | |
def start_server | |
# Remove the X to enable the parameters for tuning. | |
# These are the default values as of Ruby 2.2.0. | |
@child = spawn(<<-EOC.split.join(" ")) | |
XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'net/sftp' | |
require 'faster_csv' | |
# Load our constants | |
host = "my.server.com" | |
user = "my_username" | |
password = "my_password" | |
port = 12345 | |
dirs_to_create = "dirs_to_create.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fireway configured with: http://major.io/2007/07/01/active-ftp-connections-through-iptables/ | |
require 'net/ftp' | |
require 'stringio' | |
# allows us to upload files by content instead of writing to disk first | |
class Net::FTP | |
def puttextcontent(content, remotefile, &block) | |
f = StringIO.new(content) | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## vendor/extensions/database_form/app/models/database_form_page.rb | |
# Save form data | |
def save_form | |
form_response = FormResponse.new(:name => form_name) | |
form_response.content = form_data | |
if !form_response.save | |
@form_error = "Error encountered while trying to submit form. #{$!}" | |
false | |
else |
OlderNewer