text:
<?php
/**
 * bloodstone community V1.0.0
 * @link https://www.facebook.com/Mazn.touati
 * @author Mazen Touati
 * @version 1.0.0
 */
class create extends Controller
{
    /**
     *
     */
    public function thread()
    {
        if (!usersAPI::isLogged())
            header('Location: '.URL.'home');
        //get the passed params
        $params = func_get_args();
        //if isset a param => isset a thread ID
        if (isset($params[0])) {
            //set the view data array
            $data = [];
            $data['forum'] = forumsAPI::getInstance()->getForumByID($params[0], 'id, cat_id, title_'.LANGUAGE_CODE.' as title, status');
            if (!empty($data['forum'])){
                if ($data['forum'][0]->status == 0)
                    header('Location: '.URL.'home');
                //prepare the language
                self::$language->load('create');
                //the title of the page on browser tab
                $data['title'] = self::$language->invokeOutput('title/thread');
                //the title shown on the page wide header
                $data['page-title'] = self::$language->invokeOutput('title/thread');
                //get the category title
                $data['forum'] = $data['forum'][0];
                $data['category'] = categoryAPI::getInstance()->getCategoryByID($data['forum']->cat_id, 'id, title_'.LANGUAGE_CODE.' as title');
                $data['category'] = isset_get($data['category'], 0, []);
                //create a new draft instance or get the already created one
                $data['draft'] = threadDraftAPI::getInstance()->initDraft();
                //load the header view
                $this->loadView('header', $data);
                //load this page view
                $this->loadView('create/thread', $data);
                //load the footer view
                $this->loadView('footer', $data);
            }else{
                //if the ID not found => show 404 error
                header('Location: ../error');
            }
        }else{
            //if no params is passed
            header('Location: ../error');
        }
    }

    /**
     *
     */
    public function reply()
    {
        if (!usersAPI::isLogged())
            header('Location: '.URL.'home');
        //get the passed params
        $params = func_get_args();
        //if isset a param => isset a thread ID
        if (isset($params[0])) {
            //set the view data array
            $data = [];
            $data['thread'] = threadsAPI::getInstance()->getThreadByID($params[0], 'id, forum_id, title');
            if (!empty($data['thread'])){
                $data['thread'] = $data['thread'][0];
                $data['forum'] = forumsAPI::getInstance()->getForumByID($data['thread']->forum_id, 'id, cat_id, title_'.LANGUAGE_CODE.' as title');
                if (!empty($data['forum'])) {
                    //prepare the language
                    self::$language->load('create');
                    //the title of the page on browser tab
                    $data['title'] = self::$language->invokeOutput('title/reply');
                    //the title shown on the page wide header
                    $data['page-title'] = self::$language->invokeOutput('title/reply');
                    //get the category title
                    $data['forum'] = $data['forum'][0];
                    $data['category'] = categoryAPI::getInstance()->getCategoryByID($data['forum']->cat_id, 'id, title_'.LANGUAGE_CODE.' as title');
                    $data['category'] = isset_get($data['category'], 0, []);
                    //load the header view
                    $this->loadView('header', $data);
                    //load this page view
                    $this->loadView('create/reply', $data);
                    //load the footer view
                    $this->loadView('footer', $data);
                }else{
                    //if the ID not found => show 404 error
                    header('Location: ../error');
                }
            }else{
                //if the ID not found => show 404 error
                header('Location: ../error');
            }
        }else{
            //if no params is passed
            header('Location: ../error');
        }
    }

    /**
     *
     */
    public function message()
    {
        if (!usersAPI::isLogged())
            header('Location: '.URL.'home');
        //get the passed params
        $params = func_get_args();
        //create the data holder
        $data = [];
        //if isset a param => isset a user id
        if (isset($params[0])){
            $id = self::$GLOBAL['logged']->id;
            //if the user attempt to send a message to himself
            if ($id == $params[0])
                header('Location: ../error');
            $user = usersAPI::getInstance()->getUserById($params[0], 'id, username');
            //if the given id is wrong
            if (empty($user))
                header('Location: ../error');
            $data['user'] = $user[0];
            //get the user preferences
            $preferences = usersAPI::getInstance()->getUserPreferences($user[0]->id, 'messages');
            if ($preferences[0]->messages == 0 && !accessAPI::is_Administration())
                header('Location: '.URL.'home');
        }
        //prepare the language
        self::$language->load('create');
        //the title of the page on browser tab
        $data['title'] = self::$language->invokeOutput('title/message');
        //the title shown on the page wide header
        $data['page-title'] = self::$language->invokeOutput('create/message');
        //create a new draft instance or get the already created one
        $data['draft'] = inboxDraftAPI::getInstance()->initDraft();
        //load the header view
        $this->loadView('header', $data);
        //load this page view
        $this->loadView('create/message', $data);
        //load the footer view
        $this->loadView('footer', $data);
    }

}


