Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Koshy benkoshy

View GitHub Profile
@benkoshy
benkoshy / innerHtml example.md
Last active Aug 12, 2021
An example: innerHtml - what is destroyed and what is retained?
View innerHtml example.md

Consider some html - this is what we want to create:

<div id="start-of-content" class="show-on-focus">
    <p> Setting innerHtml on the #start-of-content element to "" would wipe this msg away </p>   
</div>

(If you're reading this on Github, you can open the dev tools and see the relevant element.)

@benkoshy
benkoshy / zshrc.md
Created May 27, 2021
My .zshr file
View zshrc.md

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

source ~/Downloads/Programs/fm/fm.zsh

@benkoshy
benkoshy / send-grid-example.md
Last active May 4, 2021
Example of mail gun using SMTP with a rails application
View send-grid-example.md
# production.rb
# mail gun
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.smtp_settings = { address: "smtp.mailgun.org",
                                         port: 587,
                                         user_name: Chamber.dig!(:smtp_email, :mail_username),
                                         password: Chamber.dig!(:smtp_email, :mail_password),
@benkoshy
benkoshy / tekla-api-how-to-get-bolt-information-from-a-part.md
Created Apr 28, 2021
Tekla Open API - Demonstrates a hello world example of how to get bolt information from a part
View tekla-api-how-to-get-bolt-information-from-a-part.md
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Model;

namespace RopesProject
View pagy-bundle-not-working.md
[!] There was an error while loading `pagy.gemspec`: /home/koshy/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/pagy-7c9eb10dd089/lib/pagy/frontend.rb:26: syntax error, unexpected '='
...  def pagy_get_params(params) = params
...                              ^
/home/koshy/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/pagy-7c9eb10dd089/lib/pagy/frontend.rb:97: syntax error, unexpected end-of-input, expecting end. Bundler cannot continue.

 #  from /home/koshy/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/pagy-7c9eb10dd089/pagy.gemspec:5
 #  -------------------------------------------
 #  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
 >  require 'pagy'
@benkoshy
benkoshy / ransack-post-form-pagy-2.md
Last active Sep 3, 2021
Pagy Documentation - Using Stimulus JS
View ransack-post-form-pagy-2.md

Using Stimulus JS to POST

Alternatively, you can use Stimulus JS to sprinkle in the required javascript.

Whenever you use pagy links that require interception, you will need to reinitialise any javascript that you need to run. If you submit a form, and use a turbo frame to render those search results, and to also render the pagination links to those results, how are you going to reinitialize your javascript code to intercept those pagy page links?

Stimulus JS is very handy for reinitialising javascript code, and is useful if you are using a library like hotwire (by Basecamp) where changes are made to the DOM.

// pagy_controller.js - a stimulus JS controller
@benkoshy
benkoshy / BoltListFromSelectedModelObjects.cs
Last active Apr 23, 2021
How to programmatically generate a bolt list report from selected model objects
View BoltListFromSelectedModelObjects.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Model;
namespace RopesProject
{
View how-to-create-a-curved-beam.md
    class Program
    {
        static void Main(string[] args)
        {
            Model model = new Model();
            if (model.GetConnectionStatus())
            {
                PolyBeam polyBeam = new PolyBeam(PolyBeam.PolyBeamTypeEnum.BEAM);                              
                ContourPoint startPoint = new ContourPoint(new Point(1000, 0, 0), null);
@benkoshy
benkoshy / byebug_cheat_sheet.md
Last active Dec 3, 2020
Quick Cheat Sheet for Byebug - The Most Used Commands
View byebug_cheat_sheet.md

Cheat Sheet of Basic Byebug Commands

  • step - jump inside the next line of code
  • eval - print out variables: e.g. eval x
  • set linetrace
  • set basename
  • quit or q!
  • display variable_name
  • where - call stack.
  • break 5 - add a break pointto line 5