text:
//
//  UIViewController+Base.m
//  小说搜搜看
//
//  Created by Kevin Chou on 15-4-28.
//  Copyright (c) 2015年 com.nowsilence.sousou. All rights reserved.
//

#import "UIViewController+Base.h"
#import "MBProgressHUD.h"
#import "ASIHTTPRequest.h"
#import "HudResource.h"
#import "GTMBase64.h"

@implementation UIViewController (Base)

- (void)setLeftButton:(UIButton *)button
{
    if (!button)
    {
        self.navigationItem.leftBarButtonItems = nil;
        self.navigationItem.leftBarButtonItem = nil;

        return;
    }

    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];;

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {
        UIBarButtonItem *negativeSeperator =
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                      target:nil
                                                      action:nil];
        negativeSeperator.width = -16;

        [self.navigationItem setLeftBarButtonItems:@[negativeSeperator, leftBarButtonItem]];
    }
    else
    {
        [self.navigationItem setLeftBarButtonItem:leftBarButtonItem animated:NO];
    }
}

- (void)setRightButton:(UIButton *)button
{
    if (!button)
    {
        self.navigationItem.rightBarButtonItems = nil;
        self.navigationItem.rightBarButtonItem = nil;

        return;
    }

    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];;

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {
        UIBarButtonItem *negativeSeperator =
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                      target:nil
                                                      action:nil];
        negativeSeperator.width = -16;

        [self.navigationItem setRightBarButtonItems:@[negativeSeperator, rightBarButtonItem]];
    }
    else
    {
        [self.navigationItem setRightBarButtonItem:rightBarButtonItem animated:NO];
    }
}

#pragma mark 显示提示信息
- (void)showToast:(NSString *)text delay:(float)delay
{
    MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view];

    if (!hud)
    {
        hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

        hud.removeFromSuperViewOnHide = YES;
    }
    else
    {
        [hud cancelHideDelayed];
    }

    hud.padding = 5;

    hud.minSize = CGSizeZero;

    hud.mode = MBProgressHUDModeText;

    hud.detailsLabelText = text;

    [hud hide:YES afterDelay:delay];

    hud.labelText = nil;
}

- (void)showToast:(NSString *)text
{
    [self showToast:text delay:1];
}

- (void)showToast:(NSString *)text completionBlock:(void (^)(void))completionBlock
{
    double delayInSeconds = 2.f;

    [self  showToast:text delay:delayInSeconds];

    delayInSeconds -= 1;

    if (completionBlock)
    {
        if (delayInSeconds > 0) {
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                completionBlock();
            });
        }
        else
        {
            completionBlock();
        }
    }
}

- (void)showNetHud:(NSString *)text
{
    MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view];

    if (!hud)
    {
        hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

        hud.removeFromSuperViewOnHide = YES;
    }
    else
    {
        [hud cancelHideDelayed];
    }

    hud.padding = 5;

    hud.minSize = CGSizeZero;

    hud.mode = MBProgressHUDModeIndeterminate;

    hud.detailsLabelText = text;

    hud.labelText = nil;
}

- (void)bshowNetHud:(NSString *)text
{
    MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view];

    if (!hud)
    {
        hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

        hud.removeFromSuperViewOnHide = YES;
    }
    else
    {
        [hud cancelHideDelayed];
    }

    hud.mode = MBProgressHUDModeIndeterminate;

    hud.indicatorLarge = YES;

    hud.padding = 24;

    hud.minSize = CGSizeMake(150, 150);

    hud.labelText = text;

    hud.detailsLabelText = nil;
}

- (void)bshowToastErr:(NSString *)text
{
    NSData *data = [GTMBase64 decodeString:ErrImage];

    UIImage *image = [UIImage imageWithData:data scale:2];

    [self bshowToast:text image:image delay:2];
}

- (void)bshowToastInfo:(NSString *)text
{
    NSData *data = [GTMBase64 decodeString:InfoImage];

    UIImage *image = [UIImage imageWithData:data scale:2];

    [self bshowToast:text image:image delay:1];
}

- (void)bshowToastSuc:(NSString *)text completionBlock:(void (^)(void))completionBlock
{
    NSData *data = [GTMBase64 decodeString:SucImage];

    UIImage *image = [UIImage imageWithData:data scale:2];

    double delayInSeconds = 2.f;

    [self bshowToast:text image:image delay:delayInSeconds];

    delayInSeconds -= 1;

    if (completionBlock)
    {
        if (delayInSeconds > 0) {
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                completionBlock();
            });
        }
        else
        {
            completionBlock();
        }
    }

}

