This file contains hidden or 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
| window.judo = { | |
| scrollTo: function(element, to, duration) { | |
| var start = element.scrollTop, | |
| change = to - start, | |
| currentTime = 0, | |
| increment = 20, | |
| easeInOutQuad = function (t, b, c, d) { | |
| t /= d/2; | |
| if (t < 1) return c/2*t*t + b; | |
| t--; |
This file contains hidden or 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 create = function(name, props){ | |
| var el = document.createElement(name); | |
| for (var p in props) el[p] = props[p]; | |
| return el; | |
| }; |
This file contains hidden or 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
| document.getElementsByTagName('button')[0].onclick = function () { | |
| scrollTo(document.body, 0, 1250); | |
| } | |
| function scrollTo(element, to, duration) { | |
| var start = element.scrollTop, | |
| change = to - start, | |
| currentTime = 0, | |
| increment = 20; | |
This file contains hidden or 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 params = {}; | |
| if (location.search) { | |
| var parts = location.search.substring(1).split('&'); | |
| for (var i = 0; i < parts.length; i++) { | |
| var nv = parts[i].split('='); | |
| if (!nv[0]) continue; | |
| params[nv[0]] = nv[1] || true; | |
| } |
This file contains hidden or 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 len = 100; | |
| var p = document.getElementsByClassName('truncate'); | |
| if (p) { | |
| for(i=0;i<p.length;i++){ | |
| var trunc = p[i].innerHTML; | |
| if (trunc.length > len) { | |
| /* Truncate the content of the P, then go back to the end of the | |
| previous word to ensure that we don't truncate in the middle of | |
| a word */ |
This file contains hidden or 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
| int = 0 | |
| x = 5 | |
| x.times do |t| | |
| json = HTTParty.get('http://randomuser.me/g/?seed=your-app-name'+int.to_s) | |
| unless User.find_by_email(json['user']['email']) | |
| User.transaction do | |
| new_u = User.create(name: json['user']['name']['first'].capitalize+' '+json['user']['name']['last'].capitalize, email: json['user']['email'], password: '@ggrego22') | |
| puts 'Welcome '+json['user']['name']['first']+' '+json['user']['name']['last'] | |
| new_u.remote_image_url = json['user']['picture'] | |
| new_u.save! |
This file contains hidden or 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
| t = Time | |
| min = (t/60).to_s | |
| sec = (t-(60*(t/60))).to_s | |
| sec.length == 1 ? (sec = '0'+sec) : (sec = sec) | |
| min+':'+sec |
This file contains hidden or 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
| <input type="text" placeholder="filter" id="filter"> | |
| <ul class="contacts"> | |
| <li class="filterable" data-index="all my lower case search terms"> | |
| All my lower case search terms | |
| </li> | |
| <li class="filterable" data-index="lowerlowercasecase"> | |
| Lower lower case case | |
| </li> | |
| <!-- add as much data as you want, add the selector class and add the terms in data-index --> | |
| </ul> |
This file contains hidden or 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
| # Run in bash: | |
| heroku pg:psql | |
| # Run in the psql CLI: | |
| \copy (SELECT id, name, longitude, latitude FROM cities) TO cities.csv CSV DELIMITER ',' | |
| # Run in the psql CLI: | |
| \q | |
| # Voila! csv is in your pwd |
This file contains hidden or 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
| data:text/html, | |
| <html> | |
| <head> | |
| <title>ColorType</title> | |
| <link href='http://fonts.googleapis.com/css?family=Merriweather' rel='stylesheet' type='text/css'> | |
| <style type="text/css"> | |
| html { font-family: "Merriweather" } * { -webkit-transition: all linear 1s; } | |
| </style> | |
| <script> | |
| window.onload=function(){ |
NewerOlder