查找

文章
· 一月 6 阅读大约需 2 分钟

Encontre e Exiba Valores a partir de textos

A utilidade retorna os valores desejados do texto e exibe múltiplos valores, se existirem, com base na string de início e na string de término.

Class Test.Utility.FunctionSet Extends %RegisteredObject
{

/// W !,##class(Test.Utility.FunctionSet).ExtractValues("Some random text VALUE=12345; some other VALUE=2345; more text VALUE=345678;","VALUE=",";")
 

ClassMethod ExtractValues(text As %String, startStr As %String, endStr As %String) As %String
{    //Initialize Valriables
   Set values = ""
   Set start = 1
   
   While start '= 0 {
 Set start = $FIND(text, startStr, start)
 IF start = 0 QUIT }
     Set end = $FIND(text, endStr, start)
     IF end = 0 QUIT }
    //S value = $E(text, start, end-2)
     value = $E(text, start, end-$L(endStr)-1)
     IF values '= "" {
  Set values = values _" "_value   
     }Else {
  values = value   
     }
     start = end
   }
    values
} }

Output:

W !,##class(Test.Utility.FunctionSet).ExtractValues("Some random text VALUE=12345; some other VALUE=2345; more text VALUE=345678;","VALUE=",";")

12345 2345 345678

讨论 (0)1
登录或注册以继续
文章
· 一月 6 阅读大约需 1 分钟

Usando IRIS como una base de datos vectorial

Las capacidades integradas de búsqueda vectorial de InterSystems IRIS nos permiten buscar datos no estructurados y semiestructurados. Los datos se convierten en vectores (también llamados “embeddings”) y luego se almacenan e indexan en InterSystems IRIS para búsqueda semántica, generación aumentada por recuperación (RAG), análisis de texto, motores de recomendación y otros casos de uso.

Esta es una demostración sencilla de IRIS siendo utilizado como una base de datos vectorial y para búsquedas por similitud en IRIS.

Requisitos previos:

  1. Python
  2. InterSystems IRIS for Health - ya que se usará como la base de datos vectorial

Repositorio: https://github.com/piyushisc/vectorsearchusingiris

Pasos a seguir:

  1. Clonar el repositorio.
  2. Abrir VS Code, conectarse a la instancia y espacio de nombres deseados de IRIS y compilar las clases.
  3. Abrir la terminal de IRIS e invocar el comando: do ##class(vectors.vectorstore).InsertEmbeddings(), Esto lee el texto del archivo text.txt genera los embeddings y los almacena en IRIS.
  4. Invocar el comando: do ##class(vectors.vectorstore).VectorSearch("search_terms") con las palabras deseadas para realizar la búsqueda por similitud. IRIS devolverá los tres resultados más cercanos:alt text
讨论 (0)1
登录或注册以继续
文章
· 一月 6 阅读大约需 2 分钟

Causa e solução do erro <SLMSPAN> ao eliminar uma global

Rubrica de FAQ da InterSystems

Se você tentar eliminar uma global que está mapeada no nível de subscrito a partir do nó raiz, você receberá um erro e ela não será excluída. Isso ocorre porque o comando kill para globais mapeadas no nível de subscrito não pode ser usado atravessando mapeamentos.

// Suppose subscript-mapped globals exist in different databases, as shown below:
^TEST(A*~K*) -> database A
^TEST(L*~Z*) -> database B

// Trying to kill from the top level will result in a <SLMSPAN> error.
NAMESPACE>Kill ^TEST
<SLMSPAN> <- This error is output.

Para excluir apenas a global no namespace (banco de dados) atual, use o seguinte:

NAMESPACE>Kill ^["^^."]TEST

Globais mapeadas no nível de subscrito devem ser movidas para o banco de dados e eliminadas diretamente.

Para alternar para o banco de dados, use o seguinte:

zn "^^c:\intersystems\iris\mgr\user"
or
set $namespace="^^c:\intersystems\iris\mgr\user"

Ao importar globais com $System.OBJ.Load, o comportamento padrão é eliminar as globais antes de importá-las.
Como resultado, se as globais de destino estiverem mapeadas no nível de subscrito, ocorre um erro <SLMSPAN>. Nesse caso, especifique o parâmetro /mergeglobal como segundo argumento de $System.OBJ.Load, conforme abaixo, para evitar a eliminação prévia:

Set sc = $System.OBJ.Load(path," /mergeglobal",.errors)

