Skip to content

Instantly share code, notes, and snippets.

View hassan's full-sized avatar

Hassan Schroeder hassan

View GitHub Profile
@hassan
hassan / gist:f7b6fdd25330586129fafed544404ec4
Created September 4, 2018 23:17
Researching assets problem with Rails 5.2.1; comment out js_compressor = :uglifier
16:14 ~/testcases/rails/my_app:(master) [ex:][ruby-2.4.4@my_app]$ gd config/environments/production.rb
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 692320f..3bb605a 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -23,7 +23,7 @@ Rails.application.configure do
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
- config.assets.js_compressor = :uglifier
@hassan
hassan / index.js
Last active November 9, 2016 20:36
node / mysql / lambda version returns nothing and no connection or query is logged to the MySQL query or error logs; the standalone version returns the query result
'use strict';
/* @flow */
const nconf = require('nconf');
nconf.env()
.file({ file: 'api-keys.json' });
const AWS = require('aws-sdk');
AWS.config.apiVersions = {
sns: '2010-03-31',
@hassan
hassan / word_value.rb
Last active October 15, 2015 16:24
Dictionary words with a value of 100.
class String
def alpha?
('a'..'z').cover?(downcase)
end
def letter_value
return 0 unless alpha?
('a'..'z').to_a.index(downcase) + 1
end
@hassan
hassan / new_date_test.exs
Last active October 12, 2015 16:37
Elixir/Timex DateTime construction with TZ name has UTC hour value
iex(11)> Date.now
%Timex.DateTime{calendar: :gregorian, day: 12, hour: 15, minute: 28, month: 10,
ms: 34, second: 33,
timezone: %Timex.TimezoneInfo{abbreviation: "UTC", from: :min,
full_name: "UTC", offset_std: 0, offset_utc: 0, until: :max}, year: 2015}
iex(12)> Date.local
%Timex.DateTime{calendar: :gregorian, day: 12, hour: 8, minute: 30, month: 10,
ms: 519, second: 1,
timezone: %Timex.TimezoneInfo{abbreviation: "PDT",
from: {:sunday, {{2015, 3, 8}, {2, 0, 0}}}, full_name: "America/Los_Angeles",
@hassan
hassan / gist:4b075406896e9ce4fa19
Last active August 29, 2015 14:27
Getting two different results pinging seneca.systems from a Comcast home service address and a server at Rackspace (ORD1, I think).
Yesterday I got similar results and couldn't access the site in a browser; today the browser is successful (!), but pings are as below:
10:12 ~[ruby-2.2.2]$ !406
ping seneca.systems
PING seneca.systems (54.204.1.127): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
^C
@hassan
hassan / bad-encoding
Created August 11, 2014 15:39
demonstrating a problem with nokogiri and mis-encoded web content
require 'net/http'
require 'open-uri'
require 'nokogiri'
url = "http://www.skin79mall.com/Search/"
params = {'id' => '1','SearchTxt' => '', 'hdLayerView' => '40'}
uri = URI.parse(url)
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
@hassan
hassan / POST request
Last active August 29, 2015 14:04
JSON data for Zotero API v3 generated in a Ruby class and uploaded (unsuccessfully) via the rest-client gem.
RestClient.post(
"https://api.zotero.org/users/1994685/items?v=3&key=<mysecretkey>",
self.as_json,
:content_type => :json
)
@hassan
hassan / gist:852127
Created March 3, 2011 01:15
heroku db:push error
heroku db:push error (excerpted, this is where it fails):
products: 0% | | ETA: --:--:--
Saving session to push_201103021709.dat..
!!! Caught Server Exception
Taps::InvalidData: Detected data that exceeds the length limitation of its column. This is
generally due to the fact that SQLite does not enforce length restrictions.
Table : products
Column : is_unique