text:
// Code generated by the FlatBuffers compiler. DO NOT EDIT.

package model

import (
	flatbuffers "github.com/google/flatbuffers/go"
)

type GenerateRequest struct {
	_tab flatbuffers.Table
}

func GetRootAsGenerateRequest(buf []byte, offset flatbuffers.UOffsetT) *GenerateRequest {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &GenerateRequest{}
	x.Init(buf, n+offset)
	return x
}

func GetSizePrefixedRootAsGenerateRequest(buf []byte, offset flatbuffers.UOffsetT) *GenerateRequest {
	n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
	x := &GenerateRequest{}
	x.Init(buf, n+offset+flatbuffers.SizeUint32)
	return x
}

func (rcv *GenerateRequest) Init(buf []byte, i flatbuffers.UOffsetT) {
	rcv._tab.Bytes = buf
	rcv._tab.Pos = i
}

func (rcv *GenerateRequest) Table() flatbuffers.Table {
	return rcv._tab
}

func (rcv *GenerateRequest) NBits() int32 {
	o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
	if o != 0 {
		return rcv._tab.GetInt32(o + rcv._tab.Pos)
	}
	return 0
}

func (rcv *GenerateRequest) MutateNBits(n int32) bool {
	return rcv._tab.MutateInt32Slot(4, n)
}

func GenerateRequestStart(builder *flatbuffers.Builder) {
	builder.StartObject(1)
}
func GenerateRequestAddNBits(builder *flatbuffers.Builder, nBits int32) {
	builder.PrependInt32Slot(0, nBits, 0)
}
func GenerateRequestEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
	return builder.EndObject()
}

repository: jerson/rsa-mobile

repo_name: jerson/rsa-mobile

gha_license_id: MIT

gha_language: TypeScript


