text:
DEFINE_int32(reloading_period_seconds, 3600, "Num of seconds between two reloadings of the configs.");

namespace {
typedef recomm_engine::IAlgoPlugin *(*create_plugin_function_t)();

recomm_engine::IAlgoPlugin* GetPluginFromDylib(
    const std::string& dylib_file,
    const std::string& symbol_name,
    const std::string& config) {

  LOG(INFO) << "lib name: " << dylib_file << ", symbol name: " << symbol_name;

  void* so_handle = dlopen(dylib_file.c_str(), RTLD_NOW);
  if (NULL == so_handle) {
    LOG(ERROR) << "Failed dlopen " << dylib_file << ", due to " << dlerror();
    return NULL;
  }
  create_plugin_function_t create_plugin_function;
  create_plugin_function = (create_plugin_function_t)dlsym(so_handle, symbol_name.c_str());
  if (NULL == create_plugin_function || NULL == *create_plugin_function) {
    LOG(ERROR) << "Failed load symbol <" << symbol_name << "> for " << dylib_file << ", due to " << dlerror();
    return NULL;
  }
  recomm_engine::IAlgoPlugin* result = (*create_plugin_function)();
  if (NULL == result) {
    LOG(ERROR) << "Failed creating plugin object using <" << dylib_file << ">, due to " << dlerror();
    return NULL;
  }

  int status = result->Initialize(config.c_str());
  if (0 != status) {
    LOG(ERROR) << "Failed configuring plugin [" << config << "], status is " << status;
    delete result;
    return NULL;
  }

  // XXX(baigang): Do not dlclose, otherwise we will miss all function definitions and encounter segment faults...
  // dlclose(so_handle);
  return result;
}
}  // unnamed namespace

namespace recomm_engine {

AlgoPluginManager* AlgoPluginManager::instance_ = new AlgoPluginManager;

AlgoPluginManager::AlgoPluginManager()
  : current_index_(0) {
}

AlgoPluginManager::~AlgoPluginManager() {

}

// @static
void AlgoPluginManager::PeriodicalReloadingThread(AlgoPluginManager* handle) {
  while (true) {
    boost::this_thread::sleep(boost::posix_time::seconds(FLAGS_reloading_period_seconds));
    LOG_IF(ERROR, !handle->LoadPlugins()) << "Failed reloading plugin configs.";
  }
}

bool AlgoPluginManager::Initialize(const std::string& config_file) {
  config_file_ = config_file;
  if (!LoadPlugins()) {
    LOG(ERROR) << "Initialization failed due to failure to load config file " << config_file;
    return false;
  }
  boost::thread config_reloading_thread(&(AlgoPluginManager::PeriodicalReloadingThread), this);
  return true;
}

bool AlgoPluginManager::LoadPlugins() {
  // use the write buffer
  int index = 1 - current_index_;
  plugins_[index].clear();
  std::ifstream config_file(config_file_.c_str());
  if (!config_file.good()) {
    LOG(ERROR) << "Failed open config file [" << config_file_ << "]";
    return false;
  }
  boost::program_options::options_description desc("bucket configs");
  int default_bucket = 0;
  std::string buckets;
  std::string plugin_path;
  desc.add_options()
    ("num_buckets",    boost::program_options::value<int>(&num_plugins_[index]),
         "Num of traffic buckets.")
    ("default_bucket", boost::program_options::value<int>(&default_bucket)->default_value(0),
         "The default bucket, used when no bucket conf is specified.")
    ("plugin_path",    boost::program_options::value<std::string>(&plugin_path),
         "The path to the plugin libs.")
    ("buckets",        boost::program_options::value<std::string>(&buckets)->multitoken(),
         "A series of bucket specifications.")
  ;
  boost::program_options::variables_map vm;
  boost::program_options::store(boost::program_options::parse_config_file(config_file, desc), vm);
  config_file.close();
  boost::program_options::notify(vm);

  LOG(INFO) << "Buckets specification is: {" << buckets << "}";

  boost::char_separator<char> space_sep(" \t");
  boost::char_separator<char> colon_sep(":");
  boost::tokenizer<boost::char_separator<char> > bucket_items(buckets, space_sep);
  for (boost::tokenizer<boost::char_separator<char> >::iterator it = bucket_items.begin();
       it != bucket_items.end(); ++it) {
    boost::tokenizer<boost::char_separator<char> > fields(*it, colon_sep);
    boost::tokenizer<boost::char_separator<char> >::iterator field = fields.begin();

    // 1. bucket id
    int bucket_id = 0;
    try {
      bucket_id = boost::lexical_cast<int>(*field);
    } catch (boost::bad_lexical_cast &) {
      LOG(ERROR) << "Failed reading bucket_id on \"" << *it << "\"";
      return false;
    }

    // 2. bucket name
    std::string bucket_name = *(++field);

    // 3. bucket plugin
    std::string plugin_name = *(++field);
    std::string plugin_libfile = plugin_path + "/lib" + plugin_name + ".so";
    std::string plugin_config  = plugin_path + "/lib" + plugin_name + ".conf";
    std::string plugin_symbol  = "__create_" + plugin_name;

    LOG(INFO) << "Loading config for bucket [" << bucket_id << "].";

    boost::shared_ptr<IAlgoPlugin> this_plugin(GetPluginFromDylib(
        plugin_libfile, plugin_symbol, plugin_config));

    if (NULL == this_plugin) {
      LOG(ERROR) << "Failed loading plugin [" << bucket_id << "-" << plugin_name << "]";
      return false;
    }

    plugins_[index][bucket_id] = this_plugin;
    LOG(INFO) << " Name [" << bucket_name << "].";
    LOG(INFO) << " Lib file: [" << plugin_libfile << "].";
    LOG(INFO) << " Lib interface symbol name file: [" << plugin_symbol << "].";
    LOG(INFO) << " Config file: [" << plugin_config << "]";
    LOG(INFO) << "Done loading for bucket " << bucket_id;
  }

  // FIXME(baigang): use safe access
  LOG(INFO) << "Default bucket is: " << default_bucket;
  default_plugin_[index] = plugins_[index][default_bucket];
  LOG(INFO) << "Size of effective plugins is " << plugins_[index].size();

  // swap read/write buffer
  current_index_ = index;
  return true;
}

const boost::shared_ptr<IAlgoPlugin> AlgoPluginManager::Select(uint64_t id) {
  int index = current_index_;
  int mod = id % num_plugins_[index];
  boost::unordered_map<int, boost::shared_ptr<IAlgoPlugin> >::const_iterator iter = plugins_[index].find(mod);
  if (plugins_[index].end() == iter) {
    return default_plugin_[index];
  }
  return iter->second;
}

const boost::shared_ptr<IAlgoPlugin> AlgoPluginManager::Select(const std::string& id) {
  return Select(CityHash64(id.data(), id.length()));
}

}  // namespace recomm_engine


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SIL.Windows.Forms.WritingSystems;
using SIL.WritingSystems;

