text:
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/common_blue</item>
        <item name="colorPrimaryDark">@color/common_blue</item>
        <item name="colorAccent">@color/common_blue</item>
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="subtitleTextStyle">@style/Toolbar.Subtitle</item>
    </style>

    <style name="Toolbar.Subtitle" parent="Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle">
        <item name="android:textColor">@android:color/white</item>
    </style>

    <style name="AVActivity" parent="AppTheme" />

    <style name="AVActivity.FullScreen">
        <item name="android:windowFullscreen">true</item>
    </style>

    <style name="BigFont">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">70dp</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_marginBottom">14dp</item>
    </style>

    <style name="SmallFont">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">16dp</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">wrap_content</item>
    </style>

    <style name="AVTheme" parent="Theme.AppCompat.Light" />

    <style name="DividerLine">
        <item name="android:background">@color/divider_line_color</item>
    </style>

    <style name="DividerLine.Horizontal">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">@dimen/divider_line_height</item>
    </style>

    <style name="DividerLine.Vertical">
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_width">@dimen/divider_line_height</item>
    </style>

    <style name="EditText"></style>

    <style name="EditText.UserName">
        <item name="android:singleLine">true</item>
        <item name="android:maxLength">30</item>
    </style>

    <style name="EditText.Password">
        <item name="android:singleLine">true</item>
        <item name="android:inputType">textPassword</item>
    </style>

    <style name="Button"></style>

    <style name="Button.Normal" />

    <style name="Button.Larger"></style>

    <style name="TextAppearance" />

    <style name="TextAppearance.Large">
        <item name="android:textSize">@dimen/textsize_large</item>
    </style>

    <style name="TextAppearance.Large.Gray">
        <item name="android:textColor">@color/common_gray</item>
    </style>

    <style name="TextAppearance.Normal">
        <item name="android:textSize">@dimen/textsize_normal</item>
    </style>

    <style name="TextAppearance.Normal.Bold">
        <item name="android:textStyle">bold</item>
    </style>

    <style name="TextAppearance.Normal.Gray">
        <item name="android:textColor">@color/common_gray</item>
    </style>

    <style name="TextAppearance.small"></style>
</resources>


text:
import agents as ag

def HW2Agent() -> object:

    def program(percept):
        bump, status = percept
        if status == 'Dirty':
            action = 'Suck'
        else:
            lastBump, lastStatus,  = program.oldPercepts[-1]
            if bump == 'None':
                if program.bumpcount == 0:
                    action = 'Right'
                elif program.bumpcount == 1:
                    action = 'Left'
                elif program.bumpcount == 2:
                    action = 'Down'
                else:
                    action = 'Up'
            else:
                if bump == 'Bump' and program.oldActions[-1] == 'Right':
                    program.bumpcount += 1
                    action = 'Up'
                elif bump == 'Bump' and program.oldActions[-1] == 'Up':
                    program.bumpcount = 2
                    action = 'Down'
                elif bump == 'Bump' and program.oldActions[-1] == 'Left':
                    program.bumpcount -= 1
                    action = 'Up'
                else:
                    program.bumpcount -= 1
                    action = 'Left'

        program.oldPercepts.append(percept)
        program.oldActions.append(action)
        return action

    # assign static variables here
    program.bumpcount = 0
    program.oldPercepts = [('None', 'Clean')]
    program.oldActions = ['NoOp']

    agt = ag.Agent(program)
    # assign class attributes here:

    return agt

redpajama_set_name: RedPajamaGithub


text:
/* Lists that are open on the sides
/* ------------------------------------------------- */
.gh-stack {
    display: flex;
    flex-direction: column;
}

