Skip to content

Instantly share code, notes, and snippets.

View daoshengmu's full-sized avatar

Daosheng Mu daoshengmu

View GitHub Profile
@daoshengmu
daoshengmu / gleanUnity.cs
Last active July 20, 2020 22:24
Glean Unity Hello world
using Mozilla.Glean;
using Mozilla.Glean.Private;
using System;
using UnityEngine;
using static Mozilla.Glean.Glean;
public class main : MonoBehaviour
{
// Start is called before the first frame update
void Start()
@daoshengmu
daoshengmu / gleanPackage.sh
Created July 20, 2020 00:27
Glean NuGet install command
Install-Package Mozilla.Telemetry.Glean -Version 0.0.2-alpha
@daoshengmu
daoshengmu / glean.cs
Last active July 29, 2020 00:18
My first glean c#
// Initialize Glean SDK. `uploadEnabled` can be configured according to
// user telemetry enable|disable setting.
GleanInstance.Initialize(
applicationId: "org.test.glean.sample",
applicationVersion: "1.0",
uploadEnabled: true,
configuration: new Configuration(),
dataDir: gleanDataDir
);
@daoshengmu
daoshengmu / metrics.yaml
Last active July 18, 2020 00:00
hello world metric
$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0
test:
hellow_world:
type: string
description: >
The first hello world metric.
send_in_pings:
- sample
bugs:
@daoshengmu
daoshengmu / pings.yaml
Last active July 17, 2020 23:52
Glean pings
---
$schema: moz://mozilla.org/schemas/glean/pings/1-0-0
sample:
description: >
A sample custom ping.
include_client_id: true
bugs:
data_reviews:
notification_emails:
@daoshengmu
daoshengmu / install_serilog.shell
Created July 17, 2020 22:42
Install serilog commands
PM> Install-Package Serilog
PM> Install-Package Serilog.Sinks.Console
@daoshengmu
daoshengmu / glean.cs
Created July 9, 2020 00:33
Glean initialize before setuploadenabled
GleanInstance.Initialize(
applicationId: "org.mycompany.glean.tests",
applicationVersion: "0.1",
uploadEnabled: true,
configuration: new Configuration(channel: "debug", maxEvents: 500, pingTag: "unity_glean"),
dataDir: "data"
);
GleanInstance.SetUploadEnabled(false);
@daoshengmu
daoshengmu / webxr_vr_cubes.html
Created May 29, 2020 01:09
three.js vr - cube for cube location comparison.
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js vr - cubes</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link type="text/css" rel="stylesheet" href="main.css">
</head>
<body>
@daoshengmu
daoshengmu / postImgToS3.js
Created May 18, 2020 07:52
XMLHttpRequest post image to S3
const url = "https://2r5x7bfm7h.execute-api.us-west-2.amazonaws.com/v1/upload";
const xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open("POST", url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open("POST", url);
} else {
@daoshengmu
daoshengmu / gleanTest.py
Created May 14, 2020 21:29
Glean test debug logging
from mozlog.structuredlog import StructuredLogger, set_default_logger
from pathlib import Path
from glean import Glean, Configuration
from glean import (load_metrics,
load_pings)
import logging
def init_python_redirect_logger(logger):
"""Create a pipe to the main log, at debug level
This is so we can see logs from third party libraries (like Glean)