Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View m0o0scar's full-sized avatar
💻
Oscar + coffee + AI => code

Oscar m0o0scar

💻
Oscar + coffee + AI => code
  • Sea
  • Singapore
View GitHub Profile
@m0o0scar
m0o0scar / countries.json
Last active November 8, 2022 08:41 — forked from almost/countries.json
A list of countries along 2 letter ISO 3166-1 Alpha 2 (https://en.wikipedia.org/wiki/ISO_3166-1) codes in JSON format
[
{"name": "Afghanistan", "code": "AF"},
{"name": "Åland Islands", "code": "AX"},
{"name": "Albania", "code": "AL"},
{"name": "Algeria", "code": "DZ"},
{"name": "American Samoa", "code": "AS"},
{"name": "AndorrA", "code": "AD"},
{"name": "Angola", "code": "AO"},
{"name": "Anguilla", "code": "AI"},
{"name": "Antarctica", "code": "AQ"},
@m0o0scar
m0o0scar / index.css
Last active August 12, 2022 09:18
[SeaTalk Web] Copy selected messages to clipboard
#toolbar {
position: absolute;
top: -1px;
right: 180px;
padding: 10px;
border: 1px solid #ccc;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
box-shadow: 0px 0px 10px rgb(0 0 0 / 20%);
}
@m0o0scar
m0o0scar / index.html
Created July 1, 2021 04:42
Prevent google.com from crashing Electron v13
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
@m0o0scar
m0o0scar / index.html
Last active September 24, 2021 08:19
iPhone 12 HDR video overexposed issue
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>iPhone 12 HDR Video Test</h1>
<p id="userAgent"></p>
@m0o0scar
m0o0scar / isSupportFontFamily.js
Created February 27, 2018 10:18
用JS检测用户是否安装某font-family字体
//原文及原理请见:http://www.zhangxinxu.com/wordpress/2018/02/js-detect-suppot-font-family/
var isSupportFontFamily=function(f){if(typeof f!="string"){return false}var h="Arial";if(f.toLowerCase()==h.toLowerCase()){return true}var e="a";var d=100;var a=100,i=100;var c=document.createElement("canvas");var b=c.getContext("2d");c.width=a;c.height=i;b.textAlign="center";b.fillStyle="black";b.textBaseline="middle";var g=function(j){b.clearRect(0,0,a,i);b.font=d+"px "+j+", "+h;b.fillText(e,a/2,i/2);var k=b.getImageData(0,0,a,i).data;return[].slice.call(k).filter(function(l){return l!=0})};return g(h).join("")!==g(f).join("")};
@m0o0scar
m0o0scar / DistanceCalculator.cs
Last active November 16, 2017 02:28
Simple way to calculate closest distance to a cube surface
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DistanceCalculator : MonoBehaviour {
public GameObject[] targets;
void Update () {
foreach(GameObject target in targets) {
@m0o0scar
m0o0scar / uuid.js
Last active November 16, 2017 02:28
Generate UUID
//generate an uuid with specify length
function uuid(length=26) {
let len = Math.min(length, 50)/2;
return Math.random().toString(36).substring(2, 2+Math.floor(len)) +
Math.random().toString(36).substring(2, 2+Math.ceil(len));
}
@m0o0scar
m0o0scar / Microphone.cs
Last active November 16, 2017 02:27
Unity To Playback A Microphone Input In Real Time
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class Microphone : MonoBehaviour {
AudioSource source;
void Start () {
if(Microphone.devices.Length > 0) {