Skip to content

Instantly share code, notes, and snippets.

@ysaito8015
ysaito8015 / xrdp-setup-no-hw-accel.sh
Created January 20, 2024 21:48 — forked from Nexarian/xrdp-setup-no-hw-accel.sh
XRDP setup with only CPU encoding. No hardware acceleration
#!/usr/bin/env bash
set -e
sudo -v
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
#!/bin/sh
{
set -e
SUDO=''
if [ "$(id -u)" != "0" ]; then
SUDO='sudo'
echo "This script requires superuser access to install apt packages."
echo "You will be prompted for your password by sudo."
# clear any previous sudo permission
sudo -k
@ysaito8015
ysaito8015 / gnuplot_quickstart.md
Created January 2, 2024 04:15 — forked from darencard/gnuplot_quickstart.md
A quick-start guide for using gnuplot for in-terminal plotting

A quick-start guide for using gnuplot for in-terminal plotting

Sometimes it is really nice to just take a quick look at some data. However, when working on remote computers, it is a bit of a burden to move data files to a local computer to create a plot in something like R. One solution is to use gnuplot and make a quick plot that is rendered in the terminal. It isn't very pretty by default, but it gets the job done quickly and easily. There are also advanced gnuplot capabilities that aren't covered here at all.

gnuplot has it's own internal syntax that can be fed in as a script, which I won't get into. Here is the very simplified gnuplot code we'll be using:

set terminal dumb size 120, 30; set autoscale; plot '-' using 1:3 with lines notitle

Let's break this down:

@ysaito8015
ysaito8015 / lpmixnorm.R
Created December 26, 2023 02:17 — forked from abikoushi/lpmixnorm.R
posterior density of the mixture normal distribution
library(ggplot2)
library(gganimate)
logsumexp=function (logx1,logx2){
logx1 + log1p(exp(logx2-logx1))
}
llmixnorm <- function(par, y){
a0 <- par[1]
b0 <- par[2]
options(repos = "https://cran.rstudio.com/")
if (!require("pacman")) install.packages("pacman")
# isntall linelist
pacman::p_load_gh("reconhub/linelist", dependencies = TRUE)
# install dsr
pacman::p_load_gh("cran/dsr", dependencies = TRUE)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
require "google/apis/gmail_v1"
require "googleauth"
require "googleauth/stores/file_token_store"
require "fileutils"
require "mail"
require "pry"
OOB_URI = "urn:ietf:wg:oauth:2.0:oob".freeze
APPLICATION_NAME = "Gmail API Ruby Mail Sender".freeze
CREDENTIALS_PATH = "credentials.json".freeze
import base64
import pickle
from email.mime.text import MIMEText
from googleapiclient.discovery import build
def create_message(sender, to, subject, message_text):
"""Create a message for an email.
Args:
@ysaito8015
ysaito8015 / stop-blank-screen-one-time.md
Last active May 16, 2020 07:14
Raspbian の blank screen 設定を止める

xset コマンドを使う場合

  • s
    • s オプションはスクリーンセーバのパラメータを設定する。 このオプションには 2 つまでの数値パラメータ、'blank/noblank' フラグ、'expose/noexpose' フラグ、'on/off' フラグ、'activate/reset' フラグ、'default' フラグを指定することができる。 パラメータを指定しなかった場合と 'default' フラグを指定した場合、システムはデフォルトのスクリーンセーバの設定を使用する。
      • 'on/off' フラグは単にスクリーンセーバ機能のオンとオフを設定するだけ である。
sudo xset s off
@ysaito8015
ysaito8015 / Baseline Data, ML, AI: Challenge Lab.md
Created May 15, 2020 13:53
Task 04 at GSP323 https://google.qwiklabs.com/focuses/11044 version (Lab Last Tested May 13, 2020)

Natural language

gcloud iam service-accounts create my-natlang-sa \
  --display-name "my natural language service account"
gcloud iam service-accounts keys create ~/key.json \