Skip to content

Instantly share code, notes, and snippets.

View alielmajdaoui's full-sized avatar

Ali El Majdaoui alielmajdaoui

View GitHub Profile
@alielmajdaoui
alielmajdaoui / metro.config.js
Created October 16, 2021 19:41
Link Local Dependency in React Native - Metro Config - Without watchFolders option
// Absolute path to your package
const packagePath =
'/Users/mac/my-own-packages/my-awesome-package';
module.exports = {
resolver: {
nodeModulesPaths: [packagePath],
// rest of metro resolver options...
},
// rest of metro options...
@alielmajdaoui
alielmajdaoui / metro.config.js
Created October 16, 2021 20:02
Link Local Dependency in React Native - Metro Config - With watchFolders option
// Absolute path to your package
const packagePath =
'/Users/mac/my-own-packages/my-awesome-package';
module.exports = {
resolver: {
nodeModulesPaths: [packagePath],
// rest of metro resolver options...
},
watchFolders: [packagePath],
@alielmajdaoui
alielmajdaoui / geobox.py
Created February 7, 2022 20:51
code.google.com/p/mutiny/source/browse/trunk/geobox.py
#!/usr/bin/env python
#
# Copyright 2008 Brett Slatkin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@alielmajdaoui
alielmajdaoui / settings-main.ts
Last active November 5, 2022 00:47
./src/settings-main/settings-main.ts
/* eslint global-require: off, no-console: off, promise/always-return: off, import/prefer-default-export: off */
import path from 'path';
import { app, BrowserWindow, shell } from 'electron';
import { resolveHtmlPath } from '../main/util';
let settingsWindow: BrowserWindow | null = null;
const isDebug =
process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true';
@alielmajdaoui
alielmajdaoui / index.ejs
Created October 30, 2022 01:32
./src/settings-renderer/index.ejs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
http-equiv="Content-Security-Policy"
content="script-src 'self' 'unsafe-inline'"
/>
<title>Settings Renderer</title>
</head>
@alielmajdaoui
alielmajdaoui / index.tsx
Created October 30, 2022 01:33
./src/settings-renderer/index.tsx
import { createRoot } from 'react-dom/client';
const App = () => <div>Settings window!</div>;
const container = document.getElementById('root')!;
const root = createRoot(container);
root.render(<App />);
@alielmajdaoui
alielmajdaoui / webpack.paths.ts
Created October 30, 2022 01:37
./erb/configs/webpack.paths.ts
const path = require('path');
const rootPath = path.join(__dirname, '../..');
const dllPath = path.join(__dirname, '../dll');
const srcPath = path.join(rootPath, 'src');
const srcMainPath = path.join(srcPath, 'main');
const srcRendererPath = path.join(srcPath, 'renderer');
const srcSettingsMainPath = path.join(srcPath, 'settings-main');
@alielmajdaoui
alielmajdaoui / webpack.config.renderer.dev.ts
Created October 30, 2022 01:51
./erb/configs/webpack.config.renderer.dev.ts
import 'webpack-dev-server';
import path from 'path';
import fs from 'fs';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import chalk from 'chalk';
import { merge } from 'webpack-merge';
import { execSync, spawn } from 'child_process';
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
import baseConfig from './webpack.config.base';
@alielmajdaoui
alielmajdaoui / preload.ts
Created October 30, 2022 02:16
./src/main/preload.ts
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
export type Channels = 'ipc-example';
contextBridge.exposeInMainWorld('electron', {
ipcRenderer: {
openSettingsWindow() {
ipcRenderer.send('open-settings-window');
},
sendMessage(channel: Channels, args: unknown[]) {
@alielmajdaoui
alielmajdaoui / main.ts
Created November 4, 2022 21:25
./src/main/main.ts
/* eslint global-require: off, no-console: off, promise/always-return: off */
/**
* This module executes inside of electron's main process. You can start
* electron renderer process from here and communicate with the other processes
* through IPC.
*
* When running `npm run build` or `npm run build:main`, this file is compiled to
* `./src/main.js` using webpack. This gives us some performance wins.
*/