Skip to content

Instantly share code, notes, and snippets.

Ben Koshy BKSpurgeon

  • Bangalore, India
View GitHub Profile
@BKSpurgeon
BKSpurgeon / autocad-dot-net-pre-message-filter-tab.md
Created Apr 19, 2019
Premessage Filter - catch instance of users pressing the tab button
View autocad-dot-net-pre-message-filter-tab.md

In my case I want to catch instance where the user has pressed the tab button in a jig. I will paste only the relevant parts (i.e. omitting the constructor and overriden methods):

    internal class BlockReferenceJig : DrawJig, System.Windows.Forms.IMessageFilter
    {
        private const int WM_KEYDOWN = 0x0100;

        public bool PreFilterMessage(ref Message m)
        {
            if (m.Msg != WM_KEYDOWN)
@BKSpurgeon
BKSpurgeon / test-colinearity-dot-net-api.md
Created Apr 12, 2019
Tests the Collinearity of LineSegment2d objects (AutoCAD .net API)
View test-colinearity-dot-net-api.md
        [CommandMethod("TestCollinearity")]
        public void TestCollinearity()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            try
            {
@BKSpurgeon
BKSpurgeon / section_note_jig.md
Created Apr 11, 2019
Precast Tools - Section and note insert
View section_note_jig.md
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
@BKSpurgeon
BKSpurgeon / figures_of_speech.md
Last active Mar 6, 2019
Ella Baron - 27 Figures of Speech
View figures_of_speech.md
@BKSpurgeon
BKSpurgeon / So-help-user-signed-in.md
Last active Feb 5, 2019
SO help - check if user is signed in
View So-help-user-signed-in.md
module SignInHelper
  def sign_in_as(name)
    sign_in users(name)    
    byebug # check here whether the user is signed in.
    
    
    # IMPORTANT: remove the monkey patch because it might not be signing your users in properly
    
  end
@BKSpurgeon
BKSpurgeon / viewDirectionObtainer.md
Created Jan 11, 2019
View Direction Obtainer (AutoCAD .net Sample code - Focusing Mainly on the LineDirectionJigger
View viewDirectionObtainer.md
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

namespace BKTools.Tools.PrecastTools.LayoutsToElevationsCommand
{
    /// <summary>
    /// We want panel lines that are perpendicular to the rotation of a particular block reference
    /// </summary>
@BKSpurgeon
BKSpurgeon / elm-timesheet-sample-code.md
Created Jan 3, 2019
ELM - Time Sheet App - Sample Code
View elm-timesheet-sample-code.md
  • This is some sample code that I had written to record the time employees punch-in and punch-out.
  • Consequently, we need to keep track of a Shift's start time and end time.
  • These values will need to be sent to a back end server via a post request.
module Main exposing (..)

import Browser
import Html exposing (Html, text, div, h1, img, button)
@BKSpurgeon
BKSpurgeon / checkTransport.md
Created Dec 13, 2018
Check Transport - The Key Server Classes
View checkTransport.md
        internal class Truck
        {
            private readonly string name;
            private readonly double heightLimit;
            private readonly double lengthLimit;
            private readonly double massLimit;

            public Truck(string name, double heightLimit, double lengthLimit, double mass)
            {
@BKSpurgeon
BKSpurgeon / Elm-Programming-Hello-World.md
Created Dec 7, 2018
ELM 0.19 - A Simple ELM Programming
View Elm-Programming-Hello-World.md

If you're following along the Beginning Elm book then, after much stuggle, this is the code which worked for me. I hope it saves you a lot of heartache.

HomePage.elm

module Main exposing (..)

import Html exposing (..)
import Html.Attributes exposing (..)
View trace-back-for-pagy.md
rspec pagy_test.rb 
Traceback (most recent call last):
	16: from /home/koshy/.rbenv/versions/2.5.1/bin/rspec:23:in `<main>'
	15: from /home/koshy/.rbenv/versions/2.5.1/bin/rspec:23:in `load'
	14: from /home/koshy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rspec-core-3.8.0/exe/rspec:4:in `<top (required)>'
	13: from /home/koshy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:45:in `invoke'
	12: from /home/koshy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:71:in `run'
	11: from /home/koshy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:87:in `run'
	10: from /home/koshy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:110:in `run_specs'
You can’t perform that action at this time.