Skip to content

Instantly share code, notes, and snippets.

@javan
javan / index.html
Created April 8, 2016 18:26
Sample Electron app Windows 10 notification issue: https://github.com/electron/electron/issues/4973
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<ul>
<li>appUserModelId: "<script>document.write(require("electron").remote.getGlobal("appUserModelId"))</script>"</li>
<li>Electron version: <script>document.write(process.versions.electron)</script></li>
@javan
javan / optimized-screenshots.md
Created July 8, 2019 18:51
macOS: Optimized Screenshots
😱 Before: ~/Desktop/Screen Shot….png 4.1 MB
🏆 After: ~/Screenshots/Screen Shot….png 937 KB

  ⤵

  1. Install https://pngquant.org/
    $ brew install pngquant
@javan
javan / screenshot.js
Created June 19, 2012 21:40
Create a screenshot of any URL using phantomjs (headless webkit)
//
// Example usage: phantomjs screenshot.js http://yahoo.com /tmp/yahoo.png
//
var system = require('system');
var url = system.args[1];
var filename = system.args[2];
var page = new WebPage();
page.open(url, function (status) {
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
Trix.config.textAttributes.red = {
style: { backgroundColor: "red" }
}
element.editor.activateAttribute("red")
// See available attribute options in:
// https://github.com/basecamp/trix/blob/master/src/trix/config/text_attributes.coffee
// https://github.com/basecamp/trix/blob/master/src/trix/config/block_attributes.coffee
buttonHTML = """<button type="button" class="attach" data-action="x-attach">Attach Files</button>"""
fileInputHTML = """<input type="file" multiple>"""
$(Trix.config.toolbar.content).find(".button_group.block_tools").append(buttonHTML)
$(document).on "trix-action-invoke", ($event) ->
if $event.originalEvent.actionName is "x-attach"
editorElement = $event.target
editorElement.focus()
@javan
javan / bc_require_element.coffee
Created November 28, 2016 20:24
<bc-require>: Basecamp 3's lazy JavaScript loader
BC.registerElement "bc-require",
createdCallback: ->
@setAttribute("pending", "")
attachedCallback: ->
BC.ready =>
if Loader.find(@script)?.loaded
@activate()
else
@deactivate()
@javan
javan / test.html
Last active June 24, 2018 14:01 — forked from triskweline/test.html
Custom Elements v0 vs. DOMParser
<!doctype html>
<html>
<head>
<title>Custom elements test</title>
</head>
<body>
<h3>Custom elements from HTML</h3>
<ol class="from-html" start="0">
@javan
javan / webpack-fixme.md
Created May 30, 2018 14:33
Ideas for improving webpack.config.js

This is the example webpack.config.js on https://webpack.js.org/:

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  }
}
(async () => {
if (await mutionObserverIsBuggy()) {
patchInnerHTML()
}
})()
function mutionObserverIsBuggy(): Promise<boolean> {
return new Promise(resolve => {
const element = document.createElement("div")
element.innerHTML = "<a><em></em></a>"