.gh-stack-item {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.gh-stack-item .gh-setting-content {
    margin-right: 24px;
}


text:
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
 *     Copyright 2010 Couchbase, Inc
 *
 *   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.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#include "btree.h"
#include "btree_fast_str_kv.h"

#include "memleak.h"

typedef uint16_t key_len_t;

/*
=== node->data structure overview ===

[offset of key 1]: sizeof(key_len_t) bytes
[offset of key 2]: ...
...
[offset of key n]: ...
[offset of key n+1]: points to the byte offset right after the end of n-th entry
[key 1][value 1]
[key 2][value 2]
...
[key n][value n]

Note that the maximum node size is limited to 2^(8*sizeof(key_len_t)) bytes
*/

static void _get_fast_str_kv(struct bnode *node, idx_t idx, void *key, void *value)
{
    int ksize, vsize, i;
    void *key_ptr, *ptr;
    key_len_t *_offset_arr;
    key_len_t keylen, _keylen;
    key_len_t offset;

    _get_kvsize(node->kvsize, ksize, vsize);
    ksize = sizeof(void *);

    ptr = node->data;
    offset = 0;

    // get offset array
    _offset_arr = (key_len_t*)ptr;

    // get keylen & offset
    offset = _endian_decode(_offset_arr[idx]);
    keylen = _endian_decode(_offset_arr[idx+1]) - offset - vsize;

    // if KEY already points to previous key, then free it
    memcpy(&key_ptr, key, ksize);
    if (key_ptr) {
        free(key_ptr);
    }

    // allocate space for key
    key_ptr = (void*)malloc(sizeof(key_len_t) + keylen);

    // copy key
    _keylen = _endian_encode(keylen);
    memcpy(key_ptr, &_keylen, sizeof(key_len_t));
    memcpy((uint8_t*)key_ptr + sizeof(key_len_t),
           (uint8_t*)ptr + offset, keylen);
    // copy key pointer
    memcpy(key, &key_ptr, ksize);
    // copy value
    if (value) {
        memcpy(value, (uint8_t*)ptr + offset + keylen, vsize);
    }
}

static void _set_fast_str_kv(struct bnode *node, idx_t idx, void *key, void *value)
{
    int ksize, vsize, i;
    void *key_ptr, *ptr;
    key_len_t *_offset_arr, offset;
    key_len_t keylen, keylen_ins, keylen_idx;
    key_len_t _keylen, _keylen_ins;
    key_len_t offset_idx, offset_next, next_len;

    _get_kvsize(node->kvsize, ksize, vsize);
    ksize = sizeof(void *);

    ptr = node->data;

    // get offset array
    _offset_arr = (key_len_t*)ptr;

    // copy key info from KEY
    memcpy(&key_ptr, key, ksize);
    memcpy(&_keylen_ins, key_ptr, sizeof(key_len_t));
    keylen_ins = _endian_decode(_keylen_ins);

    // get (previous) keylen & offset
    if (idx < node->nentry) {
        // overwriting the existing entry
        offset_idx = _endian_decode(_offset_arr[idx]);
        offset_next = _endian_decode(_offset_arr[idx+1]);
        keylen_idx = offset_next - offset_idx - vsize;

        if (keylen_ins != keylen_idx) {
            // if key length is not same
            if (idx+1 < node->nentry) {
                // 'idx' is not the last entry
                // shift idx+1 ~ nentry-1 KVs to right
                next_len = _endian_decode(_offset_arr[node->nentry]) - offset_next;

                // move
                memmove((uint8_t*)ptr + offset_next + (keylen_ins - keylen_idx),
                        (uint8_t*)ptr + offset_next, next_len);
            }

            // update offset array
            for (i=idx+1; i<=node->nentry; ++i){
                offset = _endian_decode(_offset_arr[i]);
                offset = offset + keylen_ins - keylen_idx;
                _offset_arr[i] = _endian_encode(offset);
            }
        }
    } else {
        // append at the end (new entry)
        if (node->nentry > 0) {
            // shift KV pairs to right by sizeof(key_len_t) bytes
            // for making a room in offset array
            offset = _endian_decode(_offset_arr[0]);
            next_len = _endian_decode(_offset_arr[node->nentry]) - offset;
            memmove((uint8_t*)ptr + offset + sizeof(key_len_t),
                    (uint8_t*)ptr + offset, next_len);

            // update offset array
            for (i=0;i<=node->nentry;++i){
                offset = _endian_decode(_offset_arr[i]);
                offset = offset + sizeof(key_len_t);
                _offset_arr[i] = _endian_encode(offset);
            }
            offset_idx = _endian_decode(_offset_arr[idx]);
        } else {
            // this means that idx == 0, and
            // there are two (idx, idx+1) entries in offset array
            offset_idx = sizeof(key_len_t) * 2;
            _offset_arr[0] = _endian_encode(offset_idx);
        }
        offset = _endian_decode(_offset_arr[idx]);
        offset = offset + keylen_ins + vsize;
        _offset_arr[idx+1] = _endian_encode(offset);
    }
    // copy key into the node
    memcpy((uint8_t*)ptr + offset_idx, (uint8_t*)key_ptr + sizeof(key_len_t), keylen_ins);
    // copy value
    memcpy((uint8_t*)ptr + offset_idx + keylen_ins, value, vsize);
}

static void _ins_fast_str_kv(struct bnode *node, idx_t idx, void *key, void *value)
{
    int ksize, vsize, i;
    void *key_ptr, *ptr;
    key_len_t *_offset_arr;
    key_len_t keylen, keylen_ins;
    key_len_t _keylen, _keylen_ins;
    key_len_t offset, offset_begin, offset_idx, offset_next, next_len;

    _get_kvsize(node->kvsize, ksize, vsize);
    ksize = sizeof(void *);

    ptr = node->data;

    // get offset array
    _offset_arr = (key_len_t*)ptr;

    // get (previous) keylen & offset
    offset_begin = _endian_decode(_offset_arr[0]);
    offset_idx = _endian_decode(_offset_arr[idx]);
    offset_next = _endian_decode(_offset_arr[idx+1]);

    if (key && value) {
        // insert

        // copy key info from KEY to KEY_PTR
        memcpy(&key_ptr, key, ksize);
        memcpy(&_keylen_ins, key_ptr, sizeof(key_len_t));
        keylen_ins = _endian_decode(_keylen_ins);

        // move idx ~ nentry-1 KVs to right by (keylen + vsize + sizeof(key_len_t))
        next_len = _endian_decode(_offset_arr[node->nentry]) - offset_idx;
        memmove((uint8_t*)ptr + offset_idx + keylen_ins + vsize + sizeof(key_len_t),
                (uint8_t*)ptr + offset_idx, next_len);

        // move 0 ~ idx to right by sizeof(key_len_t)
        next_len = _endian_decode(_offset_arr[idx]) - offset_begin;
        memmove((uint8_t*)ptr + offset_begin + sizeof(key_len_t),
                (uint8_t*)ptr + offset_begin, next_len);
        offset_idx += sizeof(key_len_t);

        // also move offset array
        memmove(_offset_arr + (idx+1), _offset_arr + idx,
                sizeof(key_len_t) * (node->nentry - idx + 1));

        // copy key into the node
        memcpy((uint8_t*)ptr + offset_idx, (uint8_t*)key_ptr + sizeof(key_len_t), keylen_ins);
        // copy value
        memcpy((uint8_t*)ptr + offset_idx + keylen_ins, value, vsize);

        // update offset array
        for (i=0;i<=node->nentry+1;++i){
            offset = _endian_decode(_offset_arr[i]);
            if (i <= idx) {
                offset = offset + sizeof(key_len_t);
            } else {
                offset = offset + sizeof(key_len_t) + keylen_ins + vsize;
            }
            _offset_arr[i] = _endian_encode(offset);
        }
    }else{
        // we have to move idx+1 ~ nentry KVs to appropriate position
        key_len_t len_left, len_right;

        // get the length of the key to be removed
        keylen_ins = offset_next - offset_idx - vsize;
        len_left = _endian_decode(_offset_arr[idx]) - offset_begin;
        len_right = _endian_decode(_offset_arr[node->nentry]) - offset_next;

        // shift offset array first
        memmove(_offset_arr + idx, _offset_arr + (idx+1),
                sizeof(key_len_t) * (node->nentry - (idx+1) + 1));

        // move 0 ~ idx to left by sizeof(key_len_t)
        memmove((uint8_t*)ptr + offset_begin - sizeof(key_len_t),
                (uint8_t*)ptr + offset_begin, len_left);

        // move idx+1 ~ nentry-1
        memmove((uint8_t*)ptr + offset_idx - sizeof(key_len_t),
                (uint8_t*)ptr + offset_next, len_right);

        // update offset array
        for (i=0;i<node->nentry;++i){
            offset = _endian_decode(_offset_arr[i]);
            if (i < idx) {
                offset = offset - sizeof(key_len_t);
            } else {
                offset = offset - (sizeof(key_len_t) + keylen_ins + vsize);
            }
            _offset_arr[i] = _endian_encode(offset);
        }
    }
}

static void _copy_fast_str_kv(struct bnode *node_dst,
                         struct bnode *node_src,
                         idx_t dst_idx,
                         idx_t src_idx,
                         idx_t len)
{
    int i;
    int ksize, vsize;
    void *ptr_src, *ptr_dst, *ptr_swap;
    void *key_ptr;
    key_len_t *_src_offset_arr, *_dst_offset_arr;
    key_len_t keylen, _keylen;
    key_len_t offset, src_offset, src_len, dst_offset;

    // not support when dst_idx != 0
    assert(dst_idx == 0);

    _get_kvsize(node_src->kvsize, ksize, vsize);
    ksize = sizeof(void *);

    ptr_src = node_src->data;
    ptr_dst = node_dst->data;

    // get offset array
    _src_offset_arr = (key_len_t*)ptr_src;
    _dst_offset_arr = (key_len_t*)ptr_dst;

    // calculate offset of src_idx
    src_offset = _endian_decode(_src_offset_arr[src_idx]);

    // calculate offset of dst_idx
    dst_offset = 0 + sizeof(key_len_t)*(len+1);

    // calculate data length to be copied
    src_len = _endian_decode(_src_offset_arr[src_idx+len]) - src_offset;

    if (node_dst == node_src) {
        // to avoid corruption due to memcpy from/to same region
        ptr_swap = ptr_dst;
        ptr_dst = (void *)malloc(dst_offset + src_len);
        _dst_offset_arr = (key_len_t*)ptr_dst;
    }

    // copy
    memcpy((uint8_t*)ptr_dst + dst_offset,
           (uint8_t*)ptr_src + src_offset, src_len);

    // update offset array
    for (i=0;i<=len;++i){
        offset = _endian_decode(_src_offset_arr[src_idx + i]);
        offset = offset + dst_offset - src_offset;
        _dst_offset_arr[dst_idx + i] = _endian_encode(offset);
    }

    if (node_dst == node_src) {
        // copy to the original node and free
        memcpy(ptr_swap, ptr_dst, dst_offset + src_len);
        free(ptr_dst);
    }
}

static size_t _get_fast_str_kv_size(struct btree *tree, void *key, void *value)
{
    void *key_ptr;
    key_len_t keylen, _keylen;

    if (key) {
        memcpy(&key_ptr, key, sizeof(void *));
        memcpy(&_keylen, key_ptr, sizeof(key_len_t));
        keylen = _endian_decode(_keylen);
    }

    return ((key)?(sizeof(key_len_t) + keylen):0) + ((value)?tree->vsize:0);
}

static size_t _get_fast_str_data_size(
    struct bnode *node, void *new_minkey, void *key_arr, void *value_arr, size_t len)
{
    int ksize, vsize, i;
    void *ptr, *key_ptr;
    size_t size;
    key_len_t *_offset_arr;
    key_len_t keylen, _keylen;

    _get_kvsize(node->kvsize, ksize, vsize);
    ksize = sizeof(void *);

    ptr = node->data;
    size = 0;

    if (node->nentry == 0) return 0;

    // get offset array
    _offset_arr = (key_len_t*)ptr;

    // get size from the last offset
    size = _endian_decode(_offset_arr[node->nentry]);

    // if new_minkey exists
    if (new_minkey) {
        // subtract the length of the smallest key-value pair
        size -= _endian_decode(_offset_arr[1]) - _endian_decode(_offset_arr[0]);
        // get the length of 'new_minkey'
        memcpy(&key_ptr, new_minkey, ksize);
        memcpy(&_keylen, key_ptr, sizeof(key_len_t));
        keylen = _endian_decode(_keylen);
        size += keylen + vsize;
    }

    if (key_arr && value_arr && len > 0) {
        // there are KV pairs to be inserted
        for (i=0;i<len;++i){
            memcpy(&key_ptr, (uint8_t*)key_arr + ksize*i, ksize);
            memcpy(&_keylen, key_ptr, sizeof(key_len_t));
            keylen = _endian_decode(_keylen);
            size += sizeof(key_len_t) + keylen + vsize;
        }
    }

    return size;
}

INLINE void _init_fast_str_kv_var(struct btree *tree, void *key, void *value)
{
    if (key) memset(key, 0, sizeof(void *));
    if (value) memset(value, 0, tree->vsize);
}

static void _free_fast_str_kv_var(struct btree *tree, void *key, void *value)
{
    void *key_ptr;

    memcpy(&key_ptr, key, sizeof(void *));
    if (key_ptr) {
        free(key_ptr);
        key_ptr = NULL;
        memcpy(key, &key_ptr, sizeof(void *));
    }
}

static void _set_fast_str_key(struct btree *tree, void *dst, void *src)
{
    void *key_ptr_old, *key_ptr_new;
    key_len_t keylen_new, _keylen_new;

    memcpy(&key_ptr_new, src, sizeof(void *));
    memcpy(&_keylen_new, key_ptr_new, sizeof(key_len_t));
    keylen_new = _endian_decode(_keylen_new);

    // free previous key (if exist)
    memcpy(&key_ptr_old, dst, sizeof(void *));
    if (key_ptr_old) {
        free(key_ptr_old);
    }
    key_ptr_old = (void*)malloc(sizeof(key_len_t) + keylen_new);
    memcpy(key_ptr_old, key_ptr_new, sizeof(key_len_t) + keylen_new);
    memcpy(dst, &key_ptr_old, sizeof(void *));
}

INLINE void _set_fast_str_value(struct btree *tree, void *dst, void *src)
{
    memcpy(dst, src, tree->vsize);
}

INLINE void _get_fast_str_nth_idx(struct bnode *node, idx_t num, idx_t den, idx_t *idx)
{
    size_t rem = node->nentry - (int)(node->nentry / den) * den;
    *idx = (int)(node->nentry / den) * num + ((num < rem)?(num):(rem));
}

INLINE void _get_fast_str_nth_splitter(struct bnode *prev_node, struct bnode *node, void *key)
{
    // always return the smallest key of 'node'
    _get_fast_str_kv(node, 0, key, NULL);
}

void btree_fast_str_kv_set_key(void *key, void *str, size_t len)
{
    void *key_ptr;
    key_len_t keylen = len;
    key_len_t _keylen;

    key_ptr = (void *)malloc(sizeof(key_len_t) + keylen);
    _keylen = _endian_encode(keylen);
    memcpy(key_ptr, &_keylen, sizeof(key_len_t));
    memcpy((uint8_t*)key_ptr + sizeof(key_len_t), str, keylen);
    memcpy(key, &key_ptr, sizeof(void *));
}

void btree_fast_str_kv_get_key(void *key, void *strbuf, size_t *len)
{
    void *key_ptr;
    key_len_t keylen;
    key_len_t _keylen;

    memcpy(&key_ptr, key, sizeof(void *));
    if (key_ptr) {
        memcpy(&_keylen, key_ptr, sizeof(key_len_t));
        keylen = _endian_decode(_keylen);
        memcpy(strbuf, (uint8_t*)key_ptr + sizeof(key_len_t), keylen);
        *len = keylen;
    } else {
        *len = 0;
    }
}

void btree_fast_str_kv_free_key(void *key)
{
    void *key_ptr;
    memcpy(&key_ptr, key, sizeof(void *));
    if (key_ptr) free(key_ptr);
    key_ptr = NULL;
    memcpy(key, &key_ptr, sizeof(void *));
}

INLINE bid_t _fast_str_value_to_bid_64(void *value)
{
    return *((bid_t *)value);
}

INLINE void* _fast_str_bid_to_value_64(bid_t *bid)
{
    return (void *)bid;
}

int _cmp_fast_str64(void *key1, void *key2, void* aux)
{
    (void) aux;
    void *key_ptr1, *key_ptr2;
    key_len_t keylen1, keylen2;
    key_len_t _keylen1, _keylen2;

    memcpy(&key_ptr1, key1, sizeof(void *));
    memcpy(&key_ptr2, key2, sizeof(void *));

    if (key_ptr1 == NULL && key_ptr2 == NULL) {
        return 0;
    } else if (key_ptr1 == NULL) {
        return -1;
    } else if (key_ptr2 == NULL) {
        return 1;
    }

    memcpy(&_keylen1, key_ptr1, sizeof(key_len_t));
    memcpy(&_keylen2, key_ptr2, sizeof(key_len_t));
    keylen1 = _endian_decode(_keylen1);
    keylen2 = _endian_decode(_keylen2);

    if (keylen1 == keylen2) {
        return memcmp((uint8_t*)key_ptr1 + sizeof(key_len_t),
                      (uint8_t*)key_ptr2 + sizeof(key_len_t), keylen1);
    }else{
        key_len_t len = MIN(keylen1, keylen2);
        int cmp = memcmp((uint8_t*)key_ptr1 + sizeof(key_len_t),
                         (uint8_t*)key_ptr2 + sizeof(key_len_t), len);
        if (cmp != 0) return cmp;
        else {
            return (int)((int)keylen1 - (int)keylen2);
        }
    }
}

struct btree_kv_ops * btree_fast_str_kv_get_kb64_vb64(struct btree_kv_ops *kv_ops)
{
    struct btree_kv_ops *btree_kv_ops;
    if (kv_ops) {
        btree_kv_ops = kv_ops;
    }else{
        btree_kv_ops = (struct btree_kv_ops *)malloc(sizeof(struct btree_kv_ops));
    }

    btree_kv_ops->get_kv = _get_fast_str_kv;
    btree_kv_ops->set_kv = _set_fast_str_kv;
    btree_kv_ops->ins_kv = _ins_fast_str_kv;
    btree_kv_ops->copy_kv = _copy_fast_str_kv;
    btree_kv_ops->set_key = _set_fast_str_key;
    btree_kv_ops->set_value = _set_fast_str_value;
    btree_kv_ops->get_data_size = _get_fast_str_data_size;
    btree_kv_ops->get_kv_size = _get_fast_str_kv_size;
    btree_kv_ops->init_kv_var = _init_fast_str_kv_var;
    btree_kv_ops->free_kv_var = _free_fast_str_kv_var;

    btree_kv_ops->get_nth_idx = _get_fast_str_nth_idx;
    btree_kv_ops->get_nth_splitter = _get_fast_str_nth_splitter;

    btree_kv_ops->cmp = _cmp_fast_str64;

    btree_kv_ops->bid2value = _fast_str_bid_to_value_64;
    btree_kv_ops->value2bid = _fast_str_value_to_bid_64;

    return btree_kv_ops;
}


text:
package com.simonenfp.me.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.simonenfp.me.adapter.viewHolder.CommonViewHolder;

import java.util.List;

/**
 * Created by simonenfp on 2016/7/29.
 */
public abstract class CommonAdapter<T> extends RecyclerView.Adapter<CommonViewHolder> {

    protected Context mContext;
    protected int mLayoutId;
    protected List<T> mDatas;
    protected LayoutInflater mInflater;

    public CommonAdapter(Context context, int layoutId, List<T> datas)
    {
        mContext = context;
        mInflater = LayoutInflater.from(context);
        mLayoutId = layoutId;
        mDatas = datas;
    }

    @Override
    public CommonViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return CommonViewHolder.get(mContext,parent,mLayoutId);
    }

    @Override
    public void onBindViewHolder(CommonViewHolder holder, int position) {
        convert(holder, mDatas.get(position));
    }
    public abstract void convert(CommonViewHolder holder,T t);

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

}


