Skip to content

Instantly share code, notes, and snippets.

@Usse
Usse / youtube.txt
Created July 1, 2013 12:14
Youtube thumbs
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
The first one in the list is a full size image and others are thumbnail images.
For the high quality version of the thumbnail use a url similar to this:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
@Usse
Usse / tap-highlight-color.js
Created June 27, 2013 13:20
Overrides the highlight color shown when the user taps a link or a JavaScript clickable element in Safari on iPhone.
div {
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
@Usse
Usse / test_if_mention.js
Created June 22, 2013 12:43
Wrap with an <a> element all the mention occurrences in a string.
test_if_mention : function(string) {
var thestring=string;
var pattern = /@([a-zA-Z0-9_]+)/g;
return thestring.replace(pattern, "<a href='http://twitter.com/$1' target='_blank'>@$1</a>");
}
@Usse
Usse / hideUrlBar.js
Last active December 18, 2015 15:19
Hide the url bar Works on iOS and some Android phones
function hideURLbar() {
if (window.location.hash.indexOf('#') == -1) {
window.scrollTo(0, 1);
}
}
@Usse
Usse / iPad.js
Created June 6, 2013 14:43
Fix orientation change bug on iPad and some other tablets
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
document.body.addEventListener('gesturestart', function () {
viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
}, false);
}
}
@Usse
Usse / isMailOk.js
Created June 3, 2013 08:13
email validation
function isMailOk(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
@Usse
Usse / quotes.txt
Last active December 17, 2015 21:49
just for fun.. :)
1. “There are two ways of constructing a software design: One way is to make it so simple that there are
obviously no deficiencies, and the other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult.”
- C.A.R. Hoare (British computer scientist, winner of the 1980 Turing Award)
2. “If debugging is the process of removing software bugs, then programming must be the process of putting
them in.”
- Edsger Dijkstra (Dutch computer scientist, winner of the 1972 Turing Award)
3. “Measuring programming progress by lines of code is like measuring aircraft building progress by weight.”
@Usse
Usse / yt_api.html
Last active December 17, 2015 19:38
Youtube api boilerplate
<div style="width:759px; height:427px;" id="ytPlayer"></div>
@Usse
Usse / socialEU.js
Created May 22, 2013 13:45
Share strings twitter facebook google plus pinterest tumblr
****TWITTER****
https://twitter.com/intent/tweet?text=[TEXT]
****FACEBOOK****
http://www.facebook.com/sharer.php?u=[URL]
****GOOGLE PLUS****
https://plus.google.com/share?url=[URL]
****PINTEREST****
@Usse
Usse / facebook.html
Created May 20, 2013 12:51
Facebook: add tab to page
http://www.facebook.com/add.php?api_key=APP_API_KEY&pages=1