text:
require 'rails_helper'

describe 'tools routes', :type => :routing do
  it "GET /tools/url_decoding_tool should route to 'tools#url_decoding_tool'" do
    expect(:get => '/tools/url_decoding_tool').
        to route_to(:controller => 'tools',
                    :action => 'url_decoding_tool')
  end

  it "POST /tools/url_decoding_tool should route to 'tools#url_decoding_tool'" do
    expect(:post => '/tools/url_decoding_tool').
        to route_to(:controller => 'tools',
                    :action => 'url_decoding_tool')
  end

  it "GET /tools/hash_generator should route to 'tools#hash_generator'" do
    expect(:get => '/tools/hash_generator').
        to route_to(:controller => 'tools',
                    :action => 'hash_generator')
  end

  it "POST /tools/hash_generator should route to 'tools#hash_generator'" do
    expect(:post => '/tools/hash_generator').
        to route_to(:controller => 'tools',
                    :action => 'hash_generator')
  end

  it "GET /tools/base64_encoder should route to 'tools#base64_encoder'" do
    expect(:get => '/tools/base64_encoder').
        to route_to(:controller => 'tools',
                    :action => 'base64_encoder')
  end

  it "POST /tools/base64_encoder should route to 'tools#base64_encoder'" do
    expect(:post => '/tools/base64_encoder').
        to route_to(:controller => 'tools',
                    :action => 'base64_encoder')
  end

  it "GET /tools/json_beautifier should route to 'tools#json_beautifier'" do
    expect(:get => '/tools/json_beautifier').
        to route_to(:controller => 'tools',
                    :action => 'json_beautifier')
  end

  it "POST /tools/json_beautifier should route to 'tools#json_beautifier'" do
    expect(:post => '/tools/json_beautifier').
        to route_to(:controller => 'tools',
                    :action => 'json_beautifier')
  end

  it "GET /tools/json_to_ruby_class should route to 'tools#json_to_ruby_class'" do
    expect(:get => '/tools/json_to_ruby_class').
        to route_to(:controller => 'tools',
                    :action => 'json_to_ruby_class')
  end

  it "POST /tools/json_to_ruby_class should route to 'tools#json_to_ruby_class'" do
    expect(:post => '/tools/json_to_ruby_class').
        to route_to(:controller => 'tools',
                    :action => 'json_to_ruby_class')
  end

  it "GET /tools/xml_beautifier should route to 'tools#xml_beautifier'" do
    expect(:get => '/tools/xml_beautifier').
        to route_to(:controller => 'tools',
                    :action => 'xml_beautifier')
  end

  it "POST /tools/xml_beautifier should route to 'tools#xml_beautifier'" do
    expect(:post => '/tools/xml_beautifier').
        to route_to(:controller => 'tools',
                    :action => 'xml_beautifier')
  end

  it "GET /tools/sql_beautifier should route to 'tools#sql_beautifier'" do
    expect(:get => '/tools/sql_beautifier').
        to route_to(:controller => 'tools',
                    :action => 'sql_beautifier')
  end

  it "POST /tools/sql_beautifier should route to 'tools#sql_beautifier'" do
    expect(:post => '/tools/sql_beautifier').
        to route_to(:controller => 'tools',
                    :action => 'sql_beautifier')
  end

  it "GET /tools/ssh_generator should route to 'tools#ssh_generator'" do
    expect(:get => '/tools/ssh_generator').
        to route_to(:controller => 'tools',
                    :action => 'ssh_generator')
  end

  it "POST /tools/ssh_generator should route to 'tools#ssh_generator'" do
    expect(:post => '/tools/ssh_generator').
        to route_to(:controller => 'tools',
                    :action => 'ssh_generator')
  end

  it "GET /tools/text_analysis should route to 'tools#text_analysis'" do
    expect(:get => '/tools/text_analysis').
        to route_to(:controller => 'tools',
                    :action => 'text_analysis')
  end

  it "POST /tools/text_analysis should route to 'tools#text_analysis'" do
    expect(:post => '/tools/text_analysis').
        to route_to(:controller => 'tools',
                    :action => 'text_analysis')
  end

  it "GET /tools/json_web_token should route to 'tools#json_web_token'" do
    expect(:get => '/tools/json_web_token').
        to route_to(:controller => 'tools',
                    :action => 'json_web_token')
  end

  it "POST /tools/json_web_token should route to 'tools#json_web_token'" do
    expect(:post => '/tools/json_web_token').
        to route_to(:controller => 'tools',
                    :action => 'json_web_token')
  end