text:
namespace blink {

// static
WorkerNavigatorGPU& WorkerNavigatorGPU::From(WorkerNavigator& navigator) {
  WorkerNavigatorGPU* supplement =
      Supplement<WorkerNavigator>::From<WorkerNavigatorGPU>(navigator);
  if (!supplement) {
    supplement = MakeGarbageCollected<WorkerNavigatorGPU>(navigator);
    ProvideTo(navigator, supplement);
  }
  return *supplement;
}

// static
GPU* WorkerNavigatorGPU::gpu(ScriptState* script_state,
                             WorkerNavigator& navigator) {
  return WorkerNavigatorGPU::From(navigator).gpu(script_state);
}

GPU* WorkerNavigatorGPU::gpu(ScriptState* script_state) {
  if (!gpu_) {
    ExecutionContext* context = ExecutionContext::From(script_state);
    DCHECK(context);

    gpu_ = GPU::Create(*context);
  }
  return gpu_;
}

void WorkerNavigatorGPU::Trace(Visitor* visitor) {
  visitor->Trace(gpu_);
  Supplement<WorkerNavigator>::Trace(visitor);
}

WorkerNavigatorGPU::WorkerNavigatorGPU(WorkerNavigator& navigator)
    : Supplement<WorkerNavigator>(navigator) {}

const char WorkerNavigatorGPU::kSupplementName[] = "WorkerNavigatorGPU";

}  // namespace blink


