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 / change-dns.sh
Last active March 24, 2023 13:58
Bash functions to change DNS from terminal.
function setGoogleDNS() {
CHANNEL=`route get google.com | grep interface | sed -n -e 's/^.*interface: //p'`
NETWORK=`networksetup -listnetworkserviceorder | grep $CHANNEL | sed -n -e 's/^.*Port: //p' | sed -n -e 's/,.*//p'`
echo "Setting Google's DNS on channel '$CHANNEL' for network '$NETWORK'."
sudo networksetup -setdnsservers $NETWORK 8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
}
function setCloudflareDNS() {
CHANNEL=`route get google.com | grep interface | sed -n -e 's/^.*interface: //p'`
NETWORK=`networksetup -listnetworkserviceorder | grep $CHANNEL | sed -n -e 's/^.*Port: //p' | sed -n -e 's/,.*//p'`
@yoannmoinet
yoannmoinet / .block
Created July 29, 2020 09:13 — forked from steveharoz/.block
d3-force testing ground
license: gpl-3.0
height: 1030
scrolling: yes
@yoannmoinet
yoannmoinet / browserWindow.js
Last active December 19, 2017 13:06
Show devtools for browser windows.
const newWindow = new BrowserWindow({
webPreferences: {
devTools: !IS_PRODUCTION
}
});
@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'
])
@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 / 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 / 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 / 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 / icons.sh
Last active October 25, 2022 20:28
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 / 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({