namespace Bloom.ToPalaso
{
	public static class LanguageLookupModelExtensions
	{
		/// <summary>
		/// A smarter way to get a name for an iso code. Currently StandardSubtags.RegisteredLanguages.TryGet does not find
		/// an entry at all using 3-letter codes. This adds a fall-back which still finds a language
		/// that has the exact requested language code.
		/// If we can't find ANY name, the out param is set to the code itself, and we return false.
		/// Possibly obsolete, I don't know whether the recent rework of writing systems in libpalaso fixed the problem.
		/// </summary>
		/// <returns>true if it found a name</returns>
		public static bool GetBestLanguageName(this LanguageLookupModel isoModel, string code, out string name)
		{
			LanguageSubtag match;
			var codeToMatch = code.ToLowerInvariant();
			if (StandardSubtags.RegisteredLanguages.TryGet(codeToMatch, out match))
			{
				name = match.Name;
				return true;
			}
			foreach (var lang in StandardSubtags.RegisteredLanguages)
			{
				if (lang.Iso3Code == codeToMatch)
				{
					name = lang.Name;
					return true;
				}
			}
			name = code; // best name we can come up with is the code itself
			return false;
		}
	}
}

redpajama_set_name: RedPajamaGithub


text:
{% load dashboard_extras %}

Transactions