text:
CREATE TABLE IF NOT EXISTS photo.rating (
    photo_id INTEGER NOT NULL,
    user_id SMALLINT NOT NULL,
    score SMALLINT NOT NULL,
    CONSTRAINT pk_photo_rating PRIMARY KEY (photo_id, user_id),
    CONSTRAINT fk_photo_rating_photo FOREIGN KEY (photo_id) REFERENCES photo.photo(id),
    CONSTRAINT fk_photo_rating_user FOREIGN KEY (user_id) REFERENCES maw.user(id)
);

DO
$$
BEGIN
    IF NOT EXISTS (SELECT 1
                     FROM pg_catalog.pg_indexes
                    WHERE schemaname = 'photo'
                      AND tablename = 'rating'
                      AND indexname = 'ix_photo_rating_photo_id') THEN

        CREATE INDEX ix_photo_rating_photo_id
            ON photo.rating(photo_id);

    END IF;
END
$$;

DO
$$
BEGIN
    IF NOT EXISTS (SELECT 1
                     FROM pg_catalog.pg_indexes
                    WHERE schemaname = 'photo'
                      AND tablename = 'rating'
                      AND indexname = 'ix_photo_rating_user_id') THEN

        CREATE INDEX ix_photo_rating_user_id
            ON photo.rating(user_id);

    END IF;
