Skip to content

Instantly share code, notes, and snippets.

View Snouzy's full-sized avatar
🏠
Working from home

Mat B. Snouzy

🏠
Working from home
  • Freelance
  • All around the world, France based
  • X @BradiceanuM
View GitHub Profile
@callaginn
callaginn / ajax-contact-form.js
Last active May 3, 2024 16:38
Shopify Ajax Contact Form
// Before implementing this, you'll need to contact Shopify support and ask them to turn off Google's ReCaptcha
// for your Shopify store's contact forms. Otherwise, it will redirect to the captcha's verification page.
// Retrieves input data from a form and returns it as a JSON object:
function formToJSON(elements) {
return [].reduce.call(elements, function (data, element) {
data[element.name] = element.value;
return data;
}, {});
}
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active April 15, 2024 09:41
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active May 12, 2024 15:13
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@varmais
varmais / thinced.js
Created October 1, 2015 19:43
Geolocation to Promise wrap example
var getPosition = function (options) {
return new Promise(function (resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
getPosition()
.then((position) => {
console.log(position);
})
@384400
384400 / benchmark-javascript.md
Created September 14, 2015 15:24
[JavaScript] Mesurer les performances d'un code en JavaScript

Comment mesurer les performances d'un code en JavaScript ?

Quand on a le choix entre deux (groupes d') instructions, il peut être opportun d'en comparer les performances avant de prolonger un développement. L'intérêt est assurément théorique : aucun utilisateur lambda ne lancera 20 000 itérations ! Cependant, une comparaison peut constituer une aide au choix.

En matière de Benchmarking, [jsPerf] (https://jsperf.com/) constitue le site de référence dans le monde du développement. Néanmoins, l'inscription est plutôt fastidieuse.

Voici pourquoi, nous présentons un code rudimentaire, sans doute perfectible, qui permet de mesurer facilement la performance d'un code en JavaScript. Ce code a été mentionné dans une conversation sur [stackoverflow] (http://stackoverflow.com/questions/111368/how-do-you-performance-test-javascript-code).

Les résultats du test s'affichent dans la console du navigateur. Ici, [Google Chrome] (https://www.google.com/chrome/browser/desktop/index.html) est commode d'emploi.

@DavidWells
DavidWells / reset.css
Last active May 4, 2024 20:04 — forked from karbassi/reset.css
CSS reset. Follow me on the twitters for more tips: https://twitter.com/davidwells
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})