This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_number?(str) | |
true if Float(str) rescue false | |
end | |
def prettify(str) | |
str = str.to_f | |
str.to_i == str ? str.to_i : str | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var resizeText = function(el) { | |
elNewFontSize = (parseInt($(el).css('font-size').slice(0, -2)) - 1) + 'px' | |
console.log(elNewFontSize); | |
$(el).css('font-size', elNewFontSize) | |
}; | |
elements = $('.long-text'); | |
elements.each(function(index, el) { | |
while(el.scrollWidth > el.offsetWidth) { | |
resizeText(el); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
response = HTTParty.get("http://api.giffy.co/gifs/limit/1/offset/#{rand(8000)}") | |
@gif = JSON.parse(response.body)['gifs'].first['url'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$('input:checkbox').attr('checked', 'checked'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyController < ApplicationController | |
def new | |
end | |
def create | |
@job_id = MyWorker.perform_async(my_params) | |
render :status => :accepted, :json => { jobId: @job_id } | |
end | |
def fetch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://stackoverflow.com/questions/497790 | |
var dates = { | |
convert:function(d) { | |
// Converts the date in d to a date-object. The input can be: | |
// a date object: returned without modification | |
// an array : Interpreted as [year,month,day]. NOTE: month is 0-11. | |
// a number : Interpreted as number of milliseconds | |
// since 1 Jan 1970 (a timestamp) | |
// a string : Any format supported by the javascript engine, like | |
// "YYYY/MM/DD", "MM/DD/YYYY", "Jan 31 2009" etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
monitorEvents(window, 'click'); | |
monitorEvents(window, 'scroll'); | |
//After store as global variable, save to clipboard | |
copy($_) | |
//timeline | |
console.timeline('xxx'); | |
console.timelineEnd('xxx'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | |
<CORSRule> | |
<AllowedOrigin>*</AllowedOrigin> | |
<AllowedMethod>GET</AllowedMethod> | |
<AllowedMethod>HEAD</AllowedMethod> | |
</CORSRule> | |
<CORSRule> | |
<AllowedOrigin>http://mydomain.com</AllowedOrigin> | |
<AllowedMethod>GET</AllowedMethod> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TeaClock | |
attr_accessor :timer | |
attr_accessor :ui | |
def initialize(minutes) | |
#Tie ui object | |
self.ui = StdioUi.new | |
#Tie timer object. Pass ui object so that the final implementation of notify (after plugins are loaded) is called | |
self.timer = SleepTimer.new(minutes, ui) | |
#Extend ui or timer objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | |
<title>Your Message Subject or Title</title> | |
<style type="text/css"> | |
/* Based on The MailChimp Reset INLINE: Yes. */ | |
/* Client-specific Styles */ | |
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */ |
OlderNewer