Skip to content

Instantly share code, notes, and snippets.

View xcarpentier's full-sized avatar
🌐
Remote!

Xavier Carpentier xcarpentier

🌐
Remote!
View GitHub Profile
document.body.innerHTML = '<svg></svg>'
const SVG = document.getElementsByTagName('svg')[0]
const Text = document.createElementNS("http://www.w3.org/2000/svg", "text")
Text.setAttribute('y', 10)
Text.appendChild(document.createTextNode("this is the text content"))
SVG.appendChild(Text)
const Rect = document.createElementNS("http://www.w3.org/2000/svg", "rect")
Rect.setAttribute('x', '0')
Rect.setAttribute('y', '10')
const nfib_data = {}
function fibo(n: number) {
if(nfib_data[n]) {
return nfib_data[n]
}
let result
if(n === 0 || n === 1) {
result = n;
} else {
result = fibo(n - 1) + fibo(n - 2)
@xcarpentier
xcarpentier / firebase-hook.ts
Created January 17, 2020 10:48 — forked from 73nko/firebase-hook.js
React Hooks for loading Firebase Data
import React, { useReducer, useEffect, useRef } from 'react';
import firebase from 'firebase/app';
import equal from 'deep-equal';
function filterKeys(raw, allowed) {
if (!raw) {
return raw;
}
let s = new Set(allowed);
return Object.keys(raw)
@xcarpentier
xcarpentier / react-native-gifted-chat+0.9.11.patch
Created January 3, 2020 08:50 — forked from GollyJer/react-native-gifted-chat+0.9.11.patch
Patch react-native-gifted-chat to eliminate need for sizing code. Allows the chat data to stay cached.
diff --git a/node_modules/react-native-gifted-chat/lib/GiftedChat.js b/node_modules/react-native-gifted-chat/lib/GiftedChat.js
index 7f3f4b5..78ea7a1 100644
--- a/node_modules/react-native-gifted-chat/lib/GiftedChat.js
+++ b/node_modules/react-native-gifted-chat/lib/GiftedChat.js
@@ -1,6 +1,13 @@
import PropTypes from 'prop-types';
import React from 'react';
-import { Animated, Platform, StyleSheet, View, SafeAreaView, } from 'react-native';
+import {
+ Animated,
export function isValidEmail(mel: string) {
return mel.match(/\w+@\w+\.\w{2,}/i) !== null ? true : false
}
// This gist explains how to setup scalable Parse LiveQuery server on Heroku
// Because there is one and only 'web' process on Heroku, it will divide into two Heroku apps: Main and LiveQuery.
// A: Main app - All features except for LiveQuery server
// Step A1. Setup a Parse app on Heroku
// Step A2. Add a Heroku Redis (free plan is enough for testing)
// Step A3. Configure Parse app, add redisURL for liveQuery
var api = new ParseServer({
...
liveQuery: {
@xcarpentier
xcarpentier / fibonacci-generator.js
Created June 16, 2016 13:20 — forked from jfairbank/fibonacci-generator.js
Fibonacci ES6 Generator
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
@xcarpentier
xcarpentier / startup-noob-guide.md
Created April 29, 2016 07:49 — forked from adrienjoly/startup-noob-guide.md
Tips and resources on how to test, develop your startup idea, or find a developer/associate/CTO
'use strict'
class DataService
@$inject: ['$http', '$log']
constructor: (@http, log) ->
log.debug 'DataService instance'
countries: ->
@http.get('/api/countries/')
#!/usr/bin/env bash
function launchSupervisor {
echo " #############################"
echo " ! Supervisor will be START !"
echo " #############################"
supervisor -e 'js|ejs|node|coffee' -p 1000 -x npm -- start
}
function main {
issupervisorinstalled=$(npm list supervisor 2>&1 | grep "empty")