Addresses

         To
         From
         Comment
         Conf.
         Info
         When
         Amount

       bogus row

     {% if transactions %}
     {% for transaction in transactions %}
     {% if transaction.confirmations > 6 or transaction.category == "move" %}

     {% else %}

     {% endif %}

        {% if transaction.category == 'receive' %}

        {% elif transaction.category == 'send' %}

        {% elif transaction.category == 'move' %}

        {% endif %}

     {% if transaction.category = 'move' %}
     		this account
     {% elif transaction.category == 'receive' %}
  {% if transaction.address.alias %}
   	 {{ transaction.address.alias }}
     	  {% else %}
     	    {{ transaction.currency_symbol }} {{ transaction.address }}
     	  {% endif %}
      {% elif transaction.category == 'send' %}

       {% if transaction.addressbook_name %}
       	{{ transaction.currency_symbol }} {{ transaction.addressbook_name }}
       {% else %}
       	{{ transaction.currency_symbol }} {{ transaction.address }}
       {% endif %}

     {% endif %}

         {% if transaction.category == 'receive' %}
          {% if transaction.source_address.getAddressBookName %}
          	{{ transaction.currency_symbol }} {{ transaction.source_address|getaddressbookname }}
          {% else %}
          	{{ transaction.currency_symbol }} {{ transaction.details.sender_address }}
          {% endif %}

         {% elif transaction.category == 'send' %}

          this account

         {% elif transaction.category == 'move' %}
         	{{ transaction.currency_symbol }} {{ transaction.otheraccount|getaccountname }}
         {% endif %}

         {% if transaction.comment %}{{ transaction.comment }}{% else %}-{% endif %}

         {% if transaction.txid %}{% endif %}
         {{ transaction.time_pretty }}
          0 %}in{% else %}out{% endif %}">{{ transaction.amount }} {{ transaction.currency|upper }}

     {% endfor %}
     {% else %}

         No data

     {% endif %}

«

-1000

-100

-10

1st page

+10

+100

+1000

       <li {% if transactions|length < transactions_per_page %}class="disabled"{% endif %}>»

Legend:

 local address alias

$ address book entry

$ resolved address from ScriptSig

$ account name


text:
namespace cobalt {
namespace speech {

// The speech recognition result object represents a single one-shot recognition
// match, either as one small part of a continuous recognition or as the
// complete return result of a non-continuous recognition.
//   https://dvcs.w3.org/hg/speech-api/raw-file/9a0075d25326/speechapi.html#speechreco-result
class SpeechRecognitionResult : public script::Wrappable {
 public:
  typedef std::vector<scoped_refptr<SpeechRecognitionAlternative> >
      SpeechRecognitionAlternatives;

  SpeechRecognitionResult(const SpeechRecognitionAlternatives& alternatives,
                          bool final);

  // Represents how many n-best alternatives are represented in the item array.
  uint32 length() const {
    CHECK_LE(alternatives_.size(), std::numeric_limits<uint32>::max());
    return static_cast<uint32>(alternatives_.size());
  }
  // The item getter returns a SpeechRecognitionAlternative from the index into
  // an array of n-best values.
  scoped_refptr<SpeechRecognitionAlternative> Item(uint32 index) const;
  // The final MUST be set to true if this is the final time the speech service
  // will return this particular index value. If the value is false, then this
  // represents an interim result that could still be changed.
  bool is_final() const { return final_; }

  DEFINE_WRAPPABLE_TYPE(SpeechRecognitionResult);
  void TraceMembers(script::Tracer* tracer) override;

 private:
  SpeechRecognitionAlternatives alternatives_;
  bool final_;

  DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionResult);
};

}  // namespace speech
}  // namespace cobalt

#endif  // COBALT_SPEECH_SPEECH_RECOGNITION_RESULT_H_


text:
package com.example.newframtool.util;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.example.newframtool.R;

/**
 * Created by dufangyu on 2016/7/18.
 */
public class MLImageView extends AppCompatImageView {
    private Paint mPressPaint;

    private int mWidth;
    private int mHeight;

    private int mPressAlpha;
    private int mPressColor;
    private int mRadius;
    private int mShapeType;
    private int mBorderWidth;
    private int mBorderColor;

    public MLImageView(Context context) {
        super(context);
        init(context, null);
    }

    public MLImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public MLImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        //初始化默认值
        mPressAlpha = 64;
        mPressColor = getResources().getColor(R.color.ml_gray);
        mRadius = 16;
        mShapeType = 1;
        mBorderWidth = 0;
        mBorderColor = getResources().getColor(R.color.ml_red);

