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 / seeThroughMain.js
Last active September 21, 2024 15:00
Apply a masked circle on element.
// Main process
export const createSeeThroughWindow = () => {
const w = new BrowserWindow({ transparent: true });
w.setIgnoreMouseEvents(true);
};
@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 / 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 / mailUnhandled.js
Last active November 21, 2017 17:56
Unhandled send mails.
import unhandled from 'electron-unhandled';
import mailgunInitializer from 'mailgun-js';
import { APP_VERSION, MAILGUN_PRIVATE, MAILGUN_SERVER } from './config';
const mailgun = mailgunInitializer(({
apiKey: MAILGUN_PRIVATE,
domain: MAILGUN_SERVER
}));
unhandled({
@yoannmoinet
yoannmoinet / icons.sh
Last active January 13, 2025 13:09
Mac OS X icon.icns
#!/bin/sh
#Usage: ./icons.sh ../assets/media/icon_color_1024.png ../assets/icons
name=$(basename "$1" ".png")
dir=$(cd "$(dirname "$2")"; pwd)/$(basename "$2")
mkdir $dir/$name.iconset
sips -Z 16 --out $dir/$name.iconset/icon_16x16.png $1
sips -Z 32 --out $dir/$name.iconset/icon_16x16@2x.png $1
sips -Z 32 --out $dir/$name.iconset/icon_32x32.png $1
@yoannmoinet
yoannmoinet / upscale.sh
Created November 28, 2017 13:03
Upscale png file with transparent to make it square 1024px.
convert icon_white.png -resize x1024 \
-size 1024x1024 xc:transparent +swap -gravity center -composite \
icon_white_1024.png
@yoannmoinet
yoannmoinet / signApp.js
Last active November 28, 2017 17:21
Sign Mac OS X app for production.
import { sign, flat } from 'electron-osx-sign';
import { PARENT_PLIST_PATH, CHILD_PLIST_PATH, PROVISIONING_PROFILE } from './config';
const signApp = (appPath, pkgPath) => {
const resourcesPath = path.join(appPath, './Contents/Resources/');
const signOpts = {
app: appPath,
platform: 'mas',
binaries: [ /* Here goes the list of binaries you have in your app, like the widevine plugin. */ ],
entitlements: PARENT_PLIST_PATH,
@yoannmoinet
yoannmoinet / signApp.js
Created November 28, 2017 17:27
Sign Mac OS X app for development
import { sign } from 'electron-osx-sign';
import { PARENT_PLIST_PATH, CHILD_PLIST_PATH, DEV_PROVISIONING_PROFILE } from './config';
const signApp = (appPath, pkgPath) => {
const resourcesPath = path.join(appPath, './Contents/Resources/');
const signOpts = {
app: appPath,
platform: 'mas',
binaries: [ /* Here goes the list of binaries you have in your app, like the widevine plugin. */ ],
entitlements: PARENT_PLIST_PATH,
@yoannmoinet
yoannmoinet / videoSupportHandling.js
Created November 29, 2017 08:26
Video missing support error handling.
const video = document.querySelector('video');
video.addEventListener('error', () => {
switch (video.error.code) {
case video.error.MEDIA_ERR_DECODE:
case video.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
// Video format not supported.
break;
case video.error.MEDIA_ERR_ABORTED:
case video.error.MEDIA_ERR_NETWORK:
default:
@yoannmoinet
yoannmoinet / streamDecodedVideo.js
Created November 29, 2017 08:41
Stream video back in correct format.
import ffmpeg form 'fluent-ffmpeg';
const filePath = '/Users/yoann/Desktop/video.avi';
const route = (req, res) => {
res.writeHead(200, getHeaders({'Content-Type': 'video/mp4'}));
ffmpeg(filePath)
.format('mp4')
.addOptions([
'-movflags frag_keyframe+faststart'
])