text:
<!DOCTYPE html>

        <meta charset="utf-8">
        <title>
            TCS: Telecommunication System - ECE3SAT
        </title>

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="stylesheet" type="text/css" href="http://www.ece3sat.com/css/v1.css">
        <link rel="stylesheet" type="text/css" href="http://www.ece3sat.com/css/styles.css" />
        <link rel="stylesheet" type="text/css" href="http://www.ece3sat.com/css/fonts-googleapis-com-css-family-Lato.css">
        <link rel="stylesheet" type="text/css" href="http://www.ece3sat.com/css/cdnjs-cloudflare-com-ajax-libs-font-awesome-4.7.0-css-font-awesome.min.css">

             Home

             The Project

             ECE3Sat SubModules

             Blog

             Home

             The Project

             ECE3Sat SubModules

             Blog

        TCS: Telecommunication System

        <legend style="margin:auto; text-align:center;">Ground station at Naval Computer and Telecommunications Area Master Station Pacific, Hawaii - From https://commons.wikimedia.org/wiki/File:The_Mobile_User_Objective_System.jpg</legend>

Telecommunication System (TCS)

Presentation

The TCS, or telecommunication system, communicates with the Ground
Control Station. It sends data to the Earth and receive orders (to shut
down the satellite because of an external factor for example). The data
sent to the Ground Control Station are transmitted to the TCS by the
OBC. And, in the same way, orders sent
from Earth to TCS are transmit to the
OBC.

Subsystem division

The TCS is divided in three subsystems which are Antenna,
Modulation/Demodulation (MODEM) and Data processing.

TCS Subsystems

The first subsystem, is mixed of two antenna embedded on the CubeSat.
One to receive order, and the other one to send data and transmit
messages.

The MODEM convert signals received and sent by and from antenna. It
apply a digital-to-analog conversion for the orders received, and
analog-to-digital conversion for the data which has to be send. The
signal is amplified since there is attenuation of the signal during the
transmission process.

The third subsystem, data processing, is the encapsulation and
decapsulation of the frame. It corresponds to the encryption of the
frame before being sent.

State Of The Art TCS

Anthena

The role of the antenna of CubeSat is to create the electromagnetic
waves which contain the necessary information for the realization of the
spatial mission to be able to receive them and interpret them on the
ground. The system converts the existing electric signal containing the
information in electromagnetic signal in the space.

Protocol

The communication subsystem of a CubeSat has two main purposes:

Transmit telemetry data, including a beacon.

Provide a mean for the satellite to communicate with ground station
and vice versa. (The Ground station will receive data from the
CubeSat only in this direction)

The protocol for communication follow the layer Model :

Protocol TCS

Several protocol can be used for satellites. The most used are the
following :

AX.25 :

It is the most used data link layer protocol between radio
amateurs is AX.25

CCSDS :

It is the most used transmission protocol for professional
satellite

CCSDS prootcol TCS

Protocol TCS

The carrier is a pure sinusoidal signal of constant amplitude, frequency
and phase. This carrier must be modified to carry the signal we want to
transmit. We say that the signal is modulated.

The carrier is described by the equation y = a sin (2πFt + φ) in which:

a is the amplitude of the carrier,

F is the frequency of the carrier,

φ is the phase of the carrier.

To modulate the carrier, we will modify one of these three parameter as
function of the signal to transmit.

Concept of envelope: The envelope of a signal is the external form
of the modulated signal.

Baud rate: The baud expresses the number of modulation moments per
second, this is the modulation rate. Each modulation moment being able
to transmit one or more bits.

Connection flow: Produces the baud rate and the length of the symbol
in bit.

Spectral efficiency: Ratio between flow rate (kb/s) and bandwidth
(Hz)

Concept of symbol: Unit of information transmitted by moment of
modulation. A symbol is a certain combined state of frequency, amplitude
and/or phase that represents a number of bits. If a symbol represents
one bit, it is the binary case. The single bit (k=1) can either be a
logical 1 or 0, thus rendering two symbol possibilities (M=2). If a
symbol consists of two bits (k=2), there is a total number of four
symbols (00, 01, 10 and 11), therefore M=4. The relationship between the
number of symbols and bits is:

M = 2k

Nyquist's theorem gives the upper limit of the bit rate for a system
defined by the following equation:

C = 2 B log2(2k)

C = 2 B log2(M)

C is the channel capacity in bps

B is the channel bandwidth in Hz

Modulation TCS

Sizing TCS

The different studies we did are referenced there :

Electronic Components

General constraints :

Altitude: 400 – 1000 km above the sea level

Inclination: 0° to 56° (inclination of ISS)

Radiation: resisting UV radiation, X, protons, and plasma in LEO

Duration of lifetime: 2 weeks to 1,5 month

Vibration on the launch

Maximum consumption of the CubeSat communication sub-system is 1,5W.

To respect those values, we saw the cards on board of other cubeSats.
The band chosen for downlink communications is 435-438 MHzand the
transmission rate: 1200 to 9600 bauds

Electronic components TCS

Mecanical Components

Environmental constraints :

Thermal constraint: -150°C to +150°C

Radiation constraint: resisting UV radiation, X, protons, and plasma
in LEO

The friction on the external surfaces including the antenna
shall not impact its functioning

The erosion due to the Oxygen (200-100km) must be managed

The luminescence due to the Oxygen (200-100km) must be managed

Launch vibrations

Compatibility criteria :

Transmission rate: 1200 to 9600 bauds

Broadcast max power: 1,5W

Frequency band: 435 to 438 MHz

Antenna gain max: 0 to2 dB

Dipole length: λ/4 minimum, λ/2 required

Interface: I²C

Envelope stowed: 98 mm x 98 mm x 7 mm

for the choice of the antenna, two companies designing parts for
CubeSats could propose interesting solutions for our project: ISIS and
Clyde Space, both proposing systems of antennas. Our choice is towards a
solution similar to the ISIS dipole antenna because characteristics
match with system and environmental specifications:

