Skip to content

Instantly share code, notes, and snippets.

View gfortaine's full-sized avatar

Guillaume FORTAINE gfortaine

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 22, 2024 09:14
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@geoffreydhuyvetters
geoffreydhuyvetters / react_fiber.md
Last active January 13, 2023 06:49
What is React Fiber? And how can I try it out today?
@addyosmani
addyosmani / route-based-chunking.md
Last active December 28, 2021 06:18
Route-based chunking

Route-based chunking

Many of us building single-page apps today use JavaScript module bundling tools that trend towards a monolithic "bundle.js" file including the full app and vendor code for multiple routes. This means if a user lands on any arbitrary route they need to wait for a large bundle of JS to be fetched, parsed and executed before the application is fully rendered and interactive.

screen shot 2016-09-28 at 4 45 52 pm

This is a little backwards, especially when apps are used under real-world network (3G) and device

@delphinus
delphinus / generator-test.js
Created June 18, 2016 04:31
Javascript Generator のテスト
(() => {
function range(n) {
let value = 0;
return {
next() {
if (value < n) {
const result = {value, done: false};
value += 1;
return result;
}
@rmunn
rmunn / git-prompt-howto.md
Created March 9, 2016 03:13
How to get a nice Bash prompt that includes your current Git branch

Edit your .bashrc as follows. Before the "case $TERM" statement that sets color_prompt, add the following:

# GNOME Terminal is broken re: $TERM settings
if [ "$COLORTERM" = "gnome-terminal" -a "$TERM" = "xterm" ]; then
    TERM="xterm-256color"
fi

Now edit that "case $TERM" statement to look like this:

@adrienjoly
adrienjoly / startup-noob-guide.md
Last active March 31, 2024 04:37
Startup Noob Guide: Tips and resources on how to test, develop your startup idea, or find a developer/associate/CTO

Startup Noob Guide (bit.ly/startupnoob)

If you want to create a startup, and you've never done that before, you should consult the resources that are relevant to your situation.

[FR] Si vous comprenez le français, je vous invite à regarder la vidéo de mon pote Shubham qui résume assez bien le plus gros des conseils de cette page, en 8 minutes: Vous avez une idée de startup ?.

[FR] ...et si vous voulez comprendre tout ce contenu de manière plus efficace et ludique, inscrivez-vous sur mon MOOC "Startup Tour: créez votre startup en 3h" (gratuit).


@mbbx6spp
mbbx6spp / README.md
Last active December 21, 2023 05:05
Gerrit vs Github for code review and codebase management

Gerrit vs Github: for code review and codebase management

Sure, Github wins on the UI. Hands down. But, despite my initial annoyance with Gerrit when I first started using it almost a year ago, I am now a convert. Fully. Let me tell you why.

Note: This is an opinionated (on purpose) piece. I assume your preferences are like mine on certain ideas, such as:

  • Fast-forward submits to the target branch are better than allowing merge commits to the target branch. The reason I personally prefer this is that, even if a non-conflicting merge to the target branch is possible, the fact that the review/pull request is not up to date with the latest on the target branch means feature branch test suite runs in the CI pipeline reporting on the review/PR may not be accurate. Another minor point is that forced merge commits are annoying as fuck (opinion) and clutter up Git log histories unnecessarily and I prefer clean histories.
  • Atomic/related changes all in one commit is something worth striving for. Having your dev
var init = sync(function* (resume) {
var data1, data2;
console.log('Start by waiting for a second...');
yield sleep(1000, resume);
console.log('Then send a GET request to a couple of websites with XMLHttpRequest');
data1 = yield get('https://cors-test.appspot.com/test', resume);
<script>
// fbAsyncInit
// http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId: '<?php echo(FB_APP_ID); ?>',
status: true,
cookie: true,
xfbml: true,
@lrvick
lrvick / bitcolor.js
Created March 18, 2012 20:02
Javascript functions for doing fast binary/hex/RGB color conversions using bitwise operations.
// convert 0..255 R,G,B values to binary string
RGBToBin = function(r,g,b){
var bin = r << 16 | g << 8 | b;
return (function(h){
return new Array(25-h.length).join("0")+h
})(bin.toString(2))
}
// convert 0..255 R,G,B values to a hexidecimal color string
RGBToHex = function(r,g,b){