END
$$;

GRANT SELECT, INSERT, UPDATE, DELETE
   ON photo.rating
   TO website;


text:
<!DOCTYPE html>

<title>cgoppy's tech blog</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="your-stylesheet-link-here.css">

Tech Blog Challenge

March 22, 2015

What are the benefits of version control?

The benefits of version control are to minimize mistakes. You can create multiple versions over time and go back and forth between revisions.

How does git help you keep track of changes?
Git has a log showing versions of changes made to the file.

Why use GitHub to store your code?
Github is accessible to everyone and multiple people can view and edit your code.


text:
#pragma once

#ifndef _LIB_ALMATH_ALMATH_DSP_DIGITALFILTER_H_
#define _LIB_ALMATH_ALMATH_DSP_DIGITALFILTER_H_

#include <vector>
#include <almath/api.h>
#include <boost/version.hpp>
#if (BOOST_VERSION < 106200) && !defined(BOOST_CB_DISABLE_DEBUG)
# define BOOST_CB_DISABLE_DEBUG
#endif
#include <boost/circular_buffer.hpp>

namespace AL
{
namespace Math
{
namespace DSP
{

class ALMATH_API DigitalFilter
{
public:
  DigitalFilter(void);
  ~DigitalFilter(void);

  /*! \fn AL::Math::DSP::DigitalFilter::configureFilter(
                                 const std::vector<float> & weightsIn,
                                 const std::vector<float> & weightsOut,
                                 const float dcGain)
    \brief Configure the digital filter
    \param weightsIn A vector of float describing weights applied on input vector
    \param weightsOut A vector of float describing weights applied on output vector
    \param dcGain Static gain of the filter
  */
  void configureFilter(const std::vector<float> & pWeightsIn,
                       const std::vector<float> & pWeightsOut,
                       float pDcGain);