        // 获取控件的属性值
        if (attrs != null) {
            TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.MLImageView);
            mPressColor = array.getColor(R.styleable.MLImageView_press_color, mPressColor);
            mPressAlpha = array.getInteger(R.styleable.MLImageView_press_alpha, mPressAlpha);
            mRadius = array.getDimensionPixelSize(R.styleable.MLImageView_radius, mRadius);
            mShapeType = array.getInteger(R.styleable.MLImageView_shape_type, mShapeType);
            mBorderWidth = array.getDimensionPixelOffset(R.styleable.MLImageView_border_width, mBorderWidth);
            mBorderColor = array.getColor(R.styleable.MLImageView_border_color, mBorderColor);
            array.recycle();
        }

        // 按下的画笔设置
        mPressPaint = new Paint();
        mPressPaint.setAntiAlias(true);
        mPressPaint.setStyle(Paint.Style.FILL);
        mPressPaint.setColor(mPressColor);
        mPressPaint.setAlpha(0);
        mPressPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

        setClickable(true);
        setDrawingCacheEnabled(true);
        setWillNotDraw(false);
    }

    @Override
    protected void onDraw(Canvas canvas) {
//        super.onDraw(canvas);
        // 获取当前控件的 drawable
        Drawable drawable = getDrawable();
        if (drawable == null) {
            return;
        }
        // 这里 get 回来的宽度和高度是当前控件相对应的宽度和高度(在 xml 设置)
        if (getWidth() == 0 || getHeight() == 0) {
            return;
        }
        // 获取 bitmap,即传入 imageview 的 bitmap
        Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
        drawDrawable(canvas, bitmap);
        drawPress(canvas);
        drawBorder(canvas);

    }

    private void drawDrawable(Canvas canvas, Bitmap bitmap) {
        // 画笔
        Paint paint = new Paint();
        // 颜色设置
        paint.setColor(0xffffffff);
        // 抗锯齿
        paint.setAntiAlias(true);
        //Paint 的 Xfermode,PorterDuff.Mode.SRC_IN 取两层图像的交集部门, 只显示上层图像。
        PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
        // 标志
        int saveFlags = Canvas.MATRIX_SAVE_FLAG
                | Canvas.CLIP_SAVE_FLAG
                | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
                | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
                | Canvas.CLIP_TO_LAYER_SAVE_FLAG;
        canvas.saveLayer(0, 0, mWidth, mHeight, null, saveFlags);

        if (mShapeType == 0) {
            // 画遮罩,画出来就是一个和空间大小相匹配的圆
            canvas.drawCircle(mWidth / 2, mHeight / 2, mWidth / 2, paint);
        } else {
            // 当ShapeType = 1 时 图片为圆角矩形
            RectF rectf = new RectF(0, 0, getWidth(), getHeight());
            canvas.drawRoundRect(rectf, mRadius, mRadius, paint);
        }

        paint.setXfermode(xfermode);

        // 空间的大小 / bitmap 的大小 = bitmap 缩放的倍数
        float scaleWidth = ((float) getWidth()) / bitmap.getWidth();
        float scaleHeight = ((float) getHeight()) / bitmap.getHeight();

        Matrix matrix = new Matrix();
        matrix.postScale(scaleWidth, scaleHeight);

        //bitmap 缩放
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);

        //draw 上去
        canvas.drawBitmap(bitmap, 0, 0, paint);
        canvas.restore();
    }

    private void drawPress(Canvas canvas) {

        if(mShapeType == 0){
            canvas.drawCircle(mWidth/2, mHeight/2, mWidth/2, mPressPaint);
        }else if (mShapeType == 1) {
            RectF rectF = new RectF(0, 0, mWidth, mHeight);
            canvas.drawRoundRect(rectF, mRadius, mRadius, mPressPaint);
        }
    }
    private void drawBorder(Canvas canvas){
        if(mBorderWidth > 0){
            Paint paint = new Paint();
            paint.setStrokeWidth(mBorderWidth);
            paint.setStyle(Paint.Style.STROKE);
            paint.setColor(mBorderColor);
            paint.setAntiAlias(true);
            if (mShapeType == 0) {
                canvas.drawCircle(mWidth / 2, mHeight / 2, mWidth / 2, paint);
            } else {
                // 当ShapeType = 1 时 图片为圆角矩形
                RectF rectf = new RectF(0, 0, getWidth(), getHeight());
                canvas.drawRoundRect(rectf, mRadius, mRadius, paint);
            }
        }
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mWidth = w;
        mHeight = h;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mPressPaint.setAlpha(mPressAlpha);
                invalidate();
                break;
            case MotionEvent.ACTION_UP:
                mPressPaint.setAlpha(0);
                invalidate();
                break;
            default:
                invalidate();
                break;
        }
        return super.onTouchEvent(event);
    }

}


