Skip to content

Instantly share code, notes, and snippets.

Avatar

Corey Smedstad smedstadc

  • United States
View GitHub Profile
View $.ajax progress event
```js
function handleUploadProgress(event) {
//...
}
function handleDownloadProress(event) {
//...
}
function prepareXHR() {
View gist:f2743b419d216bb8f19b
xinput --set-prop "Logitech USB Laser Mouse" "Device Accel Velocity Scaling" 1
xinput --set-prop "Logitech USB Laser Mouse" "Device Accel Constant Deceleration" 1.0
View jsonp.js
function logIt(it) {
console.log(it);
}
ajaxOptions = {
url: 'http://myrequest.com/?param1=true&param2=false',
dataType: 'jsonp',
jsonpCallback: 'logIt'
}
@smedstadc
smedstadc / deborator.rb
Created Dec 11, 2015
Basic Ruby Decorator
View deborator.rb
class Decorator
# Uncomment for Rails
#
# include ActionView::Helpers::UrlHelper
attr_reader :decorated
def initialize(decorated)
@decorated = decorated
init_hook
@smedstadc
smedstadc / read_only_hash.rb
Created Apr 12, 2015
Read Only Ruby Hash Snippet
View read_only_hash.rb
# By extending a regular ruby hash with this module the hash will behave as if
# it were an immutable object. The brackets and fetch methods will return copies
# of values and the assignment method will raise an exception.
#
# Other methods that should be redefined for a truly immutable hash object.
# :delete, :delete_if, :reject!, :select!, :keep_if, :merge!, :update
module ReadOnlyHash
def [](key)
value = super(key)
value ? value.dup : default