text:
package oss2016.pixelforts;

import android.content.Context;;;
import android.opengl.GLSurfaceView;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.view.WindowManager;

public class GameManager extends AppCompatActivity {
    private GameView gmView;
    private static DisplayMetrics metrics = new DisplayMetrics();

    public static DisplayMetrics getMetrics() {return metrics;}

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindowManager().getDefaultDisplay().getMetrics(metrics);

        // Create a GLSurfaceVIew instance and set it
        // as the ContentView for this Activity.
        gmView = new GameView(this);
        setContentView(gmView);
    }

    /* Called by android when the player starts*/
    @Override
    protected void onResume() {
        super.onResume();

        gmView.resume();
    }

    /* Called by Android when the player change focus from the game */
    @Override
    protected void onPause() {
        super.onPause();

        gmView.pause();
    }
}
/* The main game thread.  The GLSurfaceView is used to render objects and detect touch events.
    The Runnable, allows us to define our own game thread that will run the main game loop that
    updates the game.

    Most of the game loop and GameView logic came from a web tutorial by John Horton
    <http://gamecodeschool.com/android/building-a-simple-game-engine/>
 */
class GameView extends GLSurfaceView implements Runnable{
    private final GMGLRenderer gmRenderer;
    private Thread gameLoop = null;
    volatile boolean playing;
    private static final int fpsCap = 30; /* desired maximum frame rate in seconds*/
    private static final long fpsCapMillis = 1000 / fpsCap;
    private static long fps; /* frame rate for update loop*/
    private long timeThisFrame; /* used to limit that rate update is called */

    private Player[] players;
    private int numPlayers = 5;
    private Scene scene; /* holds references to all object in the scene */
    private int currentPlayer;
    private boolean setupPlayer; /* holds if the player has been setup after switching players */
    private boolean chargingWeapon;
    private boolean fire;

    public static long FPS(){ return fps; }

    public GameView(Context context) {
        super(context);

        // Create an OpenGL ES 2.0 context
        setEGLContextClientVersion(2);

        gmRenderer = new GMGLRenderer();

        // Set the Renderer for drawing on the GMGLSurfaceView
        setRenderer(gmRenderer);

        setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

        gameStart();
    }

    /* initial game setup */
    private void gameStart() {
        players = new Player[numPlayers];
        for (int i = 0; i < numPlayers; ++i)
            players[i] = new Human("Player " + (i + 1));
        scene = new Scene(players);
        currentPlayer = 0;
        setupPlayer = false;
        chargingWeapon = false;
        fire = false;

        /* allows the run() thread method to update the game */
        playing = true;
    }

    /* called as part of the Thread class by Android and performs the main game loop updating
    * and rendering. */
    @Override
    public void run() {
        long startFrameTime;
        fps = 1000 / fpsCapMillis; /* default to desired frame rate */
        long sleepTime;
        while (playing){
            startFrameTime = SystemClock.uptimeMillis();

            update();

            /* asks gmRenderer to run onDraw */
            requestRender();

            timeThisFrame = SystemClock.uptimeMillis() - startFrameTime;
            if (timeThisFrame > 0) {
                fps = 1000 / timeThisFrame;
                sleepTime = fpsCapMillis - timeThisFrame;
                try {
                    if (sleepTime > 0)
                        Thread.sleep(sleepTime);
                    else
                        Thread.sleep(10);
                } catch (Exception e) {}
            }
        }
        Log.w("gameLoop", " finished playing");
    }

    /* Run the scene while there are active objects in it.
        If the scene is quiet, have the next player play*/
    public void update() {
        if (numPlayers < 2)
            playing = false;  /* game is over */

        else if (scene.isActive()){ /* keep running the scene until all motion has stopped */
            scene.update();

            /* check for dead players */
            for (int i = 0; i < numPlayers; ++i){
                if(players[i].IsDead()){
                    /* shift down */
                    Player temp = players[i];
                    for (int j = i + 1; j < numPlayers; ++j)
                    {
                        players[j-1] = players[j];
                    }
                    players[numPlayers - 1] = temp;
                    scene.removeFort(temp.Fort());
                    --numPlayers;

                    if (currentPlayer > i){
                        --currentPlayer;
                    }
                    --i; /* current i index is a different player now need to check them */
                }
            }
            if (currentPlayer >= numPlayers)
                currentPlayer = 0;
        }

        else{ /* player logic */
            if (!setupPlayer){
                Fort playerFort = players[currentPlayer].Fort();
                players[currentPlayer].setWeapon(new Weapon(playerFort.CenterX(), playerFort.Top(), 20, .03f));
                setupPlayer = true;
                fire = false;
                chargingWeapon = false;
            }
            if (chargingWeapon){
                /* full charge in roughly 1 second */
                players[currentPlayer].currentWeapon().charge(4.0f / fps);
            }
            else if (fire){
                Projectile bullet = players[currentPlayer].currentWeapon().fire();
                scene.addActive(bullet);
                GMGLRenderer.getRenderQueue().Add(bullet);

                players[currentPlayer].destroyWeapon();
                ++currentPlayer;
                if (currentPlayer >= numPlayers)
                    currentPlayer = 0;

                setupPlayer = false;
            }

        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent motionEvent){

        float x = motionEvent.getX();
        float y = motionEvent.getY();

        /* change to world coords */
        float width = (float) GameManager.getMetrics().widthPixels;
        float height = (float) GameManager.getMetrics().heightPixels;
        float xWorld = 4.0f * (width / 2.0f - x) / width;
        float yWorld = 2.0f * (height / 2.0f - y) / height;

        switch (motionEvent.getAction()){
            case MotionEvent.ACTION_DOWN:
                /* Check if we pressed the fire button */
               if (!chargingWeapon  && (xWorld < -1.7f && yWorld < -.7f))
                    chargingWeapon = true;

                /* else fall through to the next case */
            case MotionEvent.ACTION_MOVE:
                if (!chargingWeapon) {
                    if (players[currentPlayer].currentWeapon() != null)
                        players[currentPlayer].currentWeapon().aim(xWorld, yWorld);
                }
                break;

            case MotionEvent.ACTION_UP:
                if (chargingWeapon) {
                    fire = true;
                    chargingWeapon = false;
                }
        }
        return true;
    }

    /*User left the game, close the gameLoop thread */
    public void pause() {
        playing = false;
        try {
            Log.w("gameLoop", gameLoop.getName() + " paused");
            gameLoop.join();

        } catch (InterruptedException e){
            Log.e("Error:", "joining thread");
        }
    }

    /* The GameManager has started (restarted) */
    public void resume() {
        playing = true;
        gameLoop = new Thread(this);
        gameLoop.start();
    }
}


text:
class ApplicationController < ActionController::Base
  include DeviseTokenAuth::Concerns::SetUserByToken
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  # protect_from_forgery with: :exception
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected
  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << [:company]
  end
end

redpajama_set_name: RedPajamaGithub


text:
import * as paths from 'vs/base/common/paths';
import { URI } from 'vs/base/common/uri';
import { canceled } from 'vs/base/common/errors';

export type ValueCallback<T = any> = (value: T | Thenable<T>) => void;

export class DeferredPromise<T> {

	private completeCallback: ValueCallback<T>;
	private errorCallback: (err: any) => void;

	public p: Promise<any>;

	constructor() {
		this.p = new Promise<any>((c, e) => {
			this.completeCallback = c;
			this.errorCallback = e;
		});
	}

	public complete(value: T) {
		return new Promise(resolve => {
			process.nextTick(() => {
				this.completeCallback(value);
				resolve();
			});
		});
	}

	public error(err: any) {
		return new Promise(resolve => {
			process.nextTick(() => {
				this.errorCallback(err);
				resolve();
			});
		});
	}

	public cancel() {
		process.nextTick(() => {
			this.errorCallback(canceled());
		});
	}
}

export function toResource(this: any, path: string) {
	return URI.file(paths.join('C:\\', Buffer.from(this.test.fullTitle()).toString('base64'), path));
}

export function suiteRepeat(n: number, description: string, callback: (this: any) => void): void {
	for (let i = 0; i < n; i++) {
		suite(`${description} (iteration ${i})`, callback);
	}
}

export function testRepeat(n: number, description: string, callback: (this: any, done: MochaDone) => any): void {
	for (let i = 0; i < n; i++) {
		test(`${description} (iteration ${i})`, callback);
	}
}

export function testRepeatOnly(n: number, description: string, callback: (this: any, done: MochaDone) => any): void {
	suite.only('repeat', () => testRepeat(n, description, callback));
}


text:
<!DOCTYPE html>

    <title>Tags :: TrozWare</title>

  <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta name="description" content=""/>
<meta name="keywords" content="[Swift Apple macOS iOS Apple Watch]"/>
<meta name="robots" content="noodp"/>
<link rel="canonical" href="https://troz.net/tags/" />

<link rel="stylesheet" href="https://troz.net/assets/style.css">

<link rel="stylesheet" href="https://troz.net/style.css">

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://troz.net/img/apple-touch-icon-144-precomposed.png">
<link rel="shortcut icon" href="https://troz.net/img/favicon.png">

<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Tags :: TrozWare — " />
<meta name="twitter:description" content="" />
<meta name="twitter:site" content="https://troz.net/" />
<meta name="twitter:creator" content="" />
<meta name="twitter:image" content="">

<meta property="og:locale" content="en" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Tags :: TrozWare — ">
<meta property="og:description" content="" />
<meta property="og:url" content="https://troz.net/tags/" />
<meta property="og:site_name" content="Tags" />
<meta property="og:image" content="">
<meta property="og:image:width" content="2048">
<meta property="og:image:height" content="1024">

    <svg xmlns="http://www.w3.org/2000/svg" class="greater-icon" width="44" height="44" viewBox="0 0 44 44">
  <polyline fill="none" stroke="#000" stroke-width="2" points="15 8 29.729 22.382 15 35.367"/>
</svg>

