text:
class   Buffered_DatagramWriter  :  public RingBuffer
{
    int     _flush_point;
public:
    inline void ReSet(void);            // destroy all buffered data

    Buffered_DatagramWriter( size_t in_size , int in_flush_point = -1);
    inline int AddData(const void * data, size_t len, Socket_TCP &sck);
    inline int AddData(const void * data, size_t len);
// THE FUNCTIONS THAT TAKE A SOCKET NEED TO BE TEMPLATED TO WORK..

        template < class SOCK_TYPE>
        int  FlushNoBlock(SOCK_TYPE &sck) {  // this is the ugly part

          int answer = 0;
          size_t Writesize = AmountBuffered();

          if(Writesize > 0) {
            int Writen = sck.SendData(GetMessageHead(),(int)Writesize);
            if(Writen > 0) {
              _StartPos += Writen;
              FullCompress();
              if(AmountBuffered() > 0) // send 0 if empty else send 1 for more to do
                answer = 1;
            }
            else if(Writen < 0) {
              if(!sck.ErrorIs_WouldBlocking(Writen))
                answer = -1;
              else
                answer = 1;  // 1 = more to do.....
            }
          }
          return answer;
        };

        template < class SOCK_TYPE>
        inline int  Flush(SOCK_TYPE &sck) {
          int answer = 0;
          size_t Writesize = AmountBuffered();

          if(Writesize > 0) {
            int Writen = sck.SendData(GetMessageHead(),(int)Writesize);

            if(Writen > 0) {
              _StartPos += Writen;
              FullCompress();
              if(AmountBuffered() > 0) //send 0 if empty else send 1 for more to do
                answer = 1;
            }
            else if(Writen < 0) {
              if(sck.ErrorIs_WouldBlocking(Writen) != true)
                answer = -1;
            }
          }

          return answer;
        };
};

///////////////////////////////////////////////////////
// Function name    : Buffered_DatagramWriter::ReSet
// Description      : used to clear the buffrers ...
//                    use of this in mid stream is a very bad thing as
//                    you can not guarany network writes are message alligned
// Return type      : void
///////////////////////////////////////////////////////
inline void Buffered_DatagramWriter::ReSet(void) {
  ResetContent();
}
////////////////////////////////////////////////
//  Buffered_DatagramWriter::Buffered_DatagramWriter
//
//
////////////////////////////////////////////////
inline Buffered_DatagramWriter::Buffered_DatagramWriter( size_t in_size , int in_flush_point) : RingBuffer(in_size) {
  _flush_point = in_flush_point;
}

//////////////////////////////////////////////////////////////
// Function name    : Buffered_DatagramWriter::AddData
// Description      :
// Return type      : inline int
// Argument         : const void * data
// Argument         : int len
// Argument         : Socket_TCP &sck
//////////////////////////////////////////////////////////////
inline int Buffered_DatagramWriter::AddData(const void * data, size_t len, Socket_TCP &sck) {
  int answer = 0;

  if(len >  BufferAvailabe())
    answer = Flush(sck);

  if(answer >= 0)
    answer = AddData(data,len);

  if(answer >= 0 && _flush_point != -1)
    if(_flush_point <  (int)AmountBuffered())
      if(Flush(sck) < 0)
        answer = -1;

  return answer;
}

//////////////////////////////////////////////////////////////
// Function name    : Buffered_DatagramWriter::AddData
// Description      :
// Return type      : inline int
// Argument         : const char * data
// Argument         : int len
//////////////////////////////////////////////////////////////
inline int Buffered_DatagramWriter::AddData(const void * data, size_t len)
{
  int answer = -1;
  if(BufferAvailabe() > len+2) {
    unsigned short len1(len);
    TS_GetInteger(len1,(char *)&len1);
    if(Put((char *)&len1,sizeof(len1)) == true) {
      if(Put((char *)data,len) == true) {
        answer = 1;
      }
    }
  }

  return answer;
}
#endif //__BufferedWriter_H__


text: My Own Modified TreeHouse App -- FunFacts for Android

redpajama_set_name: RedPajamaGithub


