Skip to content

Instantly share code, notes, and snippets.

@seb
seb / js
Created March 31, 2018 08:36
= f.fields_for :images,@image do |image_form|
= image_form.file_field :attachment,
onchange:"document.getElementById('preview').src = window.URL.createObjectURL(this.files[0]);document.getElementById('preview').classList.add('visible');;document.getElementById('imgpreview').classList.remove('hidden');"
@seb
seb / mixins.scss
Created November 15, 2016 15:49
Cool SASS Mixins to start a project
@mixin box-shadow($x:1px,$y:1px,$width:0px,$color:rgba(0, 0, 0, 0.1)) {
box-shadow: $x $y $width $color;
-webkit-box-shadow: $x $y $width $color;
-moz-box-shadow: $x $y $width $color;
}
@mixin inset($x:0px,$y:1px,$width:8px,$color:rgba(0, 0, 0, 0.8)){
box-shadow: inset $x $y $width $color;
-webkit-box-shadow: inset $x $y $width $color;
-moz-box-shadow: inset $x $y $width $color;
}
#css
.info,#people{display:block;width:100%}
.person{display:inline-block;width:30%}
<dic id="people">
<div class="person" data-name="John Lennon" data-content="Lorem Ipsum..."><img src="photo.jpg" /></div>
<div class="person" data-name="Paul McCartney" data-content="Lorem Ipsum..."><img src="photo.jpg" /></div>
<div class="info"></
@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 / 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 / pan.html
Created October 16, 2013 13:12
Pan / HTML
<div class='visible-phone no-flick' id='pan'>
<h1>Catégories</h1>
<ul>
<li class='first '><a href="/tele-series">Télé &amp; Series</a></li>
<li class=' '><a href="/jeux-jouets">Jeux &amp; Jouets</a></li>
<li class=' '><a href="/films">Films</a></li>
<li class=' '><a href="/musiques">Musiques</a></li>
<li class=' '><a href="/objets-et-deco">Objets et Déco</a></li>
<li class=' '><a href="/vetements">Vêtements</a></li>
<li class=' '><a href="/livres-bandes-dessinees">Livres &amp; BD</a></li>
@seb
seb / pan.js
Created October 16, 2013 13:08
Pan / JS
$(document).on('click', '#pan li a', function(e) {
return $("#pan").toggleClass("toggle");
});
@seb
seb / pan.css
Created October 16, 2013 13:07
Responsive pan / CSS
#pan-button {
color: #FFF;
position: absolute;
top: 0px;
right: -60px;
padding: 10px 30px 10px 10px;
}
#pan {
-webkit-overflow-scrolling: touch;
@seb
seb / jpegoptim
Created October 15, 2013 10:15
Image compression if not done via #railsapp your app post process
# Lowless compression & exif stripping
find . -iname "*.jpg" -exec jpegoptim --strip-all {} \;
# More compression for some style of your pics
find path/to/your/assets/*/style -type f -exec jpegoptim --strip-all -m85 {} \;
@seb
seb / gist:6796412
Created October 2, 2013 16:26
Compress
after_post_process :compress
private
def compress
image = self.attachment
current_format = File.extname(image.queued_for_write[:original].path)
image.queued_for_write.each do |key, file|
reg_jpegoptim = /(jpg|jpeg|jfif)/i