text:
package libcore.java.util;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import junit.framework.TestCase;
import libcore.util.SerializationTester;

public class OldPriorityQueueTest extends TestCase {
    public void test_ConstructorI() {
        PriorityQueue<Object> queue = new PriorityQueue<Object>(100);
        assertNotNull(queue);
        assertEquals(0, queue.size());
        assertNull(queue.comparator());

        try {
            new PriorityQueue(0);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            //expected
        }
    }

    public void test_remove_Ljava_lang_Object_using_comparator() {
        PriorityQueue<String> queue = new PriorityQueue<String>(10,
                new MockComparatorStringByLength());
        String[] array = { "AAAAA", "AA", "AAAA", "AAAAAAAA" };
        for (int i = 0; i < array.length; i++) {
            queue.offer(array[i]);
        }
        assertFalse(queue.contains("BB"));
        // Even though "BB" is equivalent to "AA" using the string length comparator, remove()
        // uses equals(), so only "AA" succeeds in removing element "AA".
        assertFalse(queue.remove("BB"));
        assertTrue(queue.remove("AA"));
    }

    public void test_remove_Ljava_lang_Object_not_exists() {
        Integer[] array = { 2, 45, 7, -12, 9, 23, 17, 1118, 10, 16, 39 };
        List<Integer> list = Arrays.asList(array);
        PriorityQueue<Integer> integerQueue = new PriorityQueue<Integer>(list);
        assertFalse(integerQueue.remove(111));
        assertFalse(integerQueue.remove(null));
        assertFalse(integerQueue.remove(""));
    }

    public void test_Serialization() throws Exception {
        String s = "aced0005737200176a6176612e7574696c2e5072696f72697479517565756594"
                + "da30b4fb3f82b103000249000473697a654c000a636f6d70617261746f7274001"
                + "64c6a6176612f7574696c2f436f6d70617261746f723b78700000000b70770400"
                + "00000c737200116a6176612e6c616e672e496e746567657212e2a0a4f78187380"
                + "2000149000576616c7565787200106a6176612e6c616e672e4e756d62657286ac"
                + "951d0b94e08b0200007870fffffff47371007e0003000000027371007e0003000"
                + "000077371007e00030000000a7371007e0003000000097371007e000300000017"
                + "7371007e0003000000117371007e00030000045e7371007e00030000002d73710"
                + "07e0003000000107371007e00030000002778";
        PriorityQueue<Integer> srcIntegerQueue = new PriorityQueue<Integer>(
                Arrays.asList(2, 45, 7, -12, 9, 23, 17, 1118, 10, 16, 39));
        new SerializationTester<PriorityQueue<Integer>>(srcIntegerQueue, s) {
            @Override protected boolean equals(PriorityQueue<Integer> a, PriorityQueue<Integer> b) {
                return Arrays.equals(a.toArray(), b.toArray());
            }
        }.test();
    }

    private static class MockComparatorStringByLength implements
            Comparator<String> {

        public int compare(String object1, String object2) {
            int length1 = object1.length();
            int length2 = object2.length();
            if (length1 > length2) {
                return 1;
            } else if (length1 == length2) {
                return 0;
            } else {
                return -1;
            }
        }

    }

    private static class MockComparatorCast<E> implements Comparator<E> {

        public int compare(E object1, E object2) {
            return 0;
        }
    }

    /**
     * removeAt(.) must sometimes perform siftUp(.).
     */
    public void test_removeAt_siftUp() {
        PriorityQueue<Integer> q = new PriorityQueue<Integer>();
        // Adding a valid heap will keep elements in the same order
        for (int i : new int[] { 0, 3, 1, 4, 5, 6, 2 }) {
            q.add(i);
        }
        q.remove(4);  // 2 replaces 4 but parent is 3, siftUp(.) is needed
        for (int i : new int[] { 0, 1, 2, 3, 5, 6 }) {
            assertEquals(i, (int) q.poll());
        }
        assertNull(q.poll());
    }

}


text:
package org.auraframework.def;

import java.util.List;
import java.util.Set;

import org.auraframework.adapter.ExpressionBuilder;
import org.auraframework.throwable.quickfix.AuraValidationException;

import com.salesforce.omakase.plugin.Plugin;

/**
 * Base class for CSS source code definitions.
 */
public interface BaseStyleDef extends Definition {
    @Override
    DefDescriptor<? extends BaseStyleDef> getDescriptor();

    /**
     * Gets the CSS code for this {@link StyleDef}.
     *

     * The initially preprocessed code may be processed again during this method call for dynamic or contextual
     * substitutions, changes, and validation (e.g., applying tokens or browser conditionals).
     *
     * @return The processed CSS code.
     */
    String getCode();

    /**
     * Gets the CSS code for this {@link StyleDef}, using the specified CSS plugins.
     *

     * The initially preprocessed code may be processed again during this method call for dynamic or contextual
     * substitutions, changes, and validation (e.g., applying tokens or browser conditionals), in addition to the
     * given {@link Plugin}s.
     *
     * @param plugins The list of {@link Plugin}s to run against the CSS code.
     *
     * @return The processed CSS code.
     */
    String getCode(List<Plugin> plugins);

    /**
     * Gets the CSS code for this {@link StyleDef}, without doing any additional processing (conditionals, tokens,
     * etc...)
     *

     * This is not the exact code as from the source, as some preprocessing has already been performed (.THIS
     * class name replacement, etc...)
     *
     * @return The CSS code.
     */
    String getRawCode();

    /**
     * Gets the set of raw token function expressions within this {@link StyleDef}.
     *
     * @return The set of token function expressions.
     */
    Set<String> getExpressions();

    /**
     * Gets the set of token names referenced from expressions within this {@link StyleDef}. This performs a
     * calculation so cache the result if needed more than once.
     *
     * @param expressionBuilder The builder bean for processing expressions.
     * @return The set of token names.
     * @throws AuraValidationException If there is a problem evaluating an expression.
     */
    Set<String> getTokenNames(ExpressionBuilder expressionBuilder) throws AuraValidationException;
}

redpajama_set_name: RedPajamaGithub


text:
require 'spec_helper'

describe 'Dynamic::Record has_many association' do
  before(:each) do
    @schema = Dynamic::Schema::Base.create!(name: 'earth')

    @Person = @schema.klasses.create!(name: 'Person')
    @Person.attrs.create!(name: 'last_name', type: 'Dynamic::Schema::Attribute::String')

    @Document = @schema.klasses.create!(name: 'Document')
    @Document.attrs.create!(name: 'title', type: 'Dynamic::Schema::Attribute::String')

    @belongs_to = @Document.associations.create!(name: 'owner', type: 'Dynamic::Schema::Association::BelongsTo', target_klass: @Person, schema: @schema)
    @has_many = @Person.associations.create!(name: 'documents', type: 'Dynamic::Schema::Association::HasMany', target_klass: @Document, inverse_of: @belongs_to, schema: @schema)
    @belongs_to.update_attribute(:inverse_of, @has_many)

    @schema.load
  end

  context 'create through an association' do
    before(:each) do
      @a = D::Earth::Person.create(last_name: 'A')
      expect(@a).to respond_to(:documents)
    end

    it 'should create a dynamic_association' do
      expect {
        @a.documents.create!(title: 'CV')
        @a.dynamic_associations.reload # TODO improve in order to prevent reload
      }.to change {
        @a.dynamic_associations.length
      }.by(1)
    end
  end

  context 'create a DynamicAssociation' do
    before(:each) do
      @a = D::Earth::Person.create(last_name: 'A')
      @d = D::Earth::Document.create(title: 'CV')
    end

    it 'should change dynamic_associations' do
      expect {
        D::Earth::DynamicAssociation.create!(association_owner: @a, association_target: @d, schema_association: @has_many)
        @a.dynamic_associations.reload
      }.to change {
        @a.dynamic_associations.length
      }.by(1)
    end

    it 'should change association' do
      expect {
        c = D::Earth::DynamicAssociation.create!(association_owner: @a, association_target: @d, schema_association: @has_many)
        @a.documents.reload
      }.to change {
        @a.documents.map(&:id)
      }.to([@d.id])
    end

  end

  context 'with inverse of' do

    context 'create a DynamicAssociation' do
      before(:each) do
        @a = D::Earth::Person.create(last_name: 'A')
        @d = D::Earth::Document.create(title: 'CV')
      end

      it 'should create an inverse DynamicAssociation' do
        expect {
          D::Earth::DynamicAssociation.create!(association_owner: @a, association_target: @d, schema_association: @has_many)
          @a.dynamic_associations_as_target.reload
        }.to change {
          @a.dynamic_associations_as_target.length
        }.by(1)
      end

      it 'should change inverse association' do
        expect {
          c = D::Earth::DynamicAssociation.create!(association_owner: @a, association_target: @d, schema_association: @has_many)
          @a.documents.reload
        }.to change {
          @a.documents.map(&:owner_id)
        }.to([@a.id])
      end

    end

    context 'create throuth an assocation' do
      before(:each) do
        @a = D::Earth::Person.create(last_name: 'A')
        @d = @a.documents.create!(title: 'CV')
      end

      it 'should set inverse association' do
        expect(@a.documents.first.owner).to eq(@a)
      end

      context 'destroy' do
        before(:each) do
          @a.documents.destroy(@d)
        end

        it 'should destroy inverse association' do
          expect(@d.owner).to be_nil
        end
      end
    end

    context 'load/reload association' do
      before(:each) do
        @a = D::Earth::Person.create(last_name: 'A')
        @d = @a.documents.create!(title: 'CV')
        @a.documents.reload
      end

      it 'should set inverse association in order to prevent additional queries' do
        expect{@a.documents[0].owner}.to_not exceed_query_limit(0)
      end
    end

  end

end


text:
module Lexer where

import qualified GenericLexer as G

import qualified Text.Parsec.String as PS

l = G.lexer False

braces = G.braces l
brackets = G.brackets l
commaSep = G.commaSep l
float = G.float l
identifier = G.identifier l
imaginary = G.imaginary l
integer = G.integer l
keyword = G.keyword l
operator = G.operator l
parens = G.parens l
rune = G.rune l
semi = G.semi l
string = G.string l

-- parse
parse parser = G.parse parser


