Skip to content

Instantly share code, notes, and snippets.

@javan
javan / index.html
Created June 9, 2017 13:25
Electron <webview> document.visibiltyState
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div style="margin: 20px;">
<p>
&lt;webview&gt; visibilityState: <strong id="visibility-state"></strong>
<button id="update-visibility-state">Update</button>
@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 / shortcuts.md
Created November 17, 2016 16:46
Trix Keyboard Shortcuts
[...document.querySelectorAll("trix-toolbar [data-trix-key]")].map(e => `${e.title}: command+${e.dataset.trixKey}`).join("\n")
Bold: command+b
Italic: command+i
Link: command+k
Undo: command+z
Redo: command+shift+z
@javan
javan / kinda.rb
Created August 29, 2016 13:02
Kinda
require "levenshtein"
class Object
def kinda?(klass)
Levenshtein.normalized_distance(self.class.to_s, klass.to_s) < 0.85
end
end
>> "foo".class
=> String
@javan
javan / action-cable.diff
Created July 2, 2016 19:33
Diff of lib/assets/compiled/action_cable.js from actioncable-5.0.0.gem against a freshly compiled version
--- a/action_cable.js
+++ b/action_cable.js
@@ -1,590 +1,599 @@
(function() {
- var slice = [].slice;
-
- this.ActionCable = {
- INTERNAL: {
- "message_types": {
- "welcome": "welcome",
addEventListener("trix-initialize", function(event) {
event.target.toolbarElement.querySelector("button[data-trix-attribute=bullet]").dataset.trixKey = "l";
})
addEventListener "trix-initialize", (event) ->
new TrixAutoLinker event.target
class TrixAutoLinker
constructor: (@element) ->
{@editor} = @element
@element.addEventListener("trix-render", @autoLink)
@autoLink()
autoLink: =>
@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>

Keybase proof

I hereby claim:

  • I am javan on github.
  • I am javan (https://keybase.io/javan) on keybase.
  • I have a public key whose fingerprint is 3CEF DCBC 59FD 1512 4D31 A5C3 A8E5 0C47 67F6 765A

To claim this, I am signing this object:

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