Skip to content

Instantly share code, notes, and snippets.

View mrpunkin's full-sized avatar

Bryan Corey mrpunkin

View GitHub Profile
class ZohoOrder
include ActiveModel::Model
include ActiveModel::Validations::Callbacks
ZohoFields = [
'ID',
'Added_Time'
]
def self.converted_zoho_attributes
@mrpunkin
mrpunkin / Spam.rb
Created June 27, 2018 22:17
ZendeskAPI code to loop through specific tickets and mark them all as spam.
class Spam
require 'zendesk_api'
def self.client
@client ||= ZendeskAPI::Client.new do |config|
config.url = "https://pediment.zendesk.com/api/v2" # e.g. https://mydesk.zendesk.com/api/v2
config.username = "[email protected]"
config.password = "pedb00ks"
config.retry = true
end
{
"height":2448,
"width":3264,
"md5":"8c6e38213c009aa62ccbfed210db7189",
"exif":{
"EXIF ApertureValue":"None",
"Image ExifOffset":"204",
"EXIF ComponentsConfiguration":"YCbCr",
"GPS GPSLatitudeRef":"N",
"GPS GPSAltitudeRef":"0",
singular = {cats: false}
multiple = [{cats: false}, {dogs: true}]
puts Array(singular).inspect #=>
[[:cats, false]]
## Desired output: [{cats: false }]
puts Array(multiple).inspect #=>
[{:cats=>false}, {:dogs=>true}]
// Use images up to 1.2x their size to save file weight
@1x Breakpoints:
0 - 288: small (240w)
289 - 576: medium (480w)
577 - 720: large (600w)
721 - *: 1024x1024 (1024w)
@2x Breakpoints:
0 - 288: medium (480w)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrpunkin
mrpunkin / gist:8e7614fccba73078c5bb
Created May 5, 2015 22:09
Acronym humanize inflection
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym "URL"
inflect.human /url/i, "url"
end
def [](attr_name)
instance_variable_get("@#{attr_name}") || super(attr_name)
end
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LOAD DATA INFILE '/Users/Bryan/Sites/rubyapps/pc_3.0/db/data/geoplanet_data_7.5.' at line 7:
CREATE TEMPORARY TABLE geoplanet_changes (
woeid BIGINT(20) NOT NULL PRIMARY KEY,
replacement_woeid BIGINT(20) NOT NULL,
data_version VARCHAR(255)
);
LOAD DATA INFILE '/Users/Bryan/Sites/rubyapps/pc_3.0/db/data/geoplanet_data_7.5.1/geoplanet_changes_7.5.1.tsv' INTO TABLE geoplanet_changes
FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"'
(woeid, replacement_woeid, data_version);
@mrpunkin
mrpunkin / gist:7582190563863a84a904
Last active August 29, 2015 14:18
Trying to update woeid on geoplanet_adjacencies with matching replacement_woeid from a changes.tsv file in MySQL.
CREATE TEMPORARY TABLE geoplanet_changes (
woeid BIGINT(20) NOT NULL PRIMARY KEY,
replacement_woeid BIGINT(20) NOT NULL,
data_version VARCHAR
);
LOAD DATA INFILE 'infile.tsv' INTO TABLE geoplanet_changes
FIELDS TERMINATED BY '\\t' OPTIONALLY ENCLOSED BY '\"'
(woeid, replacement_woeid, data_version);