text:
@inproceedings{10.1145/2988450.2991128,
author = {Dieleman, Sander},
title = {Keynote: Deep Learning for Audio-Based Music Recommendation},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2991128},
doi = {10.1145/2988450.2991128},
abstract = {The advent of deep learning has made it possible to extract high-level information from perceptual signals without having to specify manually and explicitly how to obtain it; instead, this can be learned from examples. This creates opportunities for automated content analysis of musical audio signals. In this talk, I will discuss how deep learning techniques can be used for audio-based music recommendation, with which we can tackle the item cold-start problem that burdens the prevailing collaborative filtering approaches.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {1},
numpages = {1},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

@inproceedings{10.1145/2988450.2988453,
author = {Zheng, Yin and Liu, Cailiang and Tang, Bangsheng and Zhou, Hanning},
title = {Neural Autoregressive Collaborative Filtering for Implicit Feedback},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2988453},
doi = {10.1145/2988450.2988453},
abstract = {This paper proposes implicit CF-NADE, a neural autoregressive model for collaborative filtering tasks using implicit feedback( e.g. click/watch/browse behaviors). We first convert a user's implicit feedback into a "like" vector and a confidence vector, and then model the probability of the "like" vector, weighted by the confidence vector. The training objective of implicit CF-NADE is to maximize a weighted negative log-likelihood. We test the performance of implicit CF-NADE on a dataset collected from a popular digital TV streaming service. More specifically, in the experiments, we describe how to convert watch counts into implicit "relative rating", and feed into implicit CF-NADE. Then we compare the performance of implicit CF-NADE model with the popular implicit matrix factorization approach. Experimental results show that implicit CF-NADE significantly outperforms the baseline.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {2–6},
numpages = {5},
keywords = {implicit feedback, neural network, collaborative filtering, deep learning},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

@inproceedings{10.1145/2988450.2988454,
author = {Cheng, Heng-Tze and Koc, Levent and Harmsen, Jeremiah and Shaked, Tal and Chandra, Tushar and Aradhye, Hrishi and Anderson, Glen and Corrado, Greg and Chai, Wei and Ispir, Mustafa and Anil, Rohan and Haque, Zakaria and Hong, Lichan and Jain, Vihan and Liu, Xiaobing and Shah, Hemal},
title = {Wide & Deep Learning for Recommender Systems},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2988454},
doi = {10.1145/2988450.2988454},
abstract = {Generalized linear models with nonlinear feature transformations are widely used for large-scale regression and classification problems with sparse inputs. Memorization of feature interactions through a wide set of cross-product feature transformations are effective and interpretable, while generalization requires more feature engineering effort. With less feature engineering, deep neural networks can generalize better to unseen feature combinations through low-dimensional dense embeddings learned for the sparse features. However, deep neural networks with embeddings can over-generalize and recommend less relevant items when the user-item interactions are sparse and high-rank. In this paper, we present Wide & Deep learning---jointly trained wide linear models and deep neural networks---to combine the benefits of memorization and generalization for recommender systems. We productionized and evaluated the system on Google Play, a commercial mobile app store with over one billion active users and over one million apps. Online experiment results show that Wide & Deep significantly increased app acquisitions compared with wide-only and deep-only models. We have also open-sourced our implementation in TensorFlow.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {7–10},
numpages = {4},
keywords = {Recommender Systems, Wide & Deep Learning},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

@inproceedings{10.1145/2988450.2988456,
author = {Strub, Florian and Gaudel, Romaric and Mary, J\'{e}r\'{e}mie},
title = {Hybrid Recommender System Based on Autoencoders},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2988456},
doi = {10.1145/2988450.2988456},
abstract = {A standard model for Recommender Systems is the Matrix Completion setting: given partially known matrix of ratings given by users (rows) to items (columns), infer the unknown ratings. In the last decades, few attempts where done to handle that objective with Neural Networks, but recently an architecture based on Autoencoders proved to be a promising approach. In current paper, we enhanced that architecture (i) by using a loss function adapted to input data with missing values, and (ii) by incorporating side information. The experiments demonstrate that while side information only slightly improve the test error averaged on all users/items, it has more impact on cold users/items.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {11–16},
numpages = {6},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

@inproceedings{10.1145/2988450.2988452,
author = {Tan, Yong Kiam and Xu, Xinxing and Liu, Yong},
title = {Improved Recurrent Neural Networks for Session-Based Recommendations},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2988452},
doi = {10.1145/2988450.2988452},
abstract = {Recurrent neural networks (RNNs) were recently proposed for the session-based recommendation task. The models showed promising improvements over traditional recommendation approaches. In this work, we further study RNN-based models for session-based recommendations. We propose the application of two techniques to improve model performance, namely, data augmentation, and a method to account for shifts in the input data distribution. We also empirically study the use of generalised distillation, and a novel alternative model that directly predicts item embeddings. Experiments on the RecSys Challenge 2015 dataset demonstrate relative improvements of 12.8% and 14.8% over previously reported results on the Recall@20 and Mean Reciprocal Rank@20 metrics respectively.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {17–22},
numpages = {6},
keywords = {Recommender systems, Session-based recommendations, Recurrent neural networks},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

@inproceedings{10.1145/2988450.2988457,
author = {Vuurens, Jeroen B. P. and Larson, Martha and de Vries, Arjen P.},
title = {Exploring Deep Space: Learning Personalized Ranking in a Semantic Space},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2988457},
doi = {10.1145/2988450.2988457},
abstract = {Recommender systems leverage both content and user interactions to generate recommendations that fit users' preferences. The recent surge of interest in deep learning presents new opportunities for exploiting these two sources of information. To recommend items we propose to first learn a user-independent high-dimensional semantic space in which items are positioned according to their substitutability, and then learn a user-specific transformation function to transform this space into a ranking according to the user's past preferences. An advantage of the proposed architecture is that it can be used to effectively recommend items using either content that describes the items or user-item ratings. We show that this approach significantly outperforms state-of-the-art recommender systems on the MovieLens 1M dataset.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {23–28},
numpages = {6},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

@inproceedings{10.1145/2988450.2988451,
author = {Dai, Hanjun and Wang, Yichen and Trivedi, Rakshit and Song, Le},
title = {Recurrent Coevolutionary Latent Feature Processes for Continuous-Time Recommendation},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2988451},
doi = {10.1145/2988450.2988451},
abstract = {Matching users to the right items at the right time is a fundamental task in recommender systems. As users interact with different items over time, users' and items' feature may drift, evolve and co-evolve over time. Traditional models based on static latent features or discretizing time into epochs can become ineffective for capturing the fine-grained temporal dynamics in the user-item interactions. We propose a coevolutionary latent feature process model that accurately captures the coevolving nature of users' and items' feature. We use a recurrent neural network to automatically learn a representation of influences from drift, evolution and co-evolution of user and item features. We develop an efficient stochastic gradient algorithm for learning the model parameters which can readily scale up to millions of events. Experiments on diverse real-world datasets demonstrate significant improvements in user behavior prediction compared to state-of-the-arts.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {29–34},
numpages = {6},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

@inproceedings{10.1145/2988450.2988455,
author = {Zanotti, Greg and Horvath, Miller and Barbosa, Lucas Nunes and Immedisetty, Venkata Trinadh Kumar Gupta and Gemmell, Jonathan},
title = {Infusing Collaborative Recommenders with Distributed Representations},
year = {2016},
isbn = {9781450347952},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/2988450.2988455},
doi = {10.1145/2988450.2988455},
abstract = {Recommender systems assist users in navigating complex information spaces and focus their attention on the content most relevant to their needs. Often these systems rely on user activity or descriptions of the content. Social annotation systems, in which users collaboratively assign tags to items, provide another means to capture information about users and items. Each of these data sources provides unique benefits, capturing different relationships.In this paper, we propose leveraging multiple sources of data: ratings data as users report their affinity toward an item, tagging data as users assign annotations to items, and item data collected from an online database. Taken together, these datasets provide the opportunity to learn rich distributed representations by exploiting recent advances in neural network architectures. We first produce representations that subjectively capture interesting relationships among the data. We then empirically evaluate the utility of the representations to predict a user's rating on an item and show that it outperforms more traditional representations. Finally, we demonstrate that traditional representations can be combined with representations trained through a neural network to achieve even better results.},
booktitle = {Proceedings of the 1st Workshop on Deep Learning for Recommender Systems},
pages = {35–42},
numpages = {8},
keywords = {Collaborative filtering, neural networks, distributed representations, recommender systems},
location = {Boston, MA, USA},
series = {DLRS 2016}
}

license: Unlicense

repository: goyalkaraniit/acm-cr

license_type: permissive

repo_name: goyalkaraniit/acm-cr

branch_name: refs/heads/main

extension: bib


text:
require ../../include/rcar-gen2-modules-common.inc
require ../../include/omx-components-control.inc

inherit remove-libtool

LICENSE = "CLOSED"
DEPENDS = "mmngr-kernel-module mmngr-user-module \
           vspm-kernel-module vspm-user-module \
           s3ctl-kernel-module s3ctl-user-module \
           fdpm-kernel-module fdpm-user-module \
           uvcs-kernel-module"

PR = "r0"
PV = "1.0"
PN = "omx-user-module"

SRC_URI = "file://RTM0AC0000XCMCTL20SL32C.tar.bz2;name=file1 \
           file://RTM0AC0000XVCMND20SL32C.tar.bz2;name=file2 \
           file://RTM0AC0000XV264D20SL32C.tar.bz2;name=file3 \
           "
SRC_URI += '${@base_conditional( "USE_H263_DECODER", "1", " file://RTM0AC0000XV263D20SL32C.tar.bz2;name=file4", "", d )}'
SRC_URI += '${@base_conditional( "USE_MPEG2_DECODER", "1", " file://RTM0AC0000XVM2VD20SL32C.tar.bz2;name=file5", "", d )}'
SRC_URI += '${@base_conditional( "USE_MPEG4_DECODER", "1", " file://RTM0AC0000XVM4VD20SL32C.tar.bz2;name=file6", "", d )}'
SRC_URI += '${@base_conditional( "USE_DIVX_DECODER", "1", " file://RTM0AC0000XVDVXD20SL32C.tar.bz2;name=file7", "", d )}'
SRC_URI += '${@base_conditional( "USE_VC1_DECODER", "1", " file://RTM0AC0000XVVC1D20SL32C.tar.bz2;name=file8", "", d )}'
SRC_URI += '${@base_conditional( "USE_H264AVC_ENCODER", "1", " file://RTM0AC0000XV264E20SL32C.tar.bz2;name=file9", "", d )}'
SRC_URI += '${@base_conditional( "USE_VIDEO_COMMON_ENCODER", "1", " file://RTM0AC0000XVCMNE20SL32C.tar.bz2;name=file10", "", d )}'
SRC_URI += '${@base_conditional( "USE_AUDIO_COMMON", "1", " file://RTM0AC0000XACMND20SL32C.tar.bz2;name=file11", "", d )}'
SRC_URI += '${@base_conditional( "USE_AACP2_DECODER", "1", " file://RTM0AC0000XAAAPD20SL32C.tar.bz2;name=file12", "", d )}'
SRC_URI += '${@base_conditional( "USE_MP3_DECODER", "1", " file://RTM0AC0000XAMP3D20SL32C.tar.bz2;name=file13", "", d )}'
SRC_URI += '${@base_conditional( "USE_WMA_DECODER", "1", " file://RTM0AC0000XAWMAD20SL32C.tar.bz2;name=file14", "", d )}'
SRC_URI += '${@base_conditional( "USE_DDD_DECODER", "1", " file://RTM0AC0000XADD5D20SL32C.tar.bz2;name=file15", "", d )}'
SRC_URI += '${@base_conditional( "USE_ALAC_DECODER", "1", " file://RTM0AC0000XAALAD20SL32C.tar.bz2;name=file16", "", d )}'
SRC_URI += '${@base_conditional( "USE_FLAC_DECODER", "1", " file://RTM0AC0000XAFLAD20SL32C.tar.bz2;name=file17", "", d )}'
SRC_URI += '${@base_conditional( "USE_AAC_ENCODER", "1", " file://RTM0AC0000XAAACE20SL32C.tar.bz2;name=file18", "", d )}'
SRC_URI += '${@base_conditional( "ARMAACP2_MDW_DECODER", "1", " file://RTM0AC0000ADAAPMZ1SL32C.tar.bz2;name=file19", "", d )}'
SRC_URI += '${@base_conditional( "MP3_MDW_DECODER", "1", " file://RTM0AC0000ADMP3MZ1SL32C.tar.bz2;name=file20", "", d )}'
SRC_URI += '${@base_conditional( "WMA_MDW_DECODER", "1", " file://RTM0AC0000ADWMAMZ1SL32C.tar.bz2;name=file21", "", d )}'
SRC_URI += '${@base_conditional( "DDD_MDW_DECODER", "1", " file://RTM0AC0000ADDD5MZ1SL32C.tar.bz2;name=file22", "", d )}'
SRC_URI += '${@base_conditional( "ALAC_MDW_DECODER", "1", " file://RCG2ADALAMZ1SL32.tar.bz2;name=file23", "", d )}'
SRC_URI += '${@base_conditional( "FLAC_MDW_DECODER", "1", " file://RCG2ADFLAMZ1SL32.tar.bz2;name=file24", "", d )}'
SRC_URI += '${@base_conditional( "AAC_MDW_ENCODER", "1", " file://RTM0AC0000AEAACMZ1SL32C.tar.bz2;name=file25", "", d )}'

LISTSRC = "RTM0AC0000XCMCTL20SL32C \
           RTM0AC0000XVCMND20SL32C \
           RTM0AC0000XV264D20SL32C"

LISTSRC += '${@base_conditional( "USE_H263_DECODER", "1", "RTM0AC0000XV263D20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_MPEG2_DECODER", "1", "RTM0AC0000XVM2VD20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_MPEG4_DECODER", "1", "RTM0AC0000XVM4VD20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_DIVX_DECODER", "1", "RTM0AC0000XVDVXD20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_VC1_DECODER", "1", "RTM0AC0000XVVC1D20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_H264AVC_ENCODER", "1", "RTM0AC0000XV264E20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_VIDEO_COMMON_ENCODER", "1", "RTM0AC0000XVCMNE20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_AUDIO_COMMON", "1", "RTM0AC0000XACMND20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_AACP2_DECODER", "1", "RTM0AC0000XAAAPD20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_MP3_DECODER", "1", "RTM0AC0000XAMP3D20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_WMA_DECODER", "1", "RTM0AC0000XAWMAD20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_DDD_DECODER", "1", "RTM0AC0000XADD5D20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_ALAC_DECODER", "1", "RTM0AC0000XAALAD20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_FLAC_DECODER", "1", "RTM0AC0000XAFLAD20SL32C", "", d )}'
LISTSRC += '${@base_conditional( "USE_AAC_ENCODER", "1", "RTM0AC0000XAAACE20SL32C", "", d )}'

MIDWARESRC = '${@base_conditional( "ARMAACP2_MDW_DECODER", "1", "RTM0AC0000ADAAPMZ1SL32C", "", d )}'
MIDWARESRC += '${@base_conditional( "MP3_MDW_DECODER", "1", "RTM0AC0000ADMP3MZ1SL32C", "", d )}'
MIDWARESRC += '${@base_conditional( "WMA_MDW_DECODER", "1", "RTM0AC0000ADWMAMZ1SL32C", "", d )}'
MIDWARESRC += '${@base_conditional( "DDD_MDW_DECODER", "1", "RTM0AC0000ADDD5MZ1SL32C", "", d )}'
MIDWARESRC += '${@base_conditional( "ALAC_MDW_DECODER", "1", "RCG2ADALAMZ1SL32", "", d )}'
MIDWARESRC += '${@base_conditional( "FLAC_MDW_DECODER", "1", "RCG2ADFLAMZ1SL32", "", d )}'
MIDWARESRC += '${@base_conditional( "AAC_MDW_ENCODER", "1", "RTM0AC0000AEAACMZ1SL32C", "", d )}'

S = "${WORKDIR}/omx"

do_unpack_append () {
    bb.build.exec_func('do_collect_src', d)
}

do_collect_src() {
    cd ${WORKDIR}
    mkdir -p ${S}
    for dir in ${LISTSRC}; do
        cp -rf ${dir}/Software/* ${S}
        rm -rf ${dir}
    done
    cp -rf ${S}/OMXR/include ${S}/UDF_Linux
    cp -rf ${S}/OMXR/lib/linux/linaro_4_7_3/* ${S}/OMXR/lib/
    rm -rf ${S}/OMXR/lib/linux/

    # Colect audio midleware
    mkdir -p ${S}/audio_mdw
    for dir in ${MIDWARESRC}; do
        cp -rf ${dir}/* ${S}/audio_mdw
        rm -rf ${dir}
    done
}

do_configure() {
    cd ${S}/UDF_Linux
    ./autogen.sh
    ./configure --prefix=${D}${RENESAS_DATADIR}/ --host=arm-linux \
        CFLAGS="-I${BUILDDIR}/include -I${KERNELDIR}/include" \
        LDFLAGS="-L${LIBSHARED}" \
        OMXR_DEFAULT_CONFIG_FILE_NAME=${RENESAS_DATADIR}/config/omxr_config_base.txt
}

do_compile() {
    cd ${S}/UDF_Linux
    make
}

do_install() {
    # Create share files
    mkdir -p ${D}${RENESAS_DATADIR}/lib ${D}${RENESAS_DATADIR}/config
    cd ${S}/UDF_Linux
    make install
    cp -rf ${S}/OMXR/config/*.txt ${D}${RENESAS_DATADIR}/config/
    cp -rf ${S}/UDF_Linux/include ${D}${RENESAS_DATADIR}/include

    cd ${S}/OMXR/lib/

    # OMX ctrl part
    ln -sf libomxr_core.so.2.0.0 libomxr_core.so.2
    ln -sf libomxr_core.so.2.0.0 libomxr_core.so

    ln -sf libomxr_mc_cmn.so.2.0.0 libomxr_mc_cmn.so.2
    ln -sf libomxr_mc_cmn.so.2.0.0 libomxr_mc_cmn.so

    # Video (decode) common
    ln -sf libomxr_mc_vcmn.so.2.0.0 libomxr_mc_vcmn.so.2
    ln -sf libomxr_mc_vcmn.so.2.0.0  libomxr_mc_vcmn.so

    ln -sf libomxr_mc_vdcmn.so.2.0.0 libomxr_mc_vdcmn.so.2
    ln -sf libomxr_mc_vdcmn.so.2.0.0 libomxr_mc_vdcmn.so

    ln -sf libuvcs_dec.so.1.0.0 libuvcs_dec.so.1
    ln -sf libuvcs_dec.so.1.0.0 libuvcs_dec.so

    ln -sf libvcp3_mcvd.so.1.0.0 libvcp3_mcvd.so.1
    ln -sf libvcp3_mcvd.so.1.0.0 libvcp3_mcvd.so

    # H264 Decoder
    ln -sf libomxr_mc_h264d.so.2.0.0 libomxr_mc_h264d.so.2
    ln -sf libomxr_mc_h264d.so.2.0.0 libomxr_mc_h264d.so

    ln -sf libvcp3_avcd.so.1.0.0 libvcp3_avcd.so.1
    ln -sf libvcp3_avcd.so.1.0.0 libvcp3_avcd.so

    # H263 Decoder
    if [ "X${USE_H263_DECODER}" = "X1" ] ; then
        ln -sf libomxr_mc_h263d.so.2.0.0 libomxr_mc_h263d.so.2
        ln -sf libomxr_mc_h263d.so.2.0.0 libomxr_mc_h263d.so

        ln -sf libvcp3_hv3d.so.1.0.0 libvcp3_hv3d.so.1
        ln -sf libvcp3_hv3d.so.1.0.0 libvcp3_hv3d.so
    fi

    # M2VD decoder
    if [ "X${USE_MPEG2_DECODER}" = "X1" ] ; then
        ln -sf libvcp3_m2vd.so.1.0.0 libvcp3_m2vd.so.1
        ln -sf libvcp3_m2vd.so.1 libvcp3_m2vd.so

        ln -sf libomxr_mc_m2vd.so.2.0.0 libomxr_mc_m2vd.so.2
        ln -sf libomxr_mc_m2vd.so.2 libomxr_mc_m2vd.so
    fi

    # M4VD decoder
    if [ "X${USE_MPEG4_DECODER}" = "X1" ] ; then
        ln -sf libvcp3_m4vd.so.1.0.0 libvcp3_m4vd.so.1
        ln -sf libvcp3_m4vd.so.1 libvcp3_m4vd.so

        ln -sf libomxr_mc_m4vd.so.2.0.0 libomxr_mc_m4vd.so.2
        ln -sf libomxr_mc_m4vd.so.2 libomxr_mc_m4vd.so
    fi

    # DIVX decoder
    if [ "X${USE_DIVX_DECODER}" = "X1" ] ; then
        ln -sf libvcp3_dvxd.so.1.0.0 libvcp3_dvxd.so.1
        ln -sf libvcp3_dvxd.so.1 libvcp3_dvxd.so

        ln -sf libomxr_mc_divxd.so.2.0.0 libomxr_mc_divxd.so.2
        ln -sf libomxr_mc_divxd.so.2 libomxr_mc_divxd.so
    fi

    # VC1D decoder
    if [ "X${USE_VC1_DECODER}" = "X1" ] ; then
        ln -sf libvcp3_vc1d.so.1.0.0 libvcp3_vc1d.so.1
        ln -sf libvcp3_vc1d.so.1 libvcp3_vc1d.so

        ln -sf libomxr_mc_vc1d.so.2.0.0 libomxr_mc_vc1d.so.2
        ln -sf libomxr_mc_vc1d.so.2 libomxr_mc_vc1d.so
    fi

    #Encoder
    # H264E
    if [ "X${USE_H264AVC_ENCODER}" = "X1" ] ; then
        ln -sf libomxr_mc_h264e.so.2.0.0 libomxr_mc_h264e.so.2
        ln -sf libomxr_mc_h264e.so.2 libomxr_mc_h264e.so

        ln -sf libvcp3_avce.so.1.0.0 libvcp3_avce.so.1
        ln -sf libvcp3_avce.so.1.0.0 libvcp3_avce.so
    fi

    ### Encoder common
    if [ "X${USE_VIDEO_COMMON_ENCODER}" = "X1" ] ; then
        ln -sf libomxr_mc_vecmn.so.2.0.0 libomxr_mc_vecmn.so.2
        ln -sf libomxr_mc_vecmn.so.2.0.0 libomxr_mc_vecmn.so

        ln -sf libuvcs_enc.so.1.0.0 libuvcs_enc.so.1
        ln -sf libuvcs_enc.so.1.0.0 libuvcs_enc.so

        ln -sf libvcp3_mcve.so.1.0.0 libvcp3_mcve.so.1
        ln -sf libvcp3_mcve.so.1.0.0 libvcp3_mcve.so
    fi

    # audio common OMX
    if [ "X${USE_AUDIO_COMMON}" = "X1" ] ; then
        ln -sf libomxr_mc_acmn.so.2.0.0 libomxr_mc_acmn.so.2
        ln -sf libomxr_mc_acmn.so.2.0.0 libomxr_mc_acmn.so
    fi

    # aacd OMX
    if [ "X${USE_AACP2_DECODER}" = "X1" ] ; then
        ln -sf libomxr_mc_aacd.so.2.0.0 libomxr_mc_aacd.so.2
        ln -sf libomxr_mc_aacd.so.2.0.0 libomxr_mc_aacd.so
    fi

    # mp3 OMX
    if [ "X${USE_MP3_DECODER}" = "X1" ] ; then
        ln -sf libomxr_mc_mp3d.so.2.0.0 libomxr_mc_mp3d.so.2
        ln -sf libomxr_mc_mp3d.so.2.0.0 libomxr_mc_mp3d.so
    fi

    # wma OMX
    if [ "X${USE_WMA_DECODER}" = "X1" ] ; then
        ln -sf libomxr_mc_wmad.so.2.0.0 libomxr_mc_wmad.so.2
        ln -sf libomxr_mc_wmad.so.2.0.0 libomxr_mc_wmad.so
    fi

    # ddd OMX
    if [ "X${USE_DDD_DECODER}" = "X1" ] ; then
        ln -sf libomxr_mc_ddd.so.2.0.0 libomxr_mc_ddd.so.2
        ln -sf libomxr_mc_ddd.so.2.0.0 libomxr_mc_ddd.so
    fi

    # alac OMX
    if [ "X${USE_ALAC_DECODER}" = "X1" ] ; then
        ln -sf libomxr_mc_alacd.so.2.0.0 libomxr_mc_alacd.so.2
        ln -sf libomxr_mc_alacd.so.2.0.0 libomxr_mc_alacd.so
    fi

    # flac OMX
    if [ "X${USE_FLAC_DECODER}" = "X1" ] ; then
        ln -sf libomxr_mc_flacd.so.2.0.0 libomxr_mc_flacd.so.2
        ln -sf libomxr_mc_flacd.so.2.0.0 libomxr_mc_flacd.so
    fi

    # aac enc omx
    if [ "X${USE_AAC_ENCODER}" = "X1" ] ; then
        ln -sf libomxr_mc_aace.so.2.0.0 libomxr_mc_aace.so.2
        ln -sf libomxr_mc_aace.so.2.0.0 libomxr_mc_aace.so
    fi

    # Copy all the symbolic link and lib to destination
    cp -Prf ${S}/OMXR/lib/* ${D}${RENESAS_DATADIR}/lib

    # Copy the audio midleware
    # audio aacp2 midleware
    if [ "X${ARMAACP2_MDW_DECODER}" = "X1" ] ; then
        cd ${S}/audio_mdw
        ln -sf libRSACPDLA_L.so.1.1 libRSACPDAL_L.so.1.1
        ln -sf libRSACPDLA_L.so.1.1 libRSACPDLA_L.so.1
        ln -sf libRSACPDLA_L.so.1.1 libRSACPDLA_L.so
        ln -sf libRSACPDAL_L.so.1.1 libRSACPDAL_L.so.1
        ln -sf libRSACPDAL_L.so.1.1 libRSACPDAL_L.so
        cp -P ${S}/audio_mdw/*.so* ${D}${RENESAS_DATADIR}/lib/
        cp -P ${S}/audio_mdw/RSACPD_ADL.h ${D}${RENESAS_DATADIR}/include
    fi

    if [ "X${MP3_MDW_DECODER}" = "X1" ] ; then
        cd ${S}/audio_mdw
        ln -sf libMP3DLA_L.so.1.4 libMP3DLA_L.so.1
        ln -sf libMP3DLA_L.so.1.4 libMP3DLA_L.so
        cp -P ${S}/audio_mdw/*.so* ${D}${RENESAS_DATADIR}/lib/
        cp -P ${S}/audio_mdw/mp3d_Lib.h ${D}${RENESAS_DATADIR}/include
    fi

    if [ "X${WMA_MDW_DECODER}" = "X1" ] ; then
        cd ${S}/audio_mdw
        ln -sf libWMASTDLA_L.so.1.3 libWMASTDLA_L.so.1
        ln -sf libWMASTDLA_L.so.1.3 libWMASTDLA_L.so
        cp -P ${S}/audio_mdw/*.so* ${D}${RENESAS_DATADIR}/lib/
        cp -P ${S}/audio_mdw/wmastd_Lib.h ${D}${RENESAS_DATADIR}/include
    fi

    if [ "X${DDD_MDW_DECODER}" = "X1" ] ; then
        cd ${S}/audio_mdw
        ln -sf libRSDACDLA_L.so.1.0 libRSDACDLA_L.so.1
        ln -sf libRSDACDLA_L.so.1.0 libRSDACDLA_L.so
        cp -P ${S}/audio_mdw/*.so* ${D}${RENESAS_DATADIR}/lib/
        cp -P ${S}/audio_mdw/RSDACD_ADL.h ${D}${RENESAS_DATADIR}/include
    fi

    if [ "X${ALAC_MDW_DECODER}" = "X1" ] ; then
        cd ${S}/audio_mdw
        ln -sf libALACDLA_L.so.1.0 libALACDLA_L.so.1
        ln -sf libALACDLA_L.so.1.0 libALACDLA_L.so
        cp -P ${S}/audio_mdw/*.so* ${D}${RENESAS_DATADIR}/lib/
        cp -P ${S}/audio_mdw/alacd_Lib.h ${D}${RENESAS_DATADIR}/include
    fi

    if [ "X${FLAC_MDW_DECODER}" = "X1" ] ; then
        cd ${S}/audio_mdw
        ln -sf libFLACDLA_L.so.1.1 libFLACDLA_L.so.1
        ln -sf libFLACDLA_L.so.1.1 libFLACDLA_L.so
        cp -P ${S}/audio_mdw/*.so* ${D}${RENESAS_DATADIR}/lib/
        cp -P ${S}/audio_mdw/flacd_Lib.h ${D}${RENESAS_DATADIR}/include
    fi

    if [ "X${AAC_MDW_ENCODER}" = "X1" ] ; then
        cd ${S}/audio_mdw
        ln -sf libRSAACELA_L.so.2.1 libRSAACELA_L.so.2
        ln -sf libRSAACELA_L.so.2.1 libRSAACELA_L.so
        cp -P ${S}/audio_mdw/*.so* ${D}${RENESAS_DATADIR}/lib/
        cp -P ${S}/audio_mdw/RSAACE_AAC.h ${D}${RENESAS_DATADIR}/include
    fi
}

SYSROOT_PREPROCESS_FUNCS += "do_populate_share_lib"

do_populate_share_lib () {
    sysroot_stage_dir ${D}${RENESAS_DATADIR}/include ${SYSROOT_DESTDIR}/usr/include
    sysroot_stage_dir ${D}${RENESAS_DATADIR}/lib ${SYSROOT_DESTDIR}/usr/lib
}

# Append function to clean extract source
CLEANFUNCS += 'do_clean_sharedfiles'

do_clean_sharedfiles() {
    rm -f ${LIBSHARED}/libomxr_*.so*
    rm -f ${LIBSHARED}/libuvcs*.so*
    rm -f ${LIBSHARED}/libvcp3_*.so*
    rm -f ${STAGING_INCDIR}/OMX_*.h
    rm -f ${STAGING_INCDIR}/OMXR_*.h

    rm -f ${LIBSHARED}/libRSACPDLA_L.so*
    rm -f ${LIBSHARED}/libRSACPDAL_L.so*
    rm -f ${STAGING_INCDIR}/RSACPD_ADL.h

    rm -f ${LIBSHARED}/libMP3DLA_L.so*
    rm -f ${STAGING_INCDIR}/mp3d_Lib.h

    rm -f ${LIBSHARED}/libWMASTDLA_L.so*
    rm -f ${STAGING_INCDIR}/wmastd_Lib.h

    rm -f ${LIBSHARED}/libRSDACDLA_L.so*
    rm -f ${STAGING_INCDIR}/RSDACD_ADL.h

    rm -f ${LIBSHARED}/libALACDLA_L.so*
    rm -f ${STAGING_INCDIR}/alacd_Lib.h

    rm -f ${LIBSHARED}/libFLACDLA_L.so*
    rm -f ${STAGING_INCDIR}/flacd_Lib.h

    rm -f ${LIBSHARED}/libRSAACELA_L.so*
    rm -f ${STAGING_INCDIR}/RSAACE_AAC.h
}

PACKAGES = "\
    ${PN} \
    ${PN}-dev \
    ${PN}-staticdev \
"

FILES_${PN} = " \
    ${RENESAS_DATADIR}/lib/*.so \
    ${RENESAS_DATADIR}/lib/*.so.* \
    ${RENESAS_DATADIR}/config/* \
"

FILES_${PN}-dev = " \
    ${RENESAS_DATADIR}/include/* \
"

FILES_${PN}-staticdev = " \
    ${RENESAS_DATADIR}/lib/*.a \
    ${RENESAS_DATADIR}/lib/*.la \
"

INSANE_SKIP_${PN} += "rpaths"
INSANE_SKIP_${PN} += "dev-so"
INSANE_SKIP_${PN} += "libdir"
INSANE_SKIP_${PN}-dev += "libdir"
RPROVIDES_${PN} += "omx-user-module"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"

license: MIT

branch_name: refs/heads/master

gha_language: Python

extension: bb


text:
package handler_test

import (
	"github.com/gin-gonic/gin"
	"github.com/tsingsun/woocoo/web/handler"
	"net/http"
)

// ExampleErrorHandleMiddleware_customErrorParser is the example for customer ErrorHandle
func ExampleErrorHandleMiddleware_customErrorParser() {
	hdl := handler.ErrorHandle(handler.WithMiddlewareConfig(func() any {
		codeMap := map[uint64]any{
			10000: "miss required param",
			10001: "invalid param",
		}
		errorMap := map[interface{ Error() string }]string{
			http.ErrBodyNotAllowed: "username/password not correct",
		}
		return &handler.ErrorHandleConfig{
			Accepts: "application/json,application/xml",
			Message: "internal error",
			ErrorParser: func(c *gin.Context, public error) (int, any) {
				var errs = make([]gin.H, len(c.Errors))
				for i, e := range c.Errors {
					if txt, ok := codeMap[uint64(e.Type)]; ok {
						errs[i] = gin.H{"code": i, "message": txt}
						continue
					}
					if txt, ok := errorMap[e.Err]; ok {
						errs[i] = gin.H{"code": i, "message": txt}
						continue
					}
					errs[i] = gin.H{"code": i, "message": e.Error()}
				}
				return 0, errs
			},
		}
	}))
	// use in web server
	gin.Default().Use(hdl.ApplyFunc(nil))
}

repository: tsingsun/woocoo

repo_name: tsingsun/woocoo

gha_language: Go

extension: go


text:
package docker

import (
	"bytes"
	"fmt"
	"log"
	"os"
	"os/exec"
	"os/user"
	"path/filepath"
	"strings"

	"github.com/docker/docker/api/types"
	shellwords "github.com/mattn/go-shellwords"
	"wharfr.at/wharfrat/lib/config"
)

func (c *Connection) setupUser(id string, crate *config.Crate, usr *user.User, group *user.Group) error {
	cmd := []string{
		"/sbin/wr-init", "setup", "--debug",
		"--user", usr.Username, "--uid", usr.Uid, "--name", usr.Name,
		"--group", group.Name, "--gid", group.Gid,
	}

	for _, name := range crate.CopyGroups {
		group, err := user.LookupGroup(name)
		if err != nil {
			return fmt.Errorf("failed to get group information for '%s': %w", name, err)
		}
		cmd = append(cmd, "--create-group", fmt.Sprintf("%s=%s", name, group.Gid))
	}

	for _, group := range crate.Groups {
		cmd = append(cmd, "--extra-group", group)
	}

	if !crate.MountHome {
		cmd = append(cmd, "--mkhome")
	}

	buf := &bytes.Buffer{}

	exitCode, err := c.run(id, cmd, nil, nil, buf, buf)
	if err != nil {
		return err
	}

	log.Printf("Setup stderr: %s", buf)

	if exitCode != 0 {
		return fmt.Errorf("setup user command failed (%d): %s", exitCode, buf)
	}

	return nil
}

func (c *Connection) setupPrep(id, prep, path string, args ...string) error {
	if prep == "" {
		return nil
	}

	args = append([]string{"-s"}, args...)
	log.Printf("PREP ARGS: %v", args)

	cmd := exec.Command("/bin/bash", args...)
	cmd.Stdin = strings.NewReader(prep)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Dir = path

	if err := cmd.Run(); err != nil {
		return fmt.Errorf("setup prep script failed: %w", err)
	}

	return nil
}

func (c *Connection) runScript(id, label, script string, env map[string]string) error {
	if script == "" {
		return nil
	}

	cmd := []string{"/bin/sh"}
	if strings.HasPrefix(strings.TrimSpace(script), "#!") {
		parts := strings.SplitN(strings.TrimSpace(script), "\n", 2)
		items, err := shellwords.Parse(parts[0][2:])
		if err != nil {
			return err
		}
		cmd = items
	}

	log.Printf("RUN SCRIPT CMD: %#v", cmd)

	stdin := strings.NewReader(script)

	exitCode, err := c.run(id, cmd, env, stdin, os.Stdout, os.Stderr)
	if err != nil {
		return fmt.Errorf("setup %s script failed: %w", label, err)
	}

	log.Printf("SETUP %s: %d", label, exitCode)

	if exitCode != 0 {
		return fmt.Errorf("setup %s script failed: exit status %d", label, exitCode)
	}

	return nil
}

func (c *Connection) installTarball(id string, base, src, dst string) error {
	if !filepath.IsAbs(src) {
		src = filepath.Join(base, src)
	}

	if !filepath.IsAbs(dst) {
		return fmt.Errorf("tarball dest '%s' should be absolute path", dst)
	}

	log.Printf("INSTALL TARBALL: %s -> %s", src, dst)

	f, err := os.Open(src)
	if err != nil {
		return err
	}
	defer f.Close()

	options := types.CopyToContainerOptions{}
	return c.c.CopyToContainer(c.ctx, id, dst, f, options)
}

func (c *Connection) setupTarballs(id, base string, tarballs map[string]string) error {
	for src, dst := range tarballs {
		if err := c.installTarball(id, base, src, dst); err != nil {
			return err
		}
	}

	return nil
}

func (c *Connection) doSteps(id, base, prep, pre, post string, tarballs, env map[string]string, args ...string) error {
	if err := c.setupPrep(id, prep, base, args...); err != nil {
		return err
	}

	if err := c.runScript(id, "pre", pre, env); err != nil {
		return err
	}

	if err := c.setupTarballs(id, base, tarballs); err != nil {
		return err
	}

	if err := c.runScript(id, "post", post, env); err != nil {
		return err
	}

	return nil
}

func (c *Connection) setup(id string, crate *config.Crate) error {
	projectPath := filepath.Dir(crate.ProjectPath())

	usr, err := user.Current()
	if err != nil {
		return fmt.Errorf("failed to get user information: %w", err)
	}

	group, err := user.LookupGroupId(usr.Gid)
	if err != nil {
		return fmt.Errorf("failed to get group information: %w", err)
	}

	if err := c.setupUser(id, crate, usr, group); err != nil {
		return err
	}

	locals, err := config.Local().Setup(crate)
	if err != nil {
		return err
	}

	localPath := filepath.Dir(config.Local().Path())
	env := map[string]string{
		"WR_EXT_USER":    usr.Username,
		"WR_EXT_GROUP":   group.Name,
		"WR_EXT_PROJECT": projectPath,
		"WR_EXT_CONFIG":  localPath,
		"WR_CRATE":       crate.Name(),
	}

	if err := c.doSteps(id, projectPath, crate.SetupPrep, crate.SetupPre, crate.SetupPost, crate.Tarballs, env, projectPath, crate.Name()); err != nil {
		return err
	}

	for _, local := range locals {
		if err := c.doSteps(id, localPath, local.SetupPrep, local.SetupPre, local.SetupPost, local.Tarballs, env, projectPath, crate.Name()); err != nil {
			return err
		}
	}

	return nil
}

repository: wharfr/wharfrat

repo_name: wharfr/wharfrat


text:
package controllers

import (
	"strings"

	"github.com/astaxie/beego/context"
	"github.com/hzwy23/asofdate/hauth/hcache"
	"github.com/hzwy23/asofdate/hauth/models"
	"github.com/hzwy23/asofdate/utils"
	"github.com/hzwy23/asofdate/utils/hret"
	"github.com/hzwy23/asofdate/utils/logs"
)

const (
	error_resource_query       = "查询菜单资源信息失败，请重试"
	error_resource_query_theme = "查询主题信息失败，请重试"
	error_resource_exec        = "执行SQL，提交新增用户信息失败，请联系管理员"
	error_resource_type        = "资源类型不符合要求"
	error_resource_update      = "更新菜单资源名称失败"
)

type ResourceController struct {
	models *models.ResourceModel
}

var ResourceCtl = &ResourceController{
	new(models.ResourceModel),
}

// 菜单资源子页面路由
func (ResourceController) Page(ctx *context.Context) {
	ctx.Request.ParseForm()
	if !models.BasicAuth(ctx) {
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 403, "权限不足")
		return
	}

	rst, err := hcache.GetStaticFile("AsofdateResourcePage")
	if err != nil {
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 404, "页面不存在")
		return
	}

	ctx.ResponseWriter.Write(rst)
}

func (this ResourceController) Get(ctx *context.Context) {
	ctx.Request.ParseForm()
	if !models.BasicAuth(ctx) {
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 403, "权限不足")
		return
	}
	rst, err := this.models.Get()
	if err != nil {
		logs.Error(err)
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, error_resource_query, err)
		return
	}
	hret.WriteJson(ctx.ResponseWriter, rst)
}

func (this ResourceController) Query(ctx *context.Context) {
	ctx.Request.ParseForm()
	res_id := ctx.Request.FormValue("res_id")
	rst, err := this.models.Query(res_id)
	if err != nil {
		logs.Error(err)
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, error_resource_query, err)
	}
	hret.WriteJson(ctx.ResponseWriter, rst)
}

func (this ResourceController) QueryTheme(ctx *context.Context) {
	ctx.Request.ParseForm()
	res_id := ctx.Request.FormValue("res_id")
	theme_id := ctx.Request.FormValue("theme_id")
	rst, err := this.models.QueryTheme(res_id, theme_id)
	if err != nil {
		logs.Error(err)
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, error_resource_query_theme, err)
		return
	}
	hret.WriteJson(ctx.ResponseWriter, rst)
}

func (this ResourceController) Post(ctx *context.Context) {
	ctx.Request.ParseForm()
	if !models.BasicAuth(ctx) {
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 403, "权限不足")
		return
	}

	theme_id := ctx.Request.FormValue("theme_id")
	res_type := ctx.Request.FormValue("res_type")
	res_id := ctx.Request.FormValue("res_id")
	res_name := ctx.Request.FormValue("res_name")
	res_up_id := ctx.Request.FormValue("res_up_id")
	res_url := ctx.Request.FormValue("res_url")
	res_class := ctx.Request.FormValue("res_class")
	res_img := ctx.Request.FormValue("res_img")
	res_bg_color := ctx.Request.FormValue("res_bg_color")
	group_id := ctx.Request.FormValue("group_id")
	sort_id := ctx.Request.FormValue("sort_id")
	res_attr := "1"
	if res_type == "0" || res_type == "4" {
		res_attr = "0"
	}
	if res_type == "0" {
		res_up_id = "-1"
	}

	if !utils.ValidAlphaNumber(res_id, 1, 30) {
		logs.Error("资源编码必须由1,30位字母或数字组成")
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "资源编码必须由1,30位字母或数字组成")
		return
	}

	if strings.TrimSpace(res_name) == "" {
		logs.Error("菜单名称不能为空")
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单名称不能为空")
		return
	}

	if strings.TrimSpace(res_type) == "" {
		logs.Error("菜单类别不能为空")
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单类别不能为空")
		return
	}

	switch res_type {
	case "0":
		// 首页主菜单信息
		if strings.TrimSpace(res_url) == "" {
			logs.Error("菜单路由地址不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单路由地址不能为空")
			return
		}

		if strings.TrimSpace(res_up_id) == "" {
			logs.Error("菜单上级编码不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单上级编码不能为空")
			return
		}

		if strings.TrimSpace(res_class) == "" {
			logs.Error("菜单样式类型不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单样式类型不能为空")
			return
		}

		if strings.TrimSpace(res_img) == "" {
			logs.Error("菜单图标不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单图标不能为空")
			return
		}

		if !utils.ValidNumber(group_id, 1, 2) {
			logs.Error("菜单分组信息必须是数字")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单分组信息必须是数字")
			return
		}

		if !utils.ValidNumber(sort_id, 1, 2) {
			logs.Error("菜单排序号必须是数字")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单排序号必须是数字")
			return
		}
		err := this.models.Post(res_id, res_name, res_attr, res_up_id, res_type, theme_id, res_url, res_bg_color, res_class, group_id, res_img, sort_id)
		if err != nil {
			logs.Error(err)
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, error_resource_exec, err)
			return
		}
	case "1":
		// 子系统菜单信息
		if strings.TrimSpace(res_url) == "" {
			logs.Error("菜单路由地址不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单路由地址不能为空")
			return
		}

		if strings.TrimSpace(res_up_id) == "" {
			logs.Error("菜单上级编码不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单上级编码不能为空")
			return
		}

		if strings.TrimSpace(res_class) == "" {
			logs.Error("菜单样式类型不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单样式类型不能为空")
			return
		}

		if strings.TrimSpace(res_img) == "" {
			logs.Error("菜单图标不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单图标不能为空")
			return
		}

		if !utils.ValidNumber(group_id, 1, 2) {
			logs.Error("菜单分组信息必须是数字")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单分组信息必须是数字")
			return
		}

		if !utils.ValidNumber(sort_id, 1, 2) {
			logs.Error("菜单排序号必须是数字")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单排序号必须是数字")
			return
		}

		err := this.models.Post(res_id, res_name, res_attr, res_up_id, res_type, theme_id, res_url, res_bg_color, res_class, group_id, res_img, sort_id)
		if err != nil {
			logs.Error(err)
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, error_resource_exec, err)
			return
		}

	case "2":
		// 功能按钮信息
		if strings.TrimSpace(res_up_id) == "" {
			logs.Error("菜单上级编码不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单上级编码不能为空")
			return
		}

		if strings.TrimSpace(res_url) == "" {
			logs.Error("菜单路由地址不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单路由地址不能为空")
			return
		}
		sort_id = "0"
		res_img = ""
		group_id = ""
		res_class = ""
		res_bg_color = ""
		err := this.models.Post(res_id, res_name, res_attr, res_up_id, res_type, theme_id, res_url, res_bg_color, res_class, group_id, res_img, sort_id)
		if err != nil {
			logs.Error(err)
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, error_resource_exec, err)
			return
		}

	case "4":
		// 虚拟节点信息
		// 功能按钮信息
		if strings.TrimSpace(res_up_id) == "" {
			logs.Error("菜单上级编码不能为空")
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 333, "菜单上级编码不能为空")
			return
		}

		err := this.models.PostButton(res_id, res_name, res_attr, res_up_id, res_type)
		if err != nil {
			logs.Error(err)
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, error_resource_exec, err)
			return
		}
	default:
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 421, error_resource_type)
		return
	}
	hret.WriteHttpOkMsgs(ctx.ResponseWriter, "success")

}

func (this ResourceController) Delete(ctx *context.Context) {
	ctx.Request.ParseForm()
	if !models.BasicAuth(ctx) {
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 403, "权限不足")
		return
	}

	res_id := ctx.Request.FormValue("res_id")

	msg, err := this.models.Delete(res_id)

	if err != nil {
		logs.Error(err)
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 419, msg, err)
		return
	}

	hret.WriteHttpOkMsgs(ctx.ResponseWriter, "remove resource successfully.")
}

func (this ResourceController) Update(ctx *context.Context) {
	ctx.Request.ParseForm()
	if !models.BasicAuth(ctx) {
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 403, "权限不足")
		return
	}

	res_id := ctx.Request.FormValue("res_id")
	res_name := ctx.Request.FormValue("res_name")
	err := this.models.Update(res_id, res_name)
	if err != nil {
		logs.Error(err)
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 421, error_resource_update, err)
		return
	}
	hret.WriteHttpOkMsgs(ctx.ResponseWriter, "success")
}

func (this ResourceController) ConfigTheme(ctx *context.Context) {
	ctx.Request.ParseForm()
	if !models.BasicAuth(ctx) {
		hret.WriteHttpErrMsgs(ctx.ResponseWriter, 403, "权限不足")
		return
	}

	res_id := ctx.Request.FormValue("res_id")

	theme_id := ctx.Request.FormValue("theme_id")
	res_url := ctx.Request.FormValue("res_url")
	res_class := ctx.Request.FormValue("res_class")
	res_img := ctx.Request.FormValue("res_img")
	res_by_color := ctx.Request.FormValue("res_by_color")
	res_group_id := ctx.Request.FormValue("res_group_id")
	res_sort_id := ctx.Request.FormValue("res_sort_id")

	flag := this.models.CheckThemeExists(theme_id, res_id)
	if flag <= 0 {
		// 没有这个主题的配置信息,新增主题信息
		msg, err := this.models.AddThemeInfo(theme_id, res_id, res_url, res_class, res_img, res_by_color, res_group_id, res_sort_id)
		if err != nil {
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 421, msg, err)
			return
		}
		hret.WriteHttpOkMsgs(ctx.ResponseWriter, "success")
	} else {
		// 新增主题配置信息
		err := this.models.UpdateTheme(res_url, res_by_color, res_class, res_img, res_group_id, res_sort_id, theme_id, res_id)
		if err != nil {
			logs.Error(err)
			hret.WriteHttpErrMsgs(ctx.ResponseWriter, 421, "修改主题配置信息失败", err)
			return
		}
		hret.WriteHttpOkMsgs(ctx.ResponseWriter, "success")
	}
}

func init() {
	hcache.Register("AsofdateResourcePage", "./views/hauth/res_info_page.tpl")
}

repository: windzzp/asofdate

repo_name: windzzp/asofdate


text:
DESCRIPTION = "Network Kanji Code Conversion Filter"
LICENSE = "GPL"
PR = "r2"

SRC_URI = "http://ftp.debian.org/debian/pool/main/n/nkf/nkf_${PV}.orig.tar.gz"
S = "${WORKDIR}/nkf207"

EXTRA_OEMAKE = "-e"

do_install() {
	install -d ${D}${bindir} ${D}${mandir}/man1
	install -m 0755 nkf ${D}${bindir}
	install -m 0644 nkf.1 ${D}${mandir}/man1
}

SRC_URI[md5sum] = "af11dcd3fe71d67831c020e3bfd5073b"
SRC_URI[sha256sum] = "71d2ba992df209a00bb1dca45e3336729dc16e51b71526bd20f897cc6127a275"
TARGET_CC_ARCH += "${LDFLAGS}"

BBCLASSEXTEND = "native"

NATIVE_INSTALL_WORKS = "1"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD


text:
---
---

@string{aps = {American Physical Society,}}

@article{bhattacharya_precision_2017,
	title = {Precision {Diagnosis} {Of} {Melanoma} {And} {Other} {Skin} {Lesions} {From} {Digital} {Images}},
	volume = {2017},
	copyright = {All rights reserved},
	issn = {2153-4063},
	abstract = {Melanoma will affect an estimated 73,000 new cases this year and result in 9,000 deaths, yet precise diagnosis remains a serious problem. Without early detection and preventative care, melanoma can quickly spread to become fatal (Stage IV 5-year survival rate is 20-10\%) from a once localized skin lesion (Stage IA 5- year survival rate is 97\%). There is no biomarker for melanoma in clinical use, and the current diagnostic criteria for skin lesions remains subjective and imprecise. Accurate diagnosis of melanoma relies on a histopathologic gold standard; thus, aggressive excision of melanocytic skin lesions has been the mainstay of treatment. It is estimated that 36 biopsies are performed for every melanoma confirmed by pathology among excised lesions. There is significant morbidity in misdiagnosing melanoma such as progression of the disease for a false negative prediction vs the risks of unnecessary surgery for a false positive prediction. Every year, poor diagnostic precision adds an estimated \$673 million in overall cost to manage the disease. Currently, manual dermatoscopic imaging is the standard of care in selecting atypical skin lesions for biopsy, and at best it achieves 90\% sensitivity but only 59\% specificity when performed by an expert dermatologist. Many computer vision (CV) algorithms perform better than dermatologists in classifying skin lesions although not significantly so in clinical practice. Meanwhile, open source deep learning (DL) techniques in CV have been gaining dominance since 2012 for image classification, and today DL can outperform humans in classifying millions of digital images with less than 5\% error rates. Moreover, DL algorithms are readily run on commoditized hardware and have a strong online community of developers supporting their rapid adoption. In this work, we performed a successful pilot study to show proof of concept to DL skin pathology from images. However, DL algorithms must be trained on very large labelled datasets of images to achieve high accuracy. Here, we begin to assemble a large imageset of skin lesions from the UCSF and the San Francisco Veterans Affairs Medical Center (VAMC) dermatology clinics that are well characterized by their underlying pathology, on which to train DL algorithms. If trained on sufficient data, we hypothesize that our approach will significantly outperform general dermatologists in predicting skin lesion pathology. We posit that our work will allow for precision diagnosis of melanoma from widely available digital photography, which may optimize the management of the disease by decreasing unnecessary office visits and the significant morbidity and cost of melanoma misdiagnosis.},
	language = {eng},
	journal = {AMIA Joint Summits on Translational Science proceedings. AMIA Joint Summits on Translational Science},
	author = {Bhattacharya, Abhishek and Young, Albert and Wong, Andrew and Stalling, Simone and Wei, Maria and Hadley, Dexter},
	year = {2017},
	pmid = {28815132},
	pmcid = {PMC5543387},
	pages = {220--226},
	pdf = {Bhattacharya_Precision.pdf}
}

@article{young_patient_2021,
	title = {Patient and general public attitudes towards clinical artificial intelligence: a mixed methods systematic review},
	volume = {3},
	copyright = {All rights reserved},
	issn = {2589-7500},
	shorttitle = {Patient and general public attitudes towards clinical artificial intelligence},
	url = {https://www.sciencedirect.com/science/article/pii/S2589750021001321},
	doi = {10.1016/S2589-7500(21)00132-1},
	abstract = {Artificial intelligence (AI) promises to change health care, with some studies showing proof of concept of a provider-level performance in various medical specialties. However, there are many barriers to implementing AI, including patient acceptance and understanding of AI. Patients’ attitudes toward AI are not well understood. We systematically reviewed the literature on patient and general public attitudes toward clinical AI (either hypothetical or realised), including quantitative, qualitative, and mixed methods original research articles. We searched biomedical and computational databases from Jan 1, 2000, to Sept 28, 2020, and screened 2590 articles, 23 of which met our inclusion criteria. Studies were heterogeneous regarding the study population, study design, and the field and type of AI under study. Six (26\%) studies assessed currently available or soon-to-be available AI tools, whereas 17 (74\%) assessed hypothetical or broadly defined AI. The quality of the methods of these studies was mixed, with a frequent issue of selection bias. Overall, patients and the general public conveyed positive attitudes toward AI but had many reservations and preferred human supervision. We summarise our findings in six themes: AI concept, AI acceptability, AI relationship with humans, AI development and implementation, AI strengths and benefits, and AI weaknesses and risks. We suggest guidance for future studies, with the goal of supporting the safe, equitable, and patient-centred implementation of clinical AI.},
	language = {en},
	number = {9},
	urldate = {2022-10-08},
	journal = {The Lancet Digital Health},
	author = {Young, Albert T and Amara, Dominic and Bhattacharya, Abhishek and Wei, Maria L},
	month = sep,
	year = {2021},
	pages = {e599--e611},
	pdf = {Young_Systematic_AI.pdf}
}

@article{jiang_rapid_2022,
	title = {Rapid {Automated} {Analysis} of {Skull} {Base} {Tumor} {Specimens} {Using} {Intraoperative} {Optical} {Imaging} and {Artificial} {Intelligence}},
	volume = {90},
	copyright = {All rights reserved},
	issn = {0148-396X},
	url = {https://journals.lww.com/neurosurgery/Fulltext/2022/06000/Rapid_Automated_Analysis_of_Skull_Base_Tumor.14.aspx?context=FeaturedArticles&collectionId=11},
	doi = {10.1227/neu.0000000000001929},
	abstract = {BACKGROUND:
        Accurate specimen analysis of skull base tumors is essential for providing personalized surgical treatment strategies. Intraoperative specimen interpretation can be challenging because of the wide range of skull base pathologies and lack of intraoperative pathology resources.
        OBJECTIVE:
        To develop an independent and parallel intraoperative workflow that can provide rapid and accurate skull base tumor specimen analysis using label-free optical imaging and artificial intelligence.
        METHODS:
        We used a fiber laser–based, label-free, nonconsumptive, high-resolution microscopy method ({\textless}60 seconds per 1 × 1 mm2), called stimulated Raman histology (SRH), to image a consecutive, multicenter cohort of patients with skull base tumor. SRH images were then used to train a convolutional neural network model using 3 representation learning strategies: cross-entropy, self-supervised contrastive learning, and supervised contrastive learning. Our trained convolutional neural network models were tested on a held-out, multicenter SRH data set.
        RESULTS:
        SRH was able to image the diagnostic features of both benign and malignant skull base tumors. Of the 3 representation learning strategies, supervised contrastive learning most effectively learned the distinctive and diagnostic SRH image features for each of the skull base tumor types. In our multicenter testing set, cross-entropy achieved an overall diagnostic accuracy of 91.5\%, self-supervised contrastive learning 83.9\%, and supervised contrastive learning 96.6\%. Our trained model was able to segment tumor-normal margins and detect regions of microscopic tumor infiltration in meningioma SRH images.
        CONCLUSION:
        SRH with trained artificial intelligence models can provide rapid and accurate intraoperative analysis of skull base tumor specimens to inform surgical decision-making.},
	language = {en-US},
	number = {6},
	urldate = {2022-10-08},
	journal = {Neurosurgery},
	author = {Jiang, Cheng and Bhattacharya, Abhishek and Linzey, Joseph R. and Joshi, Rushikesh S. and Cha, Sung Jik and Srinivasan, Sudharsan and Alber, Daniel and Kondepudi, Akhil and Urias, Esteban and Pandian, Balaji and Al-Holou, Wajd N. and Sullivan, Stephen E. and Thompson, B. Gregory and Heth, Jason A. and Freudiger, Christian W. and Khalsa, Siri Sahib S. and Pacione, Donato R. and Golfinos, John G. and Camelo-Piragua, Sandra and Orringer, Daniel A. and Lee, Honglak and Hollon, Todd C.},
	month = jun,
	year = {2022},
	pages = {758--767},
	pdf = {Jiang_Skull.pdf}
}


text:
Automatically generated by Mendeley Desktop 1.19.4
Any changes to this file will be lost if it is regenerated by Mendeley.

BibTeX export options can be customized via Preferences -> BibTeX in Mendeley Desktop

@article{Michiels2011,
abstract = {Background During an influenza epidemic prompt diagnosis of influenza is important. This diagnosis however is still essentially based on the interpretation of symptoms and signs by general practitioners. No single symptom is specific enough to be useful in differentiating influenza from other respiratory infections. Our objective is to formulate prediction rules for the diagnosis of influenza with the best diagnostic performance, combining symptoms, signs and context among patients with influenza-like illness. Methods During five consecutive winter periods (2002-2007) 138 sentinel general practitioners sampled (naso- and oropharyngeal swabs) 4597 patients with an influenza-like illness (ILI) and registered their symptoms and signs, general characteristics and contextual information. The samples were analysed by a DirectigenFlu-A{\&}B and RT-PCR tests. 4584 records were useful for further analysis. Starting from the most relevant variables in a Generalized Estimating Equations (GEE) model, we calculated the area under the Receiver Operating Characteristic curve (ROC AUC), sensitivity, specificity and likelihood ratios for positive (LR+) and negative test results (LR-) of single and combined signs, symptoms and context taking into account pre-test and post-test odds. Results In total 52.6{\%} (2409/4584) of the samples were positive for influenza virus: 64{\%}(2066/3212) during and 25{\%} (343/1372) pre/post an influenza epidemic. During and pre/post an influenza epidemic the LR+ of 'previous flu-like contacts', 'coughing', 'expectoration on the first day of illness' and 'body temperature above 37.8degreesC' is 3.35 (95{\%}CI 2.67-4.03) and 1.34 (95{\%}CI 0.97-1.72), respectively. During and pre/post an influenza epidemic the LR- of 'coughing' and 'a body temperature above 37.8degreesC' is 0.34 (95{\%}CI 0.27-0.41) and 0.07 (95{\%}CI 0.05-0.08), respectively. Conclusions Ruling out influenza using clinical and contextual information is easier than ruling it in. Outside an influenza epidemic the absence of cough and fever ({\textgreater}37,8degreesC) makes influenza 14 times less likely in ILI patients. During an epidemic the presence of 'previous flu-like contacts', cough, 'expectoration on the first day of illness' and fever ({\textgreater}37,8degreesC) increases the likelihood for influenza threefold. The additional diagnostic value of rapid point of care tests especially for confirming influenza still has to be established.},
author = {Michiels, Barbara and Thomas, Isabelle and {Van Royen}, Paul and Coenen, Samuel},
doi = {10.1186/1471-2296-12-4},
file = {:Users/sepmein/Qsync/Papers//Michiels et al.{\_}2011{\_}Clinical prediction rules combining signs, symptoms and epidemiological context to distinguish influenza from influ.pdf:pdf},
issn = {14712296},
journal = {BMC Family Practice},
pages = {1--11},
title = {{Clinical prediction rules combining signs, symptoms and epidemiological context to distinguish influenza from influenza-like illnesses in primary care: A cross sectional study}},
volume = {12},
year = {2011}
}

repository: sepmein/references

repo_name: sepmein/references


text:
@comment{x-kbibtex-personnameformatting=<%l><, %f>}

@inproceedings{CNT12,
  added-at = "2012-04-16T00:00:00.000+0200",
  author = "Coron, Jean-S{\'e}bastien and Naccache, David and Tibouchi, Mehdi",
  booktitle = "{EUROCRYPT}",
  editor = "Pointcheval, David and Johansson, Thomas",
  isbn = "978-3-642-29010-7",
  keywords = "dblp",
  pages = "446--464",
  publisher = "Springer",
  series = "{Lecture Notes in Computer Science}",
  title = "{Public Key Compression and Modulus Switching for Fully Homomorphic Encryption over the Integers.}",
  url = "http://dblp.uni-trier.de/db/conf/eurocrypt/eurocrypt2012.html#CoronNT12; http://dx.doi.org/10.1007/978-3-642-29011-4_27; http://www.bibsonomy.org/bibtex/2612fca51fe63b0767542c2e94f08d70e/dblp",
  volume = 7237,
  year = 2012
}

@inproceedings{CN12,
  added-at = "2012-04-16T00:00:00.000+0200",
  author = "Chen, Yuanmi and Nguyen, Phong Q.",
  booktitle = "{EUROCRYPT}",
  editor = "Pointcheval, David and Johansson, Thomas",
  isbn = "978-3-642-29010-7",
  keywords = "dblp",
  pages = "502--519",
  publisher = "Springer",
  series = "{Lecture Notes in Computer Science}",
  title = "{Faster Algorithms for Approximate Common Divisors: Breaking Fully-Homomorphic-Encryption Challenges over the Integers.}",
  url = "http://dblp.uni-trier.de/db/conf/eurocrypt/eurocrypt2012.html#ChenN12; http://dx.doi.org/10.1007/978-3-642-29011-4_30; http://www.bibsonomy.org/bibtex/2f7c064232ef67a49d5c30a6a20ee3bc3/dblp",
  volume = 7237,
  year = 2012
}

@inproceedings{GHS12a,
  added-at = "2012-04-16T00:00:00.000+0200",
  author = "Gentry, Craig and Halevi, Shai and Smart, Nigel P.",
  booktitle = "{EUROCRYPT}",
  editor = "Pointcheval, David and Johansson, Thomas",
  isbn = "978-3-642-29010-7",
  keywords = "dblp",
  pages = "465--482",
  publisher = "Springer",
  series = "{Lecture Notes in Computer Science}",
  title = "{Fully Homomorphic Encryption with Polylog Overhead.}",
  url = "http://dblp.uni-trier.de/db/conf/eurocrypt/eurocrypt2012.html#GentryHS12; http://dx.doi.org/10.1007/978-3-642-29011-4_28; http://www.bibsonomy.org/bibtex/235df1b0e327db2a15ef634e487beb17a/dblp",
  volume = 7237,
  year = 2012
}

@inproceedings{GHS12b,
  added-at = "2012-08-13T00:00:00.000+0200",
  author = "Gentry, Craig and Halevi, Shai and Smart, Nigel P.",
  booktitle = "{CRYPTO}",
  editor = "Safavi-Naini, Reihaneh and Canetti, Ran",
  isbn = "978-3-642-32008-8",
  keywords = "dblp",
  pages = "850--867",
  publisher = "Springer",
  series = "{Lecture Notes in Computer Science}",
  title = "{Homomorphic Evaluation of the AES Circuit.}",
  url = "http://dblp.uni-trier.de/db/conf/crypto/crypto2012.html#GentryHS12; http://dx.doi.org/10.1007/978-3-642-32009-5_49; http://www.bibsonomy.org/bibtex/208a4d1fc34615cab881f0473cf32ba85/dblp",
  volume = 7417,
  year = 2012
}

@inproceedings{Bra12,
  added-at = "2012-08-13T00:00:00.000+0200",
  author = "Brakerski, Zvika",
  booktitle = "{CRYPTO}",
  editor = "Safavi-Naini, Reihaneh and Canetti, Ran",
  isbn = "978-3-642-32008-8",
  keywords = "dblp",
  pages = "868--886",
  publisher = "Springer",
  series = "{Lecture Notes in Computer Science}",
  title = "{Fully Homomorphic Encryption without Modulus Switching from Classical GapSVP.}",
  url = "http://dblp.uni-trier.de/db/conf/crypto/crypto2012.html#Brakerski12; http://dx.doi.org/10.1007/978-3-642-32009-5_50; http://www.bibsonomy.org/bibtex/28cf3dab174b3513142e799dfcd1ad5ca/dblp",
  volume = 7417,
  year = 2012
}

@phdthesis{Gen09,
  author = "Gentry, Craig",
  school = "Stanford University",
  title = "{A fully homomorphic encryption scheme}",
  year = "2009"
}

@inproceedings{DGHV10,
  added-at = "2010-07-21T15:58:32.000+0200",
  author = "Dijk, Marten van and Gentry, Craig and Halevi, Shai and Vaikuntanathan, Vinod",
  booktitle = "{EUROCRYPT}",
  date = "2010-06-08",
  editor = "Gilbert, Henri",
  isbn = "978-3-642-13189-9",
  keywords = "dblp",
  pages = "24--43",
  publisher = "Springer",
  series = "{Lecture Notes in Computer Science}",
  title = "{Fully Homomorphic Encryption over the Integers}",
  url = "http://dblp.uni-trier.de/db/conf/eurocrypt/eurocrypt2010.html#DijkGHV10; http://dx.doi.org/10.1007/978-3-642-13190-5_2; http://www.bibsonomy.org/bibtex/24de1780642712a54248d778d7d248083/dblp",
  volume = 6110,
  year = 2010
}

@misc{BGV11,
  author = "Brakerski, Zvika and Gentry, Craig and Vaikuntanathan, Vinod",
  howpublished = "Cryptology ePrint Archive, Report 2011/277",
  note = "\url{http://eprint.iacr.org/}",
  title = "{Fully Homomorphic Encryption without Bootstrapping}",
  year = "2011"
}

@inproceedings{BGV12,
  author = "Brakerski, Zvika and Gentry, Craig and Vaikuntanathan, Vinod",
  booktitle = "{Proceedings of the 3rd Innovations in Theoretical Computer Science Conference}",
  organization = "ACM",
  pages = "309--325",
  title = "{(Leveled) fully homomorphic encryption without bootstrapping}",
  year = "2012"
}

@misc{CMNT11,
  author = "Coron, Jean-Sebastien and Mandal, Avradip and Naccache, David and Tibouchi, Mehdi",
  howpublished = "Cryptology ePrint Archive, Report 2011/441",
  note = "\url{http://eprint.iacr.org/}",
  title = "{Fully Homomorphic Encryption over the Integers with Shorter Public Keys}",
  year = "2011"
}

@incollection{CCK13,
  author = "Cheon, JungHee and Coron, Jean-S{\'e}bastien and Kim, Jinsu and Lee, MoonSung and Lepoint, Tancr{\`e}de and Tibouchi, Mehdi and Yun, Aaram",
  booktitle = "{Advances in Cryptology -- EUROCRYPT 2013}",
  doi = "10.1007/978-3-642-38348-9_20",
  editor = "Johansson, Thomas and Nguyen, PhongQ.",
  isbn = "978-3-642-38347-2",
  language = "English",
  pages = "315--335",
  publisher = "Springer Berlin Heidelberg",
  series = "{Lecture Notes in Computer Science}",
  title = "{Batch Fully Homomorphic Encryption over the Integers}",
  url = "http://dx.doi.org/10.1007/978-3-642-38348-9_20",
  volume = "7881",
  year = "2013"
}

@misc{CLT13,
  author = "Coron, Jean-S{\'e}bastien and Lepoint, Tancr{\`e}de and Tibouchi, Mehdi",
  howpublished = "Cryptology ePrint Archive, Report 2013/036",
  note = "\url{http://eprint.iacr.org/}",
  title = "{Batch Fully Homomorphic Encryption over the Integers}",
  year = "2013"
}

@misc{KLYC13,
  author = "Kim, Jinsu and Lee, Moon Sung and Yun, Aaram and Cheon, Jung Hee",
  howpublished = "Cryptology ePrint Archive, Report 2013/057",
  note = "\url{http://eprint.iacr.org/}",
  title = "{CRT-based Fully Homomorphic Encryption over the Integers}",
  year = "2013"
}

@incollection{GSW13,
  year={2013},
  isbn={978-3-642-40040-7},
  booktitle={Advances in Cryptology – CRYPTO 2013},
  volume={8042},
  series={Lecture Notes in Computer Science},
  editor={Canetti, Ran and Garay, JuanA.},
  doi={10.1007/978-3-642-40041-4_5},
  title={Homomorphic Encryption from Learning with Errors: Conceptually-Simpler, Asymptotically-Faster, Attribute-Based},
  url={http://dx.doi.org/10.1007/978-3-642-40041-4_5},
  publisher={Springer Berlin Heidelberg},
  author={Gentry, Craig and Sahai, Amit and Waters, Brent},
  pages={75-92},
  language={English}
}

@incollection{How01,
  author = "Howgrave-Graham, Nick",
  booktitle = "{Cryptography and Lattices}",
  pages = "51--66",
  publisher = "Springer",
  title = "{Approximate integer common divisors}",
  year = "2001"
}

@article{YKPB13,
  added-at = "2013-04-08T00:00:00.000+0200",
  author = "Yi, Xun and Kaosar, Md. Golam and Paulet, Russell and Bertino, Elisa",
  journal = "IEEE Trans. Knowl. Data Eng.",
  keywords = "dblp",
  number = 5,
  pages = "1125--1134",
  title = "{Single-Database Private Information Retrieval from Fully Homomorphic Encryption.}",
  url = "http://dblp.uni-trier.de/db/journals/tkde/tkde25.html#YiKPB13; http://doi.ieeecomputersociety.org/10.1109/TKDE.2012.90; http://www.bibsonomy.org/bibtex/2b7b212a4acf7cda7fadd85e6f73baeaa/dblp",
  volume = 25,
  year = 2013
}

@incollection{CLT14,
  author = "Coron, Jean-S{\'e}bastien and Lepoint, Tancr{\`e}de and Tibouchi, Mehdi",
  booktitle = "{Public-Key Cryptography--PKC 2014}",
  pages = "311--328",
  publisher = "Springer",
  title = "{Scale-invariant fully homomorphic encryption over the integers}",
  year = "2014"
}

@misc{SV11,
  author = "Smart, N.P. and Vercauteren, F.",
  howpublished = "Cryptology ePrint Archive, Report 2011/133",
  note = "\url{http://eprint.iacr.org/}",
  title = "{Fully Homomorphic {SIMD} Operations}",
  year = "2011"
}

@misc{FV12,
  author = "Fan, Junfeng and Vercauteren, Frederik",
  howpublished = "Cryptology ePrint Archive, Report 2012/144",
  note = "\url{http://eprint.iacr.org/}",
  title = "{Somewhat Practical Fully Homomorphic Encryption}",
  year = "2012"
}

@incollection{DC14,
  author = "Dong, Changyu and Chen, Liqun",
  booktitle = "{Computer Security-ESORICS 2014}",
  pages = "380--399",
  publisher = "Springer",
  title = "{A Fast Single Server Private Information Retrieval Protocol with Low Communication Cost}",
  year = "2014"
}

@misc{LN14,
  author = "Lepoint, Tancr{\`e}de and Naehrig, Michael",
  howpublished = "Cryptology ePrint Archive, Report 2014/062",
  note = "\url{http://eprint.iacr.org/}",
  title = "{A Comparison of the Homomorphic Encryption Schemes {FV} and {YASHE}}",
  year = "2014"
}

@inproceedings{LTV12,
  author = "L{\'o}pez{-}Alt, Adriana and Tromer, Eran and Vaikuntanathan, Vinod",
  booktitle = "{Proceedings of the forty-fourth annual ACM symposium on Theory of computing}",
  organization = "ACM",
  pages = "1219--1234",
  title = "{On-the-fly multiparty computation on the cloud via multikey fully homomorphic encryption}",
  year = "2012"
}

@article{DHS15,
  title={Homomorphic AES evaluation using the modified LTV scheme},
  author={Dor{\"o}z, Yark{\i}n and Hu, Yin and Sunar, Berk},
  journal={Designs, Codes and Cryptography},
  pages={1--26},
  year={2015},
  publisher={Springer}
}

@inproceedings{BLLN13,
  added-at = "2013-12-27T00:00:00.000+0100",
  author = "Bos, Joppe W. and Lauter, Kristin and Loftus, Jake and Naehrig, Michael",
  booktitle = "{IMA Int. Conf.}",
  editor = "Stam, Martijn",
  isbn = "978-3-642-45238-3",
  keywords = "dblp",
  pages = "45--64",
  publisher = "Springer",
  series = "{Lecture Notes in Computer Science}",
  title = "{Improved Security for a Ring-Based Fully Homomorphic Encryption Scheme.}",
  url = "http://dblp.uni-trier.de/db/conf/ima/ima2013.html#BosLLN13; http://dx.doi.org/10.1007/978-3-642-45239-0_4; http://www.bibsonomy.org/bibtex/280c636c06509c566faffbacf89854c25/dblp",
  volume = 8308,
  year = 2013
}

@incollection{RC14,
  title={A scalable implementation of fully homomorphic encryption built on NTRU},
  author={Rohloff, Kurt and Cousins, David Bruce},
  booktitle={Financial Cryptography and Data Security},
  pages={221--234},
  year={2014},
  publisher={Springer}
}

@article{CN16,
  title={Which Ring Based Somewhat Homomorphic Encryption Scheme is Best?},
  author={Costache, Anamaria and Smart, Nigel P}
}

@url{Kul15,
  author = "Bogdan Kulynych",
  title = "{Implementation of a Symmetric Variant of DGHV Somewhat Homomorphic Encryption Scheme}",
  year = "2015",
  howpublished = "\url{https://github.com/bogdan-kulynych/libshe}"
}

repository: bogdan-kulynych/latex-common

repo_name: bogdan-kulynych/latex-common


text:
package main

import (
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/cookiejar"
	"net/url"
	"strings"

	"github.com/PuerkitoBio/goquery"
	"golang.org/x/net/publicsuffix"
	"gopkg.in/yaml.v2"
)

// with help from https://github.com/thomasesmith/vw-car-net-api

// auth urls
const loginURL = "https://www.volkswagen.de/app/authproxy/login?fag=vw-de,vwag-weconnect&scope-vw-de=profile,address,phone,carConfigurations,dealers,cars,vin,profession&scope-vwag-weconnect=openid&prompt-vw-de=login&prompt-vwag-weconnect=none&redirectUrl=https://www.volkswagen.de/de/besitzer-und-nutzer/myvolkswagen.html"
const identifierURL = "https://identity.vwgroup.io/signin-service/v1/4fb52a96-2ba3-4f99-a3fc-583bb197684b@apps_vw-dilab_com/login/identifier"
const authenticateURL = "https://identity.vwgroup.io/signin-service/v1/4fb52a96-2ba3-4f99-a3fc-583bb197684b@apps_vw-dilab_com/login/authenticate"
const tokenURL = "https://www.volkswagen.de/app/authproxy/vw-de/tokens"
const userInfoURL = "https://www.volkswagen.de/app/authproxy/vw-de/user"

// api urls
const carsURL = "https://w1hub-backend-production.apps.emea.vwapps.io/cars"

type conf struct {
	Mail     string `yaml:"mail"`
	Password string `yaml:"password"`
}

func (c *conf) getConf() *conf {
	yamlFile, err := ioutil.ReadFile("vw.yaml")
	if err != nil {
		log.Printf("yamlFile.Get err   #%v ", err)
	}
	err = yaml.Unmarshal(yamlFile, c)
	if err != nil {
		log.Fatalf("Unmarshal: %v", err)
	}

	return c
}

func main() {
	var c conf
	c.getConf()
	info, err := getAuthInfo(c.Mail, c.Password)
	if err != nil {
		log.Fatal(err)
	}
	var bearer = "Bearer " + info.BearerAccessToken

	req, err := http.NewRequest("GET", carsURL, nil)
	req.Header.Add("Authorization", bearer)
	client := &http.Client{}
	resp, err := executeRequest(req, *client)
	if err != nil {
		log.Fatal(err)
	}

	body, _ := ioutil.ReadAll(resp.Body)
	log.Println(string([]byte(body)))
}

type authProxyTokens struct {
	AccessToken string `json:"access_token"`
	IDToken     string `json:"id_token"`
}

type authInfo struct {
	BearerAccessToken string
	Sub               string
	Name              string
	GivenName         string `json:"given_name"`
	FamilyName        string `json:"family_name"`
	Email             string
	EmailVerified     bool  `json:"email_verified"`
	UpdatedAt         int64 `json:"updated_at"`
}

func getAuthInfo(mail string, password string) (info authInfo, err error) {
	client, err := getHTTPClient()
	if err != nil {
		return info, err
	}

	err = logIn(*client, mail, password)
	if err != nil {
		return info, err
	}

	accessToken, err := getAccessToken(*client)
	if err != nil {
		return info, err
	}
	info, err = getUserInfo(*client)
	if err != nil {
		return info, err
	}
	info.BearerAccessToken = accessToken
	return info, nil
}

func getHTTPClient() (client *http.Client, err error) {
	jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
	if err != nil {
		return client, err
	}

	return &http.Client{
		Jar: jar,
		// We have over 10 redirects (wtf) and need them
		CheckRedirect: func(req *http.Request, via []*http.Request) error {
			return nil
		},
	}, nil
}

func logIn(client http.Client, mail string, password string) error {
	idValues, err := getStartValues(client)
	if err != nil {
		return err
	}

	form := url.Values{
		"_csrf":      []string{idValues["csrf"]},
		"relayState": []string{idValues["input_relayState"]},
		"hmac":       []string{idValues["hmac"]},
		"email":      []string{mail},
	}
	hmac, err := getHmacFromMail(client, form)
	if err != nil {
		return err
	}
	form.Set("hmac", hmac)
	form.Set("password", password)
	return authenticate(client, form)
}

func getStartValues(client http.Client) (map[string]string, error) {
	req, err := http.NewRequest("GET", loginURL, nil)
	res, err := executeRequest(req, client)
	if err != nil {
		return nil, err
	}
	defer res.Body.Close()

	return getInputValues(res.Body, []string{"csrf", "input_relayState", "hmac"})
}

func getUserInfo(client http.Client) (info authInfo, err error) {
	csrf, err := getCsrfToken(client.Jar)
	if err != nil {
		return info, err
	}
	req, err := http.NewRequest("GET", userInfoURL, nil)
	req.Header.Add("x-csrf-token", csrf)
	res, err := executeRequest(req, client)
	if err != nil {
		log.Fatal(err)
	}
	decoder := json.NewDecoder(res.Body)
	err = decoder.Decode(&info)
	return info, nil
}

func getHmacFromMail(client http.Client, formValues url.Values) (string, error) {
	res, err := executePostForm(identifierURL, formValues, client)
	if err != nil {
		return "", err
	}
	defer res.Body.Close()
	idValues, err := getInputValues(res.Body, []string{"hmac"})
	if err != nil {
		return "", err
	}
	return idValues["hmac"], nil
}

func authenticate(client http.Client, formValues url.Values) error {
	res, err := executePostForm(authenticateURL, formValues, client)
	if err != nil {
		return err
	}
	if strings.HasSuffix(res.Request.URL.Path, "terms-and-conditions") {
		return fmt.Errorf("the terms and conditions have updated. Please log in with the browser and accecept them")
	}
	return nil
}

func getAccessToken(client http.Client) (string, error) {
	csrf, err := getCsrfToken(client.Jar)
	if err != nil {
		return "", err
	}
	req, err := http.NewRequest("GET", tokenURL, nil)
	if err != nil {
		return "", err
	}
	req.Header.Add("x-csrf-token", csrf)
	res, err := executeRequest(req, client)
	if err != nil {
		return "", err
	}
	decoder := json.NewDecoder(res.Body)
	var tokens authProxyTokens
	err = decoder.Decode(&tokens)
	if err != nil {
		return "", err
	}
	return tokens.AccessToken, nil
}

func getCsrfToken(jar http.CookieJar) (string, error) {
	volkswagen, _ := url.Parse("https://www.volkswagen.de/")
	cookies := jar.Cookies(volkswagen)
	for _, c := range cookies {
		if c.Name == "csrf_token" {
			return c.Value, nil
		}
	}
	return "", fmt.Errorf("found no cookie with csrf token")
}

func executePostForm(url string, data url.Values, client http.Client) (*http.Response, error) {
	res, err := client.PostForm(url, data)
	if err != nil {
		return nil, err
	}
	if res.StatusCode != 200 {
		return nil, fmt.Errorf("status code error: %d %s", res.StatusCode, res.Status)
	}
	return res, nil
}

func executeRequest(req *http.Request, client http.Client) (*http.Response, error) {
	res, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	if res.StatusCode != 200 {
		return nil, fmt.Errorf("status code error: %d %s", res.StatusCode, res.Status)
	}
	return res, nil
}

func getInputValues(body io.ReadCloser, ids []string) (map[string]string, error) {
	document, err := goquery.NewDocumentFromReader(body)
	if err != nil {
		return nil, err
	}
	idValues := make(map[string]string)
	for _, id := range ids {
		value, find := document.Find(fmt.Sprintf("#%s", id)).Attr("value")
		if !find {
			return nil, fmt.Errorf("find no elememt with id %s", id)
		}
		idValues[id] = value
	}
	return idValues, nil
}

repository: StefanSchoof/vwidentity

repo_name: StefanSchoof/vwidentity


text:
// Package rlog
// A simple Golang logger with lots of features and no external dependencies
//
//
// Rlog is a simple logging package, rich in features. It is configurable 'from
// the outside' via environment variables and/or config file and has no
// dependencies other than the standard Golang library.
//
// It is called "rlog", because it was originally written for the
// [Romana project](https://github.com/romana/romana).
//
//
// FEATURES
//
// * Logging configuration of a running process can be modified, without needing
//   to restart it. This allows for on-demand finer level logging, if a process
//   starts to experience issues, for example.
//
// * Is configured through environment variables or config file: No need to call a
//   special init function of some kind to initialize and configure the logger.
//
// * A new config file can be specified and applied programmatically at any time.
//
// * Offers familiar and easy to use log functions for the usual levels: Debug,
//   Info, Warn, Error and Critical.
//
// * Offers an additional multi level logging facility with arbitrary depth,
//   called Trace.
//
// * Log and trace levels can be configured separately for the individual files
//   that make up your executable.
//
// * Every log function comes in a 'plain' version (to be used like Println)
//   and in a formatted version (to be used like Printf). For example, there
//   is Debug() and Debugf(), which takes a format string as first parameter.
//
// * Can be configured to print caller info (process ID, module filename and line,
//   function name). In addition, can also print the goroutine ID in the caller
//   info.
//
// * Has NO external dependencies, except things contained in the standard Go
//   library.
//
// * Fully configurable date/time format.
//
// * Logging of date and time can be disabled (useful in case of systemd, which
//   adds its own time stamps in its log database).
//
// * By default logs to stderr or stdout. A logfile can be configured via
//   environment variable. Output may happen exclusively to the logfile or in
//   addition to the output on stderr/stdout. Also, a different output stream
//   or file can be specified from within your programs at any time.
//
//
// DEFAULTS
//
// Rlog comes with reasonable defaults, so you can just start using it without any
// configuration at all. By default:
//
// * Log level set to INFO.
//
// * Trace messages are not logged.
//
// * Time stamps are logged with each message.
//
// * No caller information.
//
// * Output is sent to stderr.
//
// All those defaults can easily be changed through environment variables or the
// config file.
//
//
// CONTROLLING RLOG THROUGH ENVIRONMENT OR CONFIG FILE VARIABLES
//
// Rlog is configured via the following settings, which may either be defined as
// environment variables or via a config file.
//
// * RLOG_LOG_LEVEL: Set to "DEBUG", "INFO", "WARN", "ERROR", "CRITICAL" or
//   "NONE". Any message of a level >= than what's configured will be printed. If
//   this is not defined it will default to "INFO". If it is set to "NONE" then
//   all logging is disabled, except Trace logs, which are controlled via a
//   separate variable. In addition, log levels can be set for individual files
//   (see below for more information). Default: INFO - meaning that INFO and
//   higher is logged.
//
// * RLOG_TRACE_LEVEL: "Trace" log messages take an additional numeric level as
//   first parameter. The user can specify an arbitrary number of levels. Set
//   RLOG_TRACE_LEVEL to a number. All Trace messages with a level <=
//   RLOG_TRACE_LEVEL will be printed. If this variable is undefined, or set to -1
//   then no Trace messages are printed. The idea is that the higher the
//   RLOG_TRACE_LEVEL value, the more 'chatty' and verbose the Trace message
//   output becomes. In addition, trace levels can be set for individual files
//   (see below for more information). Default: Not set - meaning that no trace
//   messages are logged.
//
// * RLOG_CALLER_INFO: If this variable is set to "1", "yes" or something else
//   that evaluates to 'true' then the message also contains the caller
//   information, consisting of the process ID, file and line number as well as
//   function name from which the log message was called. Default: No - meaning
//   that no caller info is logged.
//
// * RLOG_GOROUTINE_ID: If this variable is set to "1", "yes" or something else
//   that evaluates to 'true' AND the printing of caller info is requested, then
//   the caller info contains the goroutine ID, separated from the process ID by a
//   ':'. Note that calculation of the goroutine ID has a performance impact, so
//   please only enable this option if needed.
//
// * RLOG_TIME_FORMAT: Use this variable to customize the date/time format. The
//   format is specified either by the well known formats listed in
//   https://golang.org/src/time/format.go, for example "UnixDate" or "RFC3339".
//   Or as an example date/time output, which is described here:
//   https://golang.org/pkg/time/#Time.Format Default: Not set - formatted
//   according to RFC3339.
//
// * RLOG_LOG_NOTIME: If this variable is set to "1", "yes" or something else
//   that evaluates to 'true' then no date/time stamp is logged with each log
//   message. This is useful in environments that use systemd where access to the
//   logs via their logging tools already gives you time stamps. Default: No -
//   meaning that time/date is logged.
//
// * RLOG_LOG_FILE: Provide a filename here to determine if the logfile should
//   be written to a file, in addition to the output stream specified in
//   RLOG_LOG_STREAM. Default: Not set - meaning that output is not written to a
//   file.
//
// * RLOG_LOG_STREAM: Use this to direct the log output to a different output
//   stream, instead of stderr. This accepts three values: "stderr", "stdout" or
//   "none". If either stderr or stdout is defined here AND a logfile is specified
//   via RLOG_LOG_FILE then the output is sent to both. Default: Not set -
//   meaning the output goes to stderr.
//
// There are two more settings, related to the configuration file, which can only
// be set via environment variables.
//
// * RLOG_CONF_FILE: If this variable is set then rlog looks for the config
//   file at the specified location, which needs to be the path of the
//   file. If this variable is not defined, then rlog will look for the config
//   file in /etc/rlog/<your-executable-name>.conf. Therefore, by default every
//   executable has its own config file. By setting this variable, you could
//   force multiple processes to share the same config file.
//   Note that with the SetConfFile() function you can specify a new config file
//   programmatically at any time, even with a relative path.
//
// * RLOG_CONF_CHECK_INTERVAL: Number of seconds between checking whether the
//   config file has changed. By default, this is set to 15 seconds. This means
//   that within 15 seconds a changed logging configuration in the config file
//   will take effect. Note that this check is only performed when a log message
//   is actually written. If the program does nothing or doesn't log messages, the
//   config file won't be read. If there is no config file or it has been removed
//   then the configuration from the environment variables is used. Set this value
//   to 0 in order to switch off the regular config file checking: The config file
//   will then only be read once at the start.
//
// Please note! If these environment variables have incorrect or misspelled
// values then they will be silently ignored and a default value will be used.
//
//
// USING THE CONFIG FILE
//
// A config file for rlog is entirely optional, since rlog works just fine even
// without it. However, it does provide you with a very neat feature: You can
// change the logging configuration of a running program from the outside and
// without having to restart it!
//
// When rlog is imported it starts out with the defaults described above. It then
// takes an initial configuration from environment variables, which may override
// the default values. Next, it looks for the rlog config file. If it cannot find
// the config file it will quietly continue without error. If the config file is
// found then the configuration from environment variables is combined with the
// configuration from the config file. More about how this combination works, and
// what takes precedence, in a moment.
//
// CONFIG FILE LOCATION
//
// The path for the config file can be set via the RLOG_CONF_FILE
// environment variable. Absent that, rlog looks for a config file in
// /etc/rlog/<your-executable-name>.conf. This means that you can easily provide
// different logging configurations for each of your processes.
//
// A new config file location can also be specified at any time via the
// SetConfFile() function. An absolute or relative path may be specfied with that
// function.
//
// CONFIG FILE FORMAT
//
// The format of the config file is simple. Each setting is referred to by the
// same name as the environment variable. So, your config file may look like this:
//
//     # Comment lines start with a '#'
//     RLOG_LOG_LEVEL  = WARN
//     RLOG_LOG_STREAM = stdout
//     RLOG_TIME_FORMAT= UnixDate
//     RLOG_LOG_FILE   = /var/log/myapp.log
//
// A few notes about config file formatting:
//
// * Empty lines, or lines starting with '#' are ignored.
//
// * Leading and trailing spaces in lines are removed.
//
// * Everything after the first '=' will be taken as the value of the setting.
//
// * Leading and trailing spaces in values are removed.
//
// * Spaces or further '=' characters within values are taken as they are.
//
// COMBINING CONFIGURATION FROM ENVIRONMENT VARIABLES AND CONFIG FILE
//
// Generally, environment variables take precedence. Assume you have set a log
// level of INFO via the RLOG_LOG_LEVEL variable. This value will be used,
// even if you specified DEBUG in the config file, since an explicitly set
// environment variable takes precedence.
//
// There are only two cases when a config file value takes precedence:
//
// 1. If you do not have an explicit value set in the environment variable. For
//    example, if you do not have the RLOG_LOG_LEVEL environment variable defined
//    at all, or if it is set to the empty string.
//
// 2. If you apply a '!' as prefix in the config file. That marks this value as
//    higher priority than the environment variable. Consider the following config
//    file as example. Here RLOG_LOG_LEVEL and RLOG_TIME_FORMAT will take
//    precedence over whatever was defined in the environment variables.
//
// An example of using '!' in the config file:
//
//     !RLOG_LOG_LEVEL=WARN
//     RLOG_LOG_STREAM=stdout
//     !RLOG_TIME_FORMAT=UnixDate
//     RLOG_LOG_FILE=/var/log/myapp.log
//
//
// UPDATING LOGGING CONFIG FROM THE OUTSIDE: BY MODIFYING THE CONFIG FILE
//
// Every time you log a message and at least RLOG_CONF_CHECK_INTERVAL seconds have
// elapsed since the last reading of the config file, rlog will automatically
// re-read the content of the conf file and re-apply the configuration it finds
// there over the initial configuration, which was based on the environment
// variables.
//
// You can always just delete the config file to go back to the configuration
// based solely on environment variables.
//
// UPDATING LOGGING CONFIG FROM THE INSIDE: BY MODIFYING YOUR OWN ENVIRONMENT VARIABLES
//
// A running program may also change its rlog configuration on its own: The
// process can use the os.Setenv() function to modify its own environment
// variables and then call rlog.UpdatEnv() to reapply the settings
// from the environment variables. The examples/example.go file shows how this
// is done. But in short:
//
//     // Programmatically change an rlog setting from within the program
//     os.Setenv("RLOG_LOG_LEVEL", "DEBUG")
//     rlog.UpdateEnv()
//
// Note that this will not change rlog behaviour if the value for this config
// setting was specified with a '!' in the config file.
//
//
// PER FILE LEVEL LOG AND TRACE LEVELS
//
// In most cases you might want to set just a single log or trace level, which is
// then applied to all log messages in your program. With environment variables,
// you would set it like this:
//
//     export RLOG_LOG_LEVEL=INFO
//     export RLOG_TRACE_LEVEL=3
//
// However, with rlog the log and trace levels can not only be configured
// 'globally' with a single value, but can also independently be set for the
// individual module files that were compiled into your executable. This is useful
// if enabling high trace levels or DEBUG logging for the entire executable would
// fill up logs or consume too many resources.
//
// For example, if your executable is compiled out of several files and one of
// those files is called 'example.go' then you could set log levels like this:
//
//     export RLOG_LOG_LEVEL=INFO,example.go=DEBUG
//
// This sets the global log level to INFO, but for the messages originating from
// the module file 'example.go' it is DEBUG.
//
// Similarly, you can set trace levels for individual module files:
//
//     export RLOG_TRACE_LEVEL=example.go=5,2
//
// This sets a trace level of 5 for example.go and 2 for everyone else.
//
// More examples:
//
//     # DEBUG level for all files whose name starts with 'ex', WARNING level for
//     # everyone else.
//     export RLOG_LOG_LEVEL=WARN,ex*=DEBUG
//
//     # DEBUG level for example.go, INFO for everyone else, since INFO is the
//     # default level if nothing is specified.
//     export RLOG_LOG_LEVEL=example.go=DEBUG
//
//     # DEBUG level for example.go, no logging for anyone else.
//     export RLOG_LOG_LEVEL=NONE,example.go=DEBUG
//
//     # Multiple files' levels can be specified at once.
//     export RLOG_LOG_LEVEL=NONE,example.go=DEBUG,foo.go=INFO
//
//     # The default log level can appear anywhere in the list.
//     export RLOG_LOG_LEVEL=example.go=DEBUG,INFO,foo.go=WARN
//
// Note that as before, if in RLOG_LOG_LEVEL no global log level is specified then
// INFO is assumed to be the global log level. If in RLOG_TRACE_LEVEL no global
// trace level is specified then -1 (no trace output) is assumed as the global
// trace level.
//
//
// USAGE EXAMPLE
//
//     import "github.com/romana/rlog"
//
//     func main() {
//  	   rlog.Debug("A debug message: For the developer")
//  	   rlog.Info("An info message: Normal operation messages")
//  	   rlog.Warn("A warning message: Intermittent issues, high load, etc.")
//  	   rlog.Error("An error message: An error occurred, I will recover.")
//  	   rlog.Critical("A critical message: That's it! I give up!")
//  	   rlog.Trace(2, "A trace message")
//  	   rlog.Trace(3, "An even deeper trace message")
//     }
//
// For a more interesting example, please check out 'examples/example.go'.
//
//
// SAMPLE OUTPUT
//
// With time stamp, trace to level 2, log level WARNING, no caller info:
//
//     $ export RLOG_LOG_LEVEL=WARN
//     $ export RLOG_TRACE_LEVEL=2
//     $ go run examples/example.go
//
//     2017-11-16T08:06:56+13:00 WARN     : Warning level log message
//     2017-11-16T08:06:56+13:00 ERROR    : Error level log message
//     2017-11-16T08:06:56+13:00 CRITICAL : Critical level log message
//     2017-11-16T08:06:56+13:00 DEBUG    : You can see this message, because we changed level to DEBUG.
//     2017-11-16T08:06:56+13:00 TRACE(1) : Trace messages have their own numeric levels
//     2017-11-16T08:06:56+13:00 TRACE(1) : To see them set RLOG_TRACE_LEVEL to the cut-off number
//     2017-11-16T08:06:56+13:00 TRACE(1) : We're 1 levels down now...
//     2017-11-16T08:06:56+13:00 TRACE(2) : We're 2 levels down now...
//     2017-11-16T08:06:56+13:00 INFO     : Reached end of recursion at level 10
//     2017-11-16T08:06:56+13:00 INFO     : About to change log output. Check /tmp/rlog-output.log...
//     2017-11-16T08:06:56+13:00 INFO     : Back to stderr
//
// With time stamp, log level WARN, no trace logging (switched off by unsetting
// the variable), but with caller info ('23730' in the example below is the
// process ID):
//
//     $ export RLOG_CALLER_INFO=yes
//     $ export RLOG_LOG_LEVEL=WARN
//     $ export RLOG_TRACE_LEVEL=
//     $ go run examples/example.go
//
//     2017-11-16T08:07:57+13:00 WARN     : [21233 examples/example.go:31 (main.main)] Warning level log message
//     2017-11-16T08:07:57+13:00 ERROR    : [21233 examples/example.go:32 (main.main)] Error level log message
//     2017-11-16T08:07:57+13:00 CRITICAL : [21233 examples/example.go:33 (main.main)] Critical level log message
//     2017-11-16T08:07:57+13:00 DEBUG    : [21233 examples/example.go:42 (main.main)] You can see this message, because we changed level to DEBUG.
//     2017-11-16T08:07:57+13:00 INFO     : [21233 examples/example.go:17 (main.someRecursiveFunction)] Reached end of recursion at level 10
//     2017-11-16T08:07:57+13:00 INFO     : [21233 examples/example.go:52 (main.main)] About to change log output. Check /tmp/rlog-output.log...
//     2017-11-16T08:07:57+13:00 INFO     : [21233 examples/example.go:61 (main.main)] Back to stderr
//
// Without time stamp, no trace logging, no caller info:
//
//     $ export RLOG_LOG_NOTIME=yes
//     $ export RLOG_CALLER_INFO=no
//     $ go run examples/example.go
//
//     WARN     : Warning level log message
//     ERROR    : Error level log message
//     CRITICAL : Critical level log message
//     DEBUG    : You can see this message, because we changed level to DEBUG.
//     INFO     : Reached end of recursion at level 10
//     INFO     : About to change log output. Check /tmp/rlog-output.log...
//     INFO     : Back to stderr
//
// With time stamp in RFC822 format.
//
//     $ export RLOG_LOG_NOTIME=no
//     $ export RLOG_TIME_FORMAT=RFC822
//     $ go run examples/example.go
//
//     2017-11-16T08:08:49+13:00 WARN     : Warning level log message
//     2017-11-16T08:08:49+13:00 ERROR    : Error level log message
//     2017-11-16T08:08:49+13:00 CRITICAL : Critical level log message
//     2017-11-16T08:08:49+13:00 DEBUG    : You can see this message, because we changed level to DEBUG.
//     2017-11-16T08:08:49+13:00 INFO     : Reached end of recursion at level 10
//     2017-11-16T08:08:49+13:00 INFO     : About to change log output. Check /tmp/rlog-output.log...
//     2017-11-16T08:08:49+13:00 INFO     : Back to stderr
//
// With custom time stamp:
//
//     $ export RLOG_TIME_FORMAT="2006/01/06 15:04:05"
//     $ go run examples/example.go
//
//     2017-11-16T08:09:08+13:00 WARN     : Warning level log message
//     2017-11-16T08:09:08+13:00 ERROR    : Error level log message
//     2017-11-16T08:09:08+13:00 CRITICAL : Critical level log message
//     2017-11-16T08:09:08+13:00 DEBUG    : You can see this message, because we changed level to DEBUG.
//     2017-11-16T08:09:08+13:00 INFO     : Reached end of recursion at level 10
//     2017-11-16T08:09:08+13:00 INFO     : About to change log output. Check /tmp/rlog-output.log...
//     2017-11-16T08:09:08+13:00 INFO     : Back to stderr
//
//
//
//

package rlog

repository: romana/rlog

repo_name: romana/rlog


text:
package main

import (
	"fmt"
	"github.com/boltdb/bolt"
	"sync"
	"time"
)

type BoltStateStore struct {
	flowName  string
	requestId string
	db        *bolt.DB
	mux       sync.Mutex
}

func getDbName(flowName string) string {
	return flowName + ".db"
}

func GetBoltStateStore(flowName string) (*BoltStateStore, error) {
	ss := &BoltStateStore{}
	db, err := bolt.Open(getDbName(flowName), 0600, &bolt.Options{Timeout: 1 * time.Second})
	if err != nil {
		return nil, fmt.Errorf("failed to open file based db, error %v", err)
	}
	ss.flowName = flowName
	ss.db = db
	return ss, nil
}

// Configure the StateStore with flow name and request ID
func (ss *BoltStateStore) Configure(flowName string, requestId string) {
	ss.requestId = requestId
}

// Initialize the StateStore (called only once in a request span)
func (ss *BoltStateStore) Init() error {

	tx, err := ss.db.Begin(true)
	if err != nil {
		return fmt.Errorf("failed to create request bucket, error %v", err)
	}
	defer tx.Rollback()

	// Use the transaction...
	_, err = tx.CreateBucket([]byte(ss.requestId))
	if err != nil {
		return fmt.Errorf("failed to create request bucket, error %v", err)
	}

	// Commit the transaction and check for error.
	if err := tx.Commit(); err != nil {
		return fmt.Errorf("failed to create request bucket, error %v", err)
	}

	return nil
}

// Set a value (override existing, or create one)
func (ss *BoltStateStore) Set(key string, value string) error {
	err := ss.db.Update(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte(ss.requestId))
		err := b.Put([]byte(key), []byte(value))
		return err
	})
	if err != nil {
		return fmt.Errorf("failed to set key, error %v", err)
	}
	return nil
}

// Get a value
func (ss *BoltStateStore) Get(key string) (string, error) {

	var value string

	err := ss.db.View(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte(ss.requestId))
		data := b.Get([]byte(key))
		value = string(data)
		return nil
	})
	if err != nil {
		return "", fmt.Errorf("failed to get key, error %v", err)
	}
	return value, nil
}

// Compare and Update a value
func (ss *BoltStateStore) Update(key string, oldValue string, newValue string) error {

	err := ss.db.Update(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte(ss.requestId))
		value := b.Get([]byte(key))
		if string(value) != oldValue {
			return fmt.Errorf("value doesn't match")
		}
		err := b.Put([]byte(key), []byte(newValue))
		return err
	})
	if err != nil {
		return fmt.Errorf("failed to update key, error %v", err)
	}
	return nil
}

// Cleanup all the resources in StateStore (called only once in a request span)
func (ss *BoltStateStore) Cleanup() error {

	tx, err := ss.db.Begin(true)
	if err != nil {
		return fmt.Errorf("failed to delete request bucket, error %v", err)
	}
	defer tx.Rollback()

	// Use the transaction...
	err = tx.DeleteBucket([]byte(ss.requestId))
	if err != nil {
		return fmt.Errorf("failed to delete request bucket, error %v", err)
	}

	// Commit the transaction and check for error.
	if err := tx.Commit(); err != nil {
		return fmt.Errorf("failed to delete request bucket, error %v", err)
	}

	return nil
}

repository: jahentao/faas-workflow

repo_name: jahentao/faas-workflow