Skip to content

Instantly share code, notes, and snippets.

View Linrstudio's full-sized avatar
🌴
On vacation

xyz Linrstudio

🌴
On vacation
View GitHub Profile
Math.radians = function(degrees) {
return degrees * Math.PI / 180;
};
Math.degrees = function(radians) {
return radians * 180 / Math.PI;
};
Math.ctg = function(val) {
return 1/Math.tan(val);
}
@johannesMatevosyan
johannesMatevosyan / server.js
Last active May 8, 2023 10:08
Websockets: send message to all clients except sender.
var http = require('http');
var Static = require('node-static');
var WebSocketServer = new require('ws');
// list of users
var CLIENTS=[];
var id;
// web server is using 8081 port
var webSocketServer = new WebSocketServer.Server({ port: 8081 });
@soundyogi
soundyogi / 2018_chrome_snippet_gui_import_export.js
Last active December 21, 2024 20:04
A snippet to export and import your chrome snippets
void function() { "use strict"
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WIP DO NOT USE WIP !!!!!!!!!!!!!!!!!!!!!
DO NOT USE THIS YET.
USE THE 2016 VERSION BELOW PLEASE.
WWWWWWWW WWWWWWWWIIIIIIIIIIPPPPPPPPPPPPPPPPP
W::::::W W::::::WI::::::::IP::::::::::::::::P
W::::::W W::::::WI::::::::IP::::::PPPPPP:::::P
/**
* Lightweight script to convert touch handlers to mouse handlers
* credit: http://stackoverflow.com/a/6141093
*/
(function() {
function touchHandler(e) {
var touches = e.changedTouches;
var first = touches[0];
var type = "";
@wagonli
wagonli / DeviceTypeHelper.cs
Last active September 10, 2019 22:32
Detect device type on Universal Windows Platform (UWP)
using Windows.System.Profile;
using Windows.UI.ViewManagement;
namespace Wagonli.Tools
{
public static class DeviceTypeHelper
{
public static DeviceFormFactorType GetDeviceFormFactorType()
{
switch (AnalyticsInfo.VersionInfo.DeviceFamily)
@Linrstudio
Linrstudio / hello-apple.md
Created October 20, 2015 06:44
solutions for window.innerWidth / innerHeight issue in iOS9

iOS9 returns double the value for window.innerWidth & window.innerHeight
The versions that are concerned are: 9.0.0, 9.0.1, 9.0.2

A few people got mad on twitter:

window.innerWidth in iOS 9 Safari returns double the number it did in iOS 8? Is this real life? tell me no — @rachsmithtweets
iOS9 Safari has the most insane bug where window.innerWidth / innerHeight is *sometimes* twice as large as it should be. ughhhh. !? — @mattdesl

iOS9 innerWidth/innerHeight is having a lot of fun these days — @ayamflow

@kdzwinel
kdzwinel / main.js
Created September 24, 2015 10:13
stroke effect generator
var color = 'white';
var r = 1.4;//circle readius
var x = -0.15;//circle center
var y = 0.15;
function getXY(angle) {
return {
x: r * Math.cos(angle) + x,
y: r * Math.sin(angle) + y
};
@samarpanda
samarpanda / get_css_properties.js
Created September 10, 2015 05:51
Getting all css properties of a dom element in pure javascript
// Got from this url: http://acuriousanimal.com/blog/2012/07/09/look-mom-no-jquery-getting-all-css-properties-of-a-dom-element-in-pure-javascript/
function getComputedStyle( dom ) {
var style;
var returns = {};
// FireFox and Chrome way
if(window.getComputedStyle){
style = window.getComputedStyle(dom, null);
for(var i = 0, l = style.length; i < l; i++){
var prop = style[i];
var val = style.getPropertyValue(prop);
@rsms
rsms / seteq.js
Created August 6, 2015 21:25
ES6 Set equality test
function seteq(a, b) {
if (a != b) {
if (!a || !b) { return false; }
for (var e of a) {
if (!b.has(e)) { return false; }
}
}
return true;
}
@rsms
rsms / 0 input.js
Last active November 15, 2020 04:51
Pattern-matching parse-time macros for Babel
macro { mul(...$args) sdf } -> { [not_matched, $args] }
macro { mul(...$args) } -> { [matched, $args] }
macro { foo $a x ...$b y } -> { mul($a, $b) + 3 }
lol()
console.log( foo 1 x 2, 3 y, 6 )