Skip to content

Instantly share code, notes, and snippets.

View junalmeida's full-sized avatar
🏡
Working from home

Marcos Junior junalmeida

🏡
Working from home
View GitHub Profile
@junalmeida
junalmeida / create-public-synonyms.sql
Created February 26, 2018 00:27
Create Public Synonims (PL-SQL)
set serveroutput on
DECLARE
sql_txt VARCHAR2(300);
CURSOR obj_cur IS
SELECT object_name, owner FROM ALL_OBJECTS where owner IN ('<owner1>', '<owner2>') and object_type in ('TABLE', 'SEQUENCE', 'VIEW');
BEGIN
dbms_output.enable(10000000);
FOR obj IN obj_cur LOOP
sql_txt:='CREATE OR REPLACE PUBLIC SYNONYM ' || obj.object_name || ' FOR ' || obj.owner || '.' || obj.object_name || ';';
dbms_output.put_line(sql_txt);
@junalmeida
junalmeida / mssql-index-defrag.sql
Created July 19, 2018 22:08
MSSQL Index Fragmentation Rebuild
--this will generate only ready-to-run sql statements to rebuild.
select
'ALTER INDEX [' + a.Name + '] ON ' + a.Schema_Name + '.[' + a.[Table_Name] + '] ' +
(CASE when b.AverageFragmentation > 30 then 'REBUILD WITH (ONLINE = ON)' else 'REORGANIZE' end) + ';'
cmd, b.AverageFragmentation,b.[page_count]
FROM
(
SELECT s.name [Schema_Name], tbl.name AS [Table_Name], tbl.object_id, i.name AS [Name], i.index_id, CAST(CASE i.index_id WHEN 1 THEN 1 ELSE 0 END AS bit) AS [IsClustered],
@junalmeida
junalmeida / AdfsProvider.cs
Created July 19, 2018 22:54
ADFS Provider to get Saml and Oauth tokens (.netstandard compatible)
using Microsoft.IdentityModel.Tokens.Saml;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
@junalmeida
junalmeida / transfer.sql
Created August 22, 2018 14:38
pl-sql transfer multiple dumps over dblink
BEGIN
FOR loop_counter IN 1 .. 7
LOOP
dbms_output.put_line('EXPDAT' || LPAD(loop_counter, 2, '0') || '.DMP');
DBMS_FILE_TRANSFER.PUT_FILE(
source_directory_object => 'DATA_PUMP_DIR',
source_file_name => 'EXPDAT' || LPAD(loop_counter, 2, '0') || '.DMP',
destination_directory_object => 'DATA_PUMP_DIR',
destination_file_name => 'EXPDAT' || LPAD(loop_counter, 2, '0') || '.DMP',
destination_database => 'to_rds' --dblink
@junalmeida
junalmeida / lightweight-oracle-client-11g.md
Last active March 31, 2021 05:07
Configuring a clean and lightweight Oracle.DataAccess client for .NET applications

This guide aims to help you on how to configure a clean and lightweight Oracle Client with .NET Framework. This guide is intended for legacy applications that are bound with classic Oracle.DataAccess. It is recommended to move on to Oracle.ManagedDataAccess.

Download

32 bits version
http://www.oracle.com/technetwork/database/windows/downloads/utilsoft-087491.html
ODAC 11.2 Release 6 (11.2.0.4.0) [Released January 14, 2014]

64 bits version
http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html

steps:
- powershell: |
$VSEdition = "Enterprise"
$VSPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\$VSEdition"
$VC141 = "$VSPath\MSBuild\Microsoft\VC\v150\Platforms\x64\PlatformToolsets\v141\Toolset.props"
$MSBuildPath = "$VSPath\MSBuild\Current\Bin"
echo "##vso[task.prependpath]$MSBuildPath"
if ((Test-Path "$VC141") -eq $False) {
$VSBootstrapperURL = "https://aka.ms/vs/16/release/vs_$VSEdition.exe"
@junalmeida
junalmeida / longestPrefix.cs
Created June 5, 2020 15:13
Get Longest Prefix from a set of strings with and without prefix sharing
// Enumerate all possible m-size combinations of [0, 1, ..., n-1] array
// in lexicographic order (first [0, 1, 2, ..., m-1]).
private static IEnumerable<int[]> GetCombinations(int m, int n)
{
int[] result = new int[m];
Stack<int> stack = new Stack<int>(m);
stack.Push(0);
while (stack.Count > 0)
{
int index = stack.Count - 1;
@junalmeida
junalmeida / vscode-jira.json
Created February 8, 2021 19:35
VSCode Jira Extension
{
"atlascode.jira.jqlList": [
{
"id": "40e3738f-5ff3-4f28-bbb8-8f21c48b7603",
"siteId": "4b7fd06c-d254-4cc9-abda-9c9a1552bfa6",
"name": "My Issues",
"query": "assignee = currentUser() AND resolution = Unresolved AND status != Closed AND status != Resolved ORDER BY updated desc",
"enabled": true,
"monitor": true
},
@junalmeida
junalmeida / find-locks.sql
Created April 19, 2021 17:11
Find MSSQL Locks
WITH cteHead ( session_id,request_id,wait_type,wait_resource,last_wait_type,is_user_process,request_cpu_time
,request_logical_reads,request_reads,request_writes,wait_time,blocking_session_id,memory_usage
,session_cpu_time,session_reads,session_writes,session_logical_reads
,percent_complete,est_completion_time,request_start_time,request_status,command
,plan_handle,sql_handle,statement_start_offset,statement_end_offset,most_recent_sql_handle
,session_status,group_id,query_hash,query_plan_hash)
AS ( SELECT sess.session_id, req.request_id, LEFT (ISNULL (req.wait_type, ''), 50) AS 'wait_type'
, LEFT (ISNULL (req.wait_resource, ''), 40) AS 'wait_resource', LEFT (req.last_wait_type, 50) AS 'last_wait_type'
, sess.is_user_process, req.cpu_time AS 'request_cpu_time', req.logical_reads AS 'request_logical_reads'
, req.reads AS 'request_reads', req.writes AS 'request_writes', req.wait_time, req.blocking_session_id,sess.memory_usage
@junalmeida
junalmeida / configuration.yaml
Last active May 14, 2023 13:16
Wyze Lock Quirkz for Home Assistant
zha:
enable_quirks: true
custom_quirks_path: /config/zigbee/quirks