  /*! \fn void AL::Math::DSP::DigitalFilter::resetFilter()
    \brief Reset the processing of the filter
  */
  void resetFilter();

  /*! \fn float AL::Math::DSP::DigitalFilter::processFilter(const float inputData)
    \brief Process a step of the filter
    \param in Signal input
  */
  float processFilter(float pInputData);

private:
  boost::circular_buffer<float> fFilterBufferIn;
  boost::circular_buffer<float> fFilterBufferOut;

  float fFilterDcGain;

  std::vector<float> fFilterWeightsIn;
  std::vector<float> fFilterWeightsOut;
};
}
}
}

#endif  // _LIB_ALMATH_ALMATH_DSP_DIGITALFILTER_H_


text:
#region License, Terms and Conditions
//
// ChargifyApiBase.cs
//
// Authors: Kori Francis <twitter.com/djbyter>, David Ball
// Copyright (C) 2010 Clinical Support Systems, Inc. All rights reserved.
//
//  THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
//
//  Permission is hereby granted, free of charge, to any person obtaining a
//  copy of this software and associated documentation files (the "Software"),
//  to deal in the Software without restriction, including without limitation
//  the rights to use, copy, modify, merge, publish, distribute, sublicense,
//  and/or sell copies of the Software, and to permit persons to whom the
//  Software is furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
//  DEALINGS IN THE SOFTWARE.
//
#endregion