    TrozWare

Home

Apps

Archives

Tags

Contact

Home

Apps

Archives

Tags

Contact

          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
            <path d="M0 0h24v24H0z" fill="none"/>
            <path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
          </svg>

        <svg class="theme-toggler" width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path d="M22 41C32.4934 41 41 32.4934 41 22C41 11.5066 32.4934 3 22
  3C11.5066 3 3 11.5066 3 22C3 32.4934 11.5066 41 22 41ZM7 22C7
  13.7157 13.7157 7 22 7V37C13.7157 37 7 30.2843 7 22Z"/>
</svg>

      69

      tags in total

        app store

        apple watch

        apps

        beta

        blog

        chess

        class

        color

        crosswords

        dice

        email

        font

        framework

        functional

        gdpr

        golf

        hugo

        icons

        ios

        ipad

        iphone

        jekyll

        json

        knights move

        learning swift

        library

        lint

        livecode

        mac

        macos

        man reader

        markdown

        music

        ncss

        oop

        operating systems

        optionals

        password

        passwords

        pic a pod

        privacy

        productivity

        puzzles

        revolution

        rss

        sand box

        scoring

        screen saver

        snapshot

        struct

        style

        support

        swift

        swiftlint

        swiftui

        testflight

        time

        time in words

        travel

        trouble shooting

        trozware

        twitter

        ui

        unit tests

        watch

        web

        work

        world time in words

        xcode

    <link rel="stylesheet" href="/css/footer.css" />

      © 2012 - 2020 Sarah Reichelt

      Hugo theme created by
        panr 2018


text:
package logutil

import (
	"fmt"
	"log"
	"net/http"
)

func Print(r *http.Request, v ...interface{}) {
	logWithRequestInfo(r, fmt.Sprint(v))
}

func Printf(r *http.Request, format string, v ...interface{}) {
	logWithRequestInfo(r, fmt.Sprintf(format, v))
}

func logWithRequestInfo(r *http.Request, v string) {
	log.Printf("[%s] '%s' %s - %s", r.RemoteAddr, r.Method, r.RequestURI, v)
}


text:
#include "dcmtk/config/osconfig.h"

#include "dcmtk/dcmdata/dctypes.h"

#include "dcmtk/dcmimage/diyp2img.h"
#include "dcmtk/dcmimage/diyp2pxt.h"
#include "dcmtk/dcmimage/dilogger.h"
#include "dcmtk/dcmimgle/diinpx.h"

/*----------------*
 *  constructors  *
 *----------------*/

DiYBRPart422Image::DiYBRPart422Image(const DiDocument *docu,
                                     const EI_Status status)
  : DiColorImage(docu, status, 2)
{
    if ((Document != NULL) && (InputData != NULL) && (ImageStatus == EIS_Normal))
    {
        Init();                                                 // create intermediate representation
    }
}

/*--------------*
 *  destructor  *
 *--------------*/

DiYBRPart422Image::~DiYBRPart422Image()
{
}

/*********************************************************************/

void DiYBRPart422Image::Init()
{
    switch (InputData->getRepresentation())
    {
        case EPR_Uint8:
            InterData = new DiYBRPart422PixelTemplate<Uint8, Uint8>(Document, InputData, ImageStatus, BitsPerSample);
            break;
        case EPR_Sint8:
            InterData = new DiYBRPart422PixelTemplate<Sint8, Uint8>(Document, InputData, ImageStatus, BitsPerSample);
            break;
        case EPR_Uint16:
            InterData = new DiYBRPart422PixelTemplate<Uint16, Uint16>(Document, InputData, ImageStatus, BitsPerSample);
            break;
        case EPR_Sint16:
            InterData = new DiYBRPart422PixelTemplate<Sint16, Uint16>(Document, InputData, ImageStatus, BitsPerSample);
            break;
        case EPR_Uint32:
            InterData = new DiYBRPart422PixelTemplate<Uint32, Uint32>(Document, InputData, ImageStatus, BitsPerSample);
            break;
        case EPR_Sint32:
            InterData = new DiYBRPart422PixelTemplate<Sint32, Uint32>(Document, InputData, ImageStatus, BitsPerSample);
            break;
    }
    deleteInputData();
    checkInterData();
}

/*********************************************************************/

int DiYBRPart422Image::processNextFrames(const unsigned long fcount)
{
    if (DiImage::processNextFrames(fcount))
    {
        delete InterData;
        InterData = NULL;
        Init();
        return (ImageStatus == EIS_Normal);
    }
    return 0;
}


text:
using System;
using System.Collections.Generic;
using System.Data;
using System.FastReflection;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using Surpass.Database;
using Surpass.Infrastructure.Database;
using SurpassStandard.Utils;

namespace Surpass.ORM.EFCore
{
    ///
    /// Entity Framework Core database context

    /// Entity Framework Core的数据库上下文

    ///
    public class EFCoreDbContext : EFCoreDbContextBase,IDatabaseContext
    {
        ///
        /// Entity Framework Core transaction

        /// Entity Framework Core的事务

        ///
        protected IDbContextTransaction Transaction { get; set; }
        ///
        /// Transaction level counter

        /// 事务的嵌套计数

        ///
        protected int TransactionLevel;
        ///
        /// ORM name

        /// ORM名称

        ///
        public string ORM => ConstORM;
        internal const string ConstORM = "EFCore";

        ///
        /// Database type

        /// 数据库类型

        ///
        string IDatabaseContext.Database => database;

        protected string database;

        ///
        /// Underlying database connection

        /// 底层的数据库连接

        ///
        public object DbConnection => Database.GetDbConnection();

        ///
        /// Database Initialize Handlers

        /// 数据库初始化处理器的列表

        ///
        protected IList<IDatabaseInitializeHandler> Handlers { get; set; }
        ///
        /// Entity Mapping Providers

        /// 实体映射构建器的列表

        ///
        protected IList<IEntityMappingProvider> Providers { get; set; }
        ///
        /// Database context pool

        /// 数据库上下文的缓存池

        ///
        protected internal EFCoreDbContextPool Pool { get; set; }

        /// <inheritdoc />
        ///
        /// 初始化
        ///
        /// <param name="databaseType"></param>
        /// <param name="connectionString"></param>
        /// <param name="handlers"></param>
        /// <param name="providers"></param>
        public EFCoreDbContext(string databaseType, string connectionString, IList<IDatabaseInitializeHandler> handlers,
            IList<IEntityMappingProvider> providers) : base(databaseType, connectionString)
        {
            Transaction = null;
            TransactionLevel = 0;
            database = databaseType;
            Handlers = handlers;
            Providers = providers;
        }

        /// <inheritdoc />
        ///
        /// Configure entity model

        /// 配置实体模型

        ///
        /// <param name="modelBuilder">Model builder</param>
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            var entityProviders = Providers.GroupBy(p =>
                ReflectionUtils.GetGenericArguments(p.GetType(), typeof(IEntityMappingProvider<>))[0]).ToList();
            foreach (var group in entityProviders)
            {
                Activator.CreateInstance(
                    typeof(EFCoreEntityMappingBuilder<>).MakeGenericType(group.Key),
                    modelBuilder, Handlers, group.AsEnumerable());
            }
        }

        /// <inheritdoc />
        ///
        /// Dispose transaction, if pool exist then try return to pool, otherwise dispose the context

        /// 释放事务, 如果池存在则尝试返回给池, 否则释放上下文

        ///
        public override void Dispose()
        {
            Transaction?.Dispose();
            Transaction = null;
            if (Pool != null && Pool.Return(this))
            {
                // Returned to pool
            }
            else
            {
                base.Dispose();
            }
        }

        /// <inheritdoc />
        ///
        /// Begin a transaction

        /// 开始一个事务

        ///
        public void BeginTransaction(IsolationLevel? isolationLevel = null)
        {
            var level = Interlocked.Increment(ref TransactionLevel);
            if (level == 1)
            {
                if (Transaction != null)
                {
                    throw new InvalidOperationException("Transaction exists");
                }
                Transaction = (isolationLevel == null) ?
                    Database.BeginTransaction() :
                    Database.BeginTransaction(isolationLevel.Value);
            }
        }

        /// <inheritdoc />
        ///
        /// Finish the transaction

        /// 结束一个事务

        ///
        public void FinishTransaction()
        {
            var level = Interlocked.Decrement(ref TransactionLevel);
            if (level == 0)
            {
                if (Transaction == null)
                {
                    throw new InvalidOperationException("Transaction not exists");
                }
                Transaction.Commit();
                Transaction.Dispose();
                Transaction = null;
            }
            else if (level < 0)
            {
                Interlocked.Exchange(ref level, 0);
                throw new InvalidOperationException(
                    "You can't call FinishTransaction more times than BeginTransaction");
            }
        }

        /// <inheritdoc />
        ///
        /// Get the query object for specific entity type

        /// 获取指定实体类型的查询对象

        ///
        public IQueryable<T> Query<T>()
            where T : class, IEntity
        {
            return Set<T>();
        }

        #region 同步查询方法

        /// <inheritdoc />
        ///
        /// Get single entity that matched the given predicate

        /// It should return null if no matched entity found

        /// 获取符合传入条件的单个实体

        /// 如果无符合条件的实体应该返回null

        ///
        public T Get<T>(Expression<Func<T, bool>> predicate)
            where T : class, IEntity
        {
            return Query<T>().FirstOrDefault(predicate);
        }

        /// <inheritdoc />
        ///
        /// Get how many entities that matched the given predicate

        /// 获取符合传入条件的实体数量

        ///
        public long Size<T>(Expression<Func<T, bool>> predicate)
            where T : class, IEntity
        {
            return Query<T>().LongCount(predicate);
        }

        #endregion

        #region 异步查询方法

        ///
        /// Get single entity that matched the given predicate

        /// It should return null if no matched entity found

        /// 获取符合传入条件的单个实体

        /// 如果无符合条件的实体应该返回null