end

redpajama_set_name: RedPajamaGithub


text:
import { TableCell, TableSortLabel, TableSortLabelProps } from "@mui/material";
import React from "react";
import { ArrowDown, ArrowDownUp } from "react-bootstrap-icons";

import { ColumnType, OrderByType } from "./Table.types";

interface ISortLabelProps extends TableSortLabelProps {
  disabled?: boolean;
}

const SortLabelWrapper = ({
  disabled = false,
  children,
  ...rest
}: ISortLabelProps) => {
  if (disabled) {
    return <>{children}</>;
  }

  return <TableSortLabel {...rest}>{children}</TableSortLabel>;
};

interface IHeaderCellProps<T> {
  column: ColumnType<T>;
  orderBy: OrderByType;
  setOrderBy: React.Dispatch<React.SetStateAction<OrderByType>>;
}
export const HeaderCell = <T,>({
  column,
  orderBy,
  setOrderBy,
}: IHeaderCellProps<T>) => {
  const getCurrentColumnDir = () => {
    if (!column.sort || orderBy.field !== column.name) {
      return;
    }

    return orderBy.order;
  };

  const getNewColumnDir = () => {
    if (orderBy.field !== column.name) {
      return "desc";
    }

    return orderBy.order === "desc" ? "asc" : "desc";
  };

  const setNewOrder = () => {
    const newDir = getNewColumnDir();

    setOrderBy({
      field: column.name,
      order: newDir,
    });
    column.onSort?.(column.name, newDir);
  };

  return (
    <TableCell
      sx={{
        textAlign: column.headerAlign ?? "left",
        fontWeight: "bold",
      }}
      hidden={column.hideHeader}
      sortDirection={getCurrentColumnDir()}
    >
      <SortLabelWrapper
        disabled={!column.sort}
        active={orderBy.field === column.name}
        direction={getCurrentColumnDir()}
        sx={{
          "& .MuiTableSortLabel-icon": {
            opacity: 1,
          },
        }}
        onClick={() => setNewOrder()}
        IconComponent={column.name !== orderBy.field ? ArrowDownUp : ArrowDown}
      >
        {column.text}
      </SortLabelWrapper>
    </TableCell>
  );
};


text:
using System.Web.Mvc;
using PopForums.Models;

namespace PopForums.Extensions
{
	public static class ViewDataDictionaries
	{
		public const string ViewDataUserKey = "PopForums.Identity.CurrentUser";

		public static void SetUserInViewData(this ViewDataDictionary viewData, User user)
		{
			viewData[ViewDataUserKey] = user;
		}
	}
}


text:
package organizations_test

import (
	"context"
	"fmt"
	"testing"

	"github.com/google/go-cmp/cmp"
	"github.com/google/go-cmp/cmp/cmpopts"
	"github.com/influxdata/influxdb/v2/chronograf"
	"github.com/influxdata/influxdb/v2/chronograf/mocks"
	"github.com/influxdata/influxdb/v2/chronograf/organizations"
)

// IgnoreFields is used because ID cannot be predicted reliably
// EquateEmpty is used because we want nil slices, arrays, and maps to be equal to the empty map
var organizationCmpOptions = cmp.Options{
	cmpopts.EquateEmpty(),
	cmpopts.IgnoreFields(chronograf.Organization{}, "ID"),
}

func TestOrganizations_All(t *testing.T) {
	type fields struct {
		OrganizationsStore chronograf.OrganizationsStore
	}
	type args struct {
		organization string
		ctx          context.Context
	}
	tests := []struct {
		name    string
		args    args
		fields  fields
		want    []chronograf.Organization
		wantErr bool
	}{
		{
			name: "No Organizations",
			fields: fields{
				OrganizationsStore: &mocks.OrganizationsStore{
					AllF: func(ctx context.Context) ([]chronograf.Organization, error) {
						return nil, fmt.Errorf("no Organizations")
					},
					DefaultOrganizationF: func(ctx context.Context) (*chronograf.Organization, error) {
						return &chronograf.Organization{
							ID:   "0",
							Name: "Default",
						}, nil
					},
				},
			},
			wantErr: true,
		},
		{
			name: "All Organizations",
			fields: fields{
				OrganizationsStore: &mocks.OrganizationsStore{
					DefaultOrganizationF: func(ctx context.Context) (*chronograf.Organization, error) {
						return &chronograf.Organization{
							ID:   "0",
							Name: "Default",
						}, nil
					},
					AllF: func(ctx context.Context) ([]chronograf.Organization, error) {
						return []chronograf.Organization{
							{
								Name: "howdy",
								ID:   "1337",
							},
							{
								Name: "doody",
								ID:   "1447",
							},
						}, nil
					},
				},
			},
			args: args{
				organization: "1337",
				ctx:          context.Background(),
			},
			want: []chronograf.Organization{
				{
					Name: "howdy",
					ID:   "1337",
				},
				{
					Name: "Default",
					ID:   "0",
				},
			},
		},
	}
	for _, tt := range tests {
		s := organizations.NewOrganizationsStore(tt.fields.OrganizationsStore, tt.args.organization)
		tt.args.ctx = context.WithValue(tt.args.ctx, organizations.ContextKey, tt.args.organization)
		gots, err := s.All(tt.args.ctx)
		if (err != nil) != tt.wantErr {
			t.Errorf("%q. OrganizationsStore.All() error = %v, wantErr %v", tt.name, err, tt.wantErr)
			continue
		}
		for i, got := range gots {
			if diff := cmp.Diff(got, tt.want[i], organizationCmpOptions...); diff != "" {
				t.Errorf("%q. OrganizationsStore.All():\n-got/+want\ndiff %s", tt.name, diff)
			}
		}
	}
}

