Skip to content

Instantly share code, notes, and snippets.

View nshimiye's full-sized avatar

Marcellin Nshimiyimana nshimiye

View GitHub Profile
@nshimiye
nshimiye / package.json
Last active April 19, 2020 01:00
webpack and angular compiler
{
"name": "webpack-tsc-ngc",
"version": "1.0.0",
"description": "Webpack Angular Compiler",
"scripts": {
"build:tsc": "webpack --config webpack.config.tsc.js",
"build:ngc": "webpack --config webpack.config.ngc.js",
},
"keywords": [],
"author": "",
.tooltip:hover::before {
position: absolute;
top: 100%;
left: calc(50% - var(--tip-pointer-half-height));
content: " ";
height: 0;
width: 0;
border: var(--tip-pointer-half-height) solid transparent;
}
@nshimiye
nshimiye / tooltip.component.scss
Last active May 30, 2019 23:58
Tooltip styling
:host {
--tip-content-padding: 15px;
--tip-content-width: 250px;
--tip-content-half-width: calc(var(--tip-content-width) / 2);
--tip-content-view-spacing: 5px;
--tip-pointer-height: 44px;
--tip-pointer-half-height: calc(var(--tip-pointer-height) / 2);
--tip-pointer-top: calc(100% + 0.414 * var(--tip-pointer-half-height)); /* 0.414 = trigonometric factor cause by the rotation rotate(-45deg) */
}
@nshimiye
nshimiye / tooltip.component.ts
Last active May 22, 2019 02:46
Tooltip check for off screen
checkOffScreen() {
const tipElement = this.tipRef.nativeElement;
const tipContent = this.tipContentRef.nativeElement;
const { left: tipElementLeft } = tipElement.getBoundingClientRect();
const { width: tipContentWidth } = tipContent.getBoundingClientRect();
const { right: bodyRight } = document.body.getBoundingClientRect();
this.isLeftOffScreen = tipElementLeft < tipContentWidth / 2;
this.isRightOffScreen = tipElementLeft + (tipContentWidth / 2) > bodyRight;
}
// @WARNING this is incomplete
class YourComponent extends Component {
static contextType = GoogleMapContext;
componentDidMount() {
if (this.context.map) {
this.context.map.addListener('click', (e) => { // <= accessing map
this.context.map.setCenter(e.latLng); // <= accessing map
});
}
}
// @WARNING this is incomplete
export function GoogleMapWithLoader({
googleMapURL, children, center, zoom, height, width,
}) {
return (
<ScriptLoader scriptUrl={googleMapURL}>
<GoogleMapInitialzer
center={center}
zoom={zoom}
height={height}
@nshimiye
nshimiye / pythonOpencvHomebrewInstallFix.md
Created February 28, 2019 16:42 — forked from robrant/pythonOpencvHomebrewInstallFix.md
Script to fix opencv homebrew install on OSX > El Capitan
@nshimiye
nshimiye / App.js
Created December 15, 2018 05:05
React Native module method call
// export default class App extends Component {
// ...
componentDidMount() {
NativeModules.MDebugger.isLowMemory()
.then(lowMomery => {
this.setState({ lowMemory })
})
}
// ...
// }
@nshimiye
nshimiye / MDebuggerPackage.java
Created December 15, 2018 04:41
React Native Android Package
package com.memorydebugger;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
@nshimiye
nshimiye / MDebuggerModule.java
Last active December 17, 2018 18:18
React native android module
package com.memorydebugger;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Promise;
import android.content.Context;