Skip to content

Instantly share code, notes, and snippets.

View lou's full-sized avatar

louis cuny lou

  • fr.getaround.com
  • paris
View GitHub Profile
@lou
lou / 0_iframe.tsx
Last active April 17, 2020 11:29
Storybook Iframe height
// App side
import React, { useEffect, useRef, SyntheticEvent } from "react"
type IframePropsType = {
src: string
}
export default ({ src }: IframePropsType) => {
const el = useRef<HTMLIFrameElement>(null)
/*
* Usage:
* <PopoverStickOnHover
* component={<div>Holy guacamole! I'm Sticky.</div>}
* placement="top"
* onMouseEnter={() => { }}
* delay={200}
* >
* <div>Show the sticky tooltip</div>
* </PopoverStickOnHover>
@lou
lou / base_uploader.rb
Last active March 22, 2022 11:59
Rails - Carrierwave validation of image size
class BaseUploader < CarrierWave::Uploader::Base
attr_reader :width, :height
before :cache, :capture_size
...
# for image size validation
# fetching dimensions in uploader, validating it in model
def capture_size(file)
if version_name.blank? # Only do this once, to the original version
@lou
lou / colorbox.css
Last active September 28, 2017 21:00
Colorbox + Fontawesome
/*
Colorbox Core Style:
The following CSS is consistent between example themes and should not be altered.
*/
#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}
#cboxWrapper {max-width:none;}
#cboxOverlay{position:fixed; width:100%; height:100%;}
#cboxMiddleLeft, #cboxBottomLeft{clear:left;}
#cboxContent{position:relative;}
#cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;}
@lou
lou / multiselect-methods.js
Created April 23, 2012 14:05
multiselect public methods
// You must init the multiple select with $('#your-select').multiSelect() before calling one of the following methods
$('#your-select').multiSelect('select', 'value'); // Select the item with the value given in parameter
$('#your-select').multiSelect('deselect', 'value'); // Deselect the item with the value given in parameter
$('#your-select').multiSelect('select_all', true); // Select all elements. If parameter visible set to true, it will select only visible items. Otherwise it will also select hidden items
$('#your-select').multiSelect('deselect_all'); // Deselect all items previously selected
$('#your-select').multiSelect('refresh'); // Re-in the multiselect
@lou
lou / multiselect-methods.js
Created April 22, 2012 19:16
multiselect public methods
// You must init the multiple select with $('#your-select').multiSelect() before calling one of the following methods
$('#your-select').multiSelect('select', 'value'); // Select the item with the value given in parameter
$('#your-select').multiSelect('deselect', 'value'); // Deselect the item with the value given in parameter
$('#your-select').multiSelect('select_all', true); // Select all elements. If parameter visible set to true, it will select only visible items. Otherwise it will also select hidden items
$('#your-select').multiSelect('deselect_all'); // Deselect all items previously selected
$('#your-select').multiSelect('refresh'); // Refresh current multiselect. It will re-init the multiselect based on the <select> element (useful for when select is update through Ajax)
@lou
lou / multiselect-methods.js
Created April 22, 2012 19:14
multiselect public methods
// You must init the multiple select with $('#your-select').multiSelect() before calling one of the following methods
$('#your-select').multiSelect('select', 'value'); // Select the item with the value given in parameter
$('#your-select').multiSelect('deselect', 'value'); // Deselect the item with the value given in parameter
$('#your-select').multiSelect('select_all', true); // Select all elements. If parameter visible set to true, it will select only visible items. Otherwise it will also select hidden items
$('#your-select').multiSelect('deselect_all'); // Deselect all items previously selected
$('#your-select').multiSelect('refresh'); // Refresh current multiselect
@lou
lou / multiselect-callbacks.js
Created April 22, 2012 18:13
multiselect callbacks
// You must init the multiple select with $('#my-select').multiSelect() before calling one of the following methods
$('#countries').multiSelect('select', 'value'); // Select the item with the value given in parameter
$('#countries').multiSelect('deselect', 'value'); // Deselect the item with the value given in parameter
$('#countries').multiSelect('select_all', true); // Select all elements. If parameter visible set to true, it will select only visible items. Otherwise it will also select hidden items.
$('#countries').multiSelect('deselect_all'); // Deselect all items previously selected
@lou
lou / multiselect-usage.html
Created April 22, 2012 18:03
multiselect usage html
<select multiple="multiple" id="countries" name="countries[]">
<option value="fr">France</option>
<option value="uk">United Kingdom</option>
<option value="us">United States</option>
<option value="ch">China</option>
</select>
@lou
lou / multiselect-usage.js
Created April 22, 2012 17:59
multiselect usage
$('#countries').multiSelect({
afterSelect: function(value, text){}, // Function to call after one item is selected
afterDeselect: function(value, text){}, // Function to call after one item is deselected
selectableHeader: null, // Text or HTML to display on the selectable container
selectedHeader: null, // Text or HTML to display on the selected container
disabledClass: 'disabled' // CSS class for disabled items
});