text:
class WorldRecord < ApplicationRecord
  belongs_to :player
  validates :map, :mode, :player_id, :time, :player, presence: true
  validates :mode, inclusion: { in: 0..3 }
  validates :mode, uniqueness: { scope: :map,
                                 message: 'One record per mode for each map.' }
  validates :time, numericality: { only_integer: true,
                                   greater_than: 0 }

  def self.check(score)
    wr = world_record(score[:map], score[:mode])
    update_world_record(wr, score) if wr.time.nil? || score[:time] < wr.time
  end

  def self.map_scores
    query = <<-SQL
    SELECT wr.map, wr.mode, wr.time, p.id AS player_id, p.name AS player_name
    FROM world_records wr
    INNER JOIN players p
    ON wr.player_id = p.id
    ORDER BY wr.map, wr.mode;
    SQL
    wrs = WorldRecord.find_by_sql [query]
    map_scores = Hash.new { |hash, key| hash[key] = Array.new(4) }
    wrs.each do |wr|
      map_scores[wr.map][wr.mode] = wr
    end
    return map_scores
  end

  def self.world_record(map, mode)
    WorldRecord.find_or_initialize_by(map: map, mode: mode)
  end

  def self.most_world_records(mode)
    where_mode = mode.to_i != -1 ? " AND mode = #{mode.to_i}" : ''
    query = <<-SQL
    SELECT wr.player_id, p.name, COUNT(wr.player_id) AS num_wrs,
        (SELECT COUNT(*)
         FROM scores
         WHERE scores.player_id = wr.player_id#{where_mode}) AS num_records
    FROM world_records wr, players p
    WHERE wr.player_id = p.id#{where_mode}
    GROUP BY p.name, wr.player_id
    ORDER BY num_wrs DESC
    SQL
    Score.find_by_sql [query]
  end

  def self.update_world_record(world_record, score)
    world_record.time = score[:time]
    world_record.player_id = score[:player_id]
    world_record.match_guid = score[:match_guid]
    world_record.api_id = score[:api_id]
    world_record.updated_at = score[:date] if score[:date]
    world_record.save!
  end

  private_class_method :update_world_record
end


text:
package com.example.jdbc;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface UseDataSource {

	DataSources value();
}


text:
/*
 * lokbasis_hwdef.h
 *
 *  Created on: 22.10.2011
 *      Author: Michael Brunnbauer
 *
 *  Hardwaredefinitionen für Lokbasis Hardware
 *
 *
 *
 */

#ifndef LOKBASIS_HWDEF_H_
#define LOKBASIS_HWDEF_H_

#ifndef __AVR_ATmega2561__
#define __AVR_ATmega2561__
#endif
// mögliche Board Konfiguration
#if defined(__AVR_ATmega2560__)
	#define HW_TESTBOARD1		// Testboard1 (WLAN:uart2, log:uart3)
#elif defined(__AVR_ATmega2561__)
	#define HW_TESTBOARD2		// Testboard2 (WLAN:uart0, log:-)
#endif

// Tesboard1
#if defined( HW_TESTBOARD1 )

// UART Definitionen
#define WLAN 2	// uart2 für WLAN
#define RFID 1	// uart1 für RFID
#define LOG  3	// uart3 für log/debug-ausgabe über USB

#define UART_BAUDRATE_1	9600	// RFID-Verbindung
#define UART_BAUDRATE_2	38400	// WLAN-Verbindung
#define UART_BAUDRATE_3	250000	// USB-Verbindung zum PC

#define UART_SETTING_1 ((F_CPU/16L/UART_BAUDRATE_1)-1)	// Berechnung der UART Konfigurationsparameter
#define UART_SETTING_2 ((F_CPU/16L/UART_BAUDRATE_2)-1)
#define UART_SETTING_3 ((F_CPU/16L/UART_BAUDRATE_3)-1)

#define TESTLED		1		// Funktion TestLED ist vorhanden

#define MOTORC_L6205 1	// verwendeter Motorcontroller

#if defined( MOTORC_L6205 )
#define MC_INV_PWM_4_REV 1	// PWM für Rückwärts invertieren	// bei L6205 nötig, für MOTORC_POLOLU24V20 nicht
#endif
#endif

//---------------------------------------------------------------------------------------------

// Tesboard2
#if defined( HW_TESTBOARD2 )

// UART Definitionen
#define WLAN 0	// uart0 für WLAN
//#define RFID 1	// uart1 für RFID

#define UART_BAUDRATE_RFID	9600	// RFID-Verbindung
#define UART_BAUDRATE_WLAN	38400	// WLAN-Verbindung
#define UART_BAUDRATE_USB	250000	// USB-Verbindung zum PC

#define UART_SETTING_RFID ((F_CPU/16L/UART_BAUDRATE_RFID)-1)	// Berechnung der UART Konfigurationsparameter
#define UART_SETTING_WLAN ((F_CPU/16L/UART_BAUDRATE_WLAN)-1)
#define UART_SETTING_USB ((F_CPU/16L/UART_BAUDRATE_USB)-1)

// Motorcontroller
#define MOTOR1_ADC 	PF7 	// Input, ADC6 Motor 1
#define MOTOR2_ADC 	PF6 	// Input,ADC7 Motor 2
#define MOTOR_DIR 	PB4 	// Output, Motoren Richtung
#define MOTOR1_PWM 	PB6 	// Output, OC1B Reserve 1. Motor PWM, 	Umjumperbar (PB5/PB6 ), ob mit 1. oder 2. Motor-PWM versorgt wird
#define MOTOR2_PWM 	PB5 	// Output, OC1A 2. Motor PWM
#define MOTOR_RESET PB7 	// Output, Motoren Reset
#define MOTOR1_FF1 	PG2 	// Input, Motor1 FF1
#define MOTOR1_FF2 	PG1 	// Input, Motor1 FF2
#define MOTOR2_FF1 	PG0 	// Input, Motor2 FF1
#define MOTOR2_FF2 	PG5 	// Input, Motor2 FF2
#define DDR_MOTOR_ADC	DDRF
#define DDR_MOTOR_OUT	DDRB
#define DDR_MOTOR_IN	DDRG
#define PORT_MOTOR	PORTB
#define PIN_MOTOR_ADC PINF
#define PIN_MOTOR PING
#define MOTORC_POLOLU24V20 1	// verwendeter Motorcontroller

// WLAN-Modul
#define WLAN_RESET 	PE2 	// Output, F1: Reset bei Wiznet: (active HIGH) 1 = reset, 1 für 3s = Factory Default
#define WLAN_RX 	PE0 	// Input, Atmega RX, Wiznet Data out
#define WLAN_TX 	PE1 	// Output, Atmega TX, Wiznet Data in
#define WLAN_DATAMODE 	PE3 	// Output, F2: HW-Trigger bei Wiznet, 0: CMD, 1:Data
#define DDR_WLAN	DDRE
#define PORT_WLAN	PORTE
#define PIN_WLAN	PINE
#define WLAN_ONOFF	PE4		// Output 0: Wiznet ausgeschalten, 1: Wiznet ein

// Versorgungs-Modul
#define AKKU_OFF 	PA2 		// Output, AKKU/Schiene Umschaltung (0: Akku (stromloser Zustand), 1: Schiene (muß geschalten bleiben!) [auf ULN2803]
#define SYSTEM_OFF 	PA0 		// Output, Versorgung aus (bei Abschaltung) [auf ULN2803]
#define SYSTEM_ON 	PA1 		// Output, Versorgung ein [auf ULN2803]
#define AKKU_ADC 	PF5 		// Input, ADC Akku-Spannung
#define SCHIENE_ADC PF4 		// Input, ADC Schienenspannung
#define DDR_SYS_ADC DDRF
#define DDR_SYS		DDRA
#define PORT_SYS	PORTA
#define PIN_SYS_ADC PINF

// Test-LEDs am MC-Modul
#define TESTLED		1			// Funktion TestLED ist vorhanden
#define TESTLED0 	PF0			// (JP 1-5 gesetzt), alternative Funktion: ADC0
#define TESTLED1 	PF1 		// (JP 1-6 gesetzt), alternative Funktion: ADC1
#define TESTLED2 	PF2 		// (JP 1-7 gesetzt), alternative Funktion: ADC2
#define TESTLED3 	PF3 		// (JP 1-8 gesetzt), alternative Funktion: ADC3
#define DDR_TESTLED DDRF
#define PORT_TESTLED PORTF

// I2C LED-Controller
#define LEDC_TLC59116	1			//LED-Controller TLC59116 ist vorhanden
#define I2C_RESET   0xD6			// 0xD6 = Software Reset I2C Bus Adresse
#define LEDC_MODE2_BLINK	32		// Mode 2 = Blinken
#define LEDC_MODE2_DIMM		0		// Mode 2 = Dimmen
#define LEDC1  0xC0      			// I2C-Adresse des LED-Controller

#endif	// HW_TESTBOARD2

// allgemeine Definitionen

#define POWER_FROM_RAILS		0	// Versorgung über Schienenstrom
#define POWER_FROM_BATTERY		1	// Versorgung aus AKKU

#endif	// LOKBASIS_HWDEF_H_


text:
from setuptools import setup, find_packages
import os

version = '0.9.1dev'

setup(name='two.ol',
      version=version,
      description="It takes Two do Django. A django mini framework",
      long_description=open("README.txt").read() + "\n" +
                       open(os.path.join("docs", "HISTORY.txt")).read(),
      # Get more strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
      classifiers=[
        "Programming Language :: Python",
        ],
      keywords='',
      author='Ivo van der Wijk',
      author_email='two@in.m3r.nl',
      url='http://github.com/iivvoo/two.ol',
      license='BSD',
      packages=find_packages(exclude=['ez_setup']),
      namespace_packages=['two'],
      include_package_data=True,
      zip_safe=False,
      install_requires=[
          'setuptools',
      ],
      entry_points={
        "console_scripts":[
            "newrelic=two.ol.newrelicfix:main",
            "nr-run=two.ol.newrelicfix:runner",
        ]
      },

      )


text:
Nice example, took from a comment in HN that explains how to use arrays to search for multiple components in a record.

Really good example.

Field name
```sql
  ingredients VARCHAR[]
```

Index

```sql
  USING GIN (ingredients)
```

search with operator like @>
```sql
  SELECT * FROM table WHERE ingredients @> ARRAY['mushrooms', 'sour cream']
```


text:
package com.mradul.template.exception;

public class TemplateException extends Exception {

	private static final long serialVersionUID = -8574338062204931033L;

	public TemplateException(String message) {
		super(message);
	}

}


text:
//
//  XMGSeeBigViewController.m
//  4期-百思不得姐
//
//  Created by xiaomage on 15/10/22.
//  Copyright © 2015年 xiaomage. All rights reserved.
//

#import "XMGSeeBigViewController.h"
#import "XMGTopic.h"
#import <UIImageView+WebCache.h>

//#import <AssetsLibrary/AssetsLibrary.h> // iOS9开始废弃
#import <Photos/Photos.h> // iOS9开始推荐
#import <SVProgressHUD.h>

@interface XMGSeeBigViewController () <UIScrollViewDelegate>
/** 图片控件 */
@property (nonatomic, weak) UIImageView *imageView;
@end

@implementation XMGSeeBigViewController

static NSString * XMGAssetCollectionTitle = @"5期-百思不得姐";

- (void)viewDidLoad {
    [super viewDidLoad];

    // scrollView
    UIScrollView *scrollView = [[UIScrollView alloc] init];
    scrollView.delegate = self;
    scrollView.frame = [UIScreen mainScreen].bounds;
    [self.view insertSubview:scrollView atIndex:0];

    // scrollView.backgroundColor = [UIColor redColor];
    // scrollView.frame = self.view.bounds;
    // scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

    // imageView
    UIImageView *imageView = [[UIImageView alloc] init];
    [imageView sd_setImageWithURL:[NSURL URLWithString:self.topic.large_image]];
    [scrollView addSubview:imageView];

    imageView.xmg_width = scrollView.xmg_width;
    imageView.xmg_height = self.topic.height * imageView.xmg_width / self.topic.width;
    imageView.xmg_x = 0;

    if (imageView.xmg_height >= scrollView.xmg_height) { // 图片高度超过整个屏幕
        imageView.xmg_y = 0;
        // 滚动范围
        scrollView.contentSize = CGSizeMake(0, imageView.xmg_height);
    } else { // 居中显示
        imageView.xmg_centerY = scrollView.xmg_height * 0.5;
    }
    self.imageView = imageView;

    // 缩放比例
    CGFloat scale =  self.topic.width / imageView.xmg_width;
    if (scale > 1.0) {
        scrollView.maximumZoomScale = scale;
    }
}

- (IBAction)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)save {
    /*
     PHAuthorizationStatusNotDetermined,     用户还没有做出选择
     PHAuthorizationStatusDenied,            用户拒绝当前应用访问相册(用户当初点击了"不允许")
     PHAuthorizationStatusAuthorized         用户允许当前应用访问相册(用户当初点击了"好")
     PHAuthorizationStatusRestricted,        因为家长控制, 导致应用无法方法相册(跟用户的选择没有关系)
     */

    // 判断授权状态
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusRestricted) { // 因为家长控制, 导致应用无法方法相册(跟用户的选择没有关系)
        [SVProgressHUD showErrorWithStatus:@"因为系统原因, 无法访问相册"];
    } else if (status == PHAuthorizationStatusDenied) { // 用户拒绝当前应用访问相册(用户当初点击了"不允许")
        XMGLog(@"提醒用户去[设置-隐私-照片-xxx]打开访问开关");
    } else if (status == PHAuthorizationStatusAuthorized) { // 用户允许当前应用访问相册(用户当初点击了"好")
        [self saveImage];
    } else if (status == PHAuthorizationStatusNotDetermined) { // 用户还没有做出选择
        // 弹框请求用户授权
         XMGLog(@"请求用户授权");
        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {

            if (status == PHAuthorizationStatusAuthorized) { // 用户点击了好

                [self saveImage];
            }
        }];
    }
}
- (void)saveImage
{

    // PHAsset : 一个资源, 比如一张图片\一段视频
    // PHAssetCollection : 一个相簿

    // PHAsset的标识, 利用这个标识可以找到对应的PHAsset对象(图片对象)
    __block NSString *assetLocalIdentifier = nil;

    // 如果想对"相册"进行修改(增删改), 那么修改代码必须放在[PHPhotoLibrary sharedPhotoLibrary]的performChanges方法的block中
    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        // 1.保存图片A到"相机胶卷"中
        // 创建图片的请求

        assetLocalIdentifier = [PHAssetCreationRequest creationRequestForAssetFromImage:self.imageView.image].placeholderForCreatedAsset.localIdentifier;
    } completionHandler:^(BOOL success, NSError * _Nullable error) {
        if (success == NO) {
            [self showError:@"保存图片失败!"];
            return;
        }

        // 2.获得相簿

        PHAssetCollection *createdAssetCollection = [self createdAssetCollection];
        if (createdAssetCollection == nil) {
            [self showError:@"创建相簿失败!"];
            return;
        }

        [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
            // 3.添加"相机胶卷"中的图片A到"相簿"D中

            // 获得图片
            PHAsset *asset = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetLocalIdentifier] options:nil].lastObject;

            // 添加图片到相簿中的请求
            PHAssetCollectionChangeRequest *request = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:createdAssetCollection];

            // 添加图片到相簿
            [request addAssets:@[asset]];
        } completionHandler:^(BOOL success, NSError * _Nullable error) {
            if (success == NO) {
                [self showError:@"保存图片失败!"];;
            } else {
                [self showSuccess:@"保存图片成功!"];;
            }
        }];
    }];
}
/**
 *  获得相簿
 */