low gain: 0bB in UHF

<2W

1200 - 9600 bauds - <100g

almost omnidirectional

Dipole length: λ/2

Mecanical components TCS

Orbit and data estimation

The orbit period of the ECE3SAT is between 90 and 105 min. It's about 15
revolutions around Earth per day. We have only 3 orbits of 7 to 13
minutes per day that we can truly be exploited. That is aproximatly 30
minutes of visibility per day.

Size of data TCS

Note : The period of sampling is arbitrarily fixed here.

For the moment the total amount we have to transmit per orbit is 207663
bits or about 208 kbit.

We must also assure that we can stock the equivalent of 8 orbits of data
in the memory of the satellite: we are not able to transmit data each
orbit of our satellite and sometimes, you can have 8 successive orbits
without visibility as we can see in Gpredict for similar projects.

Orbit and data estimation TCS

Thermal simulation TCS

We can identify four sources of heat:

Equipment: The components within the satellite produce heat with
the energy they consume.

Solar radiation: This is the most important source of heat. The
solar flux accounts between 1353 and 1375 Watts / m².

Albedo: This refers to the solar radiation reflected by
the Earth. This energy represents an average radiance of 196 W / m²
in the sunny hemisphere of the Earth.

Earth radiation: This accounts an energy of 190W / m² up to 240W
/ m².

The data coming from the FUNcube-1 also gave us the temperature range in
which a satellite operates : from -30 ° C to 85 ° C

Thermal Simulation TCS

Model TCS

The purpose of this technical realization was to validate data exchange
with system specifications. To do so we decided to build our own
anthena.

That’s why we used a communication card provided by the AMSAT-F, a DVB-T
dongle, an LNA amplifier and our home-made antenna.

Software Defined Radio (SDR)

For the software part we used the software SDRSharp, a software that
allows us to pilot the key via an interface of spectrum analysis and
selection of frequency, bandwidth and signal processing tools.

TCS SDR

Doppler effect

In parallel with the SDR we used the software Orbitron to have a
satellite tracking station with TLE (Two-Line Elements) information and
automatic correction of the retroactive Doppler effect on SDRSharp.

TCS Orbit

The two-line orbital parameters (TLE) are elements measured and
calculated by NORAD and NASA, not only for artificial satellites, but
also for space debris. They allow Orbitron to calculate the position of
objects in orbit at any time because they follow the laws of Kepler and
Newton.

By setting the input text files of the software, we can easily isolate
the satellites we are interested in, namely the CubeSat of the AMSAT.

Once selected, we have access to a lot of satellite information,
including emission frequency and Doppler calculation.

TCS Dopler

The Orbitron software allows us to control the frequency selection of
SDRSharp by taking into account the value of the Doppler in real time.

Demodulation

For the demodulation, we had several choices :

The first option is that we can either use an open source amateur
radio software: MULTIPSK. This one allows us to demodulate the
signal modulated in BPSK in real time. To send the stream from
SDRSharp to MULTIPSK, we have installed Virtual Audio Cable which
allows to direct the output of SDR to the input of the demodulator.

The second option is to use a more specific software that only works
with the FUNcube and its associated dongle. This is the FUNcube
Dashboard software which is dedicated to the telemetry of
this CubeSat. The software's interface is a high level of
programming: We can't see any treatment of data and that we access
directly to the data of telemetries interpreted in background by
the dashboard. In the same way, the software is provided with the
virtual audio gateway as input and the software identifies and
interprets in real time the signal which must be at 1200 bauds in
BPSK modulation. From the moment this software recognizes an AX-25
frame, it translates it into telemetry data.

Dongle

We decided to use the following TNT USB key:

TCS USB

This key contains the RLT2832U chip and the R820T2 tuner. It competes
perfectly with the usual scanners since it covers from 30MHz to 1500MHz,
and this with two spectrum analyzers:

A 2D: frequency / amplitude

A 3D: “waterfall” frequency / amplitude / time

The disadvantage of this USB kit is that the antenna supplied with it is
not suitable for the use we want to make of it. To overcome this
problem, we started the realization of an antenna optimized for our
study

Anthena realization

We were targeting the frequency of the FUNcube in telemetry which is
145.935MHz. This is why we decided to manufacture an antenna called
Yagi-Uda 3 elements.

The Yagi-Uda is a type of antenna that has an active element, the
dipole, which will be fed with high-frequency signals. In front of the
dipole takes place a slightly shorter element, this element is called
“director”. Behind the dipole is positioned a slightly longer element
called “reflector”.

TCS Anthena

We made this antenna with a square aluminum profile and 8 mm aluminum
rod.

Concerning the length of the dipoles, it was chosen according to the
frequency of emission of the FUNcube:

TCS Anthena

To tune the antenna impedance, we installed a gamma match element as
follows:

TCS Gammamatch

Preamplifier

The chosen preamplifier is the LNA4ALL, a preamplifier and a low-pass
filter (LNA), with SMA Female connectors, for VHF and UHF frequencies
covering all bands from 28 MHz to 2500 MHz (2.5Ghz). We chose this one
because it allows to improve very clearly the reception performance, on
all bands VHF and UHF up to 2.5Ghz, of a TNT key RTL-SDR.

TCS preamplifier

The LNA was then bought and the model assembled.

TCS LNA

Technical realization TCS

     ece3sat@gmail.com
    -

    -  Source Code
    -


text:
package xm.math.slopeone;

import java.util.*;

/**
 * Created by xuming on 2016/6/20.
 * Slope One 算法
 */