        public async Task<T> GetAsync<T>(Expression<Func<T, bool>> predicate) where T : class, IEntity
        {
            return await Query<T>().FirstOrDefaultAsync(predicate);
        }

        ///
        /// Get how many entities that matched the given predicate

        /// 获取符合传入条件的实体数量

        ///
        public async Task<long> SizeAsync<T>(Expression<Func<T, bool>> predicate)
            where T : class, IEntity
        {
            return await Query<T>().LongCountAsync(predicate);
        }

        #endregion

        #region 同步插入或更新方法

        ///
        /// Insert or update entity

        /// 插入或更新实体

        ///
        protected void InsertOrUpdate<T>(T entity, Action<T> update = null)
            where T : class, IEntity
        {
            var entityInfo = Entry(entity);
            update?.Invoke(entity);
            if (entityInfo.State == EntityState.Detached)
            {
                // It's not being tracked
                if (entityInfo.IsKeySet)
                {
                    // The key is not default, we're not sure it's in database or not
                    // check it first, it's rare so it shouldn't cause performance impact
                    var property = typeof(T).FastGetProperty(nameof(IEntity<object>.Id));
                    var id = property.FastGetValue(entity);
                    var expr = ExpressionUtils.MakeMemberEqualiventExpression<T>(property.Name, id);
                    if (Size(expr) > 0)
                    {
                        Update(entity);
                    }
                    else
                    {
                        Add(entity);
                    }
                }
                else
                {
                    // The key is default, set it's state to Added
                    Add(entity);
                }
            }
            else
            {
                // It's being tracked, we don't need to attach it
            }
        }

        /// <inheritdoc />
        ///
        /// Save entity to database

        /// 保存实体到数据库

        ///
        public void Save<T>(ref T entity, Action<T> update = null)
            where T : class, IEntity
        {
            var callbacks = Application.Provider.GetServices<IEntityOperationHandler<T>>().ToList();
            var entityLocal = entity; // can't use ref parameter in lambda
            callbacks.ForEach(c => c.BeforeSave(this, entityLocal)); // notify before save
            InsertOrUpdate(entityLocal, update);
            SaveChanges(); // send commands to database
            callbacks.ForEach(c => c.AfterSave(this, entityLocal)); // notify after save
            entity = entityLocal;
        }

        /// <inheritdoc />
        ///
        /// Batch save entities

        /// 批量保存实体

        ///
        public void BatchSave<T>(ref IEnumerable<T> entities, Action<T> update = null)
            where T : class, IEntity
        {
            var entitiesLocal = entities.ToList();
            var callbacks = Application.Provider.GetServices<IEntityOperationHandler<T>>().ToList();
            foreach (var entity in entitiesLocal)
            {
                callbacks.ForEach(c => c.BeforeSave(this, entity)); // notify before save
                InsertOrUpdate(entity, update);
            }
            SaveChanges(); // send commands to database
            foreach (var entity in entitiesLocal)
            {
                callbacks.ForEach(c => c.AfterSave(this, entity)); // notify after save
            }
            entities = entitiesLocal;
        }

        /// <inheritdoc />
        ///
        /// Batch update entities

        /// 批量更新实体

        ///
        public long BatchUpdate<T>(Expression<Func<T, bool>> predicate, Action<T> update)
            where T : class, IEntity
        {
            var entities = Query<T>().Where(predicate).AsEnumerable();
            BatchSave(ref entities, update);
            return entities.LongCount();
        }

        /// <inheritdoc />
        ///
        /// Batch save entities in faster way

        /// 快速批量保存实体

        ///
        public void FastBatchSave<T, TPrimaryKey>(IEnumerable<T> entities)
            where T : class, IEntity<TPrimaryKey>
        {
            foreach (var entity in entities)
            {
                InsertOrUpdate(entity);
            }
            SaveChanges(); // send commands to database
        }

        #endregion

        #region 异步插入或更新方法

        ///
        /// Insert or update entity

        /// 插入或更新实体

        ///
        //protected void InsertOrUpdateAcync<T>(T entity, Action<T> update = null)
        //    where T : class, IEntity
        //{
        //    var entityInfo = Entry(entity);
        //    update?.Invoke(entity);
        //    if (entityInfo.State == EntityState.Detached)
        //    {
        //        // It's not being tracked
        //        if (entityInfo.IsKeySet)
        //        {
        //            // The key is not default, we're not sure it's in database or not
        //            // check it first, it's rare so it shouldn't cause performance impact
        //            var property = typeof(T).FastGetProperty(nameof(IEntity<object>.Id));
        //            var id = property.FastGetValue(entity);
        //            var expr = ExpressionUtils.MakeMemberEqualiventExpression<T>(property.Name, id);
        //            if (Count(expr) > 0)
        //            {
        //                Update(entity);
        //            }
        //            else
        //            {
        //                Add(entity);
        //            }
        //        }
        //        else
        //        {
        //            // The key is default, set it's state to Added
        //            Add(entity);
        //        }
        //    }
        //    else
        //    {
        //        // It's being tracked, we don't need to attach it
        //    }
        //}

        #endregion

        #region 同步删除方法

        /// <inheritdoc />
        ///
        /// Delete entity from database

        /// 删除数据库中的实体

        ///
        public void Delete<T>(T entity)
            where T : class, IEntity
        {
            var callbacks = Application.Provider.GetServices<IEntityOperationHandler<T>>().ToList();
            callbacks.ForEach(c => c.BeforeDelete(this, entity)); // notify before delete
            Remove(entity);
            SaveChanges(); // send commands to database
            callbacks.ForEach(c => c.AfterDelete(this, entity)); // notify after delete
        }

        /// <inheritdoc />
        ///
        /// Batch delete entities

        /// 批量删除实体

        ///
        public long BatchDelete<T>(Expression<Func<T, bool>> predicate, Action<T> beforeDelete)
            where T : class, IEntity
        {
            var entities = Query<T>().Where(predicate).ToList();
            var callbacks = Application.Provider.GetServices<IEntityOperationHandler<T>>().ToList();
            foreach (var entity in entities)
            {
                beforeDelete?.Invoke(entity);
                callbacks.ForEach(c => c.BeforeDelete(this, entity)); // notify before delete
                Remove(entity);
            }
            SaveChanges(); // send commands to database
            foreach (var entity in entities)
            {
                callbacks.ForEach(c => c.AfterDelete(this, entity)); // notify after delete
            }
            return entities.Count;
        }

        /// <inheritdoc />
        ///
        /// Batch delete entities in faster way

        /// 快速批量删除实体

        ///
        public long FastBatchDelete<T, TPrimaryKey>(Expression<Func<T, bool>> predicate)
            where T : class, IEntity<TPrimaryKey>, new()
        {
            var entities = Query<T>().Where(predicate).Select(t => new T { Id = t.Id });
            var count = entities.LongCount();
            RemoveRange(entities);
            SaveChanges(); // send commands to database
            return count;
        }

        #endregion

        #region 异步删除方法
        #endregion

        /// <inheritdoc />
        ///
        /// Perform a raw update to database

        /// 执行一个原生的更新操作

        ///
        public long RawUpdate(object query, object parameters)
        {
            return Database.ExecuteSqlCommand((string)query, (object[])parameters);
        }

        /// <inheritdoc />
        ///
        /// Perform a raw query to database

        /// 执行一个原生的查询操作

        ///
        public IEnumerable<T> RawQuery<T>(object query, object parameters)
            where T : class
        {
            return Set<T>().FromSql((string)query, (object[])parameters);
        }
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<title>SQLite Query Language: CREATE TRIGGER</title>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

Small. Fast. Reliable.
Choose any three.