enlightened [Referências]
Mapped globals cannot be exported.
How do I compile mapped classes and routines?

讨论 (0)1
登录或注册以继续
文章
· 一月 6 阅读大约需 3 分钟

Gerando JWT sem acesso aos certificados/chaves x509 do sistema

Se você quiser gerar um JWT a partir de um certificado/chave x509, qualquer operação (inclusive leitura) em %SYS.X509Credentials exige permissão U no recurso %Admin_Secure. O %Admin_Secure é necessário porque %SYS.X509Credentials é persistente e foi implementado dessa forma para impedir que todos os usuários tenham acesso às chaves privadas.

Se o recurso %Admin_Secure não estiver disponível em tempo de execução, você pode usar a seguinte alternativa.

Ao revisar o código de geração de JWT, descobri que o código de JWT utiliza %SYS.X509Credentials apenas como fonte de dados em tempo de execução para PrivateKey, PrivateKeyPassword, e Certificate. Como alternativa, você pode usar uma implementação não persistente da interface X.509 em tempo de execução, expondo apenas essas propriedades.Se você estiver usando interoperabilidade, o certificado/chave privada (Cert/PK) pode ser armazenado em credenciais para acesso seguro.

Class User.X509 Extends %RegisteredObject
{

Property PrivateKey As %VarString;
Property PrivateKeyPassword As %String;
Property Certificate As %VarString;
Property HasPrivateKey As %Boolean [ InitialExpression = {$$$YES} ];
ClassMethod GetX509() As User.X509
{
    set x509 = ..%New()
    set x509.PrivateKey = ..Key()
    set x509.Certificate = ..Cert()
    quit x509
}

/// Get X509 object from credential.
/// Username is a Cert, Password is a Private Key
ClassMethod GetX509FromCredential(credential) As User.X509
{
    set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    set x509 = ..%New()
    set x509.PrivateKey = credentialObj.Password
    set x509.Certificate = credentialObj.Username
    quit x509
}

ClassMethod Key()
{
    q "-----BEGIN RSA PRIVATE KEY-----"_$C(13,10)
    _"YOUR_TEST_KEY"_$C(13,10)
    _"-----END RSA PRIVATE KEY-----"
}

ClassMethod Cert() As %VarString
{
    q "-----BEGIN CERTIFICATE-----"_$C(13,10)
    _"YOUR_TEST_CERT"_$C(13,10)
    _"-----END CERTIFICATE-----"
}

}

E você pode gerar o JWT da seguinte forma:

ClassMethod JWT() As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set x509 = ##class(User.X509).GetX509()
    
    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
	Return sc
}

Como alternativa, você pode usar um objeto dinâmico para evitar a criação de uma classe; nesse caso, ficaria assim:

ClassMethod JWT(credential) As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    Set x509 = {
        "HasPrivateKey": true,
        "PrivateKey": (credentialObj.Password),
        "PrivateKeyPassword":"",
        "Certificate":(credentialObj.Username)
    }

    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
    Return sc
}
讨论 (0)1
登录或注册以继续
问题
· 一月 6

Top Tips for Electrical Fault Finding and Testing London Services

 

Electrical faults are more than just an inconvenience—they can pose serious safety risks if not addressed promptly. Whether you’re a homeowner, business owner, or property manager in London, knowing how to identify, test, and resolve electrical issues is essential. This guide will explore top tips for electrical fault finding and testing services in London, helping you maintain a safe and reliable electrical system.

Understanding Electrical Faults

Before diving into solutions, it’s important to understand what electrical faults are and why they occur. Electrical faults happen when there’s an abnormality in an electrical system in Romford, causing it to operate incorrectly. Common types of electrical faults include:

  • Short Circuits: When live wires touch each other or a grounded surface, causing sudden surges.
  • Overloaded Circuits: When circuits carry more current than they’re designed to handle.
  • Earth Faults: When electricity flows into the ground unexpectedly.
  • Open Circuits: When a break in wiring prevents the flow of electricity.

Electrical faults can lead to hazards like fires, electrocution, or appliance damage. Therefore, professional fault finding and testing are crucial.

Why Professional Electrical Testing in London is Essential

Electrical systems in London, especially in older buildings, can be complex. Hiring a licensed professional ensures the following:

  • Safety: Qualified electricians know how to handle high-voltage systems safely.
  • Compliance: Professionals follow UK wiring regulations (BS 7671), keeping your property legal and safe.
  • Accuracy: Advanced testing tools identify hidden faults that are difficult to detect.
  • Prevention: Regular testing reduces the risk of costly repairs and downtime.