namespace Chargify
{
    #region Imports
    using System;
    using System.Collections.Generic;
    using System.Threading.Tasks;
    using RestSharp;
    #endregion

    public class BaseService<TObject> where TObject : class
    {
        #region Properties and Accessors
        protected string ApiKey { get; private set; }
        protected string ApiPassword { get; private set; }
        protected string SharedKey { get; private set; }
        protected string Subdomain { get; private set; }
        protected bool UseJSON { get; private set; }
        private static string _userAgent;
        private static string UserAgent
        {
            get
            {
                if (_userAgent == null)
                {
                    _userAgent = string.Format(format: "Chargify .NET RestSharp Client v{0}", arg0: System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                }
                return _userAgent;
            }
        }

        private RestClient _client;
        #endregion

        #region Constructors
        public BaseService()
        {
        }

        public BaseService(string apiKey, string apiPassword)
        {
            if (string.IsNullOrEmpty(apiKey))
                throw new ArgumentException(message: "Api key is required. Details can be found at http://docs.chargify.com/api-authentication", paramName: nameof(apiKey));

            ApiKey = apiKey;
            ApiPassword = apiPassword;
            UseJSON = false;

            _client = new RestClient();
            _client.Authenticator = new HttpBasicAuthenticator(ApiKey, ApiPassword);
            _client.UserAgent = UserAgent;
            _client.BaseUrl = new Uri(Config.ApiBaseUrl);
        }

        public BaseService(string apiKey, string apiPassword, bool useJson)
            : this(apiKey, apiPassword)
        {
            UseJSON = useJson;
        }

        public BaseService(RestClient client)
        {
            _client = client;
        }
        #endregion

        #region Sync
        internal TObject GetRequest<TObject>(string path, params object[] args) where TObject : new()
        {
            return GetRequest<TObject>(path, string.Empty, args);
        }

        internal TObject GetRequest<TObject>(string path, string rootElement, params object[] args) where TObject : new()
        {
            RestRequest request = new RestRequest(BuildUrl(path, args));
            if (!string.IsNullOrWhiteSpace(rootElement)) request.RootElement = rootElement;
            SetupRequest(request);

            var response = _client.Execute<TObject>(request);

            if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                throw new ChargifyException(message: "Not Found");
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
            {
                throw new ChargifyException(message: "Internal Server Error");
            }

            return response.Data;
        }

        internal TObject PutRequest<TObject, TInput>(TInput obj, string path, params object[] args) where TObject : new()
        {
            return Request<TObject, TInput>(Method.PUT, obj, path, args);
        }

        internal TObject PostRequest<TObject, TInput>(TInput obj, string path, params object[] args) where TObject : new()
        {
            return Request<TObject, TInput>(Method.POST, obj, path, args);
        }

        internal void DeleteRequest(string path, params object[] args)
        {
            Request<List<object>, object>(method: Method.DELETE, obj: null, path: path, args: args);
        }

        private TObject Request<TObject, TInput>(Method method, TInput obj, string path, params object[] args) where TObject : new()
        {
            RestRequest request = new RestRequest(BuildUrl(path, args), method);
            SetupRequest(request);

            if (obj != null)
            {
                request.AddBody(obj);
            }

            var response = _client.Execute<TObject>(request);

            if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                throw new ChargifyException(message: "Not Found");
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
            {
                throw new ChargifyException(message: "Internal Server Error");
            }

            return response.Data;
        }
        #endregion

        #region Async
        internal async Task<T> GetRequestAsync<T>(string path, params object[] args) where T : new()
        {
            return await GetRequestAsync<T>(path, string.Empty, args).ConfigureAwait(continueOnCapturedContext: false);
        }

        internal Task<TObject> GetRequestAsync<TObject>(string path, string rootElement, params object[] args) where TObject : new()
        {
            RestRequest request = new RestRequest(BuildUrl(path, args));
            if (!string.IsNullOrWhiteSpace(rootElement)) request.RootElement = rootElement;
            SetupRequest(request);

            var tcs = new TaskCompletionSource<TObject>();
            _client.ExecuteAsync<TObject>(request, (response) =>
            {
                if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    tcs.SetException(new ChargifyException(message: "Not Found"));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    tcs.SetException(new ChargifyException(message: "Internal Server Error"));
                }
                else
                {
                    tcs.SetResult(response.Data);
                }
            });

            return tcs.Task;
        }
        internal async Task<TObject> PutRequestAsync<TObject, TInput>(TInput obj, string path, params object[] args) where TObject : new()
        {
            return await RequestAsync<TObject, TInput>(Method.PUT, obj, path, args).ConfigureAwait(continueOnCapturedContext: false);
        }