text:
require 'rubygems'
require 'sinatra'
require 'sinatra/config_file'
require 'haml'
require 'omniauth-orcid'
require 'oauth2'
require 'json'

enable :sessions
use Rack::Session::Cookie

config_file 'config.yml'
if development?
  puts "Sinatra running in development mode"
elsif production?
  puts "Sinatra running in production mode"
end

puts "Connecting to ORCID API at " + settings.site + " as client app #{settings.client_id}"

# Configure the ORCID strategy
use OmniAuth::Builder do
  provider :orcid, settings.client_id, settings.client_secret,
  :client_options => {
    :site => settings.site,
    :authorize_url => settings.authorize_url,
    :token_url => settings.token_url
  }
end

get '/' do

  @orcid = ''

  if session[:omniauth]
    @orcid = session[:omniauth][:uid]
  end
  haml <<-HTML
%html
  %head
    %title ORCID OmniAuth demo app
  %body
    - if session[:omniauth]
      %p
        Signed in with ORCiD <b>#{@orcid}</b>
        %a(href="/signout") sign out
      %p
        %a(href="/user_info")Show OmniAuth user data as JSON
      %p
        %a(href="/orcid_profile")Connect to ORCID API to fetch full profile data as JSON
    - else
      %p
        %a(href="/auth/orcid") Log in with my ORCiD
  HTML
end

get '/user_info' do
  content_type :json
  session[:omniauth].to_json
end

get '/auth/orcid/callback' do
  puts "Adding OmniAuth user info to session: " +  request.env['omniauth.auth'].inspect
  session[:omniauth] = request.env['omniauth.auth']
  redirect '/'
end

get '/orcid_profile' do
  client = OAuth2::Client.new settings.client_id,settings.client_secret, :site  => settings.site
  atoken = OAuth2::AccessToken.new client, session[:omniauth]['credentials']['token']
  response = atoken.get "/#{session[:omniauth]['uid']}/orcid-profile", :headers => {'Accept' => 'application/json'}
  response.body
end

get '/signout' do
  session.clear
  redirect '/'
end


text:
import { Map, Record } from 'immutable';

export const ActiveFilter = Record({
  uuid: undefined,
  filterBy: '',
  filterString: ''
});

export const FiltersInitialState = Record({
  nodesToolbar: Map({
    activeFilters: Map(),
    sortBy: 'name',
    sortDir: 'asc',
    contentView: 'list'
  }),
  validationsToolbar: Map({
    activeFilters: Map(),
    sortBy: 'name',
    sortDir: 'asc',
    contentView: 'list'
  })
});


text:
import ConfigStore from 'configstore'

const sanityEnv = (process.env.SANITY_INTERNAL_ENV || '').toLowerCase() // eslint-disable-line no-process-env
const defaults = {}
let config = null

const getUserConfig = () => {
  if (!config) {
    config = new ConfigStore(
      sanityEnv && sanityEnv !== 'production' ? `sanity-${sanityEnv}` : 'sanity',
      defaults,
      {globalConfigPath: true}
    )
  }

  return config
}

export default getUserConfig


text:
<!doctype html>

    <meta charset="UTF-8">
    <title>UT BIOME - Data</title>
    <link rel="shortcut icon" href="images/favicon.gif" type="image/x-icon"/>
    <link rel="stylesheet" type="text/css" href="css/basecssData.css"/>

Home

People

Data

Maps

Blog

All the sampling data is available for download on the maps
                    page. The sequencing data is available for download here upon
                    request.

                    Please fill in your name and email address below to
                    receive download links to the sequencing data in your email.

                <form action="" method="post">

Name:
                        <input type="text" name="name" value="" size="25" maxlength="50" />

Email:
                        <input type="text" name="email" value="" size="25" maxlength="50" />

                    <input disabled type="submit" name="submit" value="send me sequencing data! (coming soon)"/>
                </form>

 © 2014 The University of Texas at Austin-CRWR

        This project is funded by the Longhorn Innovation Fund for Technology(LIFT)[2013-2014]

        Contact:
        Kerry Kinney
        Paola Passalacqua
        Juan Pedro Maestre
        Harish Sangireddy