def __init__(self): GObject.Object.__init__(self) def get_background_items(self, window, file): """Returns the menu items to display when no file/folder is selected (i.e. when right-clicking the...

...file.is_directory() and file.get_uri_scheme() == "file": if os.path.exists(TERMINAL_PATH): items += [self._create_terminal_item(file)] return items def _setup_gettext(self): """Initializes gettext to localize strings.""" try: # prevent a possible exception...

...an array with a block that is called with each element. The block must return a [key, value] tuple. This is useful if both the hash key and value can...

...a block. The block is called for each element in the array and should return a 2-tuple where the first element is the key and the second element is...

...attached files to config/initializers. It gives your strings a method #to_sort_atoms that returns an object that compares as expected. You can now say: ["Schwertner", "Schöler"].sort_by(&:to...

...of #to_sort_atoms: describe String do describe '#to_sort_atoms' do it 'should return an object that correctly compares German umlauts' do expect('Äa'.to_sort_atoms <=> 'Az'.to...

makandra dev

...Version uploader and original uploader can be distinguished by checking #version_name: version uploaders return the version name, whereas the original uploader instance returns nil Version instances do not have...

...the end goal is clearly described and sufficient context is provided. Example Create notification.resolver.ts: Return the state$ property from the notification service: Use an async resolver; Update overview.component.ts: Replace injected...

...same applies for providing expected types, for example of a function signature or the return value. Information-Dense Keywords Actions: create, update, delete, edit, mirror, move, replace, refactor, add, ...

...string properties and a function property: let user = { firstName: 'Max', lastName: 'Muster', fullName: function() { return this.firstName + ' ' + this.lastName } } user.fullName() // => 'Max Muster' In ES6 we can define a function property using the...

...following shorthand syntax: let user = { firstName: 'Max', lastName: 'Muster', fullName() { return this.firstName + ' ' + this.lastName } } user.fullName() // => 'Max Muster' We can also define a getter inside the object literal, without using Object.defineProperty():

makandra dev
gist.github.com

...n] -- Steps into blocks or methods n times. If you accidentally stepped, you can return with finish 1. next [n] -- Runs n lines of code within the same frame

...find out the numbers finish [n] -- Runs the program until the n-th frame returns up -- Moves to a higher frame in the stack trace down -- Moves to a lower...

...metadata enabled (default since Rails 6). On mismatching purpose, #decrypt_and_verify will simply return nil. def decrypt_session_cookie(cookie_string) return if cookie_string.blank? cipher = ActiveSupport::MessageEncryptor.default_cipher

...it now looks like this: class BaseUploader module DoesStrictTypeValidations as_trait do def revalidate(*) return unless file check_content_type_allowlist!(file) # This was check_content_type_whitelist! before

...versions have not been initialized by store!, their file methods will at this point return nil. You most likely want to remove these stale files as soon as a new...

...may also provide a block that inspects an error object. To ignore the error, return a truthy value: BrowserConsole.ignore do |error| error.message.size < 100 end Default ignore rules By default BrowserConsole...

...to run code when an element is removed from the DOM. When your compiler returns a function, it is called when the element is detached from the DOM: compiler('textarea.wysiwyg...

let editor = new SuperEditor(select) return () => editor.shutdown...

const controller = new CustomDirectUploadController(input, input.files[0]) controller.start(storedInput) } const hasFile = function() { return (storedInput?.value !== undefined && storedInput?.value !== '') || input.value !== '' } const updateClearButton = function() { clearButton.classList.toggle('visually-hidden', !hasFile()) // Make sure...

...between the two methods is that unresolvable constants raise an error with constantize, but return nil with safe_constantize. If you validate the input string against an allowlist, an error...

...not correspond to a valid constant or if the constant is not accessible, it returns nil: "String".safe_constantize # => String "NonExistentClass".safe_constantize # => nil "Module::ExistingClass".safe_constantize # => Module::ExistingClass...

...pool has a "reaper thread" that periodically looks for connections from inactive threads and returns them to the pool. By default the reaper runs once every 60 seconds. You can...

Will the pool ever close an unused connection? A released connection will be returned to the pool, but not disconnect from the database server. The connection will remain connected...

makandra dev

...app/models/test.rb +++ app/models/test.rb @@ -19,6 +19,10 @@ module RoutingFilter path = Rails.root / 'app' + if true + + end + return path (1/1) Discard this hunk from worktree [y,n,q,a,d,e,?]? ?

...created_at: 2.days.ago..), including orphan checks via where.missing(...). Important The inverted scope will not return rows where role is NULL, since in NOT NULL equals NULL in SQL. If this...

Unit test with error describe UsersHelper do describe '#user_display_name' do it 'returns the first and last name of a user' do user = FactoryBot.create(:user) allow(helper).to...

...receive(:current_user).and_return(user) expect(helper.user_display_name).to eq('Jim Knopf') end end end Error: does not implement: current_user Solutions RSpec >= 3.6 Unit test fixed with...

...a?(String) && value.blank? - nil - else - value - end activerecord/lib/active_record/connection_adapters/column.rb + def type_cast_for_write(value) + return value unless number? + + if value == false + 0 + elsif value == true + 1 + elsif value.is_a?(String...

makandra dev
github.com

...Relation#traverse_association(*names) Edge Rider gives your relations a method #traverse_association which returns a new relation by "pivoting" around a named association. You can traverse multiple associations in...

...users WHERE sites.user_id = sites.id AND users.name = 'Bruce' It now uses these IDs to return a new relation that has no joins and a single condition on the id column...

...the database adapter gives you methods like select_rows or select_all. These methods return query results as simple arrays, hashes, strings, numbers, etc.: select_all('SELECT * FROM articles') # => [ { 'name...

...an uncommon way to retrieve a file using selenium where JavaScript is used to return a binary data array to Ruby code. The following code example retrieves a PDF but...

...array of 8-bit unsigned integers # => [37, 208, 212, ...] const unsingedInt8Array = new Uint8Array(arrayBuffer) return unsingedInt8Array JS # convert the array we got from JS into a binary string which we...

...receive a locale parameter from a matching URL segment. Before Rails 7.1, this method returned all associated routes (as enumerable) and the using methods iterated over them. As the using...

...methods like serve do not actually need all routes, but may return early, a change has been introduced to add lazy behavior by adding an iterator block and yielding. This...

...with 100 comments and 10 attachments. The OUTER JOINs will cause the query to return 1000 database rows, the full cross product of the blog post × all its comments × all...

...nameCache: TERSER_NAME_CACHE, // preserve renames across files } function terserPlugin(terserOptions = DEFAULT_TERSER_OPTIONS) { return { name: 'terserPlugin', setup(build) { build.onLoad({ filter: /\.js$/ }, async (args) => { const text = await fs.promises.readFile(args.path, "utf8...

...let { code, map } = await terser.minify(text, terserOptions) return { contents: code, loader: 'js', } }) } } } Use the plugin in your build() or context() options: esbuild.build({ entrypoints: [...], minify: true, // prevent esbuild from pretty-printing...