Skip to content

Instantly share code, notes, and snippets.

View jefferyf's full-sized avatar

Jeff Miller jefferyf

  • Minneapolis, MN
View GitHub Profile
@jefferyf
jefferyf / getAdvertisersBySerpKeyword.sql
Created May 2, 2013 15:35
Retrieve advertisers for stopping by serp keyword draft
select a.id from advertiser a
inner join advertiser_connection ac on ac.advertiser_id = a.id
where (
(a.analysis_complete is null OR a.analysis_complete = false) and
(a.last_analyzed is not null and a.last_analyzed < '2013-05-02 07:54:00')
) and ac.id in (
select distinct advertiser_connection_id from advertiser_connection_serp_entry as acse
inner join serp_keyword sk on sk.id = acse.serp_keyword_id
where (sk.last_bing_report_date is null and sk.retry_count_bing < 3)
or (sk.last_google_report_date is null and sk.retry_count_google < 3)
@jefferyf
jefferyf / reYextify.groovy
Created April 30, 2013 18:23
Recall Advertiser Directories data and save.
import com.reachlocal.grails.sales.Advertiser
import com.reachlocal.grails.sales.AdvertiserConnection
import com.reachlocal.grails.sales.AdvertiserConnectionSource
import com.reachlocal.grails.sales.AdvertiserConnectionProperty
import com.reachlocal.grails.yext.*
def advertiserId = xxxxx
def advertiser = Advertiser.get(advertiserId)
def yextSessionId = ctx.advertiserConnectionService.getYextSessionId(advertiser)
@jefferyf
jefferyf / getMissingHITs.groovy
Last active December 15, 2015 14:09
Gets Missing MT HIT data
import java.math.RoundingMode
import com.reachlocal.grails.amt.MechanicalTurkHIT
def mtService = ctx.mechanicalTurkService
//Determine the number of pages over which we need to iterate.
def node = mtService.searchHITs('CreationTime', 'Descending', 100, 1)
def numPages = (node.TotalNumResults.toInteger()/100).setScale(0, RoundingMode.UP)
println "searchHITs NumResults: ${node.NumResults}, PageNumber: ${node.PageNumber}, TotalNumResults: ${node.TotalNumResults}, TotalPages: ${numPages}"
long sd = System.currentTimeMillis()
@jefferyf
jefferyf / cleanHITs.groovy
Last active December 15, 2015 13:08
Clean up HITs missing from my local database
import java.math.RoundingMode
import com.reachlocal.grails.amt.MechanicalTurkHIT
def mtService = ctx.mechanicalTurkService
//Determine the number of pages over which we need to iterate.
def node = mtService.searchHITs('CreationTime', 'Descending', 100, 1)
println "searchHITs NumResults: ${node.NumResults}, PageNumber: ${node.PageNumber}, TotalNumResults: ${node.TotalNumResults}"
def numPages = (node.TotalNumResults.toInteger()/100).setScale(0, RoundingMode.UP)
//MT won't let us get more than 100 HITs per request, so iterate through the pages.
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.ContentType
import groovyx.net.http.Method
import groovyx.net.http.RESTClient
import com.reachlocal.grails.mozenda.MozendaAgentRun
import com.reachlocal.grails.mozenda.MozendaInputProperty
def http = new HTTPBuilder('http://localhost:8080/')
def html
@jefferyf
jefferyf / getHits.groovy
Last active December 15, 2015 04:59
Get info re mt hit
import com.reachlocal.grails.sales.Advertiser
import com.reachlocal.grails.sales.AdvertiserConnection
import com.reachlocal.grails.amt.*
import com.reachlocal.grails.question.*
String comment = "****************************************************"
def advertisers = Advertiser.findAllByLastAnalyzedIsNotNull([max: 20, sort: "id", order: "desc", offset: 0])
advertisers.each{advertiser->
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
@jefferyf
jefferyf / Howto.md
Created February 11, 2013 02:41 — forked from n1k0/Howto.md

Put test1.js and test2.js into a tests/ directory, then run the suite:

$ casperjs test tests/ --pre=pre.js --includes=inc.js --post=post.js
Test file: /Users/nperriault/tmp/pre-inc/pre.js                                 
Hey, I'm executed before the suite.
Test file: /Users/nperriault/tmp/pre-inc/tests/test1.js                         
# this is test 1
Hi, I've been included.
PASS Subject is strictly true
var casper = require('casper').create();
casper.start();
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)');
casper.viewport(1024, 768);
casper.thenOpen('http://jsbin.com/ifuma#noedit', function() {
this.capture('test.png');
var casper = require("casper").create();
var url = "https://github.com/search?langOverride=VimL&language=&q=vimrc&repo=&type=Repositories&start_value=" + casper.cli.get(0);
var repoLinks = [];
var fileLinks = [];
function getRepoLinks() {
var links = [];
$("div.results .result h2 a").each(function(i,el){
links.push(el.href);
});