func TestOrganizations_Add(t *testing.T) {
	type fields struct {
		OrganizationsStore chronograf.OrganizationsStore
	}
	type args struct {
		organizationID string
		ctx            context.Context
		organization   *chronograf.Organization
	}
	tests := []struct {
		name    string
		args    args
		fields  fields
		want    *chronograf.Organization
		wantErr bool
	}{
		{
			name: "Add Organization",
			fields: fields{
				OrganizationsStore: &mocks.OrganizationsStore{
					AddF: func(ctx context.Context, s *chronograf.Organization) (*chronograf.Organization, error) {
						return s, nil
					},
					GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
						return &chronograf.Organization{
							ID:   "1229",
							Name: "howdy",
						}, nil
					},
				},
			},
			args: args{
				organizationID: "1229",
				ctx:            context.Background(),
				organization: &chronograf.Organization{
					Name: "howdy",
				},
			},
			wantErr: true,
		},
	}
	for _, tt := range tests {
		s := organizations.NewOrganizationsStore(tt.fields.OrganizationsStore, tt.args.organizationID)
		tt.args.ctx = context.WithValue(tt.args.ctx, organizations.ContextKey, tt.args.organizationID)
		d, err := s.Add(tt.args.ctx, tt.args.organization)
		if (err != nil) != tt.wantErr {
			t.Errorf("%q. OrganizationsStore.Add() error = %v, wantErr %v", tt.name, err, tt.wantErr)
			continue
		}
		if tt.wantErr {
			continue
		}
		got, err := s.Get(tt.args.ctx, chronograf.OrganizationQuery{ID: &d.ID})
		if err != nil {
			t.Fatal(err)
		}
		if diff := cmp.Diff(got, tt.want, organizationCmpOptions...); diff != "" {
			t.Errorf("%q. OrganizationsStore.Add():\n-got/+want\ndiff %s", tt.name, diff)
		}
	}
}

func TestOrganizations_Delete(t *testing.T) {
	type fields struct {
		OrganizationsStore chronograf.OrganizationsStore
	}
	type args struct {
		organizationID string
		ctx            context.Context
		organization   *chronograf.Organization
	}
	tests := []struct {
		name     string
		fields   fields
		args     args
		addFirst bool
		wantErr  bool
	}{
		{
			name: "Delete organization",
			fields: fields{
				OrganizationsStore: &mocks.OrganizationsStore{
					DeleteF: func(ctx context.Context, s *chronograf.Organization) error {
						return nil
					},
					GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
						return &chronograf.Organization{
							ID:   "1229",
							Name: "howdy",
						}, nil
					},
				},
			},
			args: args{
				organizationID: "1229",
				ctx:            context.Background(),
				organization: &chronograf.Organization{
					ID:   "1229",
					Name: "howdy",
				},
			},
			addFirst: true,
		},
	}
	for _, tt := range tests {
		s := organizations.NewOrganizationsStore(tt.fields.OrganizationsStore, tt.args.organizationID)
		tt.args.ctx = context.WithValue(tt.args.ctx, organizations.ContextKey, tt.args.organizationID)
		err := s.Delete(tt.args.ctx, tt.args.organization)
		if (err != nil) != tt.wantErr {
			t.Errorf("%q. OrganizationsStore.All() error = %v, wantErr %v", tt.name, err, tt.wantErr)
			continue
		}
	}
}