        internal async Task<TObject> PostRequestAsync<TObject, TInput>(TInput obj, string path, params object[] args) where TObject : new()
        {
            return await RequestAsync<TObject, TInput>(Method.POST, obj, path, args).ConfigureAwait(continueOnCapturedContext: false);
        }

        internal async Task DeleteRequestAsync(string path, params object[] args)
        {
            await RequestAsync<List<object>, object>(method: Method.DELETE, obj: null, path: path, args: args).ConfigureAwait(continueOnCapturedContext: false);
        }

        private Task<TObject> RequestAsync<TObject, TInput>(Method method, TInput obj, string path, params object[] args) where TObject : new()
        {
            RestRequest request = new RestRequest(BuildUrl(path, args), method);
            SetupRequest(request);

            if (obj != null)
            {
                request.AddBody(obj);
            }

            var tcs = new TaskCompletionSource<TObject>();
            _client.ExecuteAsync<TObject>(request, (response) =>
            {
                if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    tcs.SetException(new ChargifyException(message: "Not Found"));
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                {
                    tcs.SetException(new ChargifyException(message: "Internal Server Error"));
                }
                else
                {
                    tcs.SetResult(response.Data);
                }
            });

            return tcs.Task;
        }
        #endregion

        #region Helper Methods
        protected string BuildUrl(string path, params object[] args)
        {
            // Assume for now that no querystring is added
            path = string.Format(path, args);

            if (UseJSON)
            {
                path += ".json";
            }
            else
            {
                path += ".xml";
            }

            return path;
        }

        protected void SetupRequest(RestRequest request)
        {
            if (request.Resource.ToLowerInvariant().Contains(value: ".xml"))
            {
                request.RequestFormat = DataFormat.Xml;
                request.XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer();
            }
            else
            {
                request.RequestFormat = DataFormat.Json;
                request.JsonSerializer = new JsonSerializer();
            }
        }
        #endregion
    }
}


text:
package treedb

import "errors"

var ErrCorruptedData = errors.New("treedb: corrupted data")

type NotFoundError struct {
	Path string
}

func (e *NotFoundError) Error() string {
	return "treedb: path " + e.Path + " not found"
}

type NotTreeError struct {
	Path string
}

func (e *NotTreeError) Error() string {
	return "treedb: path " + e.Path + " is not a tree"
}

type InvalidPathError struct {
	Path string
}

func (e *InvalidPathError) Error() string {
	return "treedb: invalid path: " + e.Path
}


text:
<!DOCTYPE html>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Layang-layang</title>
	<link rel="stylesheet" href="">

Layang-layang

	<form action="<?php echo site_url('layangan/hasil');?>" method="POST">
		diagonal1
		<input type="text" value="" name="d1"/>

		diagonal2
		<input type="text" value="" name="d2"/>

		<select name="hitung">
			<option value="luas">luas</option>
			<option value="keliling">keliling</option>
		</select>

		<input type="submit" value="hitung">
	</form>