Skip to content

Instantly share code, notes, and snippets.

apt-get install ruby-dev
gem install hoe
sudo apt-get install libxml2-dev libxslt1-dev
apt-get install libopenssl-ruby
gem install nokogiri
gem install mechanize
@oslego
oslego / scrollTo.js
Last active September 22, 2015 10:32 — forked from james2doyle/scrollTo.js
a native scrollTo function in javascript that uses requestAnimationFrame and easing for animation
// easing functions http://goo.gl/5HLl8
Math.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) {
return c/2*t*t + b
}
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
/*
I used your style, your header div, but with a slide like this
<section data-state="showHeader" data-header="custom head">
<p>Hello</p>
</section>
*/
Reveal.addEventListener( 'slidechanged', function( event ) {
@oslego
oslego / YQL Podcast
Created December 14, 2010 14:26
Using YQL to get titles and tracks filtered by a search term
select channel.item.enclosure.url, channel.item.title from xml where url='http://www.vibefm.ro/podcast.xml' and channel.item.title like "%Corral%"
@oslego
oslego / SafariKeypressEvents.js
Created February 8, 2011 16:45
Method for handling keypress events on non-input elements in Safari (and other webkit-based browsers)
var div = document.getElementById("demo");
div.setAttribute("tabIndex", 0);
div.focus();
div.addEventListener("keypress", function(e){
console.log(e.keyCode);
})
@oslego
oslego / gist:854869
Created March 4, 2011 16:00
Bookmarklet Template: Loader
javascript:(function(){var%20d=document,h=d.getElementsByTagName('head')[0],s=d.createElement('script');s.src='SRC_GOES_HERE';s.type='text/javascript';h.appendChild(s)})()
@oslego
oslego / versionCheck.js
Created March 5, 2011 14:05
Check two string representations of versions and return true if the testVersion is equal or greater than the testVersion.
/**
check two string respresentations of versions.
returns true if the version to test is equal or greater than the required minimum version
returns false if the test version is lower than the minimum version
@param {String} minVersion Minimum required version to test against
@param {String} testVersion Version to test
@return {Boolean}
@oslego
oslego / loadStyles.js
Created March 8, 2011 13:56
Load any number of CSS files to the current document's head.
//Loads CSS files into the head of the current document
//using arguments to reference any number of styles
function loadStyles(){
var i = 0,
d = document,
s = d.createElement("link"),
h = d.getElementsByTagName('head')[0],
createStyle = function(src){
s = s.cloneNode(false);
s.rel ="stylesheet";
@oslego
oslego / replaceURLWithHTMLLinks.js
Created March 11, 2011 15:38
replace URL-like strings with HTML link elements
@oslego
oslego / makeSearchInput.js
Created March 30, 2011 13:29
Convert a plain text field into a search field with focus/blur behavior
/**
Turn a text input into a search input with added behavior
On focus, if input value is the same as defaultValue, replace with blank
On blur, if input value is empty or full of whitespace replace with defaultValue
@param input {HTMLInputElement} element to behave as search input
@param defaultValue {String} string to be default value of the input
**/
function makeSearchInput(input, defaultValue){
input.setAttribute("data-default", defaultValue);