Skip to content

Instantly share code, notes, and snippets.

/************************************
* Store Account, Campaign, and AdGroup Level Quality Score
* Version 1.2
* ChangeLog v1.2
* - Changed status to ENABLED
* ChangeLog v1.1
* - Added APPEND option
* - Added ability to create spreadsheet sheets
* - Updated logic for faster spreadsheet insertion
* Created By: Russ Savage

RegExp.escape(string)

Computes a new version of a String value in which certain characters have been escaped, so that the regular expression engine will interpret any metacharacters that it may contain as character literals.

When the escape function is called with one argument string, the following steps are taken:

  1. Let string be ToString(string).
  2. ReturnIfAbrupt(string).
  3. Let length be the number of characters in string.
  4. Let R be the empty string.
@milesgrimshaw
milesgrimshaw / Quirky.rb
Created June 11, 2014 00:27
Ruby script to collect data from Quirky product pages
# Last Updated: 2014.06.05
# Gems to include
require 'Nokogiri'
require "open-uri"
require 'pp'
require 'json'
require 'csv'
# def get_default_data( default_stats, default_pricing, date_range )
@benjaminjackson
benjaminjackson / kickstarter_csv.rb
Created April 19, 2012 02:24
Screen Scraping Script for Kickstarter Projects
# Usage: ruby kickstarter_csv.rb output.csv
require 'rubygems'
require 'kickstarter'
LAST_REPORT_DATE = Date.parse("April 28, 2011")
FIELDS = [:name, :pledge_amount, :pledge_percent, :pledge_deadline, :owner]
def fetch_projects_for_category category, file
@josephg
josephg / saver.coffee
Created November 5, 2011 13:56
Script to automatically re-save a sharejs document as its edited.
# This script watches for changes in a document and constantly resaves a file
# with the document's contents.
#
# Usage: coffee saver.coffee -d <DOCNAME> [--url http://somehost:8000/sjs] [-f filename]
client = require('share').client
fs = require('fs')
argv = require('optimist')
.usage('Usage: $0 -d docname [--url URL] [-f filename]')
@derekmartinla
derekmartinla / gist:c660f7d326a04e2d418e
Created April 9, 2015 16:20
Ad-Group Callout Extension Example
// Set callout extensions on the ad group level for all active ad groups based on text sent in createCallouts()
// Change campaign selection criteria as needed
function main() {
campIter = AdWordsApp.campaigns().withCondition("CampaignName contains Brand").withCondition("CampaignName does_not_contain Remarketing").get();
var callouts = createCallouts();
while (campIter.hasNext()) {
camp = campIter.next();
@zirneklitis
zirneklitis / byzanz-record-window
Created February 12, 2013 05:13
Graphical interface (zenity based shell script) for command line utility byzanz-record
#!/bin/bash
# AUTHOR: (c) eko@lanet.lv 2013.02.07.
# NAME: byzanz window recorder 0.0.3
# DESCRIPTION: A script to record GIF, OGV, FLV and WebM screencasts.
# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
# DEPENDENCIES: byzanz, zenity
# Based on http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast
# Delay before starting
<?php
/* Here is some generic error handling code, not related to actual sample */
set_error_handler('my_error_handler');
set_exception_handler('my_exception_handler');
function my_exception_handler($e) {
exit('Houston! We have a problem: <br />'.$e);
}
@sarahmonster
sarahmonster / db_local.sql
Last active December 19, 2015 03:19
A series of files to include in your git directory in order to automate WordpPress database syncs.
USE DBNAME_LOCAL;
UPDATE wp_EXT_options SET option_value="http://LOCALURL:8888" WHERE option_name="siteurl";
UPDATE wp_EXT_options SET option_value="http://LOCALURL:8888" WHERE option_name="home";
@toddbluhm
toddbluhm / app.js
Created July 11, 2013 06:09
This is a modified version of the Cloudant reverse-proxy solution for setting up a CORS Couchdb request. The version uses the nano framework instead of request framework which allows for the use of cookie authentication rather than just hardcoded basic auth. This solution was tested using Pouchdb in the browser, reverse-proxied back through a no…
var forward = require('./middleware/forward.js'); //reverse proxy
var nano = require('connect-nano');
// instantiate `app` et al
//After app.use(express.cookieParser());
app.use(nano('https://username.cloudant.com')),
app.use(forward(/\/db\/(.*)/));