- (void)bshowToast:(NSString *)text image:(UIImage *)image delay:(float)delay
{
    MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view];

    if (!hud)
    {
        hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

        hud.removeFromSuperViewOnHide = YES;
    }
    else
    {
        [hud cancelHideDelayed];
    }

    hud.mode = MBProgressHUDModeCustomView;

    hud.customView = [[UIImageView alloc] initWithImage:image];

    hud.padding = 24;

    hud.minSize = CGSizeMake(150, 150);

    hud.labelText = text;

    hud.detailsLabelText = nil;

    [hud hide:YES afterDelay:delay];
}

- (void)hideHud
{
    MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view];

    if (hud)
    {
        [hud hide:YES];
    }
}

#pragma mark 旋转控制

-(NSUInteger)supportedInterfaceOrientations
{
    //    [self setMyLayout];
    return UIInterfaceOrientationMaskPortrait;
}

/**
 *  这个方法在写在viewcontroller中,在视图出现之前调用。需要注意一个地方,
 *  如果这个viewcontroller是navigationcontroller容器中的,它将永远不会被调用,
 *  只会调用navigationcontroller中的-(BOOL)shouldAutorotate。
 */
- (BOOL)shouldAutorotate
{
    return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                         duration:(NSTimeInterval)duration
{
    //    [self setMyLayout];//检测到旋转时就会被调用
}

/**
 *  为了兼容IOS6以前的版本而保留的方法
 */
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return (toInterfaceOrientation == UIDeviceOrientationPortrait);
    //    return YES;//即在IOS6.0以下版本,支持所用方向的旋屏
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}
#pragma clang diagnostic pop

#pragma mark 清除未完成的网络请求
- (void)clearRequest
{
    for (ASIHTTPRequest *request in [ASIHTTPRequest sharedQueue].operations)
    {
        NSString *description = [request.userInfo objectForKey:@"description"];

        if ([description isEqualToString:[self description]])
        {
            request.userInfo = nil;

            [request clearDelegatesAndCancel];
        }
    }
}

/**
 *  需要自己处理可重写
 */
- (void)requestFailed:(ASIHTTPRequest *)request
{
    [self showToast:@"网络异常,请检查网络后重试!"];
}

/**
 *  不可覆盖,会crash,
 */
//- (void)dealloc
//{
////    if(kBaseDebug) NSLog(@"%@ dealloc",[self class]);
////
////    [self clearRequest];
//}

@end


text:
package org.kopptech.commonbond.bindings;

import org.kopptech.commonbond.Binding;
import org.kopptech.commonbond.ObjUtils;

public class InstanceBinding implements Binding
{
    private Object value;
    private Class<?> newInstanceClass;
    private boolean allowConstraintViolations = false;

    public InstanceBinding(Class<?> newInstanceClass)
    {
        super();
        this.newInstanceClass = newInstanceClass;
    }

    public InstanceBinding(Object value)
    {
        super();
        this.value = value;
    }

    public Class<?> getType()
    {
        return value.getClass();
    }

    public Object createDefaultValue()
    {
        try
        {
            return newInstanceClass.newInstance();
        }
        catch (Exception e)
        {
            throw ObjUtils.wrap(e);
        }
    }

    public Object getValue(boolean createParentIfNull)
    {
        return value;
    }

    public void setValue(Object o, boolean allowInvalidValues)
    {
        value = o;
    }

    public Class<?> getNewInstanceClass()
    {
        return newInstanceClass;
    }

    public void setNewInstanceClass(Class<?> newInstanceClass)
    {
        this.newInstanceClass = newInstanceClass;
    }

    public boolean isAllowConstraintViolations()
    {
        return allowConstraintViolations;
    }

    public void setAllowConstraintViolations(boolean allowConstraintViolations)
    {
        this.allowConstraintViolations = allowConstraintViolations;
    }

}

redpajama_set_name: RedPajamaGithub


text:
<?php

class SV_WordCountSearch_XenForo_DataWriter_DiscussionMessage_Post extends XFCP_SV_WordCountSearch_XenForo_DataWriter_DiscussionMessage_Post
{
    protected $_includeWordCount = true;
    protected function _getFields()
    {
        $fields = parent::_getFields();
        if ($this->_includeWordCount)
        {
            $fields['xf_post_words'] = array
            (
                'post_id' => array('type' => self::TYPE_UINT,   'default' => array('xf_post', 'post_id'), 'required' => true),
                'word_count' => array('type' => self::TYPE_UINT, 'default' => 0)
            );
        }
        return $fields;
    }