public class SlopeOne {
    /// <summary>
    /// 评分系统
    /// </summary>
    public static Map<Integer, Product> dicRatingSystem = new HashMap<>();
    public Map<String, Rating> dic_Martix = new HashMap<>();
    public HashSet<Integer> hash_items = new HashSet<Integer>();
    /// <summary>
    /// 接收一个用户的打分记录
    /// </summary>
    /// <param name="userRatings"></param>
    public void AddUserRatings(HashMap<Integer, List<Product>> userRatings) {
        for (Map.Entry<Integer, List<Product>> user1 : userRatings.entrySet()) {
            List<Product> value = user1.getValue();
            for (Product item1 : value) {
                //该产品的编号(具有唯一性)
                int item1Id = item1.ProductID;
                //该项目的评分
                float item1Rating = item1.Score;
                //将产品编号字存放在hash表中
                hash_items.add(item1.ProductID);
                for (Map.Entry<Integer, List<Product>> user2 : userRatings.entrySet()) {
                    List<Product> value2 = user2.getValue();
                    for (Product item2 : value2) {
                        //过滤掉同名的项目
                        if (item2.ProductID <= item1Id)
                            continue;
                        //该产品的名字
                        int item2Id = item2.ProductID;
                        //该项目的评分
                        float item2Rating = item2.Score;
                        Rating ratingDiff;
                        //用表的形式构建矩阵
                        String key = Tools.GetKey(item1Id, item2Id);
                        //将俩俩 Item 的差值 存放到 Rating 中
                        if (dic_Martix.keySet().contains(key))
                            ratingDiff = dic_Martix.get(key);
                        else {
                            ratingDiff = new Rating();
                            dic_Martix.put(key, ratingDiff);
                        }
                        //方便以后以后userrating的编辑操作,(add)
                        if (!ratingDiff.hash_user.contains(user1.getKey())) {
                            //value保存差值
                            ratingDiff.Value += item1Rating - item2Rating;

                            //说明计算过一次
                            ratingDiff.Freq += 1;
                        }
                        //记录操作人的ID,方便以后再次添加评分
                        ratingDiff.hash_user.add(user1.getKey());
                    }
                }
            }
        }
    }

    /// <summary>
    /// 根据矩阵的值,预测出该Rating中的值
    /// </summary>
    /// <param name="userRatings"></param>
    /// <returns></returns>
    public HashMap<Integer, Float> Predict(List<Product> userRatings) {
        HashMap<Integer, Float> predictions = new HashMap<Integer, Float>();
        List<Integer> productIDs = new ArrayList<Integer>();
        userRatings.forEach(i -> productIDs.add(i.ProductID));//lambda
        //循环遍历_Items中所有的Items
        for (Integer itemId : this.hash_items) {
            //过滤掉不需要计算的产品编号
            if (productIDs.contains(itemId))
                continue;
            Rating itemRating = new Rating();
            // 内层遍历userRatings
            for (Product userRating : userRatings) {
                if (userRating.ProductID == itemId)
                    continue;
                int inputItemId = userRating.ProductID;
                //获取该key对应项目的两组AVG的值
                String key = Tools.GetKey(itemId, inputItemId);
                if (dic_Martix.keySet().contains(key)) {
                    Rating diff = dic_Martix.get(key);
                    //关键点:运用公式求解(这边为了节省空间,对角线两侧的值呈现奇函数的特性)
                    itemRating.Value += diff.Freq * (userRating.Score + diff.AverageValue * ((itemId < inputItemId) ? 1 : -1));
                    //关键点:运用公式求解 累计每两组的人数
                    itemRating.Freq += diff.Freq;
                }
            }
            predictions.put(itemId, itemRating.AverageValue=(itemRating.Value/itemRating.Freq));
        }
        return predictions;
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace Go\Aop\Intercept;

/**
 * Intercepts field access on a target object.
 *
 * The user should implement the set(FieldAccess) and
 * get(FieldAccess) methods to modify the original
 * behavior. E.g. the following class implements a tracing interceptor
 * (traces the accesses to the intercepted field(s)):
 *
 * <pre class=code>
 * class TracingInterceptor implements FieldInterceptor {
 *
 *   public function set(FieldAccess $fa) {
 *     print("field ".$fa->getField()." is set with value ".
 *                        $fa->getValueToSet());
 *     $ret=$fa->proceed();
 *     print("field ".$fa->getField()." was set to value ".$ret);
 *     return $ret;
 *   }
 *
 *   public function get(FieldAccess $fa) {
 *     print("field ".$fa->getField()." is about to be read");
 *     $ret=$fa->proceed();
 *     print("field ".$fa->getField()." was read; value is ".$ret);
 *     return $ret;
 *   }
 * }
 * </pre>
 */
interface FieldInterceptor extends Interceptor
{

    /**
     * Do the stuff you want to do before and after the
     * field is getted.
     *
     * @param FieldAccess $fieldRead the joinpoint that corresponds to the field read
     *
     * @return mixed the result of the field read
     */
    public function get(FieldAccess $fieldRead);

    /**
     * Do the stuff you want to do before and after the
     * field is setted.
     *
     * @param FieldAccess $fieldWrite the joinpoint that corresponds to the field write
     *
     * @return mixed the result of the field set
     */
    public function set(FieldAccess $fieldWrite);
}


text:
package com.sun.tools.doclets.internal.toolkit.util;

import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.javadoc.*;
import java.io.*;

/**
 * Handle the directory creations and the path string generations.
 * All static - never instaniated.
 *
 * This code is not part of an API.
 * It is implementation that is subject to change.
 * Do not use it as an API
 *
 * @since 1.2
 * @author Atul M Dambalkar
 */
public class DirectoryManager {

    /**
     * The file separator string, "/", used in the formation of the URL path.
     */
    public static final String URL_FILE_SEPARATOR = "/";

    /**
     * Never instaniated.
     */
    private DirectoryManager() {
    }

    /**
     * Given a PackageDoc, return its URL path string.
     *
     * @param pd PackageDoc
     * @see #getPath(String)
     */
    public static String createPathString(PackageDoc pd) {
        if (pd == null) {
            return "";
        }
        return getPath(pd.name());
    }

    /**
     * Given a ClassDoc, return its URL path string.
     *
     * @param cd ClassDoc
     * @see #getPath(String)
     */
    public static String createPathString(ClassDoc cd) {
        if (cd == null) {
            return "";
        }
        PackageDoc pd = cd.containingPackage();
        return (pd == null)? "": getPath(pd.name());
    }

    /**
     * Given a PackageDoc, return the corresponding directory name
     * with the platform-dependent file separator between subdirectory names.
     * For example, if name of the package is "java.lang" , then it
     * returns "java/lang" on Unix and "java\lang" on Windows.
     * If name of the package contains no dot, then the value
     * will be returned unchanged.  Because package names cannot
     * end in a dot, the return value will never end with a slash.
     *

     * Also see getPath for the URL separator version of this method
     * that takes a string instead of a PackageDoc.
     *
     * @param  pd    the PackageDoc
     * @return       the platform-dependent directory path for the package
     */
    public static String getDirectoryPath(PackageDoc pd) {
        return pd == null || pd.name().length() == 0 ? "" : getDirectoryPath(pd.name());
    }

    /**
     * Given a package name, return the corresponding directory name
     * with the platform-dependent file separator between subdirectory names.
     * For example, if name of the package is "java.lang" , then it
     * returns "java/lang" on Unix and "java\lang" on Windows.
     * If name of the package contains no dot, then the value
     * will be returned unchanged.  Because package names cannot
     * end in a dot, the return value will never end with a slash.
     *

     * Also see getPath for the URL separator version of this method
     * that takes a string instead of a PackageDoc.
     *
     * @param  packageName    the name of the package
     * @return       the platform-dependent directory path for the package
     */
    public static String getDirectoryPath(String packageName) {
        if (packageName == null || packageName.length() == 0) {
            return "";
        }
        StringBuffer pathstr = new StringBuffer();
        for (int i = 0; i < packageName.length(); i++) {
            char ch = packageName.charAt(i);
            if (ch == '.') {
                pathstr.append(URL_FILE_SEPARATOR);
            } else {
                pathstr.append(ch);
            }
        }
        if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPARATOR)) {
            pathstr.append(URL_FILE_SEPARATOR);
        }
        return pathstr.toString();
    }

