Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@ThomasG77
ThomasG77 / .block
Created March 3, 2017 23:20 — forked from veltman/.block
Scribble map
height: 600
hg clone https://bitbucket.org/tiax/bitbucket-issues-cli # Fork repo with support for Git on Bitbucket
cd bitbucket-issues-cli
hg patch ../patch-bitbucket-issues-cli-1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vue-i18next demo</title>
<script src="https://rawgit.com/i18next/i18next/master/i18next.min.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://rawgit.com/rse/vue-params/master/vue-params.js"></script>
<script src="https://rawgit.com/rse/vue-i18next/master/vue-i18next.js"></script>
</head>
@ThomasG77
ThomasG77 / auto-complete.css
Last active June 22, 2023 08:16
Leaflet demo to use autocompletion with French GeoAPI and Leaflet.js library http://bl.ocks.org/ThomasG77/0b99013795f76699c5c9a0d7daf4411e
.autocomplete-suggestions {
text-align: left; cursor: default; border: 1px solid #ccc; border-top: 0; background: #fff; box-shadow: -1px 1px 3px rgba(0,0,0,.1);
/* core styles should not be changed */
position: absolute; display: none; z-index: 9999; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box;
}
.autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; }
.autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; }
.autocomplete-suggestion.selected { background: #f0f0f0; }
  1. What is the relationship between Node.js and V8? Can Node work without V8?
  2. How come when you declare a global variable in any Node.js file it's not really global to all modules?
  3. When exporting the API of a Node module, why can we sometimes use exports and other times we have to use module.exports?
  4. Can we require local files without using relative paths?
  5. Can different versions of the same package be used in the same application?
  6. What is the Event Loop? Is it part of V8?
  7. What is the Call Stack? Is it part of V8?
  8. What is the difference between setImmediate and process.nextTick?
  9. How do you make an asynchronous function return a value?
  10. Can callbacks be used with promises or is it one way or the other?
@ThomasG77
ThomasG77 / send-sms-free-fr.js
Created April 12, 2017 23:25
Essai d'envoi de SMS uniquement avec Node et un abonnement Free.fr (adaptée à 90% de http://blog.nicolasc.eu/utiliser-api-de-notification-sms-free-mobile-depuis-node-js/)
const https = require('https');
const querystring = require('querystring');
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
function sendSms (message) {
var qs = querystring.stringify({
user: process.env.free_fr_user_account,
pass: process.env.free_fr_sms_key,
msg: message
@ThomasG77
ThomasG77 / index.html
Created April 24, 2017 21:04
Simple Map with GeoJSON markers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Simple Map with GeoJSON markers</title>
<link rel="stylesheet" href="http://openlayers.org/en/v3.18.2/css/ol.css" type="text/css">
<style>
html, body {
height: 100%;
@ThomasG77
ThomasG77 / sleep.js
Created May 4, 2017 13:43
Sleep function in JavaScript (need node v7.10+, borrowed from https://twitter.com/samccone/status/859777976199659521)
async function sleep (dur) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(), dur);
});
}
async function yay () {
console.log('i am sleepy');
await sleep(5000);
console.log('i need more sleep');
'use strict';
// Idea mainly borrowed from https://stackoverflow.com/a/30883005
const Promise = require('bluebird'); // Not required if you prefer using native promise
const exec = require('child_process').exec;
function promiseExec(command) {
var child = exec(command);
return new Promise(function (resolve, reject) {
child.addListener("error", reject);
child.stderr.on('data', function (data) {
<OGRVRTDataSource>
<OGRVRTLayer name="nga_rivers">
<SrcDataSource>rivers.gpkg</SrcDataSource>
<SrcLayer>rivers</SrcLayer>
<SrcSQL>SELECT * FROM rivers</SrcSQL>
</OGRVRTLayer>
</OGRVRTDataSource>