Skip to content

Instantly share code, notes, and snippets.

View djberg96's full-sized avatar

Daniel Berger djberg96

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# You will need Ruby on a Windows machine. Plus the ffi library.
require 'ffi'
class File::Temp
extend FFI::Library
ffi_lib :kernel32
attach_function :GetTempFileNameA, %i[string string uint buffer_out], :uint
attach_function :GetTempFileNameW, %i[buffer_in buffer_in uint buffer_out], :uint
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# user.rb
class User < ApplicationRecord
has_many :groups_users, :class_name => 'GroupsUsers'
has_many :groups, :through => :groups_users
end
# group.rb
class Group < ApplicationRecord
has_many :groups_users, :class_name => 'GroupsUsers'
#has_many :users, :through => :groups_users
[1] pry(main)> i = ActiveSupport::Inflector.inflections(:en)
=> #<ActiveSupport::Inflector::Inflections:0x0000000002532f30
@acronym_regex=/Api|GraphiQL/,
@acronyms={"api"=>"Api", "graphiql"=>"GraphiQL"},
@acronyms_camelize_regex=/^(?:(?-mix:Api|GraphiQL)(?=\b|[A-Z_])|\w)/,
@acronyms_underscore_regex=/(?:(?<=([A-Za-z\d]))|\b)((?-mix:Api|GraphiQL))(?=\b|[^a-z])/,
@humans=[],
@plurals=
[[/(z)ombies$/i, "\\1ombies"],
[/(z)ombie$/i, "\\1ombies"],
require 'hexapdf'
# Use local copy of http://foersom.com/net/HowTo/data/OoPdfFormExample.pdf
file = 'pdf_form_example.pdf'
doc = HexaPDF::Document.open(file)
page1 = doc.pages.first
widgets = page1[:Annots]&.filter{ |a| a[:Subtype] == :Widget }
# See what the widgets look like.
@djberg96
djberg96 / keybase.md
Created May 13, 2022 13:47
keybase.md

Keybase proof

I hereby claim:

  • I am djberg96 on github.
  • I am djberg96 (https://keybase.io/djberg96) on keybase.
  • I have a public key ASC4MIT3C1NsZErilv9lMvhL5h0MKq38b010veHzAu3fEQo

To claim this, I am signing this object:

native-path: BAT0
vendor: SMP
model: 5B10X19049
serial: 2080
power supply: yes
updated: Fri 27 Aug 2021 12:12:37 PM EDT (44 seconds ago)
has history: yes
has statistics: yes
battery
present: yes