Skip to content

Instantly share code, notes, and snippets.

@sy-tang
sy-tang / sse.md
Created May 29, 2023 07:50 — forked from maiha/sse.md
Nginx configuration Cheat Sheet

nginx

location /sse/ {
  # enables EventSource support
  proxy_http_version 1.1;
  proxy_set_header Connection "";

  proxy_buffering off;
}
@sy-tang
sy-tang / README
Created April 26, 2016 14:04 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
<key>Customized</key>
<dict>
<key>Delete Line</key>
<string>selectLine:, deleteBackward:</string>
<key>Duplicate Lines</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
<key>Duplicate Current Line</key>
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
</dict>
//probability : 0.6(60%)
var getRandom = function(probability){
var probability = probability*10 || 1;
var odds = Math.floor(Math.random()*10);
if(probability === 1){return 1};
if(odds < probability){
return 1;
}else{
return 0;