Skip to content

Instantly share code, notes, and snippets.

@Usse
Usse / gallery.js
Created May 7, 2013 12:34
General gallery
@Usse
Usse / db.php
Created May 20, 2013 12:46
Fast and dirty PHP db connect
<?php
$mysql_hostname = "hostname";
$mysql_user = "username";
$mysql_password = "password";
$mysql_database = "database";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("Connection error");
mysql_select_db($mysql_database, $bd) or die("DB selection error");
?>
@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
@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 / yt_api.html
Last active December 17, 2015 19:38
Youtube api boilerplate
<div style="width:759px; height:427px;" id="ytPlayer"></div>
@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 / 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 / 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 / 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 / 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>");
}