This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getDomPath = (element) => { | |
const path = []; | |
let currentElement = element; | |
while (currentElement) { | |
let selector = currentElement.tagName.toLowerCase(); | |
// Add id if it exists | |
if (currentElement.id) { | |
selector += `#${currentElement.id}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const promiseA = new Promise((res) => setTimeout(() => res("yes"), 500)); | |
const promiseB = new Promise((_, rej) => setTimeout(() => rej("fail"), 3000)); | |
return await Promise.race([promiseA, promiseB]); | |
})() | |
.then((x) => console.log("val =", x)) | |
.catch((err) => { | |
console.error("error here", err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as path from "node:path"; | |
import * as repl from "node:repl"; | |
(async () => { | |
// MAIN EXECUTION/SETUP GOES HERE | |
const replServer = repl.start({ | |
prompt: ">> ", | |
useColors: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn subscriber() -> impl tracing::subscriber::Subscriber { | |
use tracing_subscriber::{fmt::format::FmtSpan, prelude::*}; | |
tracing_subscriber::registry() | |
.with(tracing_subscriber::EnvFilter::from_default_env()) | |
.with( | |
tracing_subscriber::fmt::layer() | |
.compact() | |
.with_target(false) | |
.without_time() | |
.with_span_events(FmtSpan::CLOSE), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"time" | |
"github.com/opentracing/opentracing-go" | |
otlog "github.com/opentracing/opentracing-go/log" | |
"github.com/rs/zerolog/log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'base64' | |
require 'openssl' | |
require 'securerandom' | |
require 'uri' | |
BASE_URL = ENV['OAUTH2_BASE_URL'] | |
REDIRECT_URI = ENV['REDIRECT_URI'] | |
CLIENT_ID = ENV['OAUTH2_CLIENT_ID'] | |
code_verifier = Base64.urlsafe_encode64(SecureRandom.bytes(128), padding: false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'logger' | |
require 'semantic_logger' | |
class KubeFmt < SemanticLogger::Formatters::Json | |
# redefine the defaults for log_host and log_application to be false | |
def initialize( | |
time_format: :iso_8601, log_host: false, log_application: false, | |
time_key: :timestamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
request = require('superagent') | |
request.get('http://httpbin.org/status/200') | |
.then(req => console.log(`got status: ${req.status}`)) | |
.catch(err => console.error(err)) | |
// got status: 200 | |
request.get('http://httpbin.org/status/500') | |
.then(req => console.log(`got status: ${req.status}`)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateCats < ActiveRecord::Migration[5.0] | |
def change | |
create_table :cats do |t| | |
t.string :name | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
# class Cat < ApplicationRecord | |
# has_many :cat_toy | |
# has_many :toys, through: :cat_toy, dependent: :destroy | |
# end | |
# | |
# class Toy < ApplicationRecord | |
# end | |
# |
NewerOlder