Skip to content

Instantly share code, notes, and snippets.

View arlg's full-sized avatar

Aurélien G. arlg

View GitHub Profile
@arlg
arlg / grid.pcss
Created March 12, 2018 15:15
Pcss grid (flex fallback)
/* https://stackoverflow.com/questions/20626685/better-way-to-set-distance-between-flexbox-items */
.grid{
display: flex;
flex-flow: row wrap;
justify-content: space-between;
margin-top: 3rem;
--num: 1;
/* No Grid support = flex */
@arlg
arlg / CSSnames.html
Last active August 7, 2017 08:34
Css names
Flex :
row
> __col
list
> __item
.card__primary // Text content
.card__secondary // Image
@arlg
arlg / tweenmaxknowledge.js
Last active September 13, 2017 10:51
TweenMax - Knowledge
//Kill all Tweens currently running
TweenMax.killTweensOf( $('.my_object') );
// Sets Global ease
TweenLite.defaultEase = Circ.easeOut;
// Sets Global transform perspective
CSSPlugin.defaultTransformPerspective = 500;
// onComplete get self element
// auth parameters
$api_key = urlencode(''); // Consumer Key (API Key)
$api_secret = urlencode(''); // Consumer Secret (API Secret)
$auth_url = 'https://api.twitter.com/oauth2/token';
// what we want?
$data_username = ''; // username
$data_count = 1; // number of tweets
$data_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; // Change if you need to search for something else
@arlg
arlg / line command
Created December 12, 2014 17:01
Voir erreurs php en local
tail -f /Applications/MAMP/logs/php_error.log
@arlg
arlg / Social share
Created February 19, 2013 16:45
Facebook, Twitter, G+ single/multiple shares
NS.Shares = {
facebook : function(_title, _summary, _url, _image) {
window.open('http://www.facebook.com/sharer.php?s=100&p[title]='+encodeURIComponent(_title)+'&p[summary]='+encodeURIComponent(_summary)+'&p[url]='+encodeURIComponent(_url)+'&&p[images][0]='+encodeURIComponent(_image),'sharer','toolbar=0,status=0,width=548,height=325');
},
twitter : function(_tweet, _url){
window.open('http://twitter.com/home?status='+_tweet+' - '+_url, 'tweet','toolbar=0,status=0,width=548,height=325');
},
@arlg
arlg / Input Handler
Last active December 12, 2015 09:48
Input functions
//Clears the input on focus, restore its initial content on blur if nothing entered by user
var input = $('input[type=text]');
input.focus(function() {
var el = $(this);
if(el.val() === el.attr('data-placeholder')){
$(this).val('');
}
/*
* Specifies folders and wich matchmedia we use
* here I want a desktop 'normal' image, a desktop/ipad 3 retina image,
a mobile or a mobile retina image
fallback to noscript loads the desktop one.
*/
function getResponsiveImg($imageName, $altAttribute)
{
@arlg
arlg / Good Javascript
Last active October 15, 2018 10:37
Javascript the good way
/*FOR LOOPS
-------------------------------------------*/
//SLOW -> (no caching of the length)
for (var i = 0; i < myArray.length; i++) {}
//GOOD -> (caching the length) : http://jsperf.com/forloops3
for (var i = 0, l = myArray.length; i < l; i++) {}
//BEST -> backwards for loop + caching the length : http://jsperf.com/forward-and-backward-for-loops/2