- (PHAssetCollection *)createdAssetCollection
{
    // 从已存在相簿中查找这个应用对应的相簿
    PHFetchResult<PHAssetCollection *> *assetCollections = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
    for (PHAssetCollection *assetCollection in assetCollections) {
        if ([assetCollection.localizedTitle isEqualToString:XMGAssetCollectionTitle]) {
            return assetCollection;
        }
    }

    // 没有找到对应的相簿, 得创建新的相簿

    // 错误信息
    NSError *error = nil;

    // PHAssetCollection的标识, 利用这个标识可以找到对应的PHAssetCollection对象(相簿对象)
    __block NSString *assetCollectionLocalIdentifier = nil;
    [[PHPhotoLibrary sharedPhotoLibrary] performChangesAndWait:^{
        // 创建相簿的请求
        assetCollectionLocalIdentifier = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:XMGAssetCollectionTitle].placeholderForCreatedAssetCollection.localIdentifier;
    } error:&error];

    // 如果有错误信息
    if (error) return nil;

    // 获得刚才创建的相簿
    return [PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers:@[assetCollectionLocalIdentifier] options:nil].lastObject;
}

- (void)showSuccess:(NSString *)text
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD showSuccessWithStatus:text];
    });
}

- (void)showError:(NSString *)text
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD showErrorWithStatus:text];
    });
}

#pragma mark - <UIScrollViewDelegate>
/**
 *  返回一个scrollView的子控件进行缩放
 */
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.imageView;
}

//简单做法
//- (IBAction)save {
//    // UIImageWriteToSavedPhotosAlbum(self.imageView.image, self, @selector(a:b:c:), nil);
//    UIImageWriteToSavedPhotosAlbum(self.imageView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
//}

//- (void)a:(UIImage *)image b:(NSError *)error c:(void *)contextInfo
//{
//    XMGLogFunc
//}

/**
 *  通过UIImageWriteToSavedPhotosAlbum函数写入图片完毕后就会调用这个方法
 *
 *  @param image       写入的图片
 *  @param error       错误信息
 *  @param contextInfo UIImageWriteToSavedPhotosAlbum函数的最后一个参数
 */
//- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
//{
//    if (error) {
//        [SVProgressHUD showErrorWithStatus:@"图片保存失败!"];
//    } else {
//        [SVProgressHUD showSuccessWithStatus:@"图片保存成功!"];
//    }
//}
@end


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="generator" content="Source Themes Academic 4.7.0">

  <meta name="author" content="Gerges Dib">

  <meta name="description" content="Applied Scientist">

  <link rel="alternate" hreflang="en-us" href="https://dibgerge.github.io/tags/ultrasound/">

  <meta name="theme-color" content="#ba68c8">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.8.6/css/academicons.min.css" integrity="sha256-uFVgMKfistnJAfoCUQigIl+JfUaP47GrRKjf6CTPVmw=" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" integrity="sha256-+N4/V/SbAFiW1MPBCXnfnP9QSN3+Keu+NlB+0ev/YKQ=" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous">

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/atom-one-light.min.css" crossorigin="anonymous" title="hl-light">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/atom-one-light.min.css" crossorigin="anonymous" title="hl-dark" disabled>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.css" integrity="sha256-SHMGCYmST46SoyGgo4YR/9AlK1vf3ff84Aq9yK4hdqM=" crossorigin="anonymous">

  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,700%7CRoboto:400,400italic,700%7CRoboto+Mono&display=swap">

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

  <link rel="alternate" href="/tags/ultrasound/index.xml" type="application/rss+xml" title="Ge[o]rges Dib">

  <link rel="manifest" href="/index.webmanifest">
  <link rel="icon" type="image/png" href="/images/icon_hufb0bba0b24038dd6774d907c032416d0_44829_32x32_fill_lanczos_center_2.png">
  <link rel="apple-touch-icon" type="image/png" href="/images/icon_hufb0bba0b24038dd6774d907c032416d0_44829_192x192_fill_lanczos_center_2.png">

  <link rel="canonical" href="https://dibgerge.github.io/tags/ultrasound/">

  <meta property="twitter:card" content="summary">

  <meta property="og:site_name" content="Ge[o]rges Dib">
  <meta property="og:url" content="https://dibgerge.github.io/tags/ultrasound/">
  <meta property="og:title" content="ultrasound | Ge[o]rges Dib">
  <meta property="og:description" content="Applied Scientist"><meta property="og:image" content="https://dibgerge.github.io/images/icon_hufb0bba0b24038dd6774d907c032416d0_44829_512x512_fill_lanczos_center_2.png">
  <meta property="twitter:image" content="https://dibgerge.github.io/images/icon_hufb0bba0b24038dd6774d907c032416d0_44829_512x512_fill_lanczos_center_2.png"><meta property="og:locale" content="en-us">

    <meta property="og:updated_time" content="2018-12-01T00:00:00-08:00">

  <title>ultrasound | Ge[o]rges Dib</title>

Search

        <input name="q" id="search-query" placeholder="Search..." autocapitalize="off"
        autocomplete="off" autocorrect="off" spellcheck="false" type="search">

    <button type="button" class="navbar-toggler" data-toggle="collapse"
            data-target="#navbar-content" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">

    </button>

          Home

          #Projects

          #Publications

          Blog

ultrasound

Ultrasound Modeling and Simulation: Status Update

      The Pacific Northwest National Laboratory (PNNL) is conducting confirmatory research for the U.S. Nuclear Regulatory Commission for establishing standard methods of modeling and simulation to assess the effectiveness and reliability of ultrasonic …

Validation of Ultrasound NDE Simulation Models

      Supporting regulatory guides for the nuclear power plant industry in relation to using ultrasound computational models for non-destructive inspection.

Challenges and Solutions in SHM for Nuclear Power Environments

      As the nation's nuclear fleet looks to life extension, advanced reactor (AdvRx) concepts are being considered as alternatives that may help meet anticipated energy needs. AdvRx concepts include small modular reactors (SMRs) where the electrical …

On the usage of ultrasound computational models for decision making under ambiguity

      Computer modeling and simulation is becoming pervasive within the non-destructive evaluation (NDE) industry as a convenient tool for designing and assessing inspection techniques. This raises a pressing need for developing quantitative techniques for …

Preliminary design of high temperature ultrasonic transducers for liquid sodium environments

      Advanced reactor concepts include fast reactors (including sodium-cooled fast reactors), gas-cooled reactors, and molten-salt reactors. Common to these concepts is a higher operating temperature (when compared to light-water-cooled reactors), and the …

Validation of Ultrasonic Nondestructive Examination (NDE) Computational Models – Phase 1

      The Pacific Northwest National Laboratory (PNNL) is conducting confirmatory research for the U.S. Nuclear Regulatory Commission for the validation of computational models for ultrasonic testing (UT). The purpose of this research is to determine if UT …

Detecting Water in Dry Storage Canisters for Used Fuel

      As the United States transitions to storing used fuel from commercial nuclear reactors in interim dry storage facilities for extended periods, utilities must be prepared to technically justify the viability of extended storage to the regulating …

PVT Degradation Studies: Acoustic Diagnostics

      Under certain environmental conditions, polyvinyl toluene (PVT) plastic scintillator has been observed to undergo internal fogging. This document reports on a study of acoustic techniques to determine whether they can provide a diagnostic for the …

Experimental Design for Evaluating Selected Nondestructive Measurement Technologies

      The harsh environments in advanced reactors (AdvRx) increase the possibility of degradation of safety-critical passive components, and therefore pose a particular challenge for deployment and extended operation of these concepts. Nondestructive …

Ultrasound Sensors and Methods for Nuclear Power Plant Environments

      Applications of ultrasounds in nuclear power plants including water detection in dry cask storage, defect detection in reactors, and health monitoring of radiation detectors.

»

    Powered by the
    Academic theme for
    Hugo.

Cite

        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          ×
        </button>

           Copy

           Download


text:
package com.ae.camunda.dispatcher.api.annotation.task;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface RetryTimeout {
}


text:
@extends('views.layouts.full-width')

@section('main')

	@include( 'views.parts.modules', [ 'slug' => 'modules_container_row1' ] )

@endsection


text:
package pl.fishing.lake.feign;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import pl.fishing.lake.dto.UserDto;