    About
    Sitemap
    Documentation
    Download
    License
    News
    Developers
    Support

SQL As Understood By SQLite

CREATE TRIGGER

create-trigger-stmt:

The CREATE TRIGGER statement is used to add triggers to the
database schema. Triggers are database operations
that are automatically performed when a specified database event
occurs.

A trigger may be specified to fire whenever a DELETE, INSERT,
or UPDATE of a
particular database table occurs, or whenever an UPDATE of one or more
specified columns of a table are updated.

At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH
STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional.  FOR
EACH ROW implies that the SQL statements specified in the trigger
may be executed (depending on the WHEN clause) for each database row being
inserted, updated or deleted by the statement causing the trigger to fire.

Both the WHEN clause and the trigger actions may access elements of
the row being inserted, deleted or updated using references of the form
"NEW.column-name" and "OLD.column-name", where
column-name is the name of a column from the table that the trigger
is associated with. OLD and NEW references may only be used in triggers on
events for which they are relevant, as follows:

INSERT
NEW references are valid

UPDATE
NEW and OLD references are valid

DELETE
OLD references are valid

If a WHEN clause is supplied, the SQL statements specified
are only executed for rows for which the WHEN
clause is true. If no WHEN clause is supplied, the SQL statements
are executed for all rows.

The BEFORE or AFTER keyword determines when the trigger actions
will be executed relative to the insertion, modification or removal of the
associated row.

An ON CONFLICT clause may be specified as part of an UPDATE or INSERT
action within the body of the trigger.
However if an ON CONFLICT clause is specified as part of
the statement causing the trigger to fire, then this conflict handling
policy is used instead.

Triggers are automatically dropped
when the table that they are
associated with (the table-name table) is
dropped.  However if the the trigger actions reference
other tables, the trigger is not dropped or modified if those other
tables are dropped or modified.

Triggers are removed using the DROP TRIGGER statement.

INSTEAD OF trigger

Triggers may be created on views, as well as ordinary tables, by
specifying INSTEAD OF in the CREATE TRIGGER statement.
If one or more ON INSERT, ON DELETE
or ON UPDATE triggers are defined on a view, then it is not an
error to execute an INSERT, DELETE or UPDATE statement on the view,
respectively. Thereafter,
executing an INSERT, DELETE or UPDATE on the view causes the associated
triggers to fire. The real tables underlying the view are not modified
(except possibly explicitly, by a trigger program).

Note that the sqlite3_changes() and sqlite3_total_changes() interfaces
do not count INSTEAD OF trigger firings, but the
count_changes pragma does count INSTEAD OF trigger firing.

Examples

Assuming that customer records are stored in the "customers" table, and
that order records are stored in the "orders" table, the following trigger
ensures that all associated orders are redirected when a customer changes
his or her address:

CREATE TRIGGER update_customer_address UPDATE OF address ON customers
  BEGIN
    UPDATE orders SET address = new.address WHERE customer_name = old.name;
  END;

With this trigger installed, executing the statement:

UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones';

causes the following to be automatically executed:

UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';

Rowids and BEFORE triggers

Note that currently, triggers may behave oddly when created on tables
  with INTEGER PRIMARY KEY fields. If a BEFORE trigger program modifies the
  INTEGER PRIMARY KEY field of a row that will be subsequently updated by the
  statement that causes the trigger to fire, then the update may not occur.
  The workaround is to declare the table with a PRIMARY KEY column instead
  of an INTEGER PRIMARY KEY column.

The RAISE() function

A special SQL function RAISE() may be used within a trigger-program,
with the following syntax

raise-function:

When one of the first three forms is called during trigger-program
execution, the specified ON CONFLICT processing is performed
(either ABORT, FAIL or ROLLBACK) and the current query terminates.
An error code of SQLITE_CONSTRAINT is returned to the application,
along with the specified error message.

When RAISE(IGNORE) is called, the remainder of the current trigger program,
the statement that caused the trigger program to execute and any subsequent
trigger programs that would of been executed are abandoned. No database
changes are rolled back.  If the statement that caused the trigger program
to execute is itself part of a trigger program, then that trigger program
resumes execution at the beginning of the next step.

This page last modified 2009/05/06 23:57:30 UTC


text:
document.addEventListener('DOMContentLoaded', function(){
	function echoNavLi(n){var html='';for(i=1;i<n;i++){html+="

"}return html;}

	var changImg = ai.i("change_img"),
		change_img_nav_ul = ai.i("change_img_nav_ul"),
		change_img_li = ai.a("#change_img > li"),
		changImgLength = change_img_li.length,
		nav_li=echoNavLi(changImgLength),
		img_width  = 320;

	if(ai.hv()){
		var img_width  = ai.ww();
		var img_height = img_width/(31/12);
		var arr = Array.prototype.slice.call(ai.a("#change_img > li"));
		for(var i= 0,l= changImgLength; i < l; i++ ){
			var change_img_li_now = change_img_li[i];
			change_img_li_now.style.width  = img_width + "px";
			change_img_li_now.style.height = img_height + "px";
		}
		var ui_header_slideWrap = ai.i("ui-header-slideWrap");
		ui_header_slideWrap.style.width  = img_width + "px";
		ui_header_slideWrap.style.height = img_height + "px";
	}
	changImg.style.width=''+changImgLength*img_width+'px';
	change_img_nav_ul.innerHTML='

'+nav_li+'';
	function changeScreenEndFun() {
		document.querySelector('#change_img_nav_ul > li.active').className = '';
		ai.a('#change_img_nav_ul > li')[this.page].className = 'active';
	}
	slip('page',changImg,{
	change_time: 4000,
			num: changImgLength,
	  no_follow: true,
		 endFun: changeScreenEndFun
	});

}, false);


text:
#include <iterator>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

#include "tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.h"
#include "tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.h"
#include "tensorflow/contrib/lite/toco/model.h"
#include "tensorflow/contrib/lite/toco/tooling_util.h"
#include "tensorflow/core/platform/logging.h"

namespace toco {

namespace {

bool IsSliceTrivial(const Model& model, const Operator& op,
                    RemoveTrivialSlice* transformation) {
  CHECK(op.type == OperatorType::kSlice);

  // Slices are trivial if they are slicing the entire input contents.
  const auto& input_array = model.GetArray(op.inputs[0]);
  const auto& output_array = model.GetArray(op.outputs[0]);
  if (input_array.has_shape() && output_array.has_shape()) {
    if (input_array.shape() == output_array.shape()) {
      transformation->AddMessageF(
          "%s is trivial because its input and output shapes are equal",
          LogName(op));
      return true;
    }
  }

  return false;
}

}  // namespace

::tensorflow::Status RemoveTrivialSlice::Run(Model* model, std::size_t op_index,
                                             bool* modified) {
  *modified = false;
  const auto reshape_it = model->operators.begin() + op_index;
  auto* slice_op = reshape_it->get();
  if (slice_op->type != OperatorType::kSlice) {
    return ::tensorflow::Status::OK();
  }

  if (!IsSliceTrivial(*model, *slice_op, this)) {
    return ::tensorflow::Status::OK();
  }

  AddMessageF("Removing trivial %s", LogName(*slice_op));

  CHECK_EQ(slice_op->inputs.size(), 3);
  *modified = RemoveTrivialPassthroughOp(this, model, op_index);
  return ::tensorflow::Status::OK();
}

}  // namespace toco


text:
<?php

namespace Apacz\MapBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class ApaczMapBundle extends Bundle
{
}


text:
package com.security;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.main.boot.model.User;
import com.main.boot.model.UserRepository;

@Service
public class AppUserDetailsService implements UserDetailsService {

	@Autowired
	UserRepository userRepository;

	@Override
	public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
		// TODO Auto-generated method stub
		System.out.println("loadUserByUsername " + userName);
		Optional<User> user = userRepository.findByUserName(userName);
		user.orElseThrow(() -> new UsernameNotFoundException("Not found: " + userName));
		return user.map(AppUserDetails::new).get();
	}

}


text:
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace TunnelVisionLabs.Collections.Trees.Test.List
{
    using System.Collections.Generic;
    using Xunit;

    /// <summary>
    /// Tests for <see cref="TreeList{T}.Clear()"/>, derived from tests for
    /// <see cref="List{T}.Clear()"/> in dotnet/coreclr.
    /// </summary>
    public class TreeListClear
    {
        [Fact(DisplayName = "PosTest1: Remove int elements from the list")]
        public void PosTest1()
        {
            int[] iArray = { 1, 9, 3, 6, 5, 8, 7, 2, 4, 0 };
            TreeList<int> listObject = new TreeList<int>(iArray);
            listObject.Clear();
            Assert.Empty(listObject);
        }

        [Fact(DisplayName = "PosTest2: Remove string elements from the list")]
        public void PosTest2()
        {
            string[] strArray = { "apple", "banana", "chocolate", "dog", "food" };
            TreeList<string> listObject = new TreeList<string>(strArray);
            listObject.Clear();
            Assert.Empty(listObject);
        }

        [Fact(DisplayName = "PosTest3: Remove the elements from the list of custom type")]
        public void PosTest3()
        {
            MyClass myclass1 = new MyClass();
            MyClass myclass2 = new MyClass();
            MyClass myclass3 = new MyClass();
            MyClass[] mc = new MyClass[3] { myclass1, myclass2, myclass3 };
            TreeList<MyClass> listObject = new TreeList<MyClass>(mc);
            listObject.Clear();
            Assert.Empty(listObject);
        }

        [Fact(DisplayName = "PosTest4: Remove the elements from the empty list")]
        public void PosTest4()
        {
            TreeList<MyClass> listObject = new TreeList<MyClass>();
            listObject.Clear();
            Assert.Empty(listObject);
        }

        public class MyClass
        {
        }
    }
}


text:
# no-eol-whitespace

Disallow end-of-line whitespace.

```css
a { color: pink; }···
/**               ↑
 *  This whitespace */
```

## Options

### `true`

The following patterns are considered warnings:

```css
a { color: pink; }·
```

```css
a { color: pink; }····
```

Comment strings are also checked -- so the following is a warning:

```css
/* something····
 * something else */
```

The following patterns are *not* considered warnings:

```css
a { color: pink; }
```

```css
/* something
 * something else */
```

## Optional secondary options

### `ignore: ["empty-lines"]`

#### `"empty-lines"`

Allow end-of-line whitespace for lines that are only whitespace, "empty" lines.

The following patterns are *not* considered warnings:

```css
a {
  color: pink;
··
  background: orange;
}
```

```css
····
```

```css
a { color: pink; }
····
```


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Welcome to asamended's documentation! — asamended 0 documentation</title>

  <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>

    <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />

    <link rel="top" title="asamended 0 documentation" href="#"/>
        <link rel="next" title="Quick Start" href="quickstart.html"/>

         asamended
        <form class="wy-form" action="search.html" method="get">
  <input type="text" name="q" placeholder="Search docs" />
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form>

Quick Start

Getting Setup

Trying Things Out

        asamended

Docs »

Welcome to asamended’s documentation!

Welcome to asamended’s documentation!¶

Contents:

Quick Start

Getting Setup

Trying Things Out

Indices and tables¶

Index

Module Index

Search Page

        Next

      © Copyright 2014, AsAmended.com.

  Sphinx theme provided by Read the Docs


text:
 package org.castafiore.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.castafiore.InvalidApplicationConfigurationException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SpringApplicationRegistry implements ApplicationRegistry, ApplicationContextAware {

	private ApplicationContext context_ = null;

	public Application getApplication(HttpServletRequest request, HttpServletResponse response) {
		String applicationId = request.getParameter("casta_applicationid");
		if(applicationId == null){
			throw new RuntimeException("cannot load application. Please specify parameter casta_applicationid=<appname>");
		}
		try
		{

			Application application = (Application)context_.getBean(applicationId);
			return application;
		}
		catch(ClassCastException cce){
			throw new InvalidApplicationConfigurationException("The application " + applicationId + " configured in application context is not of type Application", cce);
		}
	}

	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.context_ = applicationContext;

	}

}


text:
from django.shortcuts import render, redirect
from django.http import HttpResponse
#DB Imports
from django.db import models
from files.models import files, stats, feedback, searches
from django.contrib.auth.models import User
from user.models import UserProfile, Communities
#Authentication
from django.contrib.auth import authenticate
from django.contrib.auth.decorators import login_required
#Querying
from ast import literal_eval as make_tuple
from django.utils import timezone
from datetime import date
import json
from django.db.models import Q
import random
#from django.core.urlresolvers import reverse
from django.contrib.staticfiles.templatetags.staticfiles import static

def test(request):
    return render(request,'files/home_logged.html')

#Homepage for the site
def index(request):
    if request.user.is_authenticated == False:
        return redirect('/login')
    if request.user.is_superuser == False or request.user.is_staff == False:
        try:
            views = stats.objects.get(date=date.today())
            views.hits = views.hits + 1
            views.save()
        except stats.DoesNotExist:
            views = stats(hits=1)
            views.save()
    return render(request,'files/home.html')

@login_required
def upload(request):
    kek = []
    for k in request.POST:
        kek = k
    kek.replace(kek[0],"")
    kek.replace(kek[-1],"")
    kek =  json.loads(kek)
    total_types = ['dmg', 'iso', 'mkv', 'avi', 'mp3', 'mp4', 'cbr', 'pdf', '3gp', 'ogg',  'm4a', 'm4v', 'mov', 'flv',
      'mpg', 'vob', 'aac', 'dvx', ' 7z', 'rar', 'zip','pub','obi','peg','flac', ' gz', 'tar', 'deb']
    tags = {'dmg':'Software', 'iso':'Software', ' 7z':'Software', 'rar':'Software', 'zip':'Software',' gz':'Software', 'tar':'Software', 'deb':'Software','mkv':'Videos', 'avi':'Videos',  'mp4':'Videos', '3gp':'Videos', 'm4v':'Videos', 'mov':'Videos', 'flv':'Videos','mpg':'Videos', 'vob':'Videos','aac':'Audio', 'dvx':'Videos','peg':'Videos','cbr':'Ebooks', 'pdf':'Ebooks', 'pub':'Ebooks','obi':'Ebooks','lac':'Audio','ogg':'Audio','m4a':'Audio','mp3':'Audio'}
    user = UserProfile.objects.get(user__username__exact=request.user)
    existing_files = user.files_set.all()
    #Test cases for quality control
    for i in kek:
        file_type = ''
        #File type check via extension
        if i['file_name'][-3:] in total_types:
            file_type = i['file_name'][-3:]
            i['file_name'] = i['file_name'][:-4]
        elif i['file_name'][-4:] in total_types:
            file_type = i['file_name'][-4:]
            i['file_name'] = i['file_name'][:-5]
        #This has become ineffective with pg_trgm search
        else:
            continue
        if existing_files.filter(file_name__exact=i['file_name']).exists():
            continue
        #Eliminating small files
        if str(i['size'])[-2:] not in ['MB','GB','TB']:
            continue
        #Eliminating keywords
        if 'sample' in i['file_name']:
            continue
        b = files(file_name=str(i['file_name']),size=str(i['size']),user=user,file_type=str(file_type))
        b.save()
    return render (request, 'files/search.html', {'post':"
Yay! All files have been listed. Thanks for pitching in. :)
"})

def search(request):
    #init
    query=request.POST['search']
    existing_files = files.objects.all()
    result = []
    peeps = []
    comms = []
    tag = request.POST['tag']
    #Not random
    if query != "":
        if tag == 'all':
            result = files.objects.filter(file_name__icontains=query)[:100].values('file_name','file_type','size','user__user__first_name','user__user__last_name','user__user__email','user__user__username','user__phone_no','user__room_no')
        #Sorting the results based on queries
        else:
            #Equating the number of queries based on tags given
            equate = 100//len(tag)
            for i in tag:
                result += files.objects.filter(file_name__icontains=query,file_type__icontains=tag)[:equate].values('file_name','file_type','size','user__user__first_name','user__user__last_name','user__user__email','user__user__username','user__phone_no','user__room_no')
    #Random cuz the 'query' in POST data is empty
    else:
        id_list = existing_files.values('id')
        count = files.objects.count()
        count = count
        for i in range(100):
            id = random.randint(0,count)
            try:
                a = existing_files.filter(id=id_list[id]['id']).values('file_name','file_type','size','user__user__first_name','user__user__last_name','user__user__email','user__user__username','user__phone_no','user__room_no')
                for b in a:
                    result.append(b)
            except:
                continue
    #No files found
    if not result:
        if request.user.is_superuser == False or request.user.is_staff == False:
            search_hit = searches(date=timezone.now(),query=query,listed=False)
            search_hit.save()
        #Doge pic cuz search failed
        return render(request,'files/search.html',{'doge':static('img/doge'+ str(random.randint(1,17)) +'.jpg'),'file':result,'peeps':peeps,'comms':comms})
    #Yay, files are found
    else:
        if request.user.is_superuser == False or request.user.is_staff == False:
            search_hit = searches(date=timezone.now(),query=query,listed=True)
            search_hit.save()
        return render(request,'files/search.html',{'file':result,'peeps':peeps,'comms':comms})

#Captain's page
def captain(request):
    if request.user.is_superuser:
        search_dict = searches.objects.all()
        users = User.objects.all()
        file_count = files.objects.count()
        hits = stats.objects.all().order_by('-date')[:100].values()
        kids = users.count()
        total_view =  stats.objects.aggregate(models.Sum('hits'))
        total_search =  search_dict.count()
        comm =  Communities.objects.count()
        listed =  search_dict.filter(listed='True').count()
        not_listed =  search_dict.filter(listed='False').count()
        msgs = feedback.objects.all().order_by('-date').values('date','msg','name','user__user__first_name','user__user__last_name')[:10]
        queries = search_dict.order_by('-date').values('query','date','listed')[:100]
        users = users.order_by('-date_joined').values('username','first_name','last_name','email','date_joined')[:10]
        return render(request, 'files/admin.html',{'hits':hits,'files':file_count,'kids':kids,'total_view':total_view['hits__sum'],
            'queries':queries,'total_search':total_search,'listed':listed,'not_listed':not_listed,'feedback':msgs,'comm':comm,'users':users})
    else:
       return redirect("/")

#Method to store feedback taken after listing and searches
def review(request):
    profile = UserProfile.objects.get(user=request.user)
    a = request.POST
    msg = feedback(name=a['name'],msg=a['msg'],date=timezone.now(),user=profile)
    msg.save()
    return render(request,"files/home   .html",{'msg':'
Your feedback has been successfully saved. Thank you.
'})

#Method to delete an individual file from the profile page
@login_required
def file_delete(request):
    file_deleted = files.objects.all().get(id=request.POST['file_id'])
    file_deleted.delete()
    profile = UserProfile.objects.get(user=request.user)
    return HttpResponse(profile.files_set.all().count())

#Method to delete all files from the profile page
@login_required
def file_delete_all(request):
    profile = UserProfile.objects.get(user=request.user)
    profile.files_set.all().delete()
    profile.save()
    return redirect('/profile')

@login_required
def file_update(request):
    file_updated = files.objects.all().get(id=request.POST['file_id'])
    file_updated.file_name = request.POST['file_name']
    file_updated.save()
    return HttpResponse('sexy')

def auto_search(request,query):
    query = list(files.objects.filter(file_name__icontains=query).order_by('file_name').values_list('file_name')[:10])
   # query = files.objects.filter(file_name__icontains=query).order_by('file_name')[:10]
    #query = str(query)
    #query = query.join(',')
    #query.replace(query[0],"")
    #query.replace(query[-1],"")
    #query = query.split(')(')
   # query = json.dumps(query)
   # query = serializers.serialize('json',query)
    return HttpResponse(query, content_type='application/json')


text:
namespace dr100 { // dr100: yes
  template<const char *> struct A {}; // expected-note 0-1{{declared here}}
  template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}}
  A<"foo"> a; // expected-error {{does not refer to any declaration}}
  B<"bar"> b; // expected-error {{does not refer to any declaration}}
}

namespace dr101 { // dr101: 3.5
  extern "C" void dr101_f();
  typedef unsigned size_t;
  namespace X {
    extern "C" void dr101_f();
    typedef unsigned size_t;
  }
  using X::dr101_f;
  using X::size_t;
  extern "C" void dr101_f();
  typedef unsigned size_t;
}

namespace dr102 { // dr102: yes
  namespace A {
    template<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
  }
  namespace B {
    struct S {};
  }
  B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}}
  template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}}
}

// dr103: na
// dr104 FIXME: add codegen test
// dr105: na

namespace dr106 { // dr106: sup 540
  typedef int &r1;
  typedef r1 &r1;
  typedef const r1 r1; // expected-warning {{has no effect}}
  typedef const r1 &r1; // expected-warning {{has no effect}}

  typedef const int &r2;
  typedef r2 &r2;
  typedef const r2 r2; // expected-warning {{has no effect}}
  typedef const r2 &r2; // expected-warning {{has no effect}}
}

namespace dr107 { // dr107: yes
  struct S {};
  extern "C" S operator+(S, S) { return S(); }
}

namespace dr108 { // dr108: yes
  template<typename T> struct A {
    struct B { typedef int X; };
    B::X x; // expected-error {{missing 'typename'}}
    struct C : B { X x; }; // expected-error {{unknown type name}}
  };
  template<> struct A<int>::B { int X; };
}

namespace dr109 { // dr109: yes
  struct A { template<typename T> void f(T); };
  template<typename T> struct B : T {
    using T::template f; // expected-error {{using declaration cannot refer to a template}}
    void g() { this->f<int>(123); } // expected-error {{use 'template'}}
  };
}

namespace dr111 { // dr111: dup 535
  struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); };
  struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}}
  const B b1;
  B b2(b1); // expected-error {{no matching constructor}}
}

namespace dr112 { // dr112: yes
  struct T { int n; };
  typedef T Arr[1];

  const T a1[1] = {};
  volatile T a2[1] = {};
  const Arr a3 = {};
  volatile Arr a4 = {};
  template<const volatile T*> struct X {};
  X<a1> x1;
  X<a2> x2;
  X<a3> x3;
  X<a4> x4;
#if __cplusplus < 201103L
  // expected-error@-5 {{internal linkage}} expected-note@-10 {{here}}
  // expected-error@-4 {{internal linkage}} expected-note@-9 {{here}}
#else
  // FIXME: Test this somehow.
#endif
}

namespace dr113 { // dr113: yes
  extern void (*p)();
  void f() {
    no_such_function(); // expected-error {{undeclared}}
    p();
  }
  void g();
  void (*p)() = &g;
}

namespace dr114 { // dr114: yes
  struct A {
    virtual void f(int) = 0; // expected-note {{unimplemented}}
  };
  struct B : A {
    template<typename T> void f(T);
    void g() { f(0); }
  } b; // expected-error {{abstract}}
}

namespace dr115 { // dr115: yes
  template<typename T> int f(T); // expected-note +{{}}
  template<typename T> int g(T); // expected-note +{{}}
  template<typename T> int g(T, int); // expected-note +{{}}

  int k1 = f(&f); // expected-error {{no match}}
  int k2 = f(&f<int>);
  int k3 = f(&g<int>); // expected-error {{no match}}

  void h() {
    (void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}}
    (void)&f<int>;
    (void)&g<int>; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}}

    &f; // expected-error {{reference to overloaded function could not be resolved}}
    &f<int>; // expected-warning {{unused}}
    &g<int>; // expected-error {{reference to overloaded function could not be resolved}}
  }

  struct S {
    template<typename T> static int f(T);
    template<typename T> static int g(T);
    template<typename T> static int g(T, int);
  } s;

  int k4 = f(&s.f); // expected-error {{non-constant pointer to member}}
  int k5 = f(&s.f<int>);
  int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}

  void i() {
    (void)&s.f; // expected-error {{non-constant pointer to member}}
    (void)&s.f<int>;
    (void)&s.g<int>; // expected-error {{non-constant pointer to member}}

    &s.f; // expected-error {{non-constant pointer to member}}
    &s.f<int>; // expected-warning {{unused}}
    &s.g<int>; // expected-error {{non-constant pointer to member}}
  }

  struct T {
    template<typename T> int f(T);
    template<typename T> int g(T);
    template<typename T> int g(T, int);
  } t;

  int k7 = f(&s.f); // expected-error {{non-constant pointer to member}}
  int k8 = f(&s.f<int>);
  int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}

  void j() {
    (void)&s.f; // expected-error {{non-constant pointer to member}}
    (void)&s.f<int>;
    (void)&s.g<int>; // expected-error {{non-constant pointer to member}}

    &s.f; // expected-error {{non-constant pointer to member}}
    &s.f<int>; // expected-warning {{unused}}
    &s.g<int>; // expected-error {{non-constant pointer to member}}
  }

#if __cplusplus >= 201103L
  // Special case kicks in only if a template argument list is specified.
  template<typename T=int> void with_default(); // expected-note +{{}}
  int k10 = f(&with_default); // expected-error {{no matching function}}
  int k11 = f(&with_default<>);
  void k() {
    (void)&with_default; // expected-error {{overloaded function}}
    (void)&with_default<>;
    &with_default; // expected-error {{overloaded function}}
    &with_default<>; // expected-warning {{unused}}
  }
#endif
}

namespace dr116 { // dr116: yes
  template<int> struct A {};
  template<int N> void f(A<N>) {} // expected-note {{previous}}
  template<int M> void f(A<M>) {} // expected-error {{redefinition}}
  template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}}
  template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}}
}

// dr117: na
// dr118 FIXME: add codegen test
// dr119: na
// dr120: na

namespace dr121 { // dr121: yes
  struct X {
    template<typename T> struct Y {};
  };
  template<typename T> struct Z {
    X::Y<T> x;
    T::Y<T> y; // expected-error +{{}}
  };
  Z<X> z;
}

namespace dr122 { // dr122: yes
  template<typename T> void f();
  void g() { f<int>(); }
}

// dr123: na
// dr124: dup 201

// dr125: yes
struct dr125_A { struct dr125_B {}; }; // expected-note {{here}}
dr125_A::dr125_B dr125_C();
namespace dr125_B { dr125_A dr125_C(); }
namespace dr125 {
  struct X {
    friend dr125_A::dr125_B (::dr125_C)(); // ok
    friend dr125_A (::dr125_B::dr125_C)(); // ok
    friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}}
    // expected-warning@-1 {{missing exception specification}}
#if __cplusplus >= 201103L
    // expected-error@-3 {{follows constexpr declaration}} expected-note@-10 {{here}}
#endif
  };
}

namespace dr126 { // dr126: no
  struct C {};
  struct D : C {};
  struct E : private C { friend class A; friend class B; };
  struct F : protected C {};
  struct G : C {};
  struct H : D, G {};

  struct A {
    virtual void cp() throw(C*);
    virtual void dp() throw(C*);
    virtual void ep() throw(C*); // expected-note {{overridden}}
    virtual void fp() throw(C*); // expected-note {{overridden}}
    virtual void gp() throw(C*);
    virtual void hp() throw(C*); // expected-note {{overridden}}

    virtual void cr() throw(C&);
    virtual void dr() throw(C&);
    virtual void er() throw(C&); // expected-note {{overridden}}
    virtual void fr() throw(C&); // expected-note {{overridden}}
    virtual void gr() throw(C&);
    virtual void hr() throw(C&); // expected-note {{overridden}}

    virtual void pv() throw(void*); // expected-note {{overridden}}

#if __cplusplus >= 201103L
    virtual void np() throw(C*); // expected-note {{overridden}}
    virtual void npm() throw(int C::*); // expected-note {{overridden}}
    virtual void nr() throw(C&); // expected-note {{overridden}}
#endif

    virtual void ref1() throw(C *const&);
    virtual void ref2() throw(C *);

    virtual void v() throw(int);
    virtual void w() throw(const int);
    virtual void x() throw(int*);
    virtual void y() throw(const int*);
    virtual void z() throw(int); // expected-note {{overridden}}
  };
  struct B : A {
    virtual void cp() throw(C*);
    virtual void dp() throw(D*);
    virtual void ep() throw(E*); // expected-error {{more lax}}
    virtual void fp() throw(F*); // expected-error {{more lax}}
    virtual void gp() throw(G*);
    virtual void hp() throw(H*); // expected-error {{more lax}}

    virtual void cr() throw(C&);
    virtual void dr() throw(D&);
    virtual void er() throw(E&); // expected-error {{more lax}}
    virtual void fr() throw(F&); // expected-error {{more lax}}
    virtual void gr() throw(G&);
    virtual void hr() throw(H&); // expected-error {{more lax}}

    virtual void pv() throw(C*); // expected-error {{more lax}} FIXME: This is valid.

#if __cplusplus >= 201103L
    using nullptr_t = decltype(nullptr);
    virtual void np() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid.
    virtual void npm() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid.
    virtual void nr() throw(nullptr_t&); // expected-error {{more lax}} This is not.
#endif

    virtual void ref1() throw(D *const &);
    virtual void ref2() throw(D *);

    virtual void v() throw(const int);
    virtual void w() throw(int);
    virtual void x() throw(const int*); // FIXME: 'const int*' is not allowed by A::h.
    virtual void y() throw(int*); // ok
    virtual void z() throw(long); // expected-error {{more lax}}
  };
}

namespace dr127 { // dr127: yes
  __extension__ typedef __decltype(sizeof(0)) size_t;
  template<typename T> struct A {
    A() throw(int);
    void *operator new(size_t, const char * = 0);
    void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}}
    void operator delete(void *) { T::error; }
  };
  A<void> *p = new A<void>; // expected-note {{instantiat}}
  A<int> *q = new ("") A<int>; // expected-note {{instantiat}}
}

namespace dr128 { // dr128: yes
  enum E1 { e1 } x = e1;
  enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1);
}

// dr129: dup 616
// dr130: na

namespace dr131 { // dr131: yes
  const char *a_with_\u0e8c = "\u0e8c";
  const char *b_with_\u0e8d = "\u0e8d";
  const char *c_with_\u0e8e = "\u0e8e";
#if __cplusplus < 201103L
  // expected-error@-4 {{expected ';'}} expected-error@-2 {{expected ';'}}
#endif
}

namespace dr132 { // dr132: no
  void f() {
    extern struct {} x; // ok
    extern struct S {} y; // FIXME: This is invalid.
  }
  static enum { E } e;
}

// dr133: dup 87
// dr134: na

namespace dr135 { // dr135: yes
  struct A {
    A f(A a) { return a; }
    friend A g(A a) { return a; }
    static A h(A a) { return a; }
  };
}

namespace dr136 { // dr136: 3.4
  void f(int, int, int = 0); // expected-note {{previous declaration is here}}
  void g(int, int, int); // expected-note {{previous declaration is here}}
  struct A {
    friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
    friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
    friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}}
    friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}}
    friend void j(int, int, int = 0) {}
    operator int();
  };
  void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
  void q() {
    j(A(), A()); // ok, has default argument
  }
  extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}}
  namespace NSA {
  struct A {
    friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} \
                                                  // expected-note {{previous declaration is here}}
  };
  }
  namespace NSB {
  struct A {
    friend void dr136::k(int, int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
  };
  }
  struct B {
    void f(int); // expected-note {{previous declaration is here}}
  };
  struct C {
    friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
  };
}

namespace dr137 { // dr137: yes
  extern void *p;
  extern const void *cp;
  extern volatile void *vp;
  extern const volatile void *cvp;
  int *q = static_cast<int*>(p);
  int *qc = static_cast<int*>(cp); // expected-error {{casts away qualifiers}}
  int *qv = static_cast<int*>(vp); // expected-error {{casts away qualifiers}}
  int *qcv = static_cast<int*>(cvp); // expected-error {{casts away qualifiers}}
  const int *cq = static_cast<const int*>(p);
  const int *cqc = static_cast<const int*>(cp);
  const int *cqv = static_cast<const int*>(vp); // expected-error {{casts away qualifiers}}
  const int *cqcv = static_cast<const int*>(cvp); // expected-error {{casts away qualifiers}}
  const volatile int *cvq = static_cast<const volatile int*>(p);
  const volatile int *cvqc = static_cast<const volatile int*>(cp);
  const volatile int *cvqv = static_cast<const volatile int*>(vp);
  const volatile int *cvqcv = static_cast<const volatile int*>(cvp);
}

namespace dr139 { // dr139: yes
  namespace example1 {
    typedef int f; // expected-note {{previous}}
    struct A {
      friend void f(A &); // expected-error {{different kind of symbol}}
    };
  }

  namespace example2 {
    typedef int f;
    namespace N {
      struct A {
        friend void f(A &);
        operator int();
        void g(A a) { int i = f(a); } // ok, f is typedef not friend function
      };
    }
  }
}

namespace dr140 { // dr140: yes
  void f(int *const) {} // expected-note {{previous}}
  void f(int[3]) {} // expected-error {{redefinition}}
  void g(const int);
  void g(int n) { n = 2; }
}

namespace dr141 { // dr141: yes
  template<typename T> void f();
  template<typename T> struct S { int n; };
  struct A : S<int> {
    template<typename T> void f();
    template<typename T> struct S {};
  } a;
  struct B : S<int> {} b;
  void g() {
    a.f<int>();
    (void)a.S<int>::n; // expected-error {{no member named 'n'}}
#if __cplusplus < 201103L
    // expected-error@-2 {{ambiguous}}
    // expected-note@-11 {{lookup from the current scope}}
    // expected-note@-9 {{lookup in the object type}}
#endif
    b.f<int>(); // expected-error {{no member}} expected-error +{{}}
    (void)b.S<int>::n;
  }
  template<typename T> struct C {
    T t;
    void g() {
      t.f<int>(); // expected-error {{use 'template'}}
    }
    void h() {
      (void)t.S<int>::n; // ok
    }
    void i() {
      (void)t.S<int>(); // ok!
    }
  };
  void h() { C<B>().h(); } // ok
  struct X {
    template<typename T> void S();
  };
  void i() { C<X>().i(); } // ok!!
}

namespace dr142 { // dr142: yes
  class B { // expected-note +{{here}}
  public:
    int mi; // expected-note +{{here}}
    static int si; // expected-note +{{here}}
  };
  class D : private B { // expected-note +{{here}}
  };
  class DD : public D {
    void f();
  };
  void DD::f() {
    mi = 3; // expected-error {{private base class}} expected-error {{private member}}
    si = 3; // expected-error {{private member}}
    B b_old; // expected-error {{private member}}
    dr142::B b;
    b.mi = 3;
    b.si = 3;
    B::si = 3; // expected-error {{private member}}
    dr142::B::si = 3;
    B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}}
    dr142::B *bp1 = this; // expected-error {{private base class}}
    B *bp2_old = (B*)this; // expected-error 2{{private member}}
    dr142::B *bp2 = (dr142::B*)this;
    bp2->mi = 3;
  }
}

namespace dr143 { // dr143: yes
  namespace A { struct X; }
  namespace B { void f(A::X); }
  namespace A {
    struct X { friend void B::f(X); };
  }
  void g(A::X x) {
    f(x); // expected-error {{undeclared identifier 'f'}}
  }
}

namespace dr145 { // dr145: yes
  void f(bool b) {
    ++b; // expected-warning {{deprecated}}
    b++; // expected-warning {{deprecated}}
  }
}

namespace dr147 { // dr147: no
  namespace example1 {
    template<typename> struct A {
      template<typename T> A(T);
    };
    // FIXME: This appears to be valid, and EDG and G++ accept.
    template<> template<> A<int>::A<int>(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}}
  }
  namespace example2 {
    struct A { A(); };
    struct B : A { B(); };
    A::A a1; // expected-error {{is a constructor}}
    B::A a2;
  }
  namespace example3 {
    template<typename> struct A {
      template<typename T> A(T);
      static A a;
    };
    template<> A<int>::A<int>(A<int>::a); // expected-error {{is a constructor}}
  }
}

namespace dr148 { // dr148: yes
  struct A { int A::*p; };
  int check1[__is_pod(int(A::*)) ? 1 : -1];
  int check2[__is_pod(A) ? 1 : -1];
}

// dr149: na

namespace dr151 { // dr151: yes
  struct X {};
  typedef int X::*p;
#if __cplusplus < 201103L
#define fold(x) (__builtin_constant_p(0) ? (x) : (x))
#else
#define fold
#endif
  int check[fold(p() == 0) ? 1 : -1];
#undef fold
}

namespace dr152 { // dr152: yes
  struct A {
    A(); // expected-note {{not viable}}
    explicit A(const A&);
  };
  A a1 = A(); // expected-error {{no matching constructor}}
  A a2((A()));
}

// dr153: na

namespace dr154 { // dr154: yes
  union { int a; }; // expected-error {{must be declared 'static'}}
  namespace {
    union { int b; };
  }
  static union { int c; };
}

namespace dr155 { // dr155: dup 632
  struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}}
}

// dr158 FIXME write codegen test

namespace dr159 { // dr159: 3.5
  namespace X { void f(); }
  void f();
  void dr159::f() {} // expected-warning {{extra qualification}}
  void dr159::X::f() {}
}

// dr160: na

namespace dr161 { // dr161: yes
  class A {
  protected:
    struct B { int n; } b; // expected-note 2{{here}}
    static B bs;
    void f(); // expected-note {{here}}
    static void sf();
  };
  struct C : A {};
  struct D : A {
    void g(C c) {
      (void)b.n;
      B b1;
      C::B b2; // ok, accessible as a member of A
      (void)&C::b; // expected-error {{protected}}
      (void)&C::bs;
      (void)c.b; // expected-error {{protected}}
      (void)c.bs;
      f();
      sf();
      c.f(); // expected-error {{protected}}
      c.sf();
      A::f();
      D::f();
      A::sf();
      C::sf();
      D::sf();
    }
  };
}

namespace dr162 { // dr162: no
  struct A {
    char &f(char);
    static int &f(int);

    void g() {
      int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
      char &b = (&A::f)('0'); // expected-error {{could not be resolved}}
    }
  };

  int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
  char &d = (&A::f)('0'); // expected-error {{could not be resolved}}
}

// dr163: na

namespace dr164 { // dr164: yes
  void f(int);
  template <class T> int g(T t) { return f(t); }

  enum E { e };
  int f(E);

  int k = g(e);
}

namespace dr165 { // dr165: no
  namespace N {
    struct A { friend struct B; };
    void f() { void g(); }
  }
  // FIXME: dr1477 says this is ok, dr165 says it's ill-formed
  struct N::B {};
  // FIXME: dr165 says this is ill-formed, but the argument in dr1477 says it's ok
  void N::g() {}
}

namespace dr166 { // dr166: yes
  namespace A { class X; }

  template<typename T> int f(T t) { return t.n; }
  int g(A::X);
  template<typename T> int h(T t) { return t.n; } // expected-error {{private}}
  int i(A::X);

  namespace A {
    class X {
      friend int f<X>(X);
      friend int dr166::g(X);
      friend int h(X);
      friend int i(X);
      int n; // expected-note 2{{here}}
    };

    int h(X x) { return x.n; }
    int i(X x) { return x.n; }
  }

  template int f(A::X);
  int g(A::X x) { return x.n; }
  template int h(A::X); // expected-note {{instantiation}}
  int i(A::X x) { return x.n; } // expected-error {{private}}
}

// dr167: sup 1012

namespace dr168 { // dr168: no
  extern "C" typedef int (*p)();
  extern "C++" typedef int (*q)();
  struct S {
    static int f();
  };
  p a = &S::f; // FIXME: this should fail.
  q b = &S::f;
}

namespace dr169 { // dr169: yes
  template<typename> struct A { int n; };
  struct B {
    template<typename> struct C;
    template<typename> void f();
    template<typename> static int n; // expected-error 0-1{{extension}}
  };
  struct D : A<int>, B {
    using A<int>::n;
    using B::C<int>; // expected-error {{using declaration cannot refer to a template specialization}}
    using B::f<int>; // expected-error {{using declaration cannot refer to a template specialization}}
    using B::n<int>; // expected-error {{using declaration cannot refer to a template specialization}}
  };
}

namespace { // dr171: yes
  int dr171a;
}
int dr171b; // expected-note {{here}}
namespace dr171 {
  extern "C" void dr171a();
  extern "C" void dr171b(); // expected-error {{conflicts}}
}

namespace dr172 { // dr172: yes
  enum { zero };
  int check1[-1 < zero ? 1 : -1];

  enum { x = -1, y = (unsigned int)-1 };
  int check2[sizeof(x) > sizeof(int) ? 1 : -1];

  enum { a = (unsigned int)-1 / 2 };
  int check3a[sizeof(a) == sizeof(int) ? 1 : -1];
  int check3b[-a < 0 ? 1 : -1];

  enum { b = (unsigned int)-1 / 2 + 1 };
  int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1];
  int check4b[-b > 0 ? 1 : -1];

  enum { c = (unsigned long)-1 / 2 };
  int check5a[sizeof(c) == sizeof(long) ? 1 : -1];
  int check5b[-c < 0 ? 1 : -1];

  enum { d = (unsigned long)-1 / 2 + 1 };
  int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1];
  int check6b[-d > 0 ? 1 : -1];

  enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}}
  int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}}
  int check7b[-e < 0 ? 1 : -1];

  enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}}
  int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}}
  int check8b[-f > 0 ? 1 : -1];
}

namespace dr173 { // dr173: yes
  int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' &&
             '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' &&
             '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1];
}

// dr174: sup 1012

namespace dr175 { // dr175: yes
  struct A {}; // expected-note {{here}}
  struct B : private A {}; // expected-note {{constrained by private inheritance}}
  struct C : B {
    A a; // expected-error {{private}}
    dr175::A b;
  };
}

namespace dr176 { // dr176: yes
  template<typename T> class Y;
  template<> class Y<int> {
    void f() {
      typedef Y A; // expected-note {{here}}
      typedef Y<char> A; // expected-error {{different types ('Y<char>' vs 'Y<int>')}}
    }
  };

  template<typename T> struct Base {}; // expected-note 2{{found}}
  template<typename T> struct Derived : public Base<T> {
    void f() {
      typedef typename Derived::template Base<T> A;
      typedef typename Derived::Base A;
    }
  };
  template struct Derived<int>;

  template<typename T> struct Derived2 : Base<int>, Base<char> {
    typename Derived2::Base b; // expected-error {{found in multiple base classes}}
    typename Derived2::Base<double> d;
  };

  template<typename T> class X { // expected-note {{here}}
    X *p1;
    X<T> *p2;
    X<int> *p3;
    dr176::X *p4; // expected-error {{requires template arguments}}
  };
}

namespace dr177 { // dr177: yes
  struct B {};
  struct A {
    A(A &); // expected-note {{not viable: expects an l-value}}
    A(const B &);
  };
  B b;
  A a = b; // expected-error {{no viable constructor copying variable}}
}

namespace dr178 { // dr178: yes
  int check[int() == 0 ? 1 : -1];
#if __cplusplus >= 201103L
  static_assert(int{} == 0, "");
  struct S { int a, b; };
  static_assert(S{1}.b == 0, "");
  struct T { constexpr T() : n() {} int n; };
  static_assert(T().n == 0, "");
  struct U : S { constexpr U() : S() {} };
  static_assert(U().b == 0, "");
#endif
}

namespace dr179 { // dr179: yes
  void f();
  int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}}
}

namespace dr180 { // dr180: yes
  template<typename T> struct X : T, T::some_base {
    X() : T::some_type_that_might_be_T(), T::some_base() {}
    friend class T::some_class;
    void f() {
      enum T::some_enum e;
    }
  };
}

namespace dr181 { // dr181: yes
  namespace X {
    template <template X<class T> > struct A { }; // expected-error +{{}}
    template <template X<class T> > void f(A<X>) { } // expected-error +{{}}
  }

  namespace Y {
    template <template <class T> class X> struct A { };
    template <template <class T> class X> void f(A<X>) { }
  }
}

namespace dr182 { // dr182: yes
  template <class T> struct C {
    void f();
    void g();
  };

  template <class T> void C<T>::f() {}
  template <class T> void C<T>::g() {}

  class A {
    class B {}; // expected-note {{here}}
    void f();
  };

  template void C<A::B>::f();
  template <> void C<A::B>::g(); // expected-error {{private}}

  void A::f() {
    C<B> cb;
    cb.f();
  }
}

namespace dr183 { // dr183: sup 382
  template<typename T> struct A {};
  template<typename T> struct B {
    typedef int X;
  };
  template<> struct A<int> {
    typename B<int>::X x;
  };
}

namespace dr184 { // dr184: yes
  template<typename T = float> struct B {};

  template<template<typename TT = float> class T> struct A {
    void f();
    void g();
  };

  template<template<typename TT> class T> void A<T>::f() { // expected-note {{here}}
    T<> t; // expected-error {{too few template arguments}}
  }

  template<template<typename TT = char> class T> void A<T>::g() {
    T<> t;
    typedef T<> X;
    typedef T<char> X;
  }

  void h() { A<B>().g(); }
}

// dr185 FIXME: add codegen test

namespace dr187 { // dr187: sup 481
  const int Z = 1;
  template<int X = Z, int Z = X> struct A;
  typedef A<> T;
  typedef A<1, 1> T;
}

namespace dr188 { // dr188: yes
  char c[10];
  int check[sizeof(0, c) == 10 ? 1 : -1];
}

// dr190 FIXME: add codegen test for tbaa

// dr193 FIXME: add codegen test

namespace dr194 { // dr194: yes
  struct A {
    A();
    void A(); // expected-error {{has the same name as its class}} expected-error {{constructor cannot have a return type}}
  };
  struct B {
    void B(); // expected-error {{has the same name as its class}} expected-error {{constructor cannot have a return type}}
    B();
  };
  struct C {
    inline explicit C(int) {}
  };
}

namespace dr195 { // dr195: yes
  void f();
  int *p = (int*)&f; // expected-error 0-1{{extension}}
  void (*q)() = (void(*)())&p; // expected-error 0-1{{extension}}
}

namespace dr197 { // dr197: yes
  char &f(char);

  template <class T> void g(T t) {
    char &a = f(1);
    char &b = f(T(1)); // expected-error {{unrelated type 'int'}}
    char &c = f(t); // expected-error {{unrelated type 'int'}}
  }

  void f(int);

  enum E { e };
  int &f(E);

  void h() {
    g('a');
    g(2);
    g(e); // expected-note {{in instantiation of}}
  }
}

namespace dr198 { // dr198: yes
  struct A {
    int n;
    struct B {
      int m[sizeof(n)];
#if __cplusplus < 201103L
      // expected-error@-2 {{invalid use of non-static data member}}
#endif
      int f() { return n; }
      // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}}
    };
    struct C;
    struct D;
  };
  struct A::C {
    int m[sizeof(n)];
#if __cplusplus < 201103L
    // expected-error@-2 {{invalid use of non-static data member}}
#endif
    int f() { return n; }
    // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}}
  };
  struct A::D : A {
    int m[sizeof(n)];
#if __cplusplus < 201103L
    // expected-error@-2 {{invalid use of non-static data member}}
#endif
    int f() { return n; }
  };
}

// dr199 FIXME: add codegen test


text:
package com.infinityraider.settlercraft.settlement.settler.ai.task;

import com.infinityraider.settlercraft.api.v1.ISettler;
import com.infinityraider.settlercraft.api.v1.ITask;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;

import java.util.ArrayList;
import java.util.List;

public abstract class TaskBase implements ITask {
    private final String name;
    private final ISettler settler;
    private boolean interrupted;
    private boolean cancelled;

    public TaskBase(String taskName, ISettler settler) {
        this.name = taskName;
        this.settler = settler;
        this.interrupted = false;
        this.cancelled = false;
    }

    @Override
    public ISettler getSettler() {
        return this.settler;
    }

    public EntityAgeable getEntitySettler() {
        return getSettler().getEntityImplementation();
    }

    @Override
    public final void onTaskCancelled() {
        this.cancelled = true;
        this.onTaskCancel();
    }

    protected void onTaskCancel() {}

    @Override
    public final void onTaskInterrupted(ITask interrupt) {
        this.interrupted = true;
        this.onTaskInterrupt(interrupt);
    }

    protected void onTaskInterrupt(ITask interrupt) {}

    @Override
    public void onTaskResumed() {
        this.interrupted = false;
        this.onTaskResume();
    }

    protected void onTaskResume() {}

    @Override
    public boolean isInterrupted() {
        return this.interrupted;
    }

    @Override
    public boolean isCancelled() {
        return this.cancelled;
    }

    @Override
    public List<ITextComponent> getTaskDescription() {
        List<ITextComponent> text = new ArrayList<>();
        text.add(new TextComponentTranslation("settlercraft.dialogue.task." + name));
        return text;
    }

    @Override
    public void onSettlerInventorySlotChanged(int slot, ItemStack stack) {}
}


text:
import { I18n } from 'react-redux-i18n'

export const getEntryCategories = () => {
  const baseCategories = [
    {
      value: 'Login',
      color: '#F58E3D'
    },

    {
      value: 'Network',
      color: '#797EC9'
    },

    {
      value: 'Software License',
      color: '#3DA8F5'
    },

    {
      value: 'Secure Note',
      color: '#75C940'
    },

    {
      value: 'Server',
      color: '#FFE738'
    },

    {
      value: 'Wallet',
      color: '#FF4F3E'
    }
  ]

  // I18n
  const enhancedCategories = baseCategories.map((category) => {
    category.title = I18n.t(`entryCategory.${category.value}`)
    return category
  })

  return enhancedCategories
}

export const getEntryCategoryByValue = (value) => {
  return getEntryCategories().find(
    category => category.value === value
  )
}


text:
module Rhinobook
	class Status < ActiveRecord::Base
		before_validation :set_status
		before_save :set_current_user

		belongs_to :statusable, polymorphic: true #, reject_if: :all_null

		STATUSES = {
			:created => 0,
			:edited => 1,
			:published => 2,
		}

		# validates :statusable_id, :statusable_type, :status, :locale, presence: true
		validates :status, :locale, presence: true
		validates_uniqueness_of :statusable_id, scope: [:statusable_type, :status, :locale]

		def pre_status
			Status.where('statusable_id = ? and statusable_type = ? and locale = ? and id != ?', self.statusable_id, self.statusable_type, self.locale, self.id).last
		end

		private
			def set_current_user
				self.user_id = Rhinoart::User::current.id
			end

			def set_status
				if self.statusable.present? && self.statusable.statuses.where(locale: self.locale).last.present?
					self.status = self.statusable.statuses.where(locale: self.locale).last.status.to_i + 1
				else
					self.status = 0
				end
			end
	end
end


text:
class TraceProcess : public QObject
{
    Q_OBJECT
public:
    TraceProcess(QObject *parent=0);
    ~TraceProcess();

    bool canTrace() const;

    void setApi(const QString &str);
    void setExecutablePath(const QString &str);
    QString executablePath() const;

    void setArguments(const QStringList &args);
    QStringList arguments() const;

public slots:
    void start();

signals:
    void tracedFile(const QString &tracePath);
    void error(const QString &msg);

private slots:
    void traceFinished();
    void traceError(QProcess::ProcessError err);

private:
    QString m_api;
    QString m_execPath;
    QStringList m_args;
    QString m_tracePath;
    QProcess *m_process;

    bool m_canTrace;
};