func TestOrganizations_Get(t *testing.T) {
	type fields struct {
		OrganizationsStore chronograf.OrganizationsStore
	}
	type args struct {
		organizationID string
		ctx            context.Context
		organization   *chronograf.Organization
	}
	tests := []struct {
		name    string
		fields  fields
		args    args
		want    *chronograf.Organization
		wantErr bool
	}{
		{
			name: "Get Organization",
			fields: fields{
				OrganizationsStore: &mocks.OrganizationsStore{
					GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
						return &chronograf.Organization{
							ID:   "1337",
							Name: "howdy",
						}, nil
					},
				},
			},
			args: args{
				organizationID: "1337",
				ctx:            context.Background(),
				organization: &chronograf.Organization{
					ID:   "1337",
					Name: "howdy",
				},
			},
			want: &chronograf.Organization{
				ID:   "1337",
				Name: "howdy",
			},
		},
	}
	for _, tt := range tests {
		s := organizations.NewOrganizationsStore(tt.fields.OrganizationsStore, tt.args.organizationID)
		tt.args.ctx = context.WithValue(tt.args.ctx, organizations.ContextKey, tt.args.organizationID)
		got, err := s.Get(tt.args.ctx, chronograf.OrganizationQuery{ID: &tt.args.organization.ID})
		if (err != nil) != tt.wantErr {
			t.Errorf("%q. OrganizationsStore.Get() error = %v, wantErr %v", tt.name, err, tt.wantErr)
			continue
		}
		if diff := cmp.Diff(got, tt.want, organizationCmpOptions...); diff != "" {
			t.Errorf("%q. OrganizationsStore.Get():\n-got/+want\ndiff %s", tt.name, diff)
		}
	}
}

func TestOrganizations_Update(t *testing.T) {
	type fields struct {
		OrganizationsStore chronograf.OrganizationsStore
	}
	type args struct {
		organizationID string
		ctx            context.Context
		organization   *chronograf.Organization
		name           string
	}
	tests := []struct {
		name     string
		fields   fields
		args     args
		want     *chronograf.Organization
		addFirst bool
		wantErr  bool
	}{
		{
			name: "Update Organization Name",
			fields: fields{
				OrganizationsStore: &mocks.OrganizationsStore{
					UpdateF: func(ctx context.Context, s *chronograf.Organization) error {
						return nil
					},
					GetF: func(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
						return &chronograf.Organization{
							ID:   "1229",
							Name: "doody",
						}, nil
					},
				},
			},
			args: args{
				organizationID: "1229",
				ctx:            context.Background(),
				organization: &chronograf.Organization{
					ID:   "1229",
					Name: "howdy",
				},
				name: "doody",
			},
			want: &chronograf.Organization{
				Name: "doody",
			},
			addFirst: true,
		},
	}
	for _, tt := range tests {
		if tt.args.name != "" {
			tt.args.organization.Name = tt.args.name
		}
		s := organizations.NewOrganizationsStore(tt.fields.OrganizationsStore, tt.args.organizationID)
		tt.args.ctx = context.WithValue(tt.args.ctx, organizations.ContextKey, tt.args.organizationID)
		err := s.Update(tt.args.ctx, tt.args.organization)
		if (err != nil) != tt.wantErr {
			t.Errorf("%q. OrganizationsStore.Update() error = %v, wantErr %v", tt.name, err, tt.wantErr)
			continue
		}
		got, err := s.Get(tt.args.ctx, chronograf.OrganizationQuery{ID: &tt.args.organization.ID})
		if err != nil {
			t.Fatal(err)
		}
		if diff := cmp.Diff(got, tt.want, organizationCmpOptions...); diff != "" {
			t.Errorf("%q. OrganizationsStore.Update():\n-got/+want\ndiff %s", tt.name, diff)
		}
	}
}


text:
using System;
using Gtk;

namespace Mono.Addins.GuiGtk3
{
	class HeaderBox: Bin
	{
		Gtk.Widget child;
		int topMargin;
		int bottomMargin;
		int leftMargin;
		int rightMargin;

		int topPadding;
		int bottomPadding;
		int leftPadding;
		int rightPadding;

		bool useCustomColor;
		Gdk.Color customColor;

		public HeaderBox ()
		{
		}

		public HeaderBox (int topMargin, int bottomMargin, int leftMargin, int rightMargin)
		{
			SetMargins (topMargin, bottomMargin, leftMargin, rightMargin);
		}

		public void Replace (Gtk.Bin parent)
		{
			Gtk.Widget c = parent.Child;
			parent.Remove (c);
			Add (c);
			parent.Add (this);
		}

		public void SetMargins (int topMargin, int bottomMargin, int leftMargin, int rightMargin)
		{
			this.topMargin = topMargin;
			this.bottomMargin = bottomMargin;
			this.leftMargin = leftMargin;
			this.rightMargin = rightMargin;
		}

