Skip to content

Instantly share code, notes, and snippets.

View yomotsu's full-sized avatar

Akihiro Oyamada yomotsu

View GitHub Profile
html {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
::-moz-selection {
background: #4a4a4a;
color: #aaa;
@yomotsu
yomotsu / .js
Last active June 2, 2016 02:41
var array = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ];
var flattened = [].concat.apply([], array );
console.log( flattened ); // [1, 2, 3, 4, 5, 6]
@yomotsu
yomotsu / fragmentShader.fs
Last active April 2, 2016 12:04
spriteAnimation in particle
uniform vec2 spriteLength;
uniform sampler2D texture;
varying float progress;
void main() {
vec2 texCoord = vec2(
gl_PointCoord.x / spriteLength.x + 1. / spriteLength.x * floor( spriteLength.x * progress * spriteLength.y ),
1. - ( gl_PointCoord.y / spriteLength.y + 1. / spriteLength.y * floor( spriteLength.y * progress ) )
@yomotsu
yomotsu / .js
Created March 18, 2016 00:57
shareDepth between 2 RTs
function shareDepth ( rendertarget1, rendertarget2 ) {
// to force setup RT1, not for rendering
renderer.render( new THREE.Scene(), new THREE.Camera(), rendertarget1 );
// to force setup RT2, not for rendering
renderer.render( new THREE.Scene(), new THREE.Camera(), rendertarget2 );
// NOTE
@yomotsu
yomotsu / .css
Created March 1, 2016 03:37
Edge CSS hack
div{
color:red;
}
@supports ( -ms-accelerator:true ) {
/*only for edge*/
div{
color:blue;
}
@yomotsu
yomotsu / gist:57541245d4429dc3a6f5
Created November 10, 2015 05:00
はみ出て100%
margin: 0 calc( -50vw + 50% );
@yomotsu
yomotsu / getDeltaAngle.js
Last active May 11, 2023 14:53
Calculates the shortest difference between two given angles given in radians, in JS
// http://docs.unity3d.com/ja/current/ScriptReference/Mathf.DeltaAngle.html
var getDeltaAngle = function () {
var TAU = 2 * Math.PI;
var mod = function ( a, n ) { return ( a % n + n ) % n; }
return function ( current, target ) {
var a = mod( ( current - target ), TAU );
@yomotsu
yomotsu / *.scss
Last active July 4, 2018 09:49
at-root + modifier
@media screen and (max-width: 320px) {
.Notifier {
$block: &;
display: block;
&_Main {
color: green;
@at-root #{$block}.-error #{&}{
color: red;
@yomotsu
yomotsu / app.js
Created October 3, 2015 04:44
hello world in node.js
// app.js
var http = require( 'http' );
var port = process.env.PORT || 3000;
http.createServer( function( req, res ) {
res.writeHead( 200, { 'Content-Type': 'text/plain' } );
res.end( 'Hello World\n' );
} ).listen( port );
@yomotsu
yomotsu / gist:95752343c22f43896ace
Created September 21, 2015 13:38
bluebird.js コード例
var a = function( val ) {
return new Promise( function( onFulfilled, onRejected ) {
setTimeout( function() { onFulfilled( 1 ); }, 2000 );
} );
};