Skip to content

Instantly share code, notes, and snippets.

View Granipouss's full-sized avatar

Brendan Daoud Granipouss

  • Paris, France
View GitHub Profile
import { useCallback, useReducer, Reducer, useRef, useEffect } from 'react';
export const useIsMounted = () => {
const isMounted = useRef<boolean>(false);
useEffect(() => {
isMounted.current = true;
return () => {
isMounted.current = false;
const keysDeep = (obj, prefix = '') => {
const isObject = (obj) => (typeof obj === 'object')
const getKeysDeep = (obj, prefix) => _.keys(obj).map(key => isObject(obj[key]) ? getKeysDeep(obj[key], prefix + key + '.') : prefix + key)
return _.flattenDeep(getKeysDeep(obj, '')).map(key => key.replace(/\.(\d+)/g, '[$1]'))
}
let keys = keysDeep({
foo: 'bar',
file: { name: 'lodash' },
person: { name: 'gunar', age: 17 },
@Granipouss
Granipouss / package.json
Created May 16, 2018 20:41
electron-webpack vue quick start
{
"name": "electron-webpack-quick-start",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"dist": "yarn compile && electron-builder",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null"
},
import sys
from toolkit import *
I = int(sys.argv[1])
J = int(sys.argv[2])
# =====================================================================
def fr (r, alpha):
sr = np.where(r == 0, 1, r)
import h5py
import inspect
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit, minimize
# =====================================================================
refC = np.zeros((256, 5), dtype=int)
refC[0, 0] = 1
@Granipouss
Granipouss / imageGen.py
Created June 16, 2017 12:20
Generate multivariate gaussian
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as img
N = 128
def relCov(ax, ay, bx, by):
d2 = np.square(ax - bx) + np.square(ay - by)
return 32 / (1 + d2)
@Granipouss
Granipouss / tpmorpho2.cc
Last active May 4, 2017 09:41
ESE42 Toolbox
#include <string.h>
#include <stdio.h>
#include "Image.hh"
#include "morfo.hh"
#include "tpmorpho1.hh"
#include "tpmorpho2.hh"
#include "tptoolbox.hh"
import _ from 'lodash'
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const routes = []
const viewFiles = require.context('views', true, /\.vue$/)
viewFiles.keys().forEach(key => {
let view = viewFiles(key)
@Granipouss
Granipouss / store.js
Created December 2, 2016 17:19
Vuex made easy
// Use Vuex
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import { merge, mapValues } from 'lodash'
const actions = {}
const getters = {}
const modules = {}