DIY electrical work is risky and often illegal, so always rely on certified services for fault finding and testing.

Top Tips for Effective Electrical Fault Finding

To get the most out of your electrical testing service Romford London, consider these expert tips:

1. Identify Symptoms Early

Notice any warning signs like flickering lights, tripping circuit breakers, or burning smells. Early detection prevents small issues from turning into serious hazards.

2. Keep a Record of Issues

Document when and where faults occur. Details like time, duration, and affected appliances help electricians diagnose problems faster.

3. Use Appropriate Testing Tools

Professionals use tools such as:

  • Multimeters: Measure voltage, current, and resistance.
  • Insulation Testers: Check wiring insulation for damage.
  • Socket Testers: Ensure outlets are wired correctly.
  • Thermal Cameras: Detects overheating circuits.

These tools allow precise fault identification and safe testing.

4. Check Common Fault Areas

Some areas in a property are more prone to faults:

  • Older fuse boxes or outdated consumer units.
  • High-use circuits in kitchens and offices.
  • Outdoor wiring exposed to weather.
  • Appliances with heavy loads like heaters or air conditioners.

Targeting these areas first can save time and prevent future issues.

5. Avoid Overloading Circuits

Spread electrical loads evenly across circuits and avoid using multiple high-power devices on a single outlet. Overloading can cause frequent tripping and potential damage.

6. Schedule Regular Testing

Periodic inspections, such as Electrical Installation Condition Reports (EICR), ensure compliance with safety standards. In London, EICR testing is recommended every 5 years for domestic properties and more frequently for commercial spaces.

Benefits of Professional Electrical Testing Services in London

Hiring a professional service provides peace of mind. Key benefits include:

  • Comprehensive Diagnostics: Modern tools detect hidden issues in wiring, outlets, and appliances.
  • Efficient Repairs: Electricians can fix faults immediately or provide a detailed report for future action.
  • Enhanced Safety: Prevent fires, shocks, and damage to sensitive electronics.
  • Cost Savings: Early fault detection reduces the likelihood of expensive replacements or downtime.

Many London services also offer emergency call-outs, providing quick solutions when faults occur unexpectedly.

Choosing the Right Electrical Fault Finding Service in London

Not all electrical services in London are equal. Here’s what to look for when choosing a provider:

Licenses and Certifications

Ensure the company and its electricians are certified by NICEIC, NAPIT, or equivalent regulatory bodies. This guarantees adherence to safety and quality standards.

Experience

Look for services with extensive experience in fault finding and testing across residential, commercial, and industrial settings.

Transparent Pricing

Reliable services provide upfront quotes and explain costs clearly. Avoid providers that offer vague estimates or hidden fees.

Reviews and References

Check online reviews and ask for references to gauge reliability, professionalism, and customer satisfaction.

Emergency Support

Choose a service that offers 24/7 support for urgent electrical faults to minimize downtime and hazards.

DIY vs Professional Electrical Testing

While some minor issues like replacing fuses or resetting breakers can be handled safely, complex fault finding requires professional expertise. DIY attempts can:

  • Increase safety risks.
  • Violate building regulations.
  • Lead to incorrect diagnosis and expensive damage.

Professional testing ensures the root cause is accurately identified and properly resolved.

Maintaining Electrical Safety After Fault Finding

After testing and repairs, ongoing maintenance is crucial:

  • Regular Inspections: Schedule periodic checks to catch emerging faults early.
  • Avoid Overloading: Spread appliances across multiple circuits.
  • Upgrade Outdated Wiring: Older properties may need rewiring for safety.
  • Install Safety Devices: RCDs (Residual Current Devices) and surge protectors improve protection.

By combining professional services with preventive measures, London properties can maintain safe and reliable electrical systems.

Conclusion

Electrical fault finding and testing in London is a critical service for ensuring safety, compliance, and efficiency. By recognizing early warning signs, using the right tools, and hiring licensed professionals, you can prevent hazards and save costs in the long run. Regular testing, proper maintenance, and smart electrical usage are key to avoiding unexpected faults and maintaining a secure environment at home or work.

Whether you’re managing an office, a commercial space, or a residential property in London, investing in expert electrical fault finding services is always worthwhile. Safety first—always.

讨论 (0)1
登录或注册以继续