    /**
     * Given a package name (a string), return the path string,
     * with the URL separator "/" separating the subdirectory names.
     * If name of the package contains no dot, then the value
     * will be returned unchanged.  Because package names cannot
     * end in a dot, the return value will never end with a slash.
     *

     * For example if the string is "com.sun.javadoc" then the URL
     * path string will be "com/sun/javadoc".
     *
     * @param name   the package name as a String
     * @return       the String URL path
     */
    public static String getPath(String name) {
        if (name == null || name.length() == 0) {
            return "";
        }
        StringBuffer pathstr = new StringBuffer();
        for (int i = 0; i < name.length(); i++) {
            char ch = name.charAt(i);
            if (ch == '.') {
                pathstr.append(URL_FILE_SEPARATOR);
            } else {
                pathstr.append(ch);
            }
        }
        return pathstr.toString();
    }

    /**
     * Given two package names as strings, return the relative path
     * from the package directory corresponding to the first string
     * to the package directory corresponding to the second string,
     * with the URL file separator "/" separating subdirectory names.
     *

     * For example, if the parameter "from" is "java.lang"
     * and parameter "to" is "java.applet", return string
     * "../../java/applet".
     *
     * @param from   the package name from which path is calculated
     * @param to     the package name to which path is calculated
     * @return       relative path between "from" and "to" with URL
     *               separators
     * @see          #getRelativePath(String)
     * @see          #getPath(String)
     */
    public static String getRelativePath(String from, String to) {
        StringBuffer pathstr = new StringBuffer();
        pathstr.append(getRelativePath(from));
        pathstr.append(getPath(to));
        pathstr.append(URL_FILE_SEPARATOR);
        return pathstr.toString();
    }

    /**
     * Given a package name as a string, return relative path string
     * from the corresponding package directory to the root of
     * the documentation, using the URL separator "/" between
     * subdirectory names.
     *

     * For example, if the string "from" is "java.lang",
     * return "../../"
     *
     * @param from    the package
     * @return        String relative path from "from".
     * @see           #getRelativePath(String, String)
     */
    public static String getRelativePath(PackageDoc from) {
        return from == null || from.name().length() == 0 ? "" : getRelativePath(from.name());
    }

    /**
     * Given a package name as a string, return relative path string
     * from the corresponding package directory to the root of
     * the documentation, using the URL separator "/" between
     * subdirectory names.
     *

     * For example, if the string "from" is "java.lang",
     * return "../../"
     *
     * @param from    the package name
     * @return        String relative path from "from".
     * @see           #getRelativePath(String, String)
     */
    public static String getRelativePath(String from) {
        if (from == null || from.length() == 0) {
            return "";
        }
        StringBuffer pathstr = new StringBuffer();
        for (int i = 0; i < from.length(); i++) {
            char ch = from.charAt(i);
            if (ch == '.') {
                pathstr.append(".." + URL_FILE_SEPARATOR);
            }
        }
        pathstr.append(".." + URL_FILE_SEPARATOR);
        return pathstr.toString();
    }

    /**
     * Given a relative or absolute path that might be empty,
     * convert it to a path that does not end with a
     * URL separator "/".  Used for converting
     * HtmlStandardWriter.relativepath when replacing {@docRoot}.
     *
     * @param path   the path to convert.  An empty path represents
     *               the current directory.
     */
    public static String getPathNoTrailingSlash(String path) {
        if ( path.equals("") ) {
            return ".";
        }
        if ( path.equals("/") ) {
            return "/.";
        }
        if ( path.endsWith("/") ) {
            // Remove trailing slash
            path = path.substring(0, path.length() -1);
        }
        return path;
    }

