Skip to content

Instantly share code, notes, and snippets.

View ef2k's full-sized avatar
🏀

Eddie Flores ef2k

🏀
  • Brooklyn, NY
View GitHub Profile
@ef2k
ef2k / asar-bin-files.md
Last active May 28, 2018 17:29
Electron: Adding an Executable Binary

You can add files to the final asar using electron-builder's extraFiles field in package.json.

In package.json,

"build": {
  "additionalFiles": {
    "from": "resources/${os}/myBin",
    "to": "Resources/bin/myBin",
    "pattern": "**/*"
 }
@ef2k
ef2k / main-to-renderer.md
Created May 28, 2018 02:23
Electron: Sending channel message from Main to Renderer

In main/index.js,

import { globalShortcut } from 'electron'

// mainWindow is an instance of BrowserWindow
let mainWindow;

app.on('ready', () => {
  globalShortcut.on('CommandOrControl+,', () => {
 mainWindow.webContents.send('shortcut-settings')
@ef2k
ef2k / asar-unpack.md
Last active May 28, 2018 16:47
Unpackaging files in Electron

Electron allows execution via child_process.execFile but, restricts fs, fork and exec in the production runtime unless the executable is unpacked.

Asar is the tar-like archiving format used by Electron. All packed files are treated as "read only". To execute a distributed file, electron-builder needs to be configured to leave our executable as an "unpacked file".

In package.json,

"build": {
  "asarUnpack": [
 "lib/mybin"
@ef2k
ef2k / docker-push.sh
Created April 18, 2018 04:52
Docker push an image over SSH (save and load)
docker save <my_image> | ssh -C user@my.remote.host.com docker load
@ef2k
ef2k / container.css
Last active April 15, 2018 20:17
Mobile first pure CSS container taken from Bootstrap (breakpoints included)
/*
usage: @import url("container.css"); at the top of your base stylesheet
*/
/* ------------ */
/* Mobile first */
/* ------------ */
.container {
padding: 0 50px;
@ef2k
ef2k / gitlog2md.sh
Last active April 10, 2018 18:37
git log to markdown list
# For formatting see: https://git-scm.com/docs/pretty-formats
git log --pretty=format:"* \`%ad\` - %s %n%b" --date=short | sed '/^\s*$/d' > gitlog.md
@ef2k
ef2k / main.go
Created January 4, 2018 01:36 — forked from Depado/main.go
Integrating Chroma in Blackfriday
package main
import (
"fmt"
"io"
"github.com/alecthomas/chroma"
"github.com/alecthomas/chroma/formatters/html"
"github.com/alecthomas/chroma/lexers"
@ef2k
ef2k / keybase.md
Last active February 26, 2018 06:32

Keybase proof

I hereby claim:

  • I am ef2k on github.
  • I am ef2k (https://keybase.io/ef2k) on keybase.
  • I have a public key ASApyjxGWIBHPkC63mloazdb4MuMrl8sBsTuCCyA6ReLUAo

To claim this, I am signing this object:

@ef2k
ef2k / getting_golang_ready.md
Last active August 17, 2016 16:13
Getting Golang Ready

Getting Golang Ready

Please note, that this is a guide that assumes you're on OSX.

Installing pre-requisites

GVM

For details see https://github.com/moovweb/gvm

@ef2k
ef2k / Caddyfile
Created May 21, 2016 10:13
Ember friendly Caddyfile
localhost:9002
root dist
gzip
log ../access.log
pprof
rewrite {
r ^(.+)$
if {file} not favicon.ico
to {path} {path}/ /index.html?{1}
}