    protected function _getExistingData($data)
    {
        $postData = parent::_getExistingData($data);
        if (isset($postData['xf_post']['word_count']))
        {
            if ($this->_includeWordCount)
            {
                $postData['xf_post_words'] = array('post_id' => $postData['xf_post']['post_id'], 'word_count' => $postData['xf_post']['word_count']);
            }
            unset($postData['xf_post']['word_count']);
        }
        return $postData;
    }

    protected function _messagePreDelete()
    {
        // prevent the datawriter trying to delete the xf_post_words row and erroring with "Cannot delete data without a condition"
        $this->_includeWordCount = false;
        unset($this->_fields['xf_post_words']);
        parent::_messagePreDelete();
    }

    protected function _messagePostDelete()
    {
        parent::_messagePostDelete();
        $db = $this->_db;
        $db->query('delete from xf_post_words where post_id = ?', array($this->get('post_id')));
    }

    protected $_wordCount = null;
    protected $deferredWordCountInsert = false;

    protected function _messagePreSave()
    {
        parent::_messagePreSave();
        $searchModel = $this->_getSearchModel();
        if ($this->isChanged('message') || $this->isInsert())
        {
            $this->_wordCount = $searchModel->getTextWordCount($this->get('message'));
            $this->set('word_count', $this->_wordCount);
        }
        if ($this->_wordCount)
        {
            $db = $this->_db;
            $threadmark = $this->_getThreadmarkDataForWC();
            if ($threadmark || $searchModel->shouldRecordPostWordCount($this->get('post_id'), $this->_wordCount))
            {
                $this->deferredWordCountInsert = $this->isChanged('word_count');
            }
            else
            {
                if ($this->getExisting('word_count'))
                {
                    $post_id = $this->get('post_id');
                    $db->query('delete from xf_post_words where post_id = ?', array($post_id));
                }
            }
            $this->_includeWordCount = false;
            unset($this->_fields['xf_post_words']);
            unset($this->_newData['xf_post_words']);
            unset($this->_existingData['xf_post_words']);
        }
    }

    protected function _messagePostSave()
    {
        $this->_includeWordCount = true;
        if ($this->_wordCount !== null)
        {
            $this->_fields = $this->_getFields();
            $this->_newData['xf_post_words']['word_count'] = $this->_wordCount;
        }
        if ($this->deferredWordCountInsert)
        {
            $db = $this->_db;
            $db->query("
                insert xf_post_words (post_id, word_count)
                values (?,?)
                on duplicate key update
                    word_count = values(word_count)
            ", array($this->get('post_id'), $this->_wordCount));
        }

        parent::_messagePostSave();
    }

    protected function _postSaveAfterTransaction()
    {
        parent::_postSaveAfterTransaction();
        // the threadmark can be created on post-insert, only need to trigger a thread wordcount rebuild if the post is updated
        if ($this->_wordCount !== null && $this->isUpdate())
        {
            $threadmark = $this->_getThreadmarkDataForWC();
            if ($threadmark)
            {
                /** @var SV_WordCountSearch_XenForo_Model_Thread $threadModel */
                $threadModel = $this->_getThreadModel();
                $threadId = $this->get('thread_id');
                $threadModel->rebuildThreadWordCount($threadId);
                $this->_updateThreadSearchIndex();
            }
        }
    }

    /**
     * @return null|array
     */
    protected function _getThreadmarkDataForWC()
    {
        if (is_callable(array($this, '_getThreadmarkData')))
        {
            /** @noinspection PhpUndefinedMethodInspection */
            return $this->_getThreadmarkData();
        }
        return null;
    }

    protected function _updateThreadSearchIndex()
    {
        $indexer = new XenForo_Search_Indexer();
        $thread = $this->getDiscussionData();

        $threadHandler = XenForo_Search_DataHandler_Abstract::create(
            'XenForo_Search_DataHandler_Thread'
        );

        $threadHandler->insertIntoIndex($indexer, $thread);
    }

    /**
     * @return SV_WordCountSearch_XenForo_Model_Search|XenForo_Model
     */
    protected function _getSearchModel()
    {
        return $this->getModelFromCache('XenForo_Model_Search');
    }
}

// ******************** FOR IDE AUTO COMPLETE ********************
if (false)
{
    class XFCP_SV_WordCountSearch_XenForo_DataWriter_DiscussionMessage_Post extends XenForo_DataWriter_DiscussionMessage_Post {}
}


text:
<!DOCTYPE html>

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="generator" content="ApiGen 2.8.0" />

