Skip to content

Instantly share code, notes, and snippets.

Avatar
🍵

Shuhei Kagawa shuhei

🍵
View GitHub Profile
@acutmore
acutmore / README.md
Last active Nov 19, 2020
Emulating a 4-Bit Virtual Machine in (TypeScript\JavaScript) (just Types no Script)
View README.md

A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.

Syntax emits zero JavaScript.

type RESULT = VM<
  [
    ["push", N_1],         // 1
    ["push", False],       // 2
    ["peek", _],           // 3
@malchata
malchata / measure-image-decode.js
Last active Aug 19, 2018
A super Jerry-rigged way of getting image decode times from traces captured using Puppeteer
View measure-image-decode.js
// This is Node script that uses Puppeteer (headless Chrome) to measure the decode time
// of a single image injected into a blank HTML document. It uses minimist to take command
// line arguments. Example usage: node measure-image-decode.js https://example.com/example-image.jpg
// This example assumes you're running a local server to grab the blank document.
// Thanks to Paul Irish and Tim Kadlec for their input!
const puppeteer = require("puppeteer");
const argv = require("minimist")(process.argv.slice(2));
async function getDecode(url) {
@addyosmani
addyosmani / preprocessing.md
Last active Nov 21, 2020
JavaScript preprocessing/precompilation
View preprocessing.md

Problem: How can we preprocess JavaScript (at build-time or on the server-side) so engines like V8 don't have to spend as much time in Parse? This is a topic that involves generating either bytecode or a bytecode-like-abstraction that an engine would need to accept. For folks that don't know, modern web apps typically spend a lot longer in Parsing & Compiling JS than you may think.

  • Yoav: This can particularly be an issue on mobile. Same files getting parsed all the time for users. Theoretically if we moved the parsing work to the server-side, we would have to worry about it less.
  • One angle to this problem is we all ship too much JavaScript. That's one perspective. We could also look at preprocessing.
  • We've been talking about this topic over the last few weeks a bit with V8. There were three main options proposed.
    1. Similar to what optimize-js does. Identify IIFEs and mark them as such so the browser and VMs heuristics will catch them and do a better job than today. optimize-js only tackles IIFE bu
View sushi-console.js
const STR_LEN = 80
const SUSHI_INTERVAL =10
let cnt = 0;
function sushiDraw(){
const sa = new Array(STR_LEN).fill(' ')
for(let i = 0; i < STR_LEN; i += SUSHI_INTERVAL){
const sushiIndex = sa.length - 1 - (cnt + i) % sa.length
sa.splice(sushiIndex, 1, '🍣')
}
@alekseykulikov
alekseykulikov / index.md
Last active Aug 8, 2020
Principles we use to write CSS for modern browsers
View index.md

Recently CSS has got a lot of negativity. But I would like to defend it and show, that with good naming convention CSS works pretty well.

My 3 developers team has just developed React.js application with 7668 lines of CSS (and just 2 !important). During one year of development we had 0 issues with CSS. No refactoring typos, no style leaks, no performance problems, possibly, it is the most stable part of our application.

Here are main principles we use to write CSS for modern (IE11+) browsers:

@taisukeoe
taisukeoe / 201607.md
Last active Jul 20, 2016
多相な関数の定義から学ぶ、型クラスデザインパターン
View 201607.md

#多相な関数の定義から学ぶ、型クラスデザインパターン

         twitter: @OE_uia github: taisukeoe

##多相な関数

  • 複数の異なる型に対して適用可能な関数
  • どの型に対して定義されているか、静的に決定できる(定義されてない型の値を渡すとコンパイルエラーになる)
@steipete
steipete / gist:d9b44d8e9f341e81414e86d7ff8fb62d
Last active Nov 5, 2020
Using iOS 14 devices with Xcode 11.5 (instead of Xcode 12)
View gist:d9b44d8e9f341e81414e86d7ff8fb62d
// The trick is to link the DeviceSupport folder from the beta to the stable version.
// sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
// Support iOS 14 devices (Xcode 12.0) with Xcode 11.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/14.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
// Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
View panama.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cvan
cvan / HOWTO.md
Last active Oct 14, 2020
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default
View HOWTO.md

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you
@oelmekki
oelmekki / doc.md
Created Dec 30, 2015
Rails + Browserify + React + es7
View doc.md

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

You can’t perform that action at this time.