		public void SetPadding (int topPadding, int bottomPadding, int leftPadding, int rightPadding)
		{
			this.topPadding = topPadding;
			this.bottomPadding = bottomPadding;
			this.leftPadding = leftPadding;
			this.rightPadding = rightPadding;
		}

		public bool GradientBackround { get; set; }

		public Gdk.Color BackgroundColor {
			get { return customColor; }
			set { customColor = value; useCustomColor = true; }
		}

		public void ResetBackgroundColor ()
		{
			useCustomColor = false;
		}

		protected override void OnAdded (Widget widget)
		{
			base.OnAdded (widget);
			child = widget;
		}

//		protected override void OnSizeRequested (ref Requisition requisition)
//		{
//			if (child != null) {
//				requisition = child.SizeRequest ();
//				requisition.Width += leftMargin + rightMargin + leftPadding + rightPadding;
//				requisition.Height += topMargin + bottomMargin + topPadding + bottomPadding;
//			} else {
//				requisition.Width = 0;
//				requisition.Height = 0;
//			}
//		}

		public new void GetPreferredWidth (out int width)
		{
			if (child != null) {
				Requisition req = child.SizeRequest ();
				req.Width += leftMargin + rightMargin + leftPadding + rightPadding;
				width = req.Width;
			} else {
				width = 0;
			}
		}

		public new void GetPreferredHeight (out int height)
		{
			if (child != null) {
				Requisition req = child.SizeRequest ();
				req.Height += topMargin + bottomMargin + topPadding + bottomPadding;
				height = req.Height;
			} else {
				height = 0;
			}
		}

		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
		{
			base.OnSizeAllocated (allocation);
			if (allocation.Width > leftMargin + rightMargin + leftPadding + rightPadding) {
				allocation.X += leftMargin + leftPadding;
				allocation.Width -= leftMargin + rightMargin + leftPadding + rightPadding;
			}
			if (allocation.Height > topMargin + bottomMargin + topPadding + bottomPadding) {
				allocation.Y += topMargin + topPadding;
				allocation.Height -= topMargin + bottomMargin + topPadding + bottomPadding;
			}
			if (child != null)
				child.SizeAllocate (allocation);
		}

		public new void Draw (Cairo.Context cr)
		{
			Gdk.Rectangle rect;

			if (GradientBackround) {
				rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
				HslColor gcol = useCustomColor ? customColor : Parent.Style.Background (Gtk.StateType.Normal);

				cr.NewPath ();
				cr.MoveTo (rect.X, rect.Y);
				cr.RelLineTo (rect.Width, 0);
				cr.RelLineTo (0, rect.Height);
				cr.RelLineTo (-rect.Width, 0);
				cr.RelLineTo (0, -rect.Height);
				cr.ClosePath ();
				using (Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Y + rect.Height - 1)) {
					Cairo.Color color1 = gcol;
					pat.AddColorStop (0, color1);
					gcol.L -= 0.1;
					if (gcol.L < 0)
						gcol.L = 0;
					pat.AddColorStop (1, gcol);
					cr.Pattern = pat;
					cr.FillPreserve ();
				}

			}

			base.Draw (cr);
			//FIXME: Get this drawing properly again!
//			Gdk.Color colour = Parent.Style.Dark (Gtk.StateType.Normal);
//			cr.SetSourceRGB (colour.Red, colour.Green, colour.Blue);
//
//			rect = Allocation;
//			for (int n=0; n<topMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Left + rect.Width - 1, rect.Y + n);
//
//			for (int n=0; n<bottomMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X, rect.Top + rect.Height - 1 - n, rect.Left + rect.Width - 1, rect.Top + rect.Height - 1 - n);
//
//			for (int n=0; n<leftMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Top + rect.Height - 1);
//
//			for (int n=0; n<rightMargin; n++)
//				GdkWindow.DrawLine (borderColor, rect.Left + rect.Width - 1 - n, rect.Y, rect.Left + rect.Width - 1 - n, rect.Top + rect.Height - 1);
		}
	}
}


text:
<?php

// Jivoo
// Copyright (c) 2015 Niels Sonnich Poulsen (http://nielssp.dk)
// Licensed under the MIT license.
// See the LICENSE file or http://opensource.org/licenses/MIT for more information.
namespace Jivoo\Data\Database;

use Jivoo\Data\Definition;

/**
 * A database schema.
 */
class DatabaseDefinitionBuilder implements DatabaseDefinition
{

    /**
     * @var Definition[] Associative array of names and definitions.
     */
    private $definitions = array();

    /**
     * @var string[] List of table names.
     */
    private $tables = array();