    /**
     * Given a path string create all the directories in the path. For example,
     * if the path string is "java/applet", the method will create directory
     * "java" and then "java/applet" if they don't exist. The file separator
     * string "/" is platform dependent system property.
     *
     * @param path Directory path string.
     */
    public static void createDirectory(Configuration configuration,
                                       String path) {
        if (path == null || path.length() == 0) {
            return;
        }
        File dir = new File(path);
        if (dir.exists()) {
            return;
        } else {
            if (dir.mkdirs()) {
                return;
            } else {
                configuration.message.error(
                       "doclet.Unable_to_create_directory_0", path);
                throw new DocletAbortException();
            }
        }
    }

    /**
     * Given a package name and a file name, return the full path to that file.
     * For example, if PackageDoc passed is for "java.lang" and the filename
     * passed is "package-summary.html", then the string returned is
     * "java/lang/package-summary.html".
     *
     * @param pd         PackageDoc.
     * @param filename   File name to be appended to the path of the package.
     */
    public static String getPathToPackage(PackageDoc pd, String filename) {
        StringBuffer buf = new StringBuffer();
        String pathstr = createPathString(pd);
        if (pathstr.length() > 0) {
            buf.append(pathstr);
            buf.append(URL_FILE_SEPARATOR);
        }
        buf.append(filename);
        return buf.toString();
    }

    /**
     * Given a class name return the full path to the class file.
     * For example, if ClassDoc passed is for "java.lang.Object" then the
     * string returned is "java/lang/Object.html".
     *
     * @param cd   ClassDoc.
     */
    public static String getPathToClass(ClassDoc cd) {
        return getPathToPackage(cd.containingPackage(), cd.name() + ".html");
    }

}


text:
' Copyright 2018 Google LLC
'
' Licensed under the Apache License, Version 2.0 (the "License")
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
'
'     http:'www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.

Imports Google.Api.Ads.AdWords.Lib
Imports Google.Api.Ads.AdWords.v201809