@FeignClient(name = "user-service")
public interface UserServiceFeign {
    @RequestMapping(method = RequestMethod.GET, value = "/users/find/{name}", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseStatus(HttpStatus.OK)
    UserDto getByUsername(@PathVariable("name") String name);
}


text:
title: 2 Col Portfolio
redirect_to:
  - http://ironsummitmedia.github.io/startbootstrap-2-col-portfolio/
---


text:
#ifndef PiFaceRTC_h
#define PiFaceRTC_h

/*
** The following are the variopus structures that make up the representation of date/time and control registers
** in the PiFace RTC
*/

struct mcp7940n_rtcsec {            // Offset 0x00
    unsigned char secone : 4;
    unsigned char secten : 3;
    unsigned char st : 1;
};

struct mcp7940n_rtcmin {            // Offset 0x01
    unsigned char minone : 4;
    unsigned char minten : 3;
    unsigned char unimplemented : 1;
};

struct mcp7940n_rtchour_12hour {    // Offset 0x02
    unsigned char hrone : 4;
    unsigned char hrten : 1;
    unsigned char ampm : 1;
    unsigned char twelvetwentyfour : 1;
    unsigned char unimplemented : 1;
};

struct mcp7940n_rtchour_24hour {    // Offset 0x02
    unsigned char hrone : 4;
    unsigned char hrten : 2;
    unsigned char twelvetwentyfour : 1;
    unsigned char unimplemented : 1;
};

struct mcp7940n_rtcwkday {          // Offset 0x03
    unsigned char wkday : 3;
    unsigned char vbaten : 1;
    unsigned char pwrfail : 1;
    unsigned char oscrun : 1;
    unsigned char unimplemented : 2;
};

struct mcp7940n_rtcdate {           // Offset 0x04
    unsigned char dateone : 4;
    unsigned char dateten : 2;
    unsigned char unimplemented : 2;
};

struct mcp7940n_rtcmnth {           // Offset 0x05
    unsigned char mthone : 4;
    unsigned char mthten : 1;
    unsigned char lpyr : 1;
    unsigned char unimplemented : 2;
};

struct mcp7940n_rtcyear {           // Offset 0x06
    unsigned char yrone : 4;
    unsigned char yrten : 4;
};

struct mcp7940n_control {           // Offset 0x07
    unsigned char sqwfs : 2;
    unsigned char crstrim : 1;
    unsigned char extosc : 1;
    unsigned char alm0en : 1;
    unsigned char alm1en : 1;
    unsigned char sqwen : 1;
    unsigned char out : 1;

};

struct mcp7940n_osctrim {           // Offset 0x08
    unsigned char trimval : 7;
    unsigned char sign : 1;
};

struct mcp7940n_datetime {
    struct mcp7940n_rtcsec  rtcseconds;
    struct mcp7940n_rtcmin  rtcminutes;
    union {
        struct mcp7940n_rtchour_12hour twelvehour;
        struct mcp7940n_rtchour_24hour twentyfourhour;
    } rtchour;
    struct mcp7940n_rtcwkday rtcweekday;
    struct mcp7940n_rtcdate rtcdate;
    struct mcp7940n_rtcmnth rtcmonth;
    struct mcp7940n_rtcyear rtcyear;
};

struct mcp7940n_pwrmin {
    unsigned char minone : 4;
    unsigned char minten : 3;
    unsigned char unimplemented : 1;
};

struct mcp7940n_pwr12hour {
    unsigned char hrone : 4;
    unsigned char hrten : 1;
    unsigned char ampm : 1;
    unsigned char twelvetwentyfour : 1;
    unsigned char unimplemented : 1;
};

struct mcp7940n_pwr24hour {
    unsigned char hrone : 4;
    unsigned char hrten : 2;
    unsigned char twelvetwentyfour : 1;
    unsigned char unimplemented : 1;

};

struct mcp7940n_pwrdate {
    unsigned char dateone : 4;
    unsigned char dateten : 2;
    unsigned char unimplemented : 2;
};

struct mcp7940n_pwrmth {
    unsigned char mthone : 4;
    unsigned char mthten : 1;
    unsigned char wkday : 3;
};

struct mcp7940n_pwrdn_timestamp {   // Offset 0x18
    struct mcp7940n_pwrmin  pwrdnminute;
    union {
        struct mcp7940n_pwr12hour twelvehour;
        struct mcp7940n_pwr24hour twentyfourhour;
    } pwrdnhour;
    struct mcp7940n_pwrdate pwrdndate;
    struct mcp7940n_pwrmth  pwrdnmth;
};

struct mcp7940n_pwrup_timestamp {   // Offset 0x1c
    struct mcp7940n_pwrmin  pwrupminute;
    union {
        struct mcp7940n_pwr12hour twelvehour;
        struct mcp7940n_pwr24hour twentyfourhour;
    } pwruphour;
    struct mcp7940n_pwrdate pwrupdate;
    struct mcp7940n_pwrmth  pwrupmth;
};

struct mcp7940n_pwrtimestamps {
    struct mcp7940n_pwrdn_timestamp pwrdn;
    struct mcp7940n_pwrup_timestamp pwrup;
};

/*
** The following are offsets in the memory of the RTC to various registers and fields
*/

# define MCP7940N_RTCSEC_OFFSET         0x00
# define MCP7940N_RTCMIN_OFFSET         0x01
# define MCP7940N_RTCHOUR_OFFSET        0x02
# define MCP7940N_RTCWKDAY_OFFSET       0x03
# define MCP7940N_RTCDATE_OFFSET        0x04
# define MCP7940N_RTCMTH_OFFSET         0x05
# define MCP7940N_RTCYEAR_OFFSET        0x06
# define MCP7940N_CONTROL_OFFSET        0x07
# define MCP7940N_OSCTRIM_OFFSET        0x08
# define MCP7940N_PWRDNMIN_OFFSET       0x18
# define MCP7940N_PWRDNHOUR_OFFSET      0x19
# define MCP7940N_PWRDNDATE_OFFSET      0x1a
# define MCP7940N_PWRDNMTH_OFFSET       0x1b
# define MCP7940N_PWRUPMIN_OFFSET       0x1c
# define MCP7940N_PWRUPHOUR_OFFSET      0x1d
# define MCP7940N_PWRUPDATE_OFFSET      0x1e
# define MCP7940N_PWRUPMTH_OFFSET       0x1f

# define MCP7940N_RTCDATETIME_OFFSET    0x00
# define MCP7940N_RTCPWRDNUP_OFFSET     0x18
# define MCP7940N_RTCPWRDN_OFFSET       0x18
# define MCP7940N_RTCPWRUP_OFFSET       0x1c
# define MCP7940N_NVRAM_OFFSET          0x20

#endif /* PiFaceRTC_h */


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="DataSourceManagerImpl" format="xml" hash="995138706">
    <data-source source="LOCAL" name="Data Source" uuid="582bf76c-21b4-49b3-a184-9d6da7027853">
      <driver-ref>mysql</driver-ref>
      <synchronize>true</synchronize>
      <jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
      <jdbc-url>jdbc:mysql://[localhost][,failoverhost...][:8889]/[ecommerce]</jdbc-url>
      <user-name>root</user-name>
      <user-password>dfd8dfc5dfc5dfde</user-password>
      <libraries>
        <library>
          <url>jar://$PROJECT_DIR$/../Database Driver for PHPStorm/mysql-connector-java-5.1.26-bin.jar!/</url>
        </library>
        <library>
          <url>file://$PROJECT_DIR$/../Database Driver for PHPStorm/mysql-connector-license.txt</url>
        </library>
      </libraries>
    </data-source>
  </component>
</project>


text:
require 'sensu-plugin/check/cli'
require 'aws-sdk'
require 'net/http'
require 'json'
require 'sensu-plugins-sensu/filter'

class EC2Filter < Sensu::Plugin::Check::CLI
  include Filter
  option :aws_access_key,
         short: '-a AWS_ACCESS_KEY',
         long: '--aws-access-key AWS_ACCESS_KEY',
         description: "AWS Access Key. Either set ENV['AWS_ACCESS_KEY_ID'] or provide it as an option"

  option :aws_secret_access_key,
         short: '-k AWS_SECRET_ACCESS_KEY',
         long: '--aws-secret-access-key AWS_SECRET_ACCESS_KEY',
         description: "AWS Secret Access Key. Either set ENV['AWS_SECRET_ACCESS_KEY'] or provide it as an option"

  option :aws_region,
         short: '-r AWS_REGION',
         long: '--aws-region REGION',
         description: 'AWS Region (such as us-east-1).',
         default: 'us-east-1'

  option :sense_host,
         short: '-h SENSU_HOST',
         long: '--host SENSU_HOST',
         description: 'Sensu host to query',
         default: 'sensu'

  option :sensu_port,
         short: '-p SENSU_PORT',
         long: '--port SENSU_PORT',
         description: 'Sensu API port',
         proc: proc(&:to_i),
         default: 4567

  option :warn,
         short: '-w WARN',
         description: 'Warn if instance has been up longer (Minutes)',
         proc: proc(&:to_i)

  option :critical,
         short: '-c CRITICAL',
         description: 'Critical if instance has been up longer (Minutes)',
         proc: proc(&:to_i)

  option :min,
         short: '-m MIN_TIME',
         description: 'Minimum Time an instance must be running (Minutes)',
         proc: proc(&:to_i),
         default: 5

  option :filter,
         short: '-f FILTER',
         description: 'Filter to use to find ec2 instances',
         default: '{}'

  option :exclude_tags,
         short: '-e {<tag-key>:[VAL1, VAL2]} {<tag-key>:[VAL1, VAL2] }',
         long: '--exclude_tags {<tag-key>:[VAL1, VAL2] } {<tag-key>:[VAL1, VAL2] }',
         description: 'Tag Values to exclude by. Values treated as regex. Any matching value will result in exclusion.',
         default: '{}'

  def aws_config
    hash = {}
    hash.update access_key_id: config[:access_key_id], secret_access_key: config[:secret_access_key] if config[:access_key_id] && config[:secret_access_key]
    hash.update region: config[:aws_region]
    hash
  end

  def run
      #Converting the string into a hash.
      filter_list = config[:exclude_tags].split(/}\s?{/).map{|x| x.gsub(/[{}]/,'')}.map {|y| h1,h2 = y.split(':'); { h1 => h2}}.reduce(:merge)
      filter_list.delete(nil)
      filter_list.each { |x,y| filter_list[x] = y.strip.gsub(/[\[\]]/,'')}
      client = Aws::EC2::Client.new aws_config

      parsed_filter = parse(config[:filter])

      unless parsed_filter.empty?
        filter = {filters: Filter.parse(config[:filter])}
      else
        filter ={}
      end

      data = client.describe_instances(filter)

      currentTime = Time.now.utc
      aws_instances = Set.new
      data.reservations.each do |r|
        r.instances.each do |i|
          aws_instances << {
            id:i[:instance_id],
            up_time: (currentTime - i[:launch_time])/60,
            tags: i.tags
          }
        end
      end

      sensu_clients = client_check

      missing = Set.new