    /**
     * Construct database definition.
     *
     * @param Definition[]|DatabaseDefinition $definitions Associative array of
     * table names and definitions or another instance of {@see DatabaseDefinition}.
     * @param boolean $dynamic
     */
    public function __construct($definitions = array())
    {
        if ($definitions instanceof DatabaseDefinitionBuilder) {
            $this->tables = $definitions->tables;
            $this->definitions = $definitions->definitions;
        } elseif ($definitions instanceof DatabaseDefinition) {
            foreach ($definitions->getTables() as $table) {
                $this->addDefinition($table, $definitions->getDefinition($table));
            }
        } else {
            foreach ($definitions as $table => $definition) {
                $this->addDefinition($table, $definition);
            }
        }
    }

    /**
     * {@inheritdoc}
     */
    public function getTables()
    {
        return $this->tables;
    }

    /**
     * {@inheritdoc}
     */
    public function getDefinition($table)
    {
        if (isset($this->definitions[$table])) {
            return $this->definitions[$table];
        }
        return null;
    }

    /**
     * Add a table to the definition.
     *
     * @param string $table Table name.
     * @param Definition $definition Table definition.
     */
    public function addDefinition($table, Definition $definition)
    {
        if (!in_array($table, $this->tables)) {
            $this->tables[] = $table;
        }
        $this->definitions[$table] = $definition;
    }
}


text:
  <title>PB2 / Monitor</title>

PB2 Monitor

  Demos

Canvas draw(old version, no client library used) (open in multiple windows)

Chat (open in multiple windows)

Giphy chat (open in multiple windows), by Florian Schaller & Timo Mäki

Map (open in multiple windows)

Mouse move

Orientation (open in mobile), Receiver (open in PC)


text:
package com.texasgamer.zephyr.provider;

import android.content.Context;

import androidx.annotation.NonNull;

import com.texasgamer.zephyr.model.ZephyrCard;
import com.texasgamer.zephyr.util.navigation.INavigationManager;

import java.util.List;

/**
 * Zephyr card provider interface.
 */
public interface IZephyrCardProvider {
    List<ZephyrCard> getCards(@NonNull final Context context,
                              @NonNull INavigationManager navigationManager);
}


text:
import pytest

EXAMPLE_CONFIG_CONTENTS = """\
[AuthFiles]
example: {0}

[HTTP]
host: localhost
port: 5000
"""
EXAMPLE_AUTH_FILE_CONTENTS = """\
alice:{SSHA}xsQYxwTOV7tIbzRn00RBIvECxKT1vjcm:wonderland
bob:{SSHA}VnT6YAQ8+e4BkDCsERqH9HWa4A40BuB8
charlie:{SSHA}15YW4y+Z/1MsP3OsEOaY1+kYtRt1znkv
felix:{SSHA}hmwNBEOOGCitBOlbMLpELoPP1UV5zxkD
"""

@pytest.fixture
def config_and_example_file(tmpdir, monkeypatch):
    """\
    Creates two files:

    1. example.conf containing path to example auth file
    2. example_users, the auth file pwman operates on
    """
    # gen tmp paths
    cfg_file = tmpdir.join('example.conf')
    auth_file = tmpdir.join('example_users')
    # set auth_file path in example config
    cfg_contents = EXAMPLE_CONFIG_CONTENTS.format(auth_file)
    # write files
    cfg_file.write(cfg_contents)
    auth_file.write(EXAMPLE_AUTH_FILE_CONTENTS)
    # set PWMAN_CONFIG
    monkeypatch.setenv('PWMAN_CONFIG', str(cfg_file))
    return (cfg_file, auth_file)


text:
/**
 * Created by charlie on 10/13/16.
 */

import Vue from 'vue'

Vue.directive('clickoutside', {
  bind: function () {},
  update: function (handler) {
    // do something based on the updated value
    // this will also be called for the initial value
    if (typeof handler !== 'function') {
      return
    }

    let el = this.el
    let scope = this._scope || this.vm

    this.handler = function (ev) {
      // @NOTE: IE 5.0+
      // @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
      if (!el.contains(ev.target)) {
        scope.$event = ev
        let res = handler(ev)
        scope.$event = null
        return res
      }
    }

    Vue.util.on(document.documentElement, 'click', this.handler)
  },
  unbind: function () {
    // do clean up work
    Vue.util.off(document.documentElement, 'click', this.handler)
  }
})

export default Vue


text:
package org.jboss.resteasy.test.core.interceptors;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.test.core.interceptors.resource.PreProcessorExceptionMapperCandlepinException;
import org.jboss.resteasy.test.core.interceptors.resource.PreProcessorExceptionMapperCandlepinUnauthorizedException;
import org.jboss.resteasy.test.core.interceptors.resource.PreProcessorExceptionMapperPreProcessSecurityInterceptor;
import org.jboss.resteasy.test.core.interceptors.resource.PreProcessorExceptionMapperResource;
import org.jboss.resteasy.test.core.interceptors.resource.PreProcessorExceptionMapperRuntimeExceptionMapper;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ws.rs.core.Response;

