Skip to content

Instantly share code, notes, and snippets.

@minthantsin
minthantsin / water_ripple_canvas.js
Created January 21, 2021 07:28 — forked from laziel/water_ripple_canvas.js
Use JavaScript and canvas to create water ripple effect
/*
* Water Canvas by Almer Thie (http://code.almeros.com).
* Description: A realtime water ripple effect on an HTML5 canvas.
* Copyright 2010 Almer Thie. All rights reserved.
*
* Example: http://code.almeros.com/code-examples/water-effect-canvas/
* Tutorial: http://code.almeros.com/water-ripple-canvas-and-javascript
*/
// a promise-based locking mechanism for JavaScript.
// this can be useful to build application-level atomicity around a resource
// that does not offer it. For example, when using a K/V store like LevelDB
// you might need to do a read-then-write (which can't be done with the Level
// batch API) ensuring that no operations can happen in between; you can enforce
// this by ensuring database access happens through the lock
const Bluebird = require("bluebird");
const resources = new WeakMap();
@minthantsin
minthantsin / modern_js.md
Created December 15, 2020 06:12 — forked from gaearon/modern_js.md
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Collections.Generic;
public class SSEvent {
public string Name { get; set; }
public string Data { get; set; }
@minthantsin
minthantsin / rAF.js
Created October 10, 2020 14:02 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@minthantsin
minthantsin / SassMeister-input.scss
Created October 9, 2020 16:17 — forked from jedfoster/.gitignore
JavaScript version of Sass' mix() function
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
body {
width: 100%;
height: 10em;
background: mix(#ff0000, #0000bb, 75);
}
@minthantsin
minthantsin / livespec.py
Created June 2, 2020 10:59 — forked from boylea/livespec.py
pyqtgraph live running spectrogram from microphone
import numpy as np
import pyqtgraph as pg
import pyaudio
from PyQt4 import QtCore, QtGui
FS = 44100 #Hz
CHUNKSZ = 1024 #samples
class MicrophoneRecorder():
def __init__(self, signal):
@minthantsin
minthantsin / KeyboardHook.cs
Created February 22, 2020 07:22 — forked from Lunchbox4K/KeyboardHook.cs
C# Global Keyboard Hooks
// MP Hooks © 2016 Mitchell Pell
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace mp.hooks{
@minthantsin
minthantsin / Pixi.js Smoke Shader
Created February 1, 2020 11:46 — forked from OmarShehata/Pixi.js Smoke Shader
Example of smoke shader in Pixi.js
<!DOCTYPE html>
<html>
<head>
<title>PixiJS Shaders</title>
<style type="text/css">
body {
margin: 0;
overflow: hidden;
}
</style>
@minthantsin
minthantsin / easing.js
Created November 2, 2019 01:14 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity