Skip to content

Instantly share code, notes, and snippets.

View seafoox's full-sized avatar

Alexandre Collin seafoox

View GitHub Profile
@seafoox
seafoox / touch-detect.js
Created September 2, 2013 01:05
Detecting the ‘Tap’ event on a Mobile touch device using javascript --- JSFiddle: http://jsfiddle.net/gianlucaguarini/56Szw/light/
var $touchArea = $('#touchArea'),
touchStarted = false, // detect if a touch event is sarted
currX = 0,
currY = 0,
cachedX = 0,
cachedY = 0;
//setting the events listeners
$touchArea.on('touchstart mousedown',function (e){
e.preventDefault();
@seafoox
seafoox / algolia-vestairecollective-demo.js
Last active October 24, 2016 18:59
Algolia - VestaireCollective demo
<script type="text/javascript">
var last_query = '';
var client = new AlgoliaSearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');
function searchCallback(success, content) {
$('.browser-page-help').hide();
if (content.results.length < 2 || content.results[0].query != last_query) {
return;
}
/*
A (very) WIP collection of optimized/recommended jQuery plugin patterns
from @addyosmani, @cowboy, @ajpiano and others.
Disclaimer:
-----------------------
Whilst the end-goal of this gist is to provide a list of recommended patterns, this
is still very much a work-in-progress. I am not advocating the use of anything here
until we've had sufficient time to tweak and weed out what the most useful patterns
// Skeleton jQuery plugin
function($)
{
$.fn.myPlugin = function( options )
{
// options.
$.fn.myPlugin.settings = $.extend( {}, $.fn.myPlugin.defaults, options );
// Go through the matched elements and return the jQuery object.
@seafoox
seafoox / history-log
Created August 27, 2013 04:59
Javascript log function with history
window.log = function () {
log.history = log.history || [];
log.history.push(new Date(), arguments);
if (this.console) {
arguments.callee = arguments.callee.caller;
var a = [].slice.call(arguments);
(typeof console.log === "object" ? log.apply.call(console.log, console, a) : console.log.apply(console, a))
}
log.displayHistory = function() {
for (var i=0, len=window.log.history.length; i<len; i++)
@seafoox
seafoox / script.js
Last active December 21, 2015 03:59
Textfill Module // auto font resize based on the parent width
// Textfill Module
// ----------------
// auto font rezize based on the parent size
//
(function($, window) {
var initialFontSize = null;
$.fn.textfill = function(maxFontSize)
{
maxFontSize = parseInt(maxFontSize, 10);
@seafoox
seafoox / index.html
Created August 15, 2013 01:12
Defer loading of social script after onload --- URL: http://www.aaronpeters.nl/blog/why-loading-third-party-scripts-async-is-not-good-enough The loading of JS social buttons its deferred until onload event its fired.
<script>
(function(w, d, s) {
function go(){
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.src = url; js.id = id;
fjs.parentNode.insertBefore(js, fjs);
};
load('//connect.facebook.net/en_US/all.js#appId=272697932759946&xfbml=1', 'fbjssdk');
load('https://apis.google.com/js/plusone.js', 'gplus1js');
@seafoox
seafoox / SublimeLinter.sublime-settings
Created November 26, 2012 11:02
SublimeLinter Configuration
{
// If true, when the file is saved any errors will appear in a popup list
"sublimelinter_popup_errors_on_save": false,
// Javascript linter: "gjslint" to use the closure javascript linter (if available),
// or either "jshint" or "jslint" to use a built in linter.
"javascript_linter": "jshint",
// jshint: options for linting JavaScript. See http://www.jshint.com/options/ for more info.
@seafoox
seafoox / rAF.js
Created November 3, 2012 22:57 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@seafoox
seafoox / HowTo_SublimeText2_Terminal_MacOSX
Created April 20, 2012 15:55
Launch SublimeText2 from the Terminal
## Launch SublimeText2 from the Terminal (on MacOS X) ##
1/ Open Terminal.app
2/ Copy/paste the following symbolic link. You can replace 'subl' at the end with the keyword of your choice
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
3/ Now you can open files and projects directly from the Terminal
- Open the current folder as a project: "subl ."
- Open a file "subl _PATH_/file.js"