Skip to content

Instantly share code, notes, and snippets.

@suryart
suryart / karma-browserstack-launcher.log
Created July 28, 2022 13:29
Karma BrowserStack launcher for Angular 14 gets stuck in infinite loop.
> [email protected] test-ci
> ng test --watch=false --browsers=bs_chrome_win
Node.js version v17.4.0 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/releases/.
⠋ Generating browser application bundles (phase: setup)...28 07 2022 18:23:42.504:DEBUG [config]: Loading config /Users/surya/tests/angular-14-karma-browserstack-reproduce-hang/karma.conf.js
28 07 2022 18:23:42.511:DEBUG [karma-server]: Final config Config {
LOG_DISABLE: 'OFF',
LOG_ERROR: 'ERROR',
LOG_WARN: 'WARN',
@suryart
suryart / README.md
Last active January 24, 2022 09:23
Fixing therubyracer install issue on OS X 12.1 ARM(M1) macbook

If you have received the following error when running gem install therubyracer -v '0.12.3' -- --with-v8-dir=$(brew --prefix v8):

Building native extensions with: '--with-v8-dir=/opt/homebrew/opt/v8' This could take a while... ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension.

current directory: /Users/surya/.rvm/gems/ruby-2.6.6@rails602/gems/therubyracer-0.12.3/ext/v8

/Users/surya/.rvm/rubies/ruby-2.6.6/bin/ruby -I /Users/surya/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0 -r ./siteconf20220124-21151-13m9cq6.rb extconf.rb --with-v8-dir=/opt/homebrew/opt/v8 checking for -lpthread... yes

@suryart
suryart / spiral_print_matrix.ex
Last active June 17, 2019 19:05
Solution to Spiral print of elements of a matrix(2D array)
defmodule MatrixSpiralPrint do
@moduledoc """
Solution to Spiral print of elements of a matrix(2D array)
"""
@doc """
prints elements of matrix(2D array) in a spiral
## Examples
@suryart
suryart / gist:4db3482d5f5fc47b7722dfdd6b5b657e
Created March 26, 2019 19:19 — forked from dreamwords/gist:149518
activeresource client certificate
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index dc24e71..f814b8b 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -102,6 +102,8 @@ module ActiveResource
#
# Many REST APIs will require authentication, usually in the form of basic
# HTTP authentication. Authentication can be specified by:
+ #
+ # === HTTP Basic Authentication
require 'prawn'
Prawn::Document.generate("./my_pdf.pdf") do
# Print Name
fill_color "565656"
font_size(38) { text "HEADING", align: :center }
move_down 20
stroke_color "c0c0c0" #dimgray color code
@suryart
suryart / appliance.rb
Created February 25, 2018 15:02
observer-pattern
class Appliance
attr_accessor :name, :state , :switch
def initialize(name, switch = nil)
@name = name
@state = switch.nil? ? :off : switch.state
@switch = switch
end
def update(changed_state)
self.state = changed_state
module InstanceModule
def track
"Tracking todo: #{self.name}"
end
end
module ClassModule
def class_name
"Tracking class: #{self.name}"
@suryart
suryart / file-change.rb
Created May 23, 2017 19:26
change duplicate file names
file_extension = '.rb'
files = Dir["./*#{file_extension}"]
puts "="*10
puts " Total files: #{files.count}"
puts "="*10
files_deleted = 0
file_timestamp = Time.now.strftime('%Y%m%d')
files.each do |file|
puts File.basename file, file_extension
users:
id, username, password
tickets:
id, booking_id, amount, discount, seat_id, show_id
bookings
id, user_id, total, ticket_counts
screens
@suryart
suryart / sort_array_bin.rb
Created September 26, 2016 11:24
sort by binary 1 count then by digit value
# sort by binary 1 count then by digit value
a.sort_by{ |v1| [v1.to_s(2).split('').count('1'), v1] }.reverse