text:
module GitRuby

  class GitRubyTagNameDoesNotExist< StandardError
  end

  # represents a git object
  class Object

    class AbstractObject
      attr_accessor :objectish, :size, :type, :mode

      @base = nil
      @contents = nil
      @size = nil
      @sha = nil

      def initialize(base, objectish)
        @base = base
        @objectish = objectish.to_s
        setup
      end

      def sha
        @sha || @sha = @base.lib.revparse(@objectish)
      end

      def size
        @size || @size = @base.lib.object_size(@objectish)
      end

      # caches the contents of this call in memory
      def contents
        @contents || @contents = @base.lib.object_contents(@objectish)
      end

      def contents_array
        self.contents.split("\n")
      end

      def to_s
        @objectish
      end

=begin
      def setup
        raise NotImplementedError
      end

      def grep(string, path_limiter = nil, opts = {})
        default = {:object => sha, :path_limiter => path_limiter}
        grep_options = default.merge(opts)
        @base.lib.grep(string, grep_options)
      end

      def diff(objectish)
        GitRuby::Diff.new(@base, @objectish, objectish)
      end

      # creates an archive of this object (tree)
      def archive(file = nil, opts = {})
        @base.lib.archive(@objectish, file, opts)
      end

=end

      def log(count = 30)
        GitRuby::Log.new(@base, count).object(@objectish)
      end

      def tree?
        @type == 'tree'
      end

      def blob?
        @type == 'blob'
      end

      def commit?
        @type == 'commit'
      end

     def tag?
       @type == 'tag'
     end

    end

    class Blob < AbstractObject

      def initialize(base, sha, mode = nil)
        super(base, sha)
        @mode = mode
      end

      private

        def setup
          @type = 'blob'
        end
    end

    class Tree < AbstractObject

      @trees = nil
      @blobs = nil

      def initialize(base, sha, mode = nil)
        super(base, sha)
        @mode = mode
      end

      def children
        blobs.merge(subtrees)
      end

      def blobs
        check_tree
        @blobs
      end
      alias_method :files, :blobs

      def trees
        check_tree
        @trees
      end
      alias_method :subtrees, :trees
      alias_method :subdirectories, :trees

      private

        def setup
          @type = 'tree'
        end

        # actually run the git command
        def check_tree
          if !@trees
            @trees = {}
            @blobs = {}
            data = @base.lib.ls_tree(@objectish)
            data['tree'].each { |k, d| @trees[k] = GitRuby::Object::Tree.new(@base, d[:sha], d[:mode]) }
            data['blob'].each { |k, d| @blobs[k] = GitRuby::Object::Blob.new(@base, d[:sha], d[:mode]) }
          end
        end

    end

    class Commit < AbstractObject

      @tree = nil
      @parents = nil
      @author = nil
      @committer = nil
      @message = nil

      def initialize(base, sha, init = nil)
        super(base, sha)
        if init
          set_commit(init)
        end
      end

      def message
        check_commit
        @message
      end

      def name
        @base.lib.namerev(sha)
      end

      def gtree
        check_commit
        Tree.new(@base, @tree)
      end

      def parent
        parents.first
      end

      # array of all parent commits
      def parents
        check_commit
        @parents
      end

      # git author
      def author
        check_commit
        @author
      end

      def author_date
        author.date
      end

      # git author
      def committer
        check_commit
        @committer
      end

      def committer_date
        committer.date
      end
      alias_method :date, :committer_date

      def diff_parent
        diff(parent)
      end

      def set_commit(data)
        if data['sha']
          @sha = data['sha']
        end
        @committer = GitRuby::Author.new(data['committer'])
        @author = GitRuby::Author.new(data['author'])
        @tree = GitRuby::Object::Tree.new(@base, data['tree'])
        @parents = data['parent'].map{ |sha| GitRuby::Object::Commit.new(@base, sha) }
        @message = data['message'].chomp
      end

      private

        def setup
          @type = 'commit'
        end

        # see if this object has been initialized and do so if not
        def check_commit
          if !@tree
            data = @base.lib.commit_data(@objectish)
            set_commit(data)
          end
        end

    end

    class Tag < AbstractObject
      attr_accessor :name

      def initialize(base, sha, name)
        super(base, sha)
        @name = name
      end

      private

        def setup
          @type = 'tag'
        end

    end

    class << self
      # if we're calling this, we don't know what type it is yet
      # so this is our little factory method
      def new(base, objectish, type = nil, is_tag = false)
        if is_tag
          sha = base.lib.tag_sha(objectish)
          if sha == ''
            raise GitRuby::GitTagNameDoesNotExist.new(objectish)
          end
          return GitRuby::Object::Tag.new(base, sha, objectish)
        else
          if !type
            type = base.lib.object_type(objectish)
          end
        end

        klass =
          case type
          when /blob/:   Blob
          when /commit/: Commit
          when /tree/:   Tree
          end
        klass::new(base, objectish)
      end
    end

  end