import static org.jboss.resteasy.utils.PortProviderUtil.generateURL;

/**
 * @tpSubChapter Interceptors
 * @tpChapter Integration tests
 * @tpTestCaseDetails Regression test for RESTEASY-433
 * @tpSince RESTEasy 3.0.16
 */
@RunWith(Arquillian.class)
@RunAsClient
public class PreProcessorExceptionMapperTest {

    @Deployment
    public static Archive<?> deploySimpleResource() {
        WebArchive war = TestUtil.prepareArchive(GzipTest.class.getSimpleName());
        war.addClass(PreProcessorExceptionMapperCandlepinException.class);
        war.addClass(PreProcessorExceptionMapperCandlepinUnauthorizedException.class);
        return TestUtil.finishContainerPrepare(war, null, PreProcessorExceptionMapperPreProcessSecurityInterceptor.class,
                                                PreProcessorExceptionMapperRuntimeExceptionMapper.class,
                                                PreProcessorExceptionMapperResource.class);
    }

    /**
     * @tpTestDetails Generate PreProcessorExceptionMapperCandlepinUnauthorizedException
     * @tpPassCrit SC_PRECONDITION_FAILED (412) HTTP code is excepted
     * @tpSince RESTEasy 3.0.16
     */
    @Test
    public void testMapper() throws Exception {
        ResteasyClient client = new ResteasyClientBuilder().build();
        Response response = client.target(generateURL("/interception", GzipTest.class.getSimpleName())).request().get();
        Assert.assertEquals(HttpResponseCodes.SC_PRECONDITION_FAILED, response.getStatus());
        response.close();
        client.close();
    }

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using MasterCard.SDK.Services.Restaurants.Domain.Options;
using MasterCard.SDK.Util;

namespace MasterCard.SDK.Services.Restaurants
{
    public class RestaurantsLocalFavoritesService : Connector
    {
        private Environments.Environment environment;
        private readonly string PRODUCTION_URL = "https://api.mastercard.com/restaurants/v1/restaurant?Format=XML";
        private readonly string SANDBOX_URL = "https://sandbox.api.mastercard.com/restaurants/v1/restaurant?Format=XML";

        public RestaurantsLocalFavoritesService(string consumerKey, AsymmetricAlgorithm privateKey, Environments.Environment environment)
            : base(consumerKey, privateKey)
        {
            this.environment = environment;
        }

        public Restaurants.Domain.Restaurants GetRestaurants(RestaurantsLocalFavoritesOptions options)
        {
            string response = "";
            Dictionary<string, string> responseMap = doRequest(GetURL(options), "GET", null);
            responseMap.TryGetValue(MESSAGE, out response);
            return Serializer<Restaurants.Domain.Restaurants>.Deserialize(response);
        }

        private string GetURL(RestaurantsLocalFavoritesOptions options)
        {
            string url;
            if (this.environment == Environments.Environment.PRODUCTION)
            {
                url = PRODUCTION_URL;
            }
            else
            {
                url = SANDBOX_URL;
            }

            url = URLUtil.AddQueryParameter(url, "PageOffset", options.PageOffset.ToString(), false, null);
            url = URLUtil.AddQueryParameter(url, "PageLength", options.PageLength.ToString(), false, null);
            url = URLUtil.AddQueryParameter(url, "Category", options.Category, false, null);
            url = URLUtil.AddQueryParameter(url, "AddressLine1", options.AddressLine1, false, null);
            url = URLUtil.AddQueryParameter(url, "AddressLine2", options.AddressLine2, false, null);
            url = URLUtil.AddQueryParameter(url, "City", options.City, false, null);
            url = URLUtil.AddQueryParameter(url, "CountrySubdivision", options.CountrySubdivision, false, null);
            url = URLUtil.AddQueryParameter(url, "PostalCode", options.PostalCode, false, null);
            url = URLUtil.AddQueryParameter(url, "Country", options.Country, false, null);
            url = URLUtil.AddQueryParameter(url, "Latitude", options.Latitude == null ? options.Latitude.ToString() : null, false, null);
            url = URLUtil.AddQueryParameter(url, "Longitude", options.Longitude == null ? options.Longitude.ToString() : null, false, null);
            url = URLUtil.AddQueryParameter(url, "DistanceUnit", options.DistanceUnit, false, null);
            url = URLUtil.AddQueryParameter(url, "Radius", options.Radius == null ? options.Radius.ToString() : null, false, null);

            return url;
        }
    }
}