Namespace Google.Api.Ads.AdWords.Examples.VB.v201809
    ''' <summary>
    ''' This code example imports offline conversion values for specific clicks to
    ''' your account. To get Google Click ID for a click, run
    ''' CLICK_PERFORMANCE_REPORT. To set up a conversion tracker, run the
    ''' AddConversionTrackers.vb example.
    ''' </summary>
    Public Class UploadOfflineConversions
        Inherits ExampleBase

        ''' <summary>
        ''' Returns a description about the code example.
        ''' </summary>
        Public Overrides ReadOnly Property Description() As String
            Get
                Return _
                    "This code example imports offline conversion values for specific clicks to " &
                    "your account. To get Google Click ID for a click, run " &
                    "CLICK_PERFORMANCE_REPORT. To set up a conversion tracker, run the " &
                    "AddConversionTrackers.vb example."
            End Get
        End Property

        ''' <summary>
        ''' Main method, to run this code example as a standalone application.
        ''' </summary>
        ''' <param name="args">The command line arguments.</param>
        Public Shared Sub Main(ByVal args As String())
            Dim conversionName As String = "INSERT_CONVERSION_NAME_HERE"
            ' GCLID needs to be newer than 30 days.
            Dim gClId As String = "INSERT_GOOGLE_CLICK_ID_HERE"
            '  The conversion time should be higher than the click time.
            Dim conversionTime As String = "INSERT_CONVERSION_TIME_HERE"
            Dim conversionValue As Double = Double.Parse("INSERT_CONVERSION_VALUE_HERE")

            Dim codeExample As New UploadOfflineConversions
            Console.WriteLine(codeExample.Description)
            Try
                codeExample.Run(New AdWordsUser, conversionName, gClId, conversionTime,
                                conversionValue)
            Catch e As Exception
                Console.WriteLine("An exception occurred while running this code example. {0}",
                                  ExampleUtilities.FormatException(e))
            End Try
        End Sub

        ''' <summary>
        ''' Runs the code example.
        ''' </summary>
        ''' <param name="user">The AdWords user.</param>
        ''' <param name="conversionName">The name of the upload conversion to be
        ''' created.</param>
        ''' <param name="gClid">The Google Click ID of the click for which offline
        ''' conversions are uploaded.</param>
        ''' <param name="conversionValue">The conversion value to be uploaded.
        ''' </param>
        ''' <param name="conversionTime">The conversion time, in yyyymmdd hhmmss
        ''' format.</param>
        Public Sub Run(ByVal user As AdWordsUser, ByVal conversionName As String,
                       ByVal gClid As String, ByVal conversionTime As String,
                       ByVal conversionValue As Double)
            Using _
                offlineConversionFeedService As OfflineConversionFeedService =
                    CType(
                        user.GetService(
                            AdWordsService.v201809.OfflineConversionFeedService),
                        OfflineConversionFeedService)

                Try
                    ' Associate offline conversions with the existing named conversion tracker. If
                    ' this tracker was newly created, it may be a few hours before it can accept
                    ' conversions.
                    Dim feed As New OfflineConversionFeed()
                    feed.conversionName = conversionName
                    feed.conversionTime = conversionTime
                    feed.conversionValue = conversionValue
                    feed.googleClickId = gClid

                    ' Optional: To upload fractional conversion credits, set the external
                    ' attribution model and credit. To use this feature, your conversion tracker
                    ' should be marked as externally attributed. See
                    ' https://developers.google.com/adwords/api/docs/guides/conversion-tracking#importing_externally_attributed_conversions
                    ' to learn more about importing externally attributed conversions.

                    ' feed.externalAttributionModel = "Linear"
                    ' feed.externalAttributionCredit = 0.3

                    Dim offlineConversionOperation As New OfflineConversionFeedOperation()
                    offlineConversionOperation.operator = [Operator].ADD
                    offlineConversionOperation.operand = feed

                    Dim offlineConversionRetval As OfflineConversionFeedReturnValue =
                            offlineConversionFeedService.mutate(
                                New OfflineConversionFeedOperation() {offlineConversionOperation})

                    Dim newFeed As OfflineConversionFeed = offlineConversionRetval.value(0)

                    Console.WriteLine(
                        "Uploaded offline conversion value of {0} for Google Click ID = " &
                        "'{1}' to '{2}'.", newFeed.conversionValue, newFeed.googleClickId,
                        newFeed.conversionName)
                Catch e As Exception
                    Throw _
                        New System.ApplicationException("Failed to upload offline conversions.", e)
                End Try
            End Using
        End Sub
    End Class
End Namespace


text:
FROM alpine:3

RUN apk add -U ca-certificates tzdata && rm -Rf /var/cache/apk/*
COPY cm /

WORKDIR /root
ENTRYPOINT ["/cm"]


text:
package org.openqa.selenium.remote;

import java.lang.reflect.Method;

import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

// Deliberately package level visibility
class AddTakesScreenshot implements AugmenterProvider {

  public Class<?> getDescribedInterface() {
    return TakesScreenshot.class;
  }

  public InterfaceImplementation getImplementation(Object ignored) {
    // The only method on TakesScreenshot is the one to take a screenshot
    return new InterfaceImplementation() {
      public Object invoke(ExecuteMethod executeMethod, Method method, Object... args) {
        String base64 = (String) executeMethod.execute(DriverCommand.SCREENSHOT, null);
        return ((OutputType<?>) args[0]).convertFromBase64Png(base64);
      }
    };
  }
}


text:
using RedditSharp;
using RedditSharp.Things;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.IO;
using System.Linq;
namespace Mnemosyne2Reborn.UserData
{
    public class RedditUserProfileSqlite
    {
        static SQLiteCommand SQLiteSetUnarchived, SQLiteSetArchived, SQLiteSetExcluded, SQLiteSetImage, SQLiteGetImage, SQLiteAddUser, SQLiteGetArchived, SQLiteGetUnarchived, SQLiteGetExcluded, SQLiteGetOptOut, SQLiteSetOptOut, SQLiteGetUserExists, SQLiteAvgExcluded, SQLiteAvgImage, SQLiteAvgArchived, SQLiteAvgUnarchived;
        public static SQLiteConnection Connection { get; private set; }
        static bool Initialized = false;
#pragma warning disable CS0618 // Type or member is obsolete
        public static void TransferProfilesToSqlite(Dictionary<string, RedditUserProfile> dict)
#pragma warning restore CS0618 // Type or member is obsolete
        {
            CheckInitialized();
            var optedOut = from a in dict.AsParallel() where a.Value.OptedOut == true select a; // parallel because the dictionary can be absolutely enormous depending on length of runtime
            foreach (var user in optedOut)
            {
                try
                {
                    new RedditUserProfileSqlite(new Reddit().GetUser(user.Key)).OptedOut = true;
                }
                catch (System.Net.WebException e) when (e.Message.Contains("(404)"))
                {
                    Console.WriteLine($"User {user.Key} no longer exists");
                }
            }
        }
        static void CheckInitialized()
        {
            if (!Initialized)
                throw new InvalidOperationException("You must initialize using the string based constructor first, then you may use the class later on");
        }
        public static bool UserExists(string User)
        {
            CheckInitialized();
            SQLiteGetUserExists.Parameters["@Name"].Value = User;
            return Convert.ToBoolean(SQLiteGetUserExists.ExecuteScalar());
        }
        public static bool UserExists(RedditUser User) => UserExists(User.Name);
        public bool OptedOut
        {
            get
            {
                SQLiteGetOptOut.Parameters["@Name"].Value = User;
                return Convert.ToBoolean(SQLiteGetOptOut.ExecuteScalar());
            }
            set
            {
                SQLiteSetOptOut.Parameters["@Name"].Value = User;
                SQLiteSetOptOut.Parameters["@OptedOut"].Value = value ? 1 : 0;
                SQLiteSetOptOut.ExecuteNonQuery();
            }
        }
        public static float AverageImage
        {
            get
            {
                CheckInitialized();
                return Convert.ToSingle(SQLiteAvgImage.ExecuteScalar());
            }
        }
        public int Image
        {
            get
            {
                SQLiteGetImage.Parameters["@Name"].Value = User;
                return Convert.ToInt32(SQLiteGetImage.ExecuteScalar());
            }
            set
            {
                SQLiteSetImage.Parameters["@Name"].Value = User;
                SQLiteSetImage.Parameters["@ImageUrls"].Value = value;
                SQLiteSetImage.ExecuteNonQuery();
            }
        }
        public float AverageUnarchived
        {
            get
            {
                CheckInitialized();
                return Convert.ToSingle(SQLiteAvgUnarchived.ExecuteScalar());
            }
        }
        public int Unarchived
        {
            get
            {
                SQLiteGetUnarchived.Parameters["@Name"].Value = User;
                return Convert.ToInt32(SQLiteGetUnarchived.ExecuteScalar());
            }
            set
            {
                SQLiteSetUnarchived.Parameters["@Name"].Value = User;
                SQLiteSetUnarchived.Parameters["@UnarchivedUrls"].Value = value;
                SQLiteSetUnarchived.ExecuteNonQuery();
            }
        }
        public static float AverageArchived
        {
            get
            {
                CheckInitialized();
                return Convert.ToSingle(SQLiteAvgArchived.ExecuteScalar());
            }
        }
        public int Archived
        {
            get
            {
                SQLiteGetArchived.Parameters["@Name"].Value = User;
                return Convert.ToInt32(SQLiteGetArchived.ExecuteScalar());
            }
            set
            {
                SQLiteSetArchived.Parameters["@Name"].Value = User;
                SQLiteSetArchived.Parameters["@ArchivedUrls"].Value = value;
                SQLiteSetArchived.ExecuteNonQuery();
            }
        }
        public static float AverageExcluded
        {
            get
            {
                CheckInitialized();
                return Convert.ToSingle(SQLiteAvgExcluded.ExecuteScalar());
            }
        }
        public int Excluded
        {
            get
            {
                SQLiteGetExcluded.Parameters["@Name"].Value = User;
                return Convert.ToInt32(SQLiteGetExcluded.ExecuteScalar());
            }
            set
            {
                SQLiteSetExcluded.Parameters["@Name"].Value = User;
                SQLiteSetExcluded.Parameters["@ExcludedUrls"].Value = value;
                SQLiteSetExcluded.ExecuteNonQuery();
            }
        }
        string User;
        public void AddUrlUsed(string url)
        {
            if (OptedOut)
            {
                return;
            }
            if (Program.exclusions.IsMatch(url.ToString()))
            {
                Excluded++;
                return;
            }
            if (Program.providers.IsMatch(url.ToString()))
            {
                Archived++;
            }
            else
            {
                Unarchived++;
            }
            if (Program.ImageRegex.IsMatch(url.ToString()))
            {
                Image++;
            }
        }
        static void InitDbTable()
        {
            using (SQLiteCommand cmd = new SQLiteCommand("create table if not exists Users (Name text unique, UnarchivedUrls integer, ImageUrls integer, ArchivedUrls integer, ExcludedUrls integer, OptedOut integer)", Connection))
                cmd.ExecuteNonQuery();
        }
        static void InitDbCommands()
        {
            SQLiteParameter UserNameParam = new SQLiteParameter("@Name", DbType.String);

            SQLiteGetUserExists = new SQLiteCommand("select count(*) from Users where Name = @Name", Connection);
            SQLiteGetUserExists.Parameters.Add(UserNameParam);

            SQLiteAddUser = new SQLiteCommand("insert or abort into Users(Name, UnarchivedUrls, ImageUrls, ArchivedUrls, ExcludedUrls, OptedOut) values(@Name, 0, 0, 0, 0, 0)", Connection);
            SQLiteAddUser.Parameters.Add(UserNameParam);

            SQLiteGetUnarchived = new SQLiteCommand("select UnarchivedUrls from Users where Name = @Name", Connection);
            SQLiteGetUnarchived.Parameters.Add(UserNameParam);

            SQLiteGetArchived = new SQLiteCommand("select ArchivedUrls from Users where Name = @Name", Connection);
            SQLiteGetArchived.Parameters.Add(UserNameParam);

            SQLiteGetOptOut = new SQLiteCommand("select OptedOut from Users where Name = @Name", Connection);
            SQLiteGetOptOut.Parameters.Add(UserNameParam);

            SQLiteGetExcluded = new SQLiteCommand("select ExcludedUrls from Users where Name = @Name", Connection);
            SQLiteGetExcluded.Parameters.Add(UserNameParam);

            SQLiteSetArchived = new SQLiteCommand("update Users set ArchivedUrls = @ArchivedUrls where Name = @Name", Connection);
            SQLiteSetArchived.Parameters.Add(new SQLiteParameter("@ArchivedUrls", DbType.Int32));
            SQLiteSetArchived.Parameters.Add(UserNameParam);

            SQLiteSetExcluded = new SQLiteCommand("update Users set ExcludedUrls = @ExcludedUrls where Name = @Name", Connection);
            SQLiteSetExcluded.Parameters.Add(new SQLiteParameter("@ExcludedUrls", DbType.Int32));
            SQLiteSetExcluded.Parameters.Add(UserNameParam);

            SQLiteSetUnarchived = new SQLiteCommand("update Users set UnarchivedUrls = @UnarchivedUrls where Name = @Name", Connection);
            SQLiteSetUnarchived.Parameters.Add(new SQLiteParameter("@UnarchivedUrls", DbType.Int32));
            SQLiteSetUnarchived.Parameters.Add(UserNameParam);

            SQLiteSetOptOut = new SQLiteCommand("update Users set OptedOut = @OptedOut where Name = @Name", Connection);
            SQLiteSetOptOut.Parameters.Add(new SQLiteParameter("@OptedOut", DbType.Int32));
            SQLiteSetOptOut.Parameters.Add(UserNameParam);

            SQLiteSetImage = new SQLiteCommand("update Users set ImageUrls = @ImageUrls where Name = @Name", Connection);
            SQLiteSetImage.Parameters.Add(new SQLiteParameter("@ImageUrls", DbType.Int32));
            SQLiteSetImage.Parameters.Add(UserNameParam);

            SQLiteGetImage = new SQLiteCommand("select ImageUrls from Users where Name = @Name", Connection);
            SQLiteGetImage.Parameters.Add(UserNameParam);

            SQLiteAvgArchived = new SQLiteCommand("select avg(ArchivedUrls) from Users");

            SQLiteAvgExcluded = new SQLiteCommand("select avg(ExcludedUrls) from Users");

            SQLiteAvgImage = new SQLiteCommand("select avg(ImageUrls) from Users");

            SQLiteAvgUnarchived = new SQLiteCommand("select avg(UnarchivedUrls) from Users");
        }
        public RedditUserProfileSqlite(string fileName = "redditusers.sqlite")
        {
            if (!File.Exists($"{AppDomain.CurrentDomain.BaseDirectory.TrimEnd('/')}/Data/{fileName}"))
            {
                SQLiteConnection.CreateFile($"{AppDomain.CurrentDomain.BaseDirectory.TrimEnd('/')}/Data/{fileName}");
            }
            AppDomain.CurrentDomain.SetData("DataDirectory", $"{AppDomain.CurrentDomain.BaseDirectory.TrimEnd('/')}/Data/");
            Connection = new SQLiteConnection($"Data Source=|DataDirectory|{fileName};Version=3;");
            Connection.Open();
            InitDbTable();
            InitDbCommands();
            Initialized = true;
        }
        public RedditUserProfileSqlite(RedditUser user)
        {
            CheckInitialized();
            User = user.Name;
            if (!UserExists(user))
            {
                SQLiteAddUser.Parameters["@Name"].Value = user.Name;
                SQLiteAddUser.ExecuteNonQuery();
            }
        }
    }
}


text:
package com.expanset.common;

import javax.annotation.Nonnull;

/**
 * Holds other objects.
 */
public interface Wrapper {

	/**
	 * Returns other object with the required type.
	 * @param iface Type of holding object.
	 * @param <T> Type of holding object.
	 * @return Other object with the required type.
	 * @throws Exception Unwrap error.
	 */
	default <T> T unwrap(@Nonnull Class<T> iface)
			throws Exception {
		return null;
	}

	/**
	 * Check unwrap support of desired object.
	 * @param iface Type of holding object.
	 * @return true - object type is supported.
	 */
	default boolean isWrapperFor(@Nonnull Class<?> iface) {
		return false;
	}
}


text:
package me.seeber.gradle.project.groovy;

import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ExternalDependency;
import org.gradle.api.artifacts.PublishArtifact;
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.plugins.GroovyPlugin;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.tasks.javadoc.Groovydoc;
import org.gradle.model.Model;
import org.gradle.model.Mutate;
import org.gradle.model.Path;
import org.gradle.model.RuleSource;

import com.google.common.collect.ImmutableMap;

import me.seeber.gradle.plugin.AbstractProjectConfigPlugin;
import me.seeber.gradle.plugin.Projects;
import me.seeber.gradle.project.java.JavaConfigPlugin;
import me.seeber.gradle.util.Validate;

/**
 * Groovy project configuration
 */
public class GroovyConfigPlugin extends AbstractProjectConfigPlugin {

    /**
     * Plugin rules
     */
    public static class PluginRules extends RuleSource {

        /**
         * Provide the Groovy configuration
         *
         * @param groovyConfig Groovy configuration
         */
        @Model
        public void groovyConfig(GroovyConfig groovyConfig) {
        }

        /**
         * Create task to create the GroovyDoc jar
         *
         * @param task Tasl to configure
         * @param groovydocTask Groovydoc task
         */
        @Mutate
        public void configureGroovydocJarTask(@Path("tasks.groovydocJar") Jar task,
                @Path("tasks.groovydoc") Groovydoc groovydocTask) {
            task.setDescription("Assembles a jar archive containing the groovydoc documentation.");
            task.setGroup("build");
            task.setClassifier("groovydoc");
            task.from(groovydocTask);
        }
    }

    /**
     * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize()
     */
    @Override
    protected void initialize() {
        getProject().getPluginManager().apply(GroovyPlugin.class);
        getProject().getPluginManager().apply(JavaConfigPlugin.class);

        DependencyHandler dependencies = getProject().getDependencies();
        ExternalDependency spock = (ExternalDependency) dependencies.add("testCompile",
                ImmutableMap.of("group", "org.spockframework", "name", "spock-core", "version", "1.0-groovy-2.4"));
        spock.exclude(ImmutableMap.of("group", "org.codehaus.groovy", "module", "groovy-all"));

        String name = Validate.notNull(getProject().getName());
        Configuration archives = getProject().getConfigurations().getByName("archives");

        Jar groovydocJar = getProject().getTasks().create("groovydocJar", Jar.class);
        PublishArtifact groovydocArtifact = Projects.createJarPublishArtifact(getProject(), name, "groovydoc", "jar",
                "jar", groovydocJar);
        archives.getArtifacts().add(groovydocArtifact);
    }
}


text:
import github.GithubObject

import github.NamedUser

class CommitStatus(github.GithubObject.NonCompletableGithubObject):
    """
    This class represents CommitStatuss as returned for example by https://developer.github.com/v3/repos/statuses/
    """

    @property
    def created_at(self):
        """
        :type: datetime.datetime
        """
        return self._created_at.value

    @property
    def creator(self):
        """
        :type: :class:`github.NamedUser.NamedUser`
        """
        return self._creator.value

    @property
    def description(self):
        """
        :type: string
        """
        return self._description.value

    @property
    def id(self):
        """
        :type: integer
        """
        return self._id.value

    @property
    def state(self):
        """
        :type: string
        """
        return self._state.value

    @property
    def target_url(self):
        """
        :type: string
        """
        return self._target_url.value

    @property
    def updated_at(self):
        """
        :type: datetime.datetime
        """
        return self._updated_at.value

    @property
    def url(self):
        """
        :type: string
        """
        return self._url.value

    def _initAttributes(self):
        self._created_at = github.GithubObject.NotSet
        self._creator = github.GithubObject.NotSet
        self._description = github.GithubObject.NotSet
        self._id = github.GithubObject.NotSet
        self._state = github.GithubObject.NotSet
        self._target_url = github.GithubObject.NotSet
        self._updated_at = github.GithubObject.NotSet
        self._url = github.GithubObject.NotSet

    def _useAttributes(self, attributes):
        if "created_at" in attributes:  # pragma no branch
            self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
        if "creator" in attributes:  # pragma no branch
            self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"])
        if "description" in attributes:  # pragma no branch
            self._description = self._makeStringAttribute(attributes["description"])
        if "id" in attributes:  # pragma no branch
            self._id = self._makeIntAttribute(attributes["id"])
        if "state" in attributes:  # pragma no branch
            self._state = self._makeStringAttribute(attributes["state"])
        if "target_url" in attributes:  # pragma no branch
            self._target_url = self._makeStringAttribute(attributes["target_url"])
        if "updated_at" in attributes:  # pragma no branch
            self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
        if "url" in attributes:  # pragma no branch
            self._url = self._makeStringAttribute(attributes["url"])


text:
using UnityEngine;
using System.Collections;

public class Cam_controller : MonoBehaviour {

    Transform target, player;
    Vector3 to;

    // Use this for initialization
    void Start()
    {

        player = GameObject.Find("nerd").transform;

    }

    // Update is called once per frame
    void Update()
    {

        if(Input.GetKeyDown("t"))
        {
            this.transform.Translate(new Vector3(0, 0, 20));

            this.transform.Rotate(new Vector3(0, 180, 0));

        }

    }
}