Skip to content

Instantly share code, notes, and snippets.

View olivmonnier's full-sized avatar
💭
¯\_(ツ)_/¯

Olivier Monnier olivmonnier

💭
¯\_(ツ)_/¯
View GitHub Profile
@olivmonnier
olivmonnier / script_bookmark
Last active August 29, 2015 14:07
run gist since a bookmark
javascript: var scriptTag = document.createElement('script');
scriptTag.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js');
document.querySelector('head').appendChild(scriptTag);
$.ajax({
url:'https://api.github.com/gists/536dd090e777bd7abcd0', dataType: 'jsonp', success: function(data){
eval(data.data.files.script_bookmark.content);
}
});
@olivmonnier
olivmonnier / accessor.js
Last active August 29, 2015 14:13
Create Accessor attributes
var accessors = [
{
name: "Titi",
default: "Hello World",
get: function(attr){
return attr + ' Toto';
},
set: function(attr){
attr = attr + ' Tata';
}
@olivmonnier
olivmonnier / gist:852eb4d41e16cc11d260
Last active August 29, 2015 14:14
MAC OS Vagrant privilieges administrator on /etc/exports
sudo visudo
#Add these lines
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE
@olivmonnier
olivmonnier / HOWTO.md
Created January 23, 2015 10:07
How to execute rails project without vagrant ssh
  • install the plugin vagrant-exec
vagrant plugin install vagrant-exec
  • Now you can run your project as this example :
cd path/of/your/project && vagrant up && vagrant exec 'bundle exec rails server -d && echo THE APPLICATION IS READY!'
@olivmonnier
olivmonnier / launch-app.scpt
Last active January 17, 2024 22:36
Applescript - Launch application and resize window
tell application "Safari" to activate
set x to 187
set y to 22
set w to 973
set h to 816
tell application "System Events"
tell process "Safari" to get first window
set this_window to result
set position of this_window to {x, y}
set size of this_window to {w, h}
@olivmonnier
olivmonnier / index.html
Created February 12, 2015 13:31
Create div element relative to img width
<div class="wrapper">
<div class="img-bloc">
<img src="/"/>
<div class="actions-bloc">
<a href="#" class="btn">Learn more</a>
</div>
</div>
</div>
@olivmonnier
olivmonnier / guided.html.erb
Created February 12, 2015 13:41
Guided tour
<div class="guided-tour">
<div id="tour-user" class="produit tour"></div>
</div>
<script type="text/javascript">
initTour(tour, chapters, "#tour-user");
</script>
@olivmonnier
olivmonnier / index.html
Created February 12, 2015 13:44
Redirect page
<div>
<h1 class="text-center">Veuillez patienter pendant la redirection...</h1>
<p class="text-center"><a id="linkDirect" class="btn btn-primary" href="#">Accès direct</a></p>
</div>
<script>
function getParamsUrl(){
if(window.location.search.length > 0){
return JSON.parse('{"'+
decodeURIComponent(window.location.search).slice(1)
@olivmonnier
olivmonnier / socialAsync.js
Created March 12, 2015 16:37
After ajax call async social buttons
var SocialAsync = function(){};
SocialAsync.prototype.initFB = function(){
if (typeof (FB) != 'undefined') {
FB.init({ status: true, cookie: true, xfbml: true });
} else {
$.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
FB.init({ status: true, cookie: true, xfbml: true });
});
}
@olivmonnier
olivmonnier / form.html
Last active June 14, 2016 08:58
Création d'un cookie sur les formulaires
<form id="form">
<input type="text" name="first_name"/>
<input type="text" name="last_name"/>
<input type="email" name="email"/>
<input type="submit" value="Send"/>
</form>
<script>
var cookieForm = new FormCookie('form', 365);