	<title>Class WhRelationalColumn | YiiWheels</title>

	<link rel="stylesheet" type="text/css" media="all" href="resources/bootstrap.min.css?260161822" />
	<link rel="stylesheet" type="text/css" media="all" href="resources/style.css?2015443609" />

				YiiWheels

							Package

Class

							Tree

		<form id="search" class="form-search">
			<input type="hidden" name="cx" value="" />
			<input type="hidden" name="ie" value="UTF-8" />
			<input type="text" name="q" class="search-query" placeholder="Search" />
		</form>

Packages

None

yiiwheels

behaviors

widgets

widgets

ace

box

datepicker

daterangepicker

datetimepicker

detail

fileupload

fileuploader

gallery

google

grid

behaviors

operations

highcharts

maskInput

maskmoney

modal

multiselect

rangeslider

redactor

select2

sparklines

switch

timeago

timepicker

toggle

typeahead

Classes

WhGridView

WhGroupGridView

WhImageColumn

WhRelationalColumn

Class WhRelationalColumn

TbDataColumn

WhRelationalColumn

		Package: YiiWheels\widgets\grid

				Copyright:
				Copyright © 2amigos.us 2013-

				License:
				New BSD License

				Author:
				Antonio Ramirez <amigo.cobos@gmail.com>

		Located at widgets/grid/WhRelationalColumn.php

Methods summary

				 public

			#
			init( )

widget initialization

widget initialization

				 public

			#
			renderDataCell( integer <var>$row</var> )

Overrides CDataColumn renderDataCell in order to wrap up its content with the
object that will be used as a trigger. Important: Making use of links as a
content for this of column is an error.

Overrides CDataColumn renderDataCell in order to wrap up its content with the
object that will be used as a trigger. Important: Making use of links as a
content for this of column is an error.

Parameters

<var>$row</var>

integer
$row

				 protected
				null|string

			#
			getPrimaryKey( CActiveRecord <var>$data</var> )

Helper function to return the primary key of the $data

* IMPORTANT: composite keys on CActiveDataProviders will return the keys joined
by comma

Helper function to return the primary key of the $data * IMPORTANT: composite
keys on CActiveDataProviders will return the keys joined by comma

Parameters

<var>$data</var>

CActiveRecord
$data

Returns

						null|string

				 public

			#
			registerClientScript( )

Register script that will handle its behavior

Register script that will handle its behavior

Magic methods summary

Properties summary

				public
				string

					<var>$url</var>

				#

$url the route to call via AJAX to get the data from

$url the route to call via AJAX to get the data from

				public
				string

					<var>$cssClass</var>

				#

$cssClass the class name that will wrap up the cell content. Important Note:
this class will be used as the trigger for the AJAX call, so make sure is unique
for the column.

$cssClass the class name that will wrap up the cell content. Important Note:
this class will be used as the trigger for the AJAX call, so make sure is unique
for the column.

				public
				boolean

					<var>$cacheData</var>

				#

$cacheData if set to true, there won't be more than one AJAX request. If set
to false, the widget will continuously make AJAX requests. This is useful if the
data could vary. If the data doesn't change then is better to set it to true.
Defaults to true.

$cacheData if set to true, there won't be more than one AJAX request. If set
to false, the widget will continuously make AJAX requests. This is useful if the
data could vary. If the data doesn't change then is better to set it to true.
Defaults to true.

				public
				string

					<var>$afterAjaxUpdate</var>

				#

a javascript function that will be invoked if an AJAX call occurs.

The function signature is <span
class="php-keyword1">function</span>(tr, rowid, data)

tr is the newly created TR HTML object that will display the
	returned server data.

rowid the model id of the row.

data is the data returned by the server that is already
	displayed on the row.

 Note: This handler is not called for JSONP requests.

Example (add in a call to TbRelationalColumn):

 ...
 'afterAjaxUpdate'=>'js:function(tr,rowid, data){ console.log(rowid); }',
 ...

a javascript function that will be invoked if an AJAX call occurs.

The function signature is <span
class="php-keyword1">function</span>(tr, rowid, data)

tr is the newly created TR HTML object that will display the
	returned server data.

rowid the model id of the row.

data is the data returned by the server that is already
	displayed on the row.

