Skip to content

Instantly share code, notes, and snippets.

@kosamari
kosamari / _ServiceWorker_for_github_pages.md
Last active February 5, 2024 16:39
ServiceWorker for github pages.

ServiceWorker for github pages

This is a ServiceWorker template to turn small github pages into offline ready app.

Why ?

Whenever I make small tools & toys, I create github repo and make a demo page using github pages (like this one).
Often these "apps" are just an index.html file with all the nessesary CSS and JavaScript in it (or maybe 2-3 html/css/js files). I wanted to cache these files so that I can access my tools offline as well.

Notes

Make sure your github pages have HTTPS enforced, you can check Settings > GitHub Pages > Enforce HTTPS of your repository.

@kosamari
kosamari / index.js
Last active June 19, 2016 05:59
requirebin sketch
// creating input element with labal this way adds `htmlfor` attribute not `for` in <label> tag... disabling "clicl label to interact with input"
// screen shot : https://twitter.com/kosamari/status/744402490871906304
/* WITH YO*/
var yo = require('yo-yo')
function yoInput (id) {
return yo`
<div>
<input type="file" name="file" id="${id}">
<label for="${id}">label for the file input (yo)</label>
@kosamari
kosamari / slackRemind.js
Last active February 25, 2016 06:33
slack remind
var input = document.getElementById('message-input');
function setReminder(who, what, when){
var msg = `/remind ${who} ${what} ${when}`
input.value = msg
TS.view.submit()
}

Keybase proof

I hereby claim:

  • I am kosamari on github.
  • I am kosamari (https://keybase.io/kosamari) on keybase.
  • I have a public key whose fingerprint is 3F47 CFFF FB44 8B21 70AC E1BE 05AF 2049 AC38 C5CA

To claim this, I am signing this object:

@kosamari
kosamari / index.html
Last active August 29, 2015 14:26
名前
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Upstart</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="poem, generator" />
<meta name="date" content="2013-10-09" />
<style type="text/css">
a {text-decoration:none;color:black;}
@kosamari
kosamari / index.html
Last active August 29, 2015 14:26
<sarcasm></sarcasm>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://craig.global.ssl.fastly.net/js/mousetrap/mousetrap.min.js"></script>
<style>
#container{
margin-right: auto;
margin-left: auto;
text-align: center;
}

stream video is not avilable anymore

I've changed link to each video. I'll add links to slides as I find them :)

The Scary Stuff

Simon Swain - Cold War Simulation
Yan Zhu - Weird Tricks to Improve Web Security 10000000% Slides
Jed Schmidt - Inline Styles

UX & Performance

Michelle Bu - building component libraries

@kosamari
kosamari / what-I-learned.md
Created June 15, 2015 13:43
What I learned from reading PRs and issues on 'What is Code?' repo

Programmers likes to fix things. When there is a typo in your code, then your code won't work. There are many requests to fix typo in the article from inconstant numbering in footnotes to wrong filename for images. When spotting someone's mistake, get creative and title your PR like "Instagram is only worth 1 Instragram not 2 Instragrams". Programmer's attention to detail extends not only the article itself, but also the license doc in the repo.

Don't forget to fact check before spotting mistake though. It's important. Keyword to use is AFAIK and can confirm.

Programmers love to know the source of information. There are few requests to add hyperlinks to contents referenced in the article. Some are from original autho

Terms I did not know and learnd over time.

Project related

  • TC
  • TC39
  • ES6 (ES5, ES3)
  • Core (about an open source project)
  • Commit bit
  • SemVer
@kosamari
kosamari / DecimalHexBinary
Created April 27, 2015 04:35
Decimal/Hex/Binary
| Decimal | Hex | Binary |
|---------|-----|----------|
| 0 | 00 | 00000000 |
| 1 | 01 | 00000001 |
| 2 | 02 | 00000010 |
| 3 | 03 | 00000011 |
| 4 | 04 | 00000100 |
| 5 | 05 | 00000101 |
| 6 | 06 | 00000110 |
| 7 | 07 | 00000111 |