Skip to content

Instantly share code, notes, and snippets.

@seb
seb / notification.js
Last active September 11, 2015 17:23
FB -> Mail
// Tu utilises ça sur ta page
FB.Event.subscribe("comment.create", comment_callback);
// La fonction JS qui va etre appelée et faire une requete ajax
window.comment_callback = function() {
$.ajax({
url: "/poke",
type: "get",
data: "url=" + document.URL + "&kind=comment"
});
@seb
seb / gist:572813cd9476e56bc363
Created September 15, 2015 16:46
snippet.js
javascript: loc = window.location.protocol + '//' + window.location.hostname + window.location.pathname; if(loc.indexOf("destination")>0){ window.location=window.location.protocol + '//' + window.location.hostname + '/admin/categories' + window.location.pathname.replace('destinations','').replace('/conseils','') + '/edit' } else if (loc.indexOf("/conseils/")>0){ window.location=window.location.protocol + '//' + window.location.hostname + '/admin/questions/' + window.location.pathname.split("/")[3] + '/edit' } else {window.location=window.location.protocol + '//' + window.location.hostname+ '/admin/profiles/' + window.location.pathname.split("/")[2] + '/edit' }
@seb
seb / gist:733333
Created December 8, 2010 14:21
header code for twitter notification bar
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
<%= "flash('#{flash[:notice]}')" if flash[:notice] %>
});
function flash(message) {
$('#flash').html(message).slideDown("slow").delay(2500);
$('#flash').html(message).slideUp("slow");
}
</script>
@seb
seb / gist:733328
Created December 8, 2010 14:17
twitter bar css
.wrapper{width:960px;margin:0 auto;}
.hidden{display:none;}
.flash{
-moz-border-radius-bottomright:5px;
-webkit-border-bottom-right-radius:5px;
-moz-border-radius-bottomleft:5px;
-webkit-border-bottom-left-radius:5px;
font-size:16px;
text-align:center;
position:fixed;
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Amblot - Solutions pour les développements Electroniques et Mécaniques</title>
<link rel="stylesheet" href="http://www.amblot.com/AmblotV02/Styles/Accueil.css" type="text/css">
<link rel="stylesheet" href="http://www.amblot.com/AmblotV02/Styles/nivo-slider.css" type="text/css" media="screen" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://www.amblot.com/AmblotV02/Styles/jquery.nivo.slider.pack.js" type="text/javascript"></script>
ssh deploy@yourproject.com "mysqldump -u root -p yourproject_production" | mysql -u root yourproject_development
config.action_controller.asset_host = "http://yourproject.com"
config.action_controller.asset_host = Proc.new { |source|
if source.index('/images')
"http://yourproject.com"
else
"http://localhost:3000"
end
}
def seethreepio(text, from = 'fr', to = 'en')
escaped_text = CGI::escape(text)
host = Net::HTTP.new("www.googleapis.com",443)
host.use_ssl = true
body = JSON.parse(
host.get("/language/translate/v2?key=YOUR_KEY_GOES_HERE&source=#{from}&target=#{to}&q=#{escaped_text}").body)
body['data']['translations'].first['translatedText']
end