end


text:
#include <stdio.h>
#include <malloc.h>		// For _alloca
#include <windows.h>
#include "GL/glut.h"
#include "AntTweakBar.h"

#include "Opcode.h"
using namespace Opcode;


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Scurry.Scheduler.Queue.Contexts
{
    [DataContract]
    [Serializable]
    public class Job
    {
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public string Cron { get; set; }
        [DataMember]
        public Queue Queue { get; set; }
        [DataMember]
        public dynamic Message { get; set; }
    }
}


text:
samsa-website
=============

website for samsa RPG


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PetClinic.Data.DomainObjects
{
    public interface IEntity
    {
        int Id { get; }
    }
}


text:
window.org_vaadin_SketchCanvas =
    function () {
        var self = this;
        var element = this.getElement();
        var lc = null;

        var width = null;
        var height = null;
        var enabled = true;

        var canvasWidth = null;
        var canvasHeight = null;

        var loadingSnapshot = false;
        var backgroundImageUrl = null;

        var currentToolName;
        var currentPColor = "black";
        var currentSColor = "white";
        var currentBColor = "hsla(0,100%,100%,0)";

        this.onStateChange = function () {
            var state = this.getState();

            if (width !== state.width || height !== state.height) {
                width = state.width;
                height = state.height;

                var lcElement = element.querySelector(".literally");
                lcElement.setAttribute("style", "width:"+width+";height:"+height);

                // trigger resize
                var evt = document.createEvent("UIEvent");
                evt.initEvent("resize", false, true);
                window.dispatchEvent(evt);
            }

            if (canvasWidth !== state.canvasWidth || height !== state.canvasHeight) {
            	canvasWidth = state.canvasWidth;
            	canvasHeight = state.canvasHeight;
            	lc.setImageSize(canvasWidth, canvasHeight);
            }

            if (enabled !== state.enabled && state.enabled !== undefined) {
                enabled = state.enabled;

                var toolbarVertical = element.querySelector(".lc-picker");
                var toolbarHorizontal = element.querySelector(".horz-toolbar");
                var drawingArea = element.querySelector(".lc-drawing");

                if (enabled) {
                    toolbarVertical.classList.remove("disabled");
                    toolbarHorizontal.classList.remove("disabled");
                    drawingArea.classList.remove("disabled");
                } else {
                    toolbarVertical.classList.add("disabled");
                    toolbarHorizontal.classList.add("disabled");
                    drawingArea.classList.add("disabled");
                }
            }
        };

        var contextPath = this.getState().contextPath;

        lc = LC.init(
            element,
            {imageURLPrefix: contextPath + '/VAADIN/sketchcanvas/img'},
            {imageSize: {width: width, height: height}}
        );

        this.updateDrawing = function (snapshot, ignoreColorChanges) {
            loadingSnapshot = true;
            lc.loadSnapshot(JSON.parse(snapshot));

            if (ignoreColorChanges)
              restoreOriginalColors();

            loadingSnapshot = false;
        };

        this.updateDrawingWithScale = function (scalingFactor, snapshot) {
            loadingSnapshot = true;
            var scaledSnapshot = snapshot.replace(new RegExp("scale\":[0-9.]*,"),"scale\":"+scalingFactor+",");
            lc.loadSnapshot(JSON.parse(scaledSnapshot));
            restoreOriginalColors();
            loadingSnapshot = false;
        };

        this.clearDrawing = function () {
            lc.clear();
        };

        function removeSelectedClassNameFromPreviousTool() {
            var previousToolElement = element.querySelector("div.lc-pick-tool[title=" + currentToolName + "]");
            if (previousToolElement) {
                previousToolElement.classList.remove("selected");
            }
        }

        function addSelectedClassNameToTool(tool) {
            var toolElement = element.querySelector("div.lc-pick-tool[title=" + tool + "]");
            toolElement.classList.add("selected");
        }

        function restoreOriginalColors() {
            lc.setColor("primary", currentPColor);
            lc.setColor("secondary", currentSColor);
            lc.setColor("background", currentBColor);
        }

        this.setSelectedTool = function (tool, storeWidth) {
            // TODO update css selected classname
            switch (tool) {
                case "Pencil" :
                    var pencil = new LC.tools.Pencil(lc);
                    pencil.strokeWidth = storeWidth;
                    lc.setTool(pencil);
                    break;
                case "Eraser" :
                    var eraser = new LC.tools.Eraser(lc);
                    eraser.strokeWidth = storeWidth;
                    lc.setTool(eraser);
                    break;
                case "Ellipse" :
                    var ellipse = new LC.tools.Ellipse(lc);
                    ellipse.strokeWidth = storeWidth;
                    lc.setTool(ellipse);
                    break;
                case "Line" :
                    var line = new LC.tools.Line(lc);
                    line.strokeWidth = storeWidth;
                    lc.setTool(line);
                    break;
                case "Rectangle" :
                    var rectangle = new LC.tools.Rectangle(lc);
                    rectangle.strokeWidth = storeWidth;
                    lc.setTool(rectangle);
                    break;
                case "Text" :
                    var text = new LC.tools.Text(lc);
                    lc.setTool(text);
                    break;
                case "Polygon" :
                    var polygon = new LC.tools.Polygon(lc);
                    polygon.strokeWidth = storeWidth;
                    lc.setTool(polygon);
                    break;
                case "Pan" :
                    var pan = new LC.tools.Pan(lc);
                    lc.setTool(pan);
                    break;
                case "Eyedropper" :
                    var eyedropper = new LC.tools.Eyedropper(lc);
                    lc.setTool(eyedropper);
                    break;
            }
            addSelectedClassNameToTool(tool);
        };

        this.setUsedColor = function (colorName, colorValue) {
            console.log(colorName + " " + colorValue);
            lc.setColor(colorName, colorValue);
        };

        var unsubscribeDrawingChange = lc.on('drawingChange', function () {
            if (!loadingSnapshot) {
                self.drawingChange(JSON.stringify(lc.getSnapshot()));
            }
        });

        var unsubscribeToolChange = lc.on('toolChange', function (tool) {
            console.log(tool.tool);
            if (tool.tool.name != currentToolName) {
                removeSelectedClassNameFromPreviousTool();
                currentToolName = tool.tool.name;
            }
            self.toolChange(tool.tool.name, tool.tool);
        });

        var unsubscribePrimaryColorChange = lc.on('primaryColorChange', function (color) {
            if (!loadingSnapshot) {
                console.log(color);
                currentPColor = color;
                self.primaryColorChange(color);
            }
        });

        var unsubscribeSecondaryColorChange = lc.on('secondaryColorChange', function (color) {
            if (!loadingSnapshot) {
                console.log(color);
                currentSColor = color;
                self.secondaryColorChange(color);
            }
        });

        var unsubscribeBackgroundColorChange = lc.on('backgroundColorChange', function (color) {
            if (!loadingSnapshot) {
                console.log(color);
                currentBColor = color;
                self.backgroundColorChange(color);
            }
        });

        this.setBackgroundImage = function(url) {
          backgroundImageUrl = url;
          self.updateBackground(url);
          lc.respondToSizeChange();
        };

        this.updateBackground = function(url) {
          loadingSnapshot = true;
          if (url || url != '') {
            var newImage = new Image();
            newImage.style.width = '100%';
            newImage.style.height = '100%';
            newImage.src = self.translateVaadinUri(url);

            lc.backgroundShapes = [LC.createShape('Image', {
              x: 0,
              y: 0,
              image: newImage,
              scale: 1
            })];
          } else {
            lc.backgroundShapes = [];
          }
          loadingSnapshot = false;
        }

        this.requestSVG = function() {
            var svgStr = lc.getSVGString();
            self.setSVGString(svgStr);
        };

        this.requestImage = function() {
            //self.updateBackground(backgroundImageUrl);
            var imgData = lc.getImage().toDataURL();
            self.setImageData(imgData);
        };

        this.requestSnapshot = function() {
        	var snapshot= JSON.stringify(lc.getSnapshot());
        	this.setSnapshot(snapshot);
        };

        this.addResizeListener(element, function() {
          lc.respondToSizeChange();
        });
    };