Skip to content

Instantly share code, notes, and snippets.

View yoannmoinet's full-sized avatar
🐶
DX and Tooling

Yoann Moinet yoannmoinet

🐶
DX and Tooling
View GitHub Profile
@yoannmoinet
yoannmoinet / initUnhandled.js
Last active November 21, 2017 17:11
Unhandled configuration.
import unhandled from 'electron-unhandled';
unhandled({
logger: (error) => {
// Handle all your errors here.
},
showDialog: !IS_PRODUCTION
});
@yoannmoinet
yoannmoinet / webpack.config.js
Last active November 15, 2017 09:59
Webpack's configuration snippet for Electron.
const webpack = require('webpack');
const { RENDERER_INPUT, MAIN_INPUT, BUILD_OUTPUT } = require('./bin/config');
// Define a base configuration.
const baseConfig = (env) => ({
plugins: [new webpack.DefinePlugin({
IS_PRO: env.IS_PRO ? true : false,
IS_PROD: env.IS_PROD ? true : false,
IS_PACKAGED: env.IS_PACKAGED ? true : false
})],
@yoannmoinet
yoannmoinet / seeThroughMain.js
Last active November 13, 2017 09:24
Apply a masked circle on element.
// Main process
export const createSeeThroughWindow = () => {
const w = new BrowserWindow({ transparent: true });
w.setIgnoreMouseEvents(true);
};
@yoannmoinet
yoannmoinet / activatePlugins.js
Last active November 7, 2017 08:23
Activate plugins in Electron
import { app } from 'electron';
import path from 'path';
import {
WIDEVINE_PATH,
WIDEVINE_VERSION,
PEPPERFLASH_PATH,
PEPPERFLASH_VERSION
} from './config';
app.commandLine.appendSwitch('widevine-cdm-path', path.join(__dirname, WIDEVINE_PATH));
@yoannmoinet
yoannmoinet / watchClipboard.js
Last active November 4, 2017 19:42
Keep the clipboard watcher alive.
import { powerSaveBlocker} from 'electron';
let clipboardValue;
powerSaveBlocker.start('prevent-app-suspension');
setInterval(() => {
clipboardValue = clipboard.readText();
}, 1000);
@yoannmoinet
yoannmoinet / windowExists.js
Last active November 4, 2017 19:39
Check for the existence of a BrowserWindow
const windowExists = (w) => {
if (!w || (w && w.isDestroyed())) {
return false;
}
return true;
};
@yoannmoinet
yoannmoinet / removeFolders.js
Last active November 6, 2017 13:23
Remove *.lproj folders
import path from 'path';
import glob from 'glob';
import fs from 'fs-extra';
export const cleanLanguages = (buildPath) => {
// Target only English and French.
const lprojRegEx = /(en|fr)\.lproj/g;
const cwd = path.join(buildPath, `Fenêtre.app/Contents/Resources`);
const lproj = glob.sync('*.lproj', { cwd });
const proms = [];
{
"name": "Testing File"
}
### Keybase proof
I hereby claim:
* I am yoannmoinet on github.
* I am yoannmoinet (https://keybase.io/yoannmoinet) on keybase.
* I have a public key whose fingerprint is 1E06 D01B CA96 C8CD 06F7 E262 3A23 D567 FF21 3F18
To claim this, I am signing this object:
@yoannmoinet
yoannmoinet / logStack.js
Last active February 3, 2016 18:19
Will output in the console what the stack is at the moment this is called.
// nb [int] the number of line to get from the stack
function logStack (nb) {
try {
throw new Error();
} catch (e) {
var stack = e.stack.match(/(https?:\/\/[\w.:0-9\/]+)/g);
if (nb === undefined) {
nb = stack.length - 2;
}
console.log(