 Note: This handler is not called for JSONP requests.

Example (add in a call to TbRelationalColumn):

 ...
 'afterAjaxUpdate'=>'js:function(tr,rowid, data){ console.log(rowid); }',
 ...

				public
				string

					<var>$ajaxErrorMessage</var>

				#

$ajaxErrorMessage the message that is displayed on the newly created row in
case there is an AJAX error.

$ajaxErrorMessage the message that is displayed on the newly created row in
case there is an AJAX error.

		YiiWheels API documentation generated by ApiGen 2.8.0


text:
`BlobUploader` uploads data from a given stream into an Azure block blob.

# Usage

```js
var fs = require('fs');

var filePath = './README.md';

fs.stat(filePath, function (err, fileStats) {
  var fileStream = fs.createReadStream(filePath);
  var uploader = new BlobUploader();
  var blobInfo = {
    hostName: '<storage.host.name>',
    containerName: '<container>',
    blobName: '<blobName>',
    sasToken: '<SAS Token>'
  };
  uploader.uploadToBlob(blobInfo, fileStream, fileStats.size, function (err) {
    if (err) {
      console.log('Upload failed: ' + err.message);
    } else {
      console.log('Upload succeeded');
    }
    fileStream.destroy();
  });
});
```

# Public API
## BlobUploader(storageApi) constructor
**SRS_NODE_DEVICE_BLOB_UPLOAD_16_007: [** `BlobUploader` should use the `azure-storage` package to upload data if `storageApi` is falsy. **]**

**SRS_NODE_DEVICE_BLOB_UPLOAD_16_008: [** `BlobUploader` should use the `storageApi` object to upload data if `storageApi` is truthy. **]**

## uploadToBlob(blobInfo, stream, streamSize, done)
**SRS_NODE_DEVICE_BLOB_UPLOAD_16_001: [** `uploadToBlob` shall throw a `ReferenceError` if `blobInfo` is falsy. **]**

**SRS_NODE_DEVICE_BLOB_UPLOAD_16_002: [** `uploadToBlob` shall throw a `ReferenceError` if `stream` is falsy. **]**

**SRS_NODE_DEVICE_BLOB_UPLOAD_16_003: [** `uploadToBlob` shall throw a `ReferenceError` if `streamSize` is falsy. **]**

**SRS_NODE_DEVICE_BLOB_UPLOAD_16_004: [** `uploadToBlob` shall throw an `ArgumentError` if `blobInfo` is missing one or more of the following properties: `hostName`, `containerName`, `blobName`, `sasToken`). **]**

**SRS_NODE_DEVICE_BLOB_UPLOAD_16_005: [** `uploadToBlob` shall call the `done` calback with the result of the storage api call. **]**


text:
package my.mvc.models;

import lombok.Data;
import my.mvc.models.parts.Engine;
import my.mvc.models.parts.GearBox;
import my.mvc.models.parts.Transmission;

import javax.persistence.*;

/**
 * Created by Ivan Sliusar on 16.05.2018.
 * Red Line Soft corp.
 */
@Entity
@Table(name = "Car")
public @Data class Car {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "name")
    private String name;

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn (name = "id_engine")
    private Engine engine;

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn (name = "id_transmission")
    private Transmission transmission;

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn (name = "id_gearbox")
    private GearBox gearbox;

    public Car(String name, Engine engine, Transmission transmission, GearBox gearbox) {
        this.name = name;
        this.engine = engine;
        this.transmission = transmission;
        this.gearbox = gearbox;
    }

    public Car() {}

    @Override
    public String toString() {
        return this.getId().toString();
    }
}


text:
class ShapeSerializer < ApplicationSerializer
  attributes :id, :type, :coordinates
end


text:
/* eslint-disable no-unused-expressions */
import R from 'ramda'
import reducer, { actionTypes } from 'redux/modules/settings'

describe('(Redux Module) settings', function () {
  describe('reducer', function () {
    it('should return the initial state', function () {
      expect(reducer(undefined, {})).to.deep.equal({})
    })

    it('should handle SET_SETTING', function () {
      const initialState = { initialKey: 'foo' }
      const setting = { bar: 'baz' }

      expect(reducer(initialState, {
        type: actionTypes.SET_SETTING,
        payload: setting
      })).to.deep.equal(R.merge(initialState, setting))
    })
  })
})