This file contains hidden or 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
| <?php | |
| function strip_inline_styles($string, $allowed_styles = array()) { | |
| $pattern = '/style="([^"\']+)"/'; | |
| $parsed = preg_replace_callback($pattern, function($match = NULL) use($allowed_styles) { | |
| // Get style attribute values | |
| $styles = $match[1]; | |
| // Parse each sytle out | |
| $pattern2 = "/(?:([\w-]+?):([\w-]+);?)/"; | |
| $parsed_styles = preg_replace_callback($pattern2, function($match2 = NULL) use($allowed_styles, $styles) { |
This file contains hidden or 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
| function escapeString(string) { | |
| string = string.replace(/\\/g, "\\\\"). | |
| replace(/\n/g, "\\n"). | |
| replace(/\r/g, "\\r"). | |
| replace(/\t/g, "\\t"); | |
| if (string.indexOf("'") < 0) { | |
| return "'" + string + "'"; | |
| } | |
| string = string.replace(/"/g, "\\\""); | |
| return '"' + string + '"'; |
This file contains hidden or 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
| function find(root, obj) { | |
| var seen = []; | |
| function search(root, name, depth) { | |
| if (root === obj) { | |
| console.log(name); | |
| return; | |
| } | |
| if (!depth) { return; } | |
| if (seen.indexOf(root) >= 0) { return; } | |
| if (typeof root !== "object") { return; } |
This file contains hidden or 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
| #!/bin/bash -ex | |
| exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 | |
| # install ThinkUp on EC2 Ubuntu instance: | |
| # | |
| # @spara 12/23/10 | |
| # @waxpancake 1/3/11 | |
| # install required packages | |
| sudo apt-get update |
This file contains hidden or 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
| Vagrant::Config.run do |global_config| | |
| aptdir = (ENV['APTCACHE'] or "#{ENV['HOME']}/aptcache/") | |
| checkout = (ENV['COOKBOOKS'] or "#{ENV['HOME']}/openstack-cookbooks") | |
| ip_prefix = (ENV['IP_PREFIX'] or "192.168.76.") | |
| mac_prefix = (ENV['MAC_PREFIX'] or "080027076") | |
| fixed = (ENV['FIXED'] or "10.0.76.0/24") | |
| global_config.vm.define :chef do |config| | |
| suffix = "100" | |
| ip = "#{ip_prefix}#{suffix}" | |
| config.vm.box = "base" |
This file contains hidden or 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
| """ Monkey patch to hit wsgi apps when using urlfetch | |
| This will monkey patch App Engine's urlfetch.fetch with a fetch that hits a local | |
| wsgi app registered with add_intercept. This module is inspired by and borrows | |
| code from the wsgi-intercept project, which doesn't work with App Engine. | |
| This is intended only for the local SDK environment for unit tests. | |
| Usage: |
This file contains hidden or 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
| #!/bin/bash | |
| apt-get update | |
| apt-get install -y ruby ruby-dev rubygems libopenssl-ruby | |
| echo "gem: --bindir /usr/local/bin" >> ~/.gemrc | |
| gem install chef |
This file contains hidden or 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> | |
| <head> | |
| <title>ColorSpin</title> | |
| <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,user-scalable=no"/> | |
| <style> | |
| html { height: 100%; } | |
| body { | |
| height: 100%; | |
| margin: 0; |
This file contains hidden or 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
| # install git | |
| sudo apt-get install g++ curl libssl-dev apache2-utils | |
| sudo apt-get install git-core | |
| # download the Node source, compile and install it | |
| git clone https://github.com/joyent/node.git | |
| cd node | |
| ./configure | |
| make | |
| sudo make install | |
| # install the Node package manager for later use |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| # | |
| # Originally written by http://redartisan.com/tags/csv | |
| # Added and minor changes by Gavin Laking | |
| # Rewritten by Andrew Bennett for Ruby 1.9 | |
| # | |
| # Usage: ruby csv_to_fixture.rb file.csv [--json] | |
| # | |
| # "id","name","mime_type","extensions","icon_url" | |
| # "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif" |