Skip to content

Instantly share code, notes, and snippets.

View remibreton's full-sized avatar
🤖

Rémi Breton remibreton

🤖
  • Ubisoft
  • Montréal
View GitHub Profile
// Change 15 to the password length
(function(e){var t="abcdefghijklmnopqrstuvwxz1234567890!@#$%?".split(""),n="";do{var r=t[Math.floor(Math.random()*t.length)];n+=Math.random()>.5?r.toUpperCase():r.toLowerCase()}while(n.length<e);return n})(15)
var get = function(url, callback, error, format){
if(!format) format = "json";
var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
if(typeof callback === "function") callback(format == "json" ? JSON.parse(xmlhttp.responseText) : xmlhttp.responseText);
} else {
if(typeof error === "function") error(format == "json" ? JSON.parse(xmlhttp.responseText) : xmlhttp.responseText);
$.getJSON('//country-finder.herokuapp.com/?callback=?', function (data) {
return data.geo.country.toLowerCase()
});
@remibreton
remibreton / HTML: IE conditional tags
Last active December 16, 2015 07:19
HTML IE conditional tags
<!--[if lt IE 7]> <html class="no-js ie6 ie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 ie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 ie" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="no-js ie9 ie" lang="en"> <![endif]-->
<!--[if gt IE 9]> <!--> <html class="no-js modern" lang="en"> <!--<![endif]-->
@remibreton
remibreton / HTML: Head tags
Last active December 16, 2015 07:19
Social media friendly head tags
<!-- Prefetching -->
<link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="dns-prefetch" href="//ajax.googleapis.com">
<link rel="dns-prefetch" href="//googlecode.com">
<!-- Stylesheets -->
<link rel="stylesheet" href="http://site.com/style.css">
<!-- Meta -->
<title>Page title - Site name</title>
UPDATE table SET field = REPLACE(field, 'string', 'anothervalue') WHERE field LIKE '%string%';
/^(([^<>()[\]\\.,;:\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,}))$/.test('test@example.com');
UPDATE t1 LEFT JOIN t2 ON t2.id = t1.id SET t1.col1 = newvalue WHERE t2.id IS NULL
/(1)?( |-)?(\()?(\d{3})(\))?( |-)?(\d{3})( |-)?(\d{4})/.test('123 456 7890');
SELECT field, count(*) FROM table GROUP BY field HAVING count(*) > 1