      aws_instances.delete_if { |instance| instance[:tags].any? { |key|
        filter_list.keys.include?(key.key) && filter_list[key.key].split(',').any? { |v|
          key.value.match(/#{v.strip}/)
          }
        }
      }

      aws_instances.each do |i|
        if sensu_clients.include?(i[:id]) == false
          if i[:up_time] > config[:min]
            missing << i
            output "Missing instance #{i[:id]}. Uptime: #{i[:up_time]} Minutes"
          end
        end
      end

      warn_flag = false;
      crit_flag = false;

      missing.each do |m|
        if(config[:critical].nil? == false) &&( m[:up_time] > config[:critical])
          crit_flag = true;
        elsif (config[:warn].nil? == false) && ( m[:up_time] > config[:warn])
          warn_flag = true;
        end
      end

      if crit_flag
        critical
      elsif warn_flag
        warning
      end
      ok
  end

  def client_check
    uri = URI("http://#{config[:sense_host]}:#{config[:sensu_port]}/clients")
    response = JSON.parse(Net::HTTP.get(uri))

    clients = Set.new
    response.each do |client|
      clients << client['name']
    end

    clients
  end
end


text:
package multiplayer.wondevwoman.model;

public enum Direction {
  N,S,W,E,NW,SW,NE,SE;
}


text:
// Copyright (c) 2006,2007,2008,2009,2010,2011 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s)     : Ron Wein           <wein@post.tau.ac.il>

#ifndef CGAL_FIG_STREAM_H
#define CGAL_FIG_STREAM_H

#include <CGAL/basic.h>
#include <CGAL/Polygon_2.h>

#include <vector>
#include <fstream>
#include <cstdio>

namespace CGAL {

/*!
 * FIG colors.
 */
enum Fig_color
{
  // Predefined colors:
  FIG_BLACK = 0,
  FIG_BLUE = 1,
  FIG_GREEN = 2,
  FIG_CYAN = 3,
  FIG_RED = 4,
  FIG_MAGENTA = 5,
  FIG_YELLOW = 6,
  FIG_WHITE = 7,
  FIG_BLUE_1 = 8, FIG_BLUE_2 = 9, FIG_BLUE_3 = 10, FIG_BLUE_4 = 11,
  FIG_GREEN_1 = 12, FIG_GREEN_2 = 13, FIG_GREEN_3 = 14,
  FIG_CYAN_1 = 15, FIG_CYAN_2 = 16, FIG_CYAN_3 = 17,
  FIG_RED_1 = 18, FIG_RED_2 = 19, FIG_RED_3 = 20,
  FIG_MAGENTA_1 = 21, FIG_MAGENTA_2 = 22, FIG_MAGENTA_3 = 23,
  FIG_BROWN_1 = 24, FIG_BROWN_2 = 25, FIG_BROWN_3 = 26,
  FIG_PINK_1 = 27, FIG_PINK_2 = 28, FIG_PINK_3 = 29, FIG_PINK_4 = 30,
  FIG_GOLD = 31,

  // User-defined colors:
  FIG_FIRST_USER_DEFINED_COLOR = 32,
  FIG_LAST_USER_DEFINED_COLOR = 543
};

/*!
 * FIG line styles.
 */
enum Fig_line_style
{
  FIG_SOLID = 0,
  FIG_DASHED = 1,
  FIG_DOTTED = 2,
  FIG_DASH_DOTTED = 3,
  FIG_DASH_DOUBLE_DOTTED = 4,
  FIG_DASH_TRIPLE_DOTTED = 5
};

#define FIG_DEFAULT_STYLE_VALUE   4.0

/*!
 * FIG fill styles.
 */
enum Fig_fill_style
{
  FIG_NOT_FILLED = -1,
  FIG_FILL_BLACK = 0,
  /// Values from 1 to 19 are shades of the color from darker to lighter.
  FIG_FILLED = 20,
  /// Values from 21 to 39 are tints of the color from the color to white.
  FIG_FILL_WHITE = 40,
  FIG_LEFT_DIAG_30DEG = 41,
  FIG_RIGHT_DIAG_30DEG = 42,
  FIG_CROSS_DIAG_30DEG = 43,
  FIG_LEFT_DIAG_45DEG = 44,
  FIG_RIGHT_DIAG_45DEG = 45,
  FIG_CROSS_DIAG_45DEG = 46,
  FIG_HORIZONTAL_BRICKS = 47,
  FIG_VERTICAL_BRICKS = 48,
  FIG_HORIZONTAL_LINES = 49,
  FIG_VERTICAL_LINES = 50,
  FIG_CROSS_LINES = 51,
  FIG_HORIZONTAL_RIGHT_SHINGLES = 52,
  FIG_HORIZONTAL_LEFT_SHINGLES = 53,
  FIG_VERTICAL_RIGHT_SHINGLES = 54,
  FIG_VERTICAL_LEFT_SHINGLES = 55,
  FIG_FISH_SCALES = 56,
  FIG_SMALL_FISH_SCALES = 57,
  FIG_CIRCLES = 58,
  FIG_HEXAGONS = 59,
  FIG_OCTAGONS = 60,
  FIG_HORIZONTAL_TIRE_TREADS = 61,
  FIG_VERTICAL_TIRE_TREADS = 62
};

/*!
 * FIG arrow types.
 */
enum Fig_arrow_type
{
  FIG_STICK = 0,
  FIG_TRIANGLE = 1,
  FIG_INDENTED_BUTT = 2,
  FIG_POINTED_BUTT = 3
};

/*!
 * Arrow modes (not based on the FIG format).
 */
enum Fig_arrow_mode
{
  FIG_NO_ARROW,
  FIG_FORWARD_ARROW,
  FIG_BACKWARD_ARROW,
  FIG_BOTH_ARROWS
};

/*!
 * Point styles (not based on the FIG format).
 */
enum Fig_point_style
{
  FIG_CROSS,
  FIG_PLUS,
  FIG_CIRCLE,
  FIG_DISC,
  FIG_SQUARE,
  FIG_BOX,
  FIG_RHOMBUS,
  FIG_DIAMOND
};

/*!
 * FIG fonts.
 */
enum Fig_font
{
  FIG_ROMAN = 1,
  FIG_BOLD = 2,
  FIG_ITALIC = 3,
  FIG_SANS_SERIF = 4,
  FIG_TYPEWRITER = 5
};

/*!
 * Depth constants.
 */
enum Fig_depth
{
  FIG_MIN_DEPTH = 0,
  FIG_DEFAULT_DEPTH = 50,
  FIG_MAX_DEPTH = 99
};

/*!
 * \class A class for writing geometric objects in a FIG format (version 3.2).
 * For more details, see: http://www.xfig.org/userman/fig-format.html
 */
template <class Kernel_>
class Fig_stream
{
public:

  typedef Kernel_                                Kernel;

  // Define the kernel objects.
  typedef typename Kernel::FT                    NT;
  typedef typename Kernel::Point_2               Point_2;
  typedef typename Kernel::Segment_2             Segment_2;
  typedef typename Kernel::Ray_2                 Ray_2;
  typedef typename Kernel::Line_2                Line_2;
  typedef typename Kernel::Triangle_2            Triangle_2;
  typedef typename Kernel::Iso_rectangle_2       Iso_rectangle_2;
  typedef Polygon_2<Kernel>                      Polygon_2;
  typedef typename Kernel::Circle_2              Circle_2;

protected:

  // Data members:
  std::ofstream           _ofile;       // The output file.

  Iso_rectangle_2         _bound_rect;  // A rectangle bounding the workspace.
  int                     _width;       // Figure width (in pixels).
  int                     _height;      // Figure height (in pixels).
  double                  _scale;       // Scaling factor.

  int                     _depth;

  Fig_color               _color;
  int                     _line_width;
  Fig_line_style          _line_style;
  double                  _style_value;

  Fig_color               _fill_color;
  Fig_fill_style          _fill_style;

  Fig_point_style         _point_style;
  NT                      _point_size;

  Fig_arrow_mode          _arrow_mode;
  Fig_arrow_type          _arrow_type;
  NT                      _arrow_width;
  NT                      _arrow_height;

  Fig_font                _font;
  int                     _font_size;

  bool                    colors[FIG_LAST_USER_DEFINED_COLOR + 1];

  // Kernel functors.
  typename Kernel::Intersect_2       intersect_func;

private:

  // Copy constructor and assignment operator - not supported.
  Fig_stream (const Fig_stream<Kernel>& );
  const Fig_stream<Kernel>& operator= (const Fig_stream<Kernel>& );

public:

  /// \name Constructors and destructor.
  //@{

  /*!
   * Default constructor.
   */
  Fig_stream () :
    _width (0),
    _height (0),
    _scale (0),
    _depth (FIG_DEFAULT_DEPTH),
    _color (FIG_BLACK),
    _line_width (1),
    _line_style (FIG_SOLID),
    _style_value (FIG_DEFAULT_STYLE_VALUE),
    _fill_color (FIG_WHITE),
    _fill_style (FIG_NOT_FILLED),
    _point_style (FIG_DISC),
    _arrow_mode (FIG_NO_ARROW),
    _arrow_type (FIG_STICK),
    _font (FIG_ROMAN),
    _font_size (12)
  {
    // Reset all colors.
    _reset_colors ();

    // Construct the necessary kernel functors.
    Kernel        ker;

    intersect_func = ker.intersect_2_object();
  }

  /*!
   * Constructor.
   * \param filename The name of the output FIG file.
   * \param rect A rectangle bounding the logical drawing area.
   * \param width The physical width of the figure (in FIG units).
   * \param height The physical height of the figure (in FIG units).
   * \pre The bounding rectangle is valid and the physical dimensions are
   *      both positive.
   */
  Fig_stream (const char *filename,
              const Iso_rectangle_2& rect,
              const int& width = 12000,
              const int& height = 12000) :
    _width (0),
    _height (0),
    _scale (0),
    _depth (FIG_DEFAULT_DEPTH),
    _color (FIG_BLACK),
    _line_width (1),
    _line_style (FIG_SOLID),
    _style_value (FIG_DEFAULT_STYLE_VALUE),
    _fill_color (FIG_WHITE),
    _fill_style (FIG_NOT_FILLED),
    _point_style (FIG_DISC),
    _arrow_mode (FIG_NO_ARROW),
    _arrow_type (FIG_STICK),
    _font (FIG_ROMAN),
    _font_size (12)
  {
    // Reset all colors.
    _reset_colors ();

    // Construct the necessary kernel functors.
    Kernel        ker;

    intersect_func = ker.intersect_2_object();

    // Open the file.
    open (filename, rect, width, height);
  }

  /*!
   * Destructor.
   */
  virtual ~Fig_stream ()
  {
    _ofile.close();
  }
  //@}

  /// \name Openning and closing the file.
  //@{

  /*!
   * Check whether the file is open.
   */
  bool is_open ()
  {
    return (_ofile.is_open());
  }

  /*!
   * Open a FIG file.
   * \param filename The name of the output FIG file.
   * \param rect A rectangle bounding the logical drawing area.
   * \param width The physical width of the figure (in FIG units).
   * \param height The physical height of the figure (in FIG units).
   * \pre The bounding rectangle is valid and the physical dimensions are
   *      both positive.
   * \return Whether the file was successfully opened.
   */
  bool open (const char *filename,
             const Iso_rectangle_2& rect,
             const int& width = 12000,
             const int& height = 12000)
  {
    CGAL_precondition (width > 0);
    CGAL_precondition (height > 0);
    CGAL_precondition (rect.xmax() > rect.xmin());
    CGAL_precondition (rect.ymax() > rect.ymin());

    // Reset all colors.
    _reset_colors ();

    // Close the current output file, if necessary.
    if (_ofile.is_open())
      _ofile.close();

    // Open the output file.
    _ofile.open (filename);

    // Set the logical and physical dimensions.
    _bound_rect = rect;
    _width = width;
    _height = height;

    // Compute the scale.
    const double x_scale = width / CGAL::to_double(rect.xmax() - rect.xmin());
    const double y_scale = height / CGAL::to_double(rect.ymax() - rect.ymin());
    _scale = (x_scale < y_scale) ? x_scale : y_scale;

    // Set the default point size and arrow dimensions.
    _point_size = (rect.xmax() - rect.xmin()) / NT(500);
    _arrow_width = _point_size;
    _arrow_height = 2*_point_size;

    // End here if the file is not opened.
    if (! _ofile.is_open())
      return (false);

    // Write the FIG header.
    _ofile << "#FIG 3.2" << std::endl;
    _ofile << "Landscape" << std::endl;
    _ofile << "Center" << std::endl;
    _ofile << "Inches" << std::endl;
    _ofile << "Letter" << std::endl;
    _ofile << "100.00" << std::endl;
    _ofile << "Single" << std::endl;
    _ofile << "-2" << std::endl;
    _ofile << "1200 2" << std::endl;

    return (true);
  }

  /*!
   * Close the FIG file.
   */
  void close ()
  {
    if (_ofile.is_open())
      _ofile.close();

    // Reset all colors.
    _reset_colors ();
  }
  //@}

  /// \name Accessing drawing properties.
  //@{

  /*!
   * Get the workspace bounding rectangle.
   */
  Iso_rectangle_2 bounding_rect() const
  {
      return (_bound_rect);
  }

/*   /\*! */
/*    * Set the workspace bounding rectangle. */
/*    *\/ */
/*   void set_bounding_rect(const Iso_rectangle_2& rect) */
/*   { */
/*       _bound_rect = rect; */
/*   } */

  /*!
   * Get the physical width of the fig
   */
  int width () const
  {
    return _width;
  }

  /*!
   * Get the physical height of the fig
   */
  int height () const
  {
    return _height;
  }

  /*!
   * Get the depth.
   */
  int depth () const
  {
    return (depth);
  }

  /*!
   * Get the color.
   */
  Fig_color color () const
  {
    return (_color);
  }

  /*!
   * Get the line width.
   */
  int line_width () const
  {
    return (line_width);
  }

  /*!
   * Get the line style.
   */
  Fig_line_style line_style () const
  {
    return (_line_style);
  }

  /*!
   * Get the style value.
   */
  double style_value () const
  {
    return (_style_value);
  }

  /*!
   * Get the fill color.
   */
  Fig_color fill_color () const
  {
    return (_fill_color);
  }

  /*!
   * Get the fill style.
   */
  Fig_fill_style fill_style () const
  {
    return (_fill_style);
  }

  /*!
   * Get the point style.
   */
  Fig_point_style point_style () const
  {
    return (_point_style);
  }

  /*!
   * Get the point size.
   */
  const NT& point_size () const
  {
    return (_point_size);
  }

  /*!
   * Get the arrow drawing mode (this mode is relevent when drawing segments,
   * polylines, circular arcs or splines).
   */
  Fig_arrow_mode arrow_mode () const
  {
    return (_arrow_mode);
  }

  /*!
   * Get the arrow type.
   */
  Fig_arrow_type arrow_type () const
  {
    return (_arrow_type);
  }

  /*!
   * Get the arrow width.
   */
  const NT& arrow_width () const
  {
    return (_arrow_width);
  }

  /*!
   * Get the arrow height.
   */
  const NT& arrow_height () const
  {
    return (_arrow_height);
  }

  /*!
   * Get the font.
   */
  Fig_font font () const
  {
    return (_font);
  }

  /*!
   * Get the font size.
   */
  int font_size () const
  {
    return (_font_size);
  }
  //@}

  /// \name Set the drawing properties.
  //@{

  /*!
   * Set the depth.
   */
  void set_depth (const int& depth)
  {
    if (depth < static_cast<int>(FIG_MIN_DEPTH))
      _depth = static_cast<int>(FIG_MIN_DEPTH);
    else if (depth > static_cast<int>(FIG_MAX_DEPTH))
      _depth = static_cast<int>(FIG_MAX_DEPTH);
    else
      _depth = depth;

    return;
  }

  /*!
   * Set the color.
   * \pre The color must be defined.
   */
  void set_color (const Fig_color& color)
  {
    CGAL_precondition (color_defined (color));

    if (color_defined (color))
        _color = color;

    return;
  }

  /*!
   * Set the line width.
   */
  void set_line_width (const unsigned int& width)
  {
    _line_width = static_cast<int>(width);
    return;
  }

  /*!
   * Set the line style.
   */
  void set_line_style (const Fig_line_style& style)
  {
    _line_style = style;
    return;
  }

  /*!
   * Set the style value.
   */
  void set_style_value (const double& val)
  {
    CGAL_precondition (val > 0);

    _style_value = val;
    return;
  }

  /*!
   * Set the fill color.
   * \pre The color must be defined.
   */
  void set_fill_color (const Fig_color& color)
  {
    CGAL_precondition (color_defined (color));

    if (color_defined (color))
        _fill_color = color;

    return;
  }

  /*!
   * Set the fill style.
   */
  void set_fill_style (const Fig_fill_style& style)
  {
    _fill_style = style;
    return;
  }

  /*!
   * Set the point style.
   */
  void set_point_style (const Fig_point_style& style)
  {
    _point_style = style;
    return;
  }

  /*!
   * Set the point size.
   */
  void set_point_size (const NT& size)
  {
    _point_size = CGAL::abs(size);
    return;
  }

  /*!
   * Set the arrow drawing mode. This mode will be applied when drawing
   * segments, polylines, circular arcs or splines.
   */
  void set_arrow_mode (const Fig_arrow_mode& mode)
  {
    _arrow_mode = mode;
    return;
  }

  /*!
   * Set the arrow type.
   */
  void set_arrow_type (const Fig_arrow_type& type)
  {
    _arrow_type = type;
    return;
  }

  /*!
   * Set the arrow width.
   */
  void set_arrow_width (const NT& width)
  {
    _arrow_width = CGAL::abs(width);
    return;
  }

  /*!
   * Get the arrow height.
   */
  void set_arrow_height (const NT& height)
  {
    _arrow_height = CGAL::abs(height);
    return;
  }

  /*!
   * Set the font.
   */
  void set_font (const Fig_font& font)
  {
    _font = font;
    return;
  }

  /*!
   * Set the font size.
   */
  void set_font_size (const unsigned int& size)
  {
    _font_size = static_cast<int>(size);
    return;
  }
  //@}

  /// \name Defining colors.
  //@{

  /*!
   * Check if a color is defined.
   */
  bool color_defined (const Fig_color& color) const
  {
    int     col = static_cast<int>(color);

    if (col < 0 || col > FIG_LAST_USER_DEFINED_COLOR)
        return (false);

    return (colors[col]);
  }

  /*!
   * Add a user-defined color.
   * Use this function after openning the FIG stream and before writing any
   * other object (i.e. before calling the write_<object> () functions).
   * \param color The color.
   * \param r The red component (0 - 255).
   * \param g The green component (0 - 255).
   * \param b The blue component (0 - 255).
   * \pre The color must be undefined.
   */
  void define_color (const Fig_color& color,
                     const unsigned char& r,
                     const unsigned char& g,
                     const unsigned char& b)
  {
    CGAL_precondition (color_defined (color));
    CGAL_precondition (_ofile.is_open());

    if (color_defined (color))
      return;

    // Prepare a string desribing the color.
    char    color_desc [10];

    sprintf ("#%02x%02x%02x", r, g, b);

    // Write the color to the FIG file.
    _ofile << "0 "                        // Desginates a color pseudo-object.
           << static_cast<int>(color) << ' '
           << color_desc << std::endl;

    // Mark that the color is now defined.
    colors[static_cast<int>(color)] = true;

    return;
  }

  //@}

  /// \name Writing objects.
  //@{

  /*!
   * Write a point.
   */
  void write_point (const Point_2& p)
  {
    CGAL_precondition (_ofile.is_open());

    //is the point outside the iso-rectangle?
    if(_bound_rect.has_on_unbounded_side(p))
      return;

    switch (_point_style)
    {
    case (FIG_CROSS):
    case (FIG_PLUS):
    {
      // Draw two segments intersecting at p.
      Point_2  s1, t1;
      Point_2  s2, t2;

      if (_point_style == FIG_PLUS)
      {
        // Draw a '+'.
        s1 = Point_2 (p.x() - _point_size, p.y());
        t1 = Point_2 (p.x() + _point_size, p.y());
        s2 = Point_2 (p.x(), p.y() - _point_size);
        t2 = Point_2 (p.x(), p.y() + _point_size);
      }
      else
      {
        // Draw an 'x'.
        s1 = Point_2 (p.x() - _point_size, p.y() - _point_size);
        t1 = Point_2 (p.x() + _point_size, p.y() + _point_size);
        s2 = Point_2 (p.x() - _point_size, p.y() + _point_size);
        t2 = Point_2 (p.x() + _point_size, p.y() - _point_size);
      }

      // Draw solid lines with width 1.
      _write_segment (Segment_2(s1, t1),
                      _color, 1, FIG_SOLID, _style_value,
                      false);
      _write_segment (Segment_2(s2, t2),
                      _color, 1, FIG_SOLID, _style_value,
                      false);

      break;
    }

    case (FIG_CIRCLE):
    {
      // Draw an empty circle (use a solid line with width 1).
      _write_ellipse (p,
                      CGAL::square(_point_size),
                      CGAL::square(_point_size),
                      _color, 1, FIG_SOLID, _style_value,
                      FIG_WHITE, FIG_NOT_FILLED);

      break;
    }

    case (FIG_DISC):
    {
      // Draw a filled disc.
      _write_ellipse (p,
                      CGAL::square(_point_size),
                      CGAL::square(_point_size),
                      _color, 1, FIG_SOLID, _style_value,
                      _color, FIG_FILLED);

      break;
    }

    case (FIG_SQUARE):
    case (FIG_BOX):
    case (FIG_RHOMBUS):
    case (FIG_DIAMOND):
    {
      // Prepare the rectangle vertices.
      std::vector<Point_2>   vertices (4);

      if (_point_style == FIG_SQUARE || _point_style == FIG_BOX)
      {
        vertices[0] = Point_2 (p.x() - _point_size, p.y() - _point_size);
        vertices[1] = Point_2 (p.x() - _point_size, p.y() + _point_size);
        vertices[2] = Point_2 (p.x() + _point_size, p.y() + _point_size);
        vertices[3] = Point_2 (p.x() + _point_size, p.y() - _point_size);
      }
      else
      {
        vertices[0] = Point_2 (p.x(), p.y() - _point_size);
        vertices[1] = Point_2 (p.x() + _point_size, p.y());
        vertices[2] = Point_2 (p.x(), p.y() + _point_size);
        vertices[3] = Point_2 (p.x() - _point_size, p.y());
      }

      if (_point_style == FIG_SQUARE || _point_style == FIG_RHOMBUS)
      {
        // Draw an empty rectangular shape (use a solid line with width 1).
        _write_polygon (4, vertices.begin(), vertices.end(),
                        _color, 1, FIG_SOLID, _style_value,
                        FIG_WHITE, FIG_NOT_FILLED);
      }
      else
      {
        // Draw a filled rectangular shape.
        _write_polygon (4, vertices.begin(), vertices.end(),
                        _color, 1, FIG_SOLID, _style_value,
                        _color, FIG_FILLED);
      }

      break;
      }
    }

    return;
  }

  /*!
   * Write a segment.
   */
  void write_segment (const Segment_2& seg)
  {
    CGAL_precondition (_ofile.is_open());

    // Clip the ray using the bounding rectangle.
    CGAL::Object    obj = intersect_func (_bound_rect, seg);
    Segment_2       clipped_seg;

    // Draw only the clipped segment (draw nothing if the segment does not
    // intersect the bounding rectangle).
    if (CGAL::assign (clipped_seg, obj))
    {
      _write_segment (clipped_seg,
                      _color, _line_width, _line_style, _style_value,
                      false);
    }

    return;
  }

  /*!
   * Write a ray.
   */
  void write_ray (const Ray_2& ray)
  {
    CGAL_precondition (_ofile.is_open());

    // Clip the ray using the bounding rectangle.
    CGAL::Object    obj = intersect_func (_bound_rect, ray);
    Segment_2       seg;

    // Draw only the clipped segment (draw nothing if the ray does not
    // intersect the bounding rectangle).
    if (CGAL::assign (seg, obj))
    {
      _write_segment (seg,
                      _color, _line_width, _line_style, _style_value,
                      false);
    }

    return;
  }

  /*!
   * Write a line.
   */
  void write_line (const Line_2& line)
  {
    CGAL_precondition (_ofile.is_open());

    // Clip the ray using the bounding rectangle.
    CGAL::Object    obj = intersect_func (_bound_rect, line);
    Segment_2       seg;

    // Draw only the clipped segment (draw nothing if the ray does not
    // intersect the bounding rectangle).
    if (CGAL::assign (seg, obj))
    {
      _write_segment (seg,
                      _color, _line_width, _line_style, _style_value,
                      false);
    }

    return;
  }

  /*!
   * Write a triangle.
   */
  void write_triangle (const Triangle_2& tri)
  {
    CGAL_precondition (_ofile.is_open());

    std::vector<Point_2>   vertices(3);

    vertices[0] = tri.vertex(0);
    vertices[1] = tri.vertex(1);
    vertices[2] = tri.vertex(2);

    _write_polygon (3, vertices.begin(), vertices.end(),
                    _color, _line_width, _line_style, _style_value,
                    _fill_color, _fill_style);
    return;
  }

  /*!
   * Write an iso-rectangle.
   */
  void write_rectangle (const Iso_rectangle_2& rect)
  {
    CGAL_precondition (_ofile.is_open());

    std::vector<Point_2>   vertices(4);

    vertices[0] = rect.vertex(0);
    vertices[1] = rect.vertex(1);
    vertices[2] = rect.vertex(2);
    vertices[3] = rect.vertex(3);

    _write_polygon (4, vertices.begin(), vertices.end(),
                    _color, _line_width, _line_style, _style_value,
                    _fill_color, _fill_style);
    return;
  }

  /*!
   * Write a polyline.
   * \param begin An iterator of the control points (of type Point_2).
   * \param end A past-the-end iterator for the control points.
   */
  template <class Input_iterator>
  void write_polyline (const Input_iterator& begin, const Input_iterator& end)
  {
    CGAL_precondition (_ofile.is_open());

    _write_polyline (begin, end,
                     _color, _line_width, _line_style, _style_value, false);
    return;
  }

  /*!
   * Write a polygon.
   */
  void write_polygon (const Polygon_2& pgn)
  {
    CGAL_precondition (_ofile.is_open());

    _write_polygon (pgn.size(),
                    pgn.vertices_begin(), pgn.vertices_end(),
                    _color, _line_width, _line_style, _style_value,
                    _fill_color, _fill_style);
    return;
  }

  /*!
   * Write a circle.
   */
  void write_circle (const Circle_2& circ)
  {
    CGAL_precondition (_ofile.is_open());

    _write_ellipse (circ.center(),
                    circ.squared_radius(), circ.squared_radius(),
                    _color, _line_width, _line_style, _style_value,
                    _fill_color, _fill_style);
    return;
  }

  /*!
   * Write a canonical ellipse.
   * \param center The center of the ellipse (the intersection of its axes).
   * \param r1_squared The squared length of the axis parallel to the x-axis.
   * \param r2_squared The squared length of the axis parallel to the y-axis.
   */
  void write_ellipse (const Point_2& center,
                      const NT& r1_squared, const NT& r2_squared)
  {
    CGAL_precondition (_ofile.is_open());

    _write_ellipse (center,
                    r1_squared, r2_squared,
                    _color, _line_width, _line_style, _style_value,
                    _fill_color, _fill_style);
    return;
  }

  /*!
   * Write a circular arc.
   * \param p1 The source point of the arc.
   * \param p2 A midpoint on the arc.
   * \param p3 The target point of the arc.
   * \pre The three points are not collinear.
   */
  void write_circular_arc (const Point_2& p1,
                           const Point_2& p2,
                           const Point_2& p3)
  {
    CGAL_precondition (_ofile.is_open());

    _write_arc (p1, p2, p3,
                _color, _line_width, _line_style, _style_value);
    return;
  }

  /*!
   * Write a spline.
   * \param begin An iterator of the control points (of type Point_2).
   * \param end A past-the-end iterator for the control points.
   * \param factor A shape factor for the spline: A value in the range [-1,1],
   *               where negative values are used for interpolated splines
   *               and positive values for approximated splines.
   *               The default value if 1.
   */
  template <class Input_iterator>
  void write_spline (const Input_iterator& begin, const Input_iterator& end,
                     const float& factor = 1)
  {
    CGAL_precondition (_ofile.is_open());

    if (begin == end)
      return;

    // Normalize the shape factor.
    float shape_factor;

    if (factor > 1)
      shape_factor = 1;
    else if (factor < -1)
      shape_factor = -1;
    else
      shape_factor = factor;

    _write_spline (begin, end, shape_factor,
                   _color, _line_width, _line_style, _style_value);
  }

  /*!
   * Write a text box.
   * \param pos The lower-left corner of the text box.
   * \param text The text to write.
   * \param angle The angle (in radians) that the text forms with the x-axis
   *              (0 by default).
   */
  void write_text (const Point_2& pos,
		   const char *text,
		   const double& angle = 0)
  {
    CGAL_precondition (_ofile.is_open());

    if (text == NULL || strlen(text) == 0)
      return;

    _write_text (pos,
		 reinterpret_cast<const unsigned char*>(text), strlen(text),
		 angle,
		 _color, _font, _font_size);
    return;
  }
  //@}

  /// \name Setting the draw properties via the << operator.
  //@{

  /*!
   * Set the depth.
   */
  Fig_stream& operator<< (const Fig_depth& depth)
  {
    set_depth (static_cast<int>(depth));
    return (*this);
  }

  /*!
   * Set the color.
   */
  Fig_stream& operator<< (const Fig_color& color)
  {
    set_color (color);
    return (*this);
  }

  /*!
   * Set the line style.
   */
  Fig_stream& operator<< (const Fig_line_style& style)
  {
    set_line_style (style);
    return (*this);
  }

  /*!
   * Set the fill style.
   */
  Fig_stream& operator<< (const Fig_fill_style& style)
  {
    set_fill_style (style);
    return (*this);
  }

  /*!
   * Set the point style.
   */
  Fig_stream& operator<< (const Fig_point_style& style)
  {
    set_point_style (style);
    return (*this);
  }

  /*!
   * Set the arrow drawing mode. This mode will be applied when drawing
   * segments, polylines, circular arcs or splines.
   */
  Fig_stream& operator<< (const Fig_arrow_mode& mode)
  {
    set_arrow_mode (mode);
    return (*this);
  }

  /*!
   * Set the arrow type.
   */
  Fig_stream& operator<< (const Fig_arrow_type& type)
  {
    set_arrow_type (type);
    return (*this);
  }

  /*!
   * Set the font.
   */
  Fig_stream& operator<< (const Fig_font& font)
  {
    set_font (font);
    return (*this);
  }
  //@}

  /// \name Drawing objects via the << operator.
  //@{

  /*!
   * Write a point.
   */
  Fig_stream& operator<< (const Point_2& p)
  {
    write_point (p);
    return (*this);
  }

  /*!
   * Write a line segment.
   */
  Fig_stream& operator<< (const Segment_2& seg)
  {
    write_segment (seg);
    return (*this);
  }

  /*!
   * Write a ray.
   */
  Fig_stream& operator<< (const Ray_2& ray)
  {
    write_ray (ray);
    return (*this);
  }

  /*!
   * Write a line.
   */
  Fig_stream& operator<< (const Line_2& line)
  {
    write_line (line);
    return (*this);
  }

  /*!
   * Write a triangle.
   */
  Fig_stream& operator<< (const Triangle_2& tri)
  {
    write_triangle (tri);
    return (*this);
  }

  /*!
   * Write a rectangle.
   */
  Fig_stream& operator<< (const Iso_rectangle_2& rect)
  {
    write_rectangle (rect);
    return (*this);
  }

  /*!
   * Write a polygon.
   */
  Fig_stream& operator<< (const Polygon_2& pgn)
  {
    write_polygon (pgn);
    return (*this);
  }

  /*!
   * Write a circle.
   */
  Fig_stream& operator<< (const Circle_2& circ)
  {
    write_circle (circ);
    return (*this);
  }
  //@}

protected:

  /*!
   * Convert a point to FIG units.
   */
  void _convert_point (const Point_2& p,
                       int& ix, int& iy) const
  {
    ix = static_cast<int> (_scale *
                           CGAL::to_double(p.x() - _bound_rect.xmin()));
    iy = static_cast<int> (_scale *
                           CGAL::to_double( _bound_rect.ymax() - p.y()));
    return;
  }

  /*!
   * Write a segment.
   */
  void _write_segment (const Segment_2& seg,
                       const Fig_color&      line_color,
                       const int&            line_width,
                       const Fig_line_style& line_style,
                       const double&         style_value,
                       const bool&      draw_arrows)
  {
    // Convert the segment to a polyline with two points and write it.
    std::vector<Point_2>   points (2);

    points[0] = seg.source();
    points[1] = seg.target();

    _write_polyline (points.begin(), points.end(),
                     line_color, line_width, line_style, style_value,
                     draw_arrows);
    return;
  }

  /*!
   * Write a polyline.
   */
  template <class Input_iterator>
  void _write_polyline (Input_iterator begin, Input_iterator end,
                        const Fig_color&      line_color,
                        const int&            line_width,
                        const Fig_line_style& line_style,
                        const double&         style_value,
                        const bool&      draw_arrows)
  {
    // Check if we should draw arrows.
    bool    forward_arrow = false;
    bool    backward_arrow = false;

    if (draw_arrows)
    {
      forward_arrow = (_arrow_mode == FIG_FORWARD_ARROW) ||
                      (_arrow_mode == FIG_BOTH_ARROWS);
      backward_arrow = (_arrow_mode == FIG_BACKWARD_ARROW) ||
                       (_arrow_mode == FIG_BOTH_ARROWS);
    }

    // Count the number of points in the spline.
    int     n_points = std::distance (begin, end);

    // Write the segment properties.
    _ofile << "2 1 "                      // Desginate a polyline.
           << line_style << ' '
           << line_width << ' '
           << line_color << ' '
           << FIG_WHITE << ' '            // Fill color (dummy).
           << _depth << ' '
           << "0 "                        // Pen style (not in use, always 0).
           << FIG_NOT_FILLED << ' '
           << style_value << ' '
           << "0 "                        // Join style (always 0).
           << "0 "                        // Cap style (always 0).
           << "-1 "                       // Radius (not in use for lines).
           << forward_arrow << ' '
           << backward_arrow << ' '
           << n_points << std::endl;

    // Write the points defining the polyline.
    bool             is_first = true;
    int              ix, iy;

    while (begin != end)
    {
      if (is_first)
      {
        _ofile << '\t';
        is_first = false;
      }
      else
      {
        _ofile << ' ';
      }

      _convert_point (*begin, ix, iy);
      _ofile << ix << ' ' << iy;

      begin++;
    }
    _ofile << std::endl;

    // Write the arrows, if necessary.
    if (forward_arrow)
        _write_arrow_line ();

    if (backward_arrow)
        _write_arrow_line ();

    return;
  }

  /*!
   * Write a polygon, reprsented as a range of points.
   */
  template <class Input_iterator>
  void _write_polygon (const int n_points,
                       Input_iterator begin, Input_iterator end,
                       const Fig_color&      line_color,
                       const int             line_width,
                       const Fig_line_style& line_style,
                       const double&         style_value,
                       const Fig_color&      fill_color,
                       const Fig_fill_style& fill_style)
  {
    // Write the polyline properties.
    _ofile << "2 3 "                      // Desginate a polygon.
           << line_style << ' '
           << line_width << ' '
           << line_color << ' '
           << fill_color << ' '
           << _depth << ' '
           << "0 "                        // Pen style (not in use, always 0).
           << fill_style << ' '
           << style_value << ' '
           << "0 "                        // Join style (always 0).
           << "0 "                        // Cap style (always 0).
           << "-1 "                       // Radius (not in use for lines).
           << "0 "                        // No forward arrow.
           << "0 "                        // No backward arrow.
           << n_points + 1 << std::endl;

    // Write the points.
    bool             is_first = true;
    Point_2          first = *begin;
    int              ix, iy;

    while (begin != end)
    {
      if (is_first)
      {
        _ofile << '\t';
        is_first = false;
      }
      else
      {
        _ofile << ' ';
      }

      _convert_point (*begin, ix, iy);
      _ofile << ix << ' ' << iy;

      begin++;
    }

    // Write the first point again.
    _convert_point (first, ix, iy);
    _ofile << ' ' << ix << ' ' << iy << std::endl;

    return;
  }

  /*!
   * Write an ellipse.
   */
  void _write_ellipse (const Point_2& center,
                       const NT& squared_radius_x,
                       const NT& squared_radius_y,
                       const Fig_color&      line_color,
                       const int&            line_width,
                       const Fig_line_style& line_style,
                       const double&         style_value,
                       const Fig_color&      fill_color,
                       const Fig_fill_style& fill_style)
  {

    // Write the ellipse properties.
    _ofile << "1 1 "                      // Desginate an ellipse.
           << line_style << ' '
           << line_width << ' '
           << line_color << ' '
           << fill_color << ' '
           << _depth << ' '
           << "0 "                        // Pen style (not in use, always 0).
           << fill_style << ' '
           << style_value << ' '
           << "1 "                        // Direction (always 1).
           << "0.000 ";                   // Angle (in radians).

    // Write the center point.
    int     ix, iy;

    _convert_point (center, ix, iy);
    _ofile << ' ' << ix << ' ' << iy;

    // Write the radii.
    int  rx = static_cast<int> (_scale *
                                std::sqrt(CGAL::to_double(squared_radius_x)));
    int  ry = static_cast<int> (_scale *
                                std::sqrt(CGAL::to_double(squared_radius_y)));

    _ofile << ' ' << rx << ' ' << ry;

    // Write the start point (the center) and the end point (one corner of
    // the rectangles bounding the ellipse).
    _ofile << ' ' << ix << ' ' << iy
           << ' ' << (ix + rx) << ' ' << (iy +ry) << std::endl;

    return;
  }

  /*!
   * Write an arc.
   */
  void _write_arc (const Point_2& p1, const Point_2& p2, const Point_2& p3,
                   const Fig_color&      line_color,
                   const int&            line_width,
                   const Fig_line_style& line_style,
                   const double&         style_value)
  {
    // Check if we should draw arrows.
    bool    forward_arrow;
    bool    backward_arrow;

    forward_arrow = (_arrow_mode == FIG_FORWARD_ARROW) ||
                  (_arrow_mode == FIG_BOTH_ARROWS);
    backward_arrow = (_arrow_mode == FIG_BACKWARD_ARROW) ||
                   (_arrow_mode == FIG_BOTH_ARROWS);

    // Construct the supporting circle of the arc and use its center and
    // orientation.
    Circle_2   circ (p1, p2, p3);
    int        orient = (circ.orientation() == CGAL::CLOCKWISE) ? 0 : 1;

    // Write the arc properties.
    _ofile << "5 1 "                      // Desginate an open arc.
           << line_style << ' '
           << line_width << ' '
           << line_color << ' '
           << FIG_WHITE << ' '            // Fill color (dummy).
           << _depth << ' '
           << "0 "                        // Pen style (not in use, always 0).
           << FIG_NOT_FILLED << ' '
           << style_value << ' '
           << "0 "                        // Cap style (always 0).
           << orient << ' '
           << forward_arrow << ' '
           << backward_arrow << ' ';

    // Write the center of the circle.
    int     ix, iy;

    _convert_point (circ.center(), ix, iy);
    _ofile << ix << ' ' << iy;

    // Write the three points defining the arc.
    _convert_point (p1, ix, iy);
    _ofile << ' ' << ix << ' ' << iy;

    _convert_point (p2, ix, iy);
    _ofile << ' ' << ix << ' ' << iy;

    _convert_point (p3, ix, iy);
    _ofile << ' ' << ix << ' ' << iy << std::endl;

    // Write the arrows, if necessary.
    if (forward_arrow)
        _write_arrow_line ();

    if (backward_arrow)
        _write_arrow_line ();

    return;
  }

  /*!
   * Write a spline
   */
  template <class Input_iterator>
  void _write_spline (Input_iterator begin, Input_iterator end,
                      const float& factor,
                      const Fig_color&      line_color,
                      const int&            line_width,
                      const Fig_line_style& line_style,
                      const double&         style_value)
  {
    // Check if we should draw arrows.
    bool    forward_arrow;
    bool    backward_arrow;

    forward_arrow = (_arrow_mode == FIG_FORWARD_ARROW) ||
                  (_arrow_mode == FIG_BOTH_ARROWS);
    backward_arrow = (_arrow_mode == FIG_BACKWARD_ARROW) ||
                   (_arrow_mode == FIG_BOTH_ARROWS);

    // Count the number of points in the spline.
    int     n_points = std::distance (begin, end);

    // Write the spline properties.
    _ofile << "3 0 "                      // Desginate an open spline.
           << line_style << ' '
           << line_width << ' '
           << line_color << ' '
           << FIG_WHITE << ' '            // Fill color (dummy).
           << _depth << ' '
           << "0 "                        // Pen style (not in use, always 0).
           << FIG_NOT_FILLED << ' '
           << style_value << ' '
           << "0 "                        // Cap style (always 0).
           << forward_arrow << ' '
           << backward_arrow << ' '
           << n_points << std::endl;

    // Write the points defining the spline.
    bool             is_first = true;
    int              ix, iy;

    while (begin != end)
    {
      if (is_first)
      {
        _ofile << '\t';
        is_first = false;
      }
      else
      {
        _ofile << ' ';
      }

      _convert_point (*begin, ix, iy);
      _ofile << ix << ' ' << iy;

      begin++;
    }
    _ofile << std::endl;

    // Write the shape factors: 0 for the endpoints and (factor) for each
    // of the midpoints.
    int     i;

    _ofile << '\t' << "0.000";
    for (i = 0; i < n_points - 2; i++)
      _ofile << ' ' << factor;
    _ofile << '\t' << "0.000" << std::endl;

    // Write the arrows, if necessary.
    if (forward_arrow)
        _write_arrow_line ();

    if (backward_arrow)
        _write_arrow_line ();

    return;
  }

  /*!
   * Write an arrow line.
   */
  void _write_arrow_line ()
  {
    int  width  = static_cast<int> (_scale * CGAL::to_double(_arrow_width));
    int  height = static_cast<int> (_scale * CGAL::to_double(_arrow_height));

    _ofile << _arrow_type << ' '
           << "0 "                        // Arrow style (always 0).
           << _line_width << ' '
           << width << ' '
           << height << std::endl;
    return;
  }

  /*!
   * Write a text box.
   */
  void _write_text (const Point_2& pos,
		    const unsigned char *text,
		    const int&          len_text,
		    const double& angle,
		    const Fig_color& font_color,
		    const Fig_font&  font,
		    const int&       font_size)
  {
    // Compute the text-box dimensions.
    const int    text_height = font_size * 1200 / 80;
    const int    text_width = len_text * font_size * 1200 / 160;

    // Write the text properties.
    _ofile << "4 0 "                      // Desginate left-justified text.
	   << font_color << ' '
	   << _depth << ' '
	   << "0 "                        // Pen style (not in use, always 0).
	   << font << ' '
	   << font_size << ' '
	   << angle << ' '
	   << "2 "                        // Indicates a special LaTeX font.
	   << text_height << ' '
	   << text_width;

    // Write the position coordinates.
    int     ix, iy;

    _convert_point (pos, ix, iy);
    _ofile << ' ' << ix << ' ' << iy << ' ';

    // Write the text.
    char    oct[10];
    int     i;

    for (i = 0; i < len_text; i++)
    {
      if (text[i] >= ' ' && text[i] < 128 && text[i] != '\\')
      {
	// If the current character is printable, just write it.
	_ofile << static_cast<char>(text[i]);
      }
      else
      {
	// Convert the current character to an octal string and write it.
	sprintf (oct, "\\%03o", text[i]);
	_ofile << oct;
      }
    }

    // Write the end-of-string sequence.
    _ofile << "\\001" << std::endl;

    return;
  }

  /*!
   * Reset all user-defined colors.
   */
  void _reset_colors ()
  {
    int     i;

    for (i = 0; i < FIG_FIRST_USER_DEFINED_COLOR; i++)
        colors[i] = true;

    for (i = FIG_FIRST_USER_DEFINED_COLOR;
         i < FIG_LAST_USER_DEFINED_COLOR; i++)
    {
        colors[i] = false;
    }

    return;
  }
};

} //namespace CGAL

#endif


text:
module ActiveRestClient
  module Caching
    module ClassMethods
      @@perform_caching = true

      def perform_caching(value = nil)
        if value.nil?
          if @perform_caching.nil?
            @@perform_caching
          else
            @perform_caching
          end
        else
          @perform_caching = value
        end
      end

      def perform_caching=(value)
        @@perform_caching = value
        @perform_caching = value
      end

      def cache_store=(value)
        @@cache_store = nil if value.nil? and return
        raise InvalidCacheStoreException.new("Cache store does not implement #read") unless value.respond_to?(:read)
        raise InvalidCacheStoreException.new("Cache store does not implement #write") unless value.respond_to?(:write)
        raise InvalidCacheStoreException.new("Cache store does not implement #fetch") unless value.respond_to?(:fetch)
        @@cache_store = value
      end

      def cache_store
        rails_cache_store = if Object.const_defined?(:Rails)
          ::Rails.cache
        else
          nil
        end
        (@@cache_store rescue nil) || rails_cache_store
      end

      def _reset_caching!
        @@perform_caching = false
        @perform_caching = false
        @@cache_store = nil
      end

      def read_cached_response(request)
        if cache_store && perform_caching
          key = "#{request.class_name}:#{request.original_url}"
          ActiveRestClient::Logger.debug "  \033[1;4;32m#{ActiveRestClient::NAME}\033[0m #{key} - Trying to read from cache"
          value = cache_store.read(key)
          value = Marshal.load(value) rescue value
        end
      end

      def write_cached_response(request, response, result)
        return if result.is_a? Symbol
        return unless perform_caching
        return unless !result.respond_to?(:_status) || [200, 304].include?(result._status)
        headers = response.response_headers

        headers.keys.select{|h| h.is_a? String}.each do |key|
          headers[key.downcase.to_sym] = headers[key]
        end

        if cache_store && (headers[:etag] || headers[:expires])
          key = "#{request.class_name}:#{request.original_url}"
          ActiveRestClient::Logger.debug "  \033[1;4;32m#{ActiveRestClient::NAME}\033[0m #{key} - Writing to cache"
          cached_response = CachedResponse.new(status:response.status, result:result)
          cached_response.etag = headers[:etag] if headers[:etag]
          cached_response.expires = Time.parse(headers[:expires]) rescue nil if headers[:expires]
          cache_store.write(key, Marshal.dump(cached_response), {}) if cached_response.etag.present? || cached_response.expires
        end
      end
    end

    def self.included(base)
      base.extend(ClassMethods)
    end

  end

  class CachedResponse
    attr_accessor :status, :result, :etag, :expires

    def initialize(options)
      @status = options[:status]
      @result = options[:result]
      @etag = options[:etag]
      @expires = options[:expires]
    end
  end
end


text:
* Ruby topics I've mastered
  * Instance vs class methods
  * Basic data types
    * numeric
    * array
    * string
    * hash
  * Defining methods
    * attr_reader
    * initialize
  * IRB
  * Reading in files
    * IO.readlines
    * JSON.parse
    * File.read
  * String methods
    * include?
    * split
    * gsub
    * gsub!
    * length
    * upcase
    * downcase
    * chomp
    * #{ }
  * Array methods
    * [ ]
    * map
    * min_by
    * max_by
    * sort_by
    * select
    * last
    * first
    * push
    * pop
    * length / size
    * join
    * flatten
    * uniq
    * reverse
    * count
    * each
* Ruby topics I've scraped the surface on
  * Time.now
  * symbols
  * begin/rescue/in
  * send
  * regular expressions
  * ERB
  * WEBrick
  * constants
  * including ruby classes in other places
* Ruby topics I'm struggling with
  * Typing | | and { } are annoying to me because the keys are so far away for my stubby pinky finger
  * Easy ruby things that are suspicious because they aren't like C++
  * Basically getting out of the C++ mindset of iteration and declaration
  * Where does data *exist*? Who can access it? What is existence? Help.
  * How do I step through / debug?
* GitHub and its shiny buttons
  * Just no.
  * I learned how to use the github desktop client, kind of.
  * I keep screwing up if I am on the wrong branch and make edits and then have to make it so they are committed in another branch. When you switch branches, files disappear, and I end up copy/paste/deleting in some janky way that can't possibly be right.
  * I still don't really get why we use branches. Maybe the changes we are making or too simple for them to seem useful right now.
  * Ok, today I forced myself to use the command line instead of the github desktop client. So that was good.
  * I just need more practice.
* Personal retrospective
  * I can finally kind of use a mac? I still have issues with folder navigation...or just navigation in general
  * My writing is, sadly, very sub-par because I have more motivation for the coding bits so I leave the writing for the end
  * I need to get out of C++ land and stop overcomplicating things
  * I need to do a better job planning out a strategy before I start coding. I will often write something that works but is ugly and inefficient, and then later go back and optimize and prettify it. I would save time if I came up with a strategy at the beginning.
  * I really, really need to remember to bring my headphones!


text:
from werkzeug.exceptions import NotFound

class SiteNotSpecifiedError(Exception):
	def __init__(self, *args, **kwargs):
		self.message = "Please specify --site sitename"
		super(Exception, self).__init__(self.message)

class ValidationError(Exception):
	http_status_code = 417

class AuthenticationError(Exception):
	http_status_code = 401

class SessionExpired(Exception):
	http_status_code = 401

class PermissionError(Exception):
	http_status_code = 403

class DoesNotExistError(ValidationError):
	http_status_code = 404

class PageDoesNotExistError(ValidationError):
	http_status_code = 404

class NameError(Exception):
	http_status_code = 409

class OutgoingEmailError(Exception):
	http_status_code = 501

class SessionStopped(Exception):
	http_status_code = 503

class UnsupportedMediaType(Exception):
	http_status_code = 415

class RequestToken(Exception):
	http_status_code = 200

class Redirect(Exception):
	http_status_code = 301

class CSRFTokenError(Exception):
	http_status_code = 400

class TooManyRequestsError(Exception):
	http_status_code = 429

class ImproperDBConfigurationError(Exception):
	"""
	Used when frappe detects that database or tables are not properly
	configured
	"""

	def __init__(self, reason, msg=None):
		if not msg:
			msg = "MariaDb is not properly configured"
		super().__init__(msg)
		self.reason = reason

class DuplicateEntryError(NameError):
	pass

class DataError(ValidationError):
	pass

class UnknownDomainError(Exception):
	pass

class MappingMismatchError(ValidationError):
	pass

class InvalidStatusError(ValidationError):
	pass

class MandatoryError(ValidationError):
	pass

class NonNegativeError(ValidationError):
	pass

class InvalidSignatureError(ValidationError):
	pass

class RateLimitExceededError(ValidationError):
	pass

class CannotChangeConstantError(ValidationError):
	pass

class CharacterLengthExceededError(ValidationError):
	pass

class UpdateAfterSubmitError(ValidationError):
	pass

class LinkValidationError(ValidationError):
	pass

class CancelledLinkError(LinkValidationError):
	pass

class DocstatusTransitionError(ValidationError):
	pass

class TimestampMismatchError(ValidationError):
	pass

class EmptyTableError(ValidationError):
	pass

class LinkExistsError(ValidationError):
	pass

class InvalidEmailAddressError(ValidationError):
	pass

class InvalidNameError(ValidationError):
	pass

class InvalidPhoneNumberError(ValidationError):
	pass

class TemplateNotFoundError(ValidationError):
	pass

class UniqueValidationError(ValidationError):
	pass

class AppNotInstalledError(ValidationError):
	pass

class IncorrectSitePath(NotFound):
	pass

class ImplicitCommitError(ValidationError):
	pass

class RetryBackgroundJobError(Exception):
	pass

class DocumentLockedError(ValidationError):
	pass

class CircularLinkingError(ValidationError):
	pass

class SecurityException(Exception):
	pass

class InvalidColumnName(ValidationError):
	pass

class IncompatibleApp(ValidationError):
	pass

class InvalidDates(ValidationError):
	pass

class DataTooLongException(ValidationError):
	pass

class FileAlreadyAttachedException(Exception):
	pass

class DocumentAlreadyRestored(ValidationError):
	pass

class AttachmentLimitReached(ValidationError):
	pass

class QueryTimeoutError(Exception):
	pass

class QueryDeadlockError(Exception):
	pass

class TooManyWritesError(Exception):
	pass

# OAuth exceptions
class InvalidAuthorizationHeader(CSRFTokenError):
	pass

class InvalidAuthorizationPrefix(CSRFTokenError):
	pass

class InvalidAuthorizationToken(CSRFTokenError):
	pass

class InvalidDatabaseFile(ValidationError):
	pass

class ExecutableNotFound(FileNotFoundError):
	pass

class InvalidRemoteException(Exception):
	pass

class LinkExpired(ValidationError):
	http_status_code = 410
	title = "Link Expired"
	message = "The link has expired"

class InvalidKeyError(ValidationError):
	http_status_code = 401
	title = "Invalid Key"
	message = "The document key is invalid"


text:
@import 'part:@lyra/base/theme/variables-style';

.link {
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;

  @nest &:hover {
    background-color: #ddd;
  }
}

.pointerList {
  text-align: left;
}
.pointerList li {
  list-style-type: circle;
  list-style-position: inside;
  margin-bottom: var(--small-padding);
}