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 / summernote-pastclean.js
Created September 18, 2016 02:27 — forked from jasonbyrne/summernote-pastclean.js
Plugin for Summernote WYSIWYG editor that cleans up the pasted in content
/**
* Summernote PasteClean
*
* This is a plugin for Summernote (www.summernote.org) WYSIWYG editor.
* It will clean up the content your editors may paste in for unknown sources
* into your CMS. It strips Word special characters, style attributes, script
* tags, and other annoyances so that the content can be clean HTML with
* no unknown hitchhiking scripts or styles.
*
* @author Jason Byrne, FloSports <jason.byrne@flosports.tv>
@jefferyf
jefferyf / checkGeoCoding.groovy
Created July 11, 2013 19:24
Compare the past google geocoding results with current api requests.
import com.reachlocal.grails.sales.Advertiser
import utils.GeoUtils
import groovy.sql.Sql
def dataSource = ctx.dataSource
def sql = Sql.newInstance(dataSource)
sql.eachRow("select * from advertiser where last_analyzed is not null and latitude is not null and longitude is not null limit 100 offset 0") { row ->
def advertiser = Advertiser.read(row["id"])
println advertiser.name
println "db: ${advertiser.latitude} | ${advertiser.longitude}"

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

username: vagrant
password: vagrant
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev
sudo aptitude install mysql-server mysql-client
sudo nano /etc/mysql/my.cnf

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key
class example_com {
file {
"/var/www/":
ensure => directory,
owner => vagrant,
group => vagrant,
mode => 775;
"/var/www/example.com/":
ensure => directory,
owner => vagrant,
@jefferyf
jefferyf / checkPushedItems.groovy
Created June 20, 2013 20:32
Check Salesforce items agains tracemessage instances denoting successful push
import com.reachlocal.grails.admin.TraceMessage
def traceMessages = TraceMessage.findAllByTextIlike("advertiser updated in salesforce of type%")
def tMessages = []
traceMessages.each{
def sp = it.text.split()
def item = [:]
item['type'] = sp[6]
item['id'] = sp[9]
item['advertiserId'] = it.domainId
@jefferyf
jefferyf / pushUpdate.groovy
Last active December 18, 2015 14:29
push updates to salesForce
import com.reachlocal.grails.sales.Advertiser
import com.reachlocal.grails.admin.TraceMessage
//Find the ids of all advertisers already pushed to salesforce
def pushedAdvertiserIds = TraceMessage.findAllByTextIlikeOrTextIlikeOrTextIlike(
"advertiser updated in salesforce%",
"unable to find salesforce%",
"went to update salesforce advertiser%"
)*.domainId
println "******* Advertisers to Exclude *********************************************"
import groovy.sql.Sql
def dataSource = ctx.dataSource
def sql = Sql.newInstance(dataSource)
sql.eachRow('SHOW FULL PROCESSLIST') { row ->
if (row['Time'] > 2000) {
sql.execute "KILL ${row['id']};"
}
}
@jefferyf
jefferyf / initializeACs.groovy
Created May 22, 2013 20:18
Cleans up uninitialized advertiserConnection instances
import com.reachlocal.grails.admin.TraceMessage
import com.reachlocal.grails.sales.*
def msgCount = 0
def connections = AdvertiserConnection.findAllByConnectionTypeAndReviewInfoPopulatedAndInitialized(AdvertiserConnectionType.YEXT_PAGE, true, false)
connections.each{
def msgs = TraceMessage.findAllByDomainIdAndDomainTypeAndText(it.id, "AdvertiserConnection", 'STATUS_CONNECTION_FORCED_ANALYSIS_COMPLETE')
if(msgs){
msgCount++