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
@echo off | |
setlocal EnableDelayedExpansion | |
rem Run trough values 0 to 31 in hex for position C | |
for /L %%a in (0, 1, 31) do ( | |
for /F %%b in ('DecToHex.bat %%a') do ( | |
@set "hex_c=%%b" | |
rem Pad left 0 | |
if "%%a" lss 16 ( | |
@set "hex_c=0!hex_c!" |
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
@echo off & setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | |
set LOOKUP=0123456789abcdef &set HEXSTR=&set PREFIX= | |
if "%1"=="" echo 0&goto :EOF | |
set /a A=%* || exit /b 1 | |
if !A! LSS 0 set /a A=0xfffffff + !A! + 1 & set PREFIX=f | |
:loop | |
set /a B=!A! %% 16 & set /a A=!A! / 16 | |
set HEXSTR=!LOOKUP:~%B%,1!%HEXSTR% | |
if %A% GTR 0 goto :loop | |
echo %PREFIX%%HEXSTR% |
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
set serveroutput on size 100000; | |
declare | |
--Text to find, case insensitive. Use % for like. | |
V_TEXT varchar(50) := '%what I want to locate%'; | |
--Tables schema | |
V_SCHEMA varchar(50) := 'SCHEMA_NAME'; | |
--List of tables to skip; comma-separated or NONE | |
V_SKIP_NAMES varchar(200) := 'NONE'; | |
--Using temporary table | |
V_TEMPORARY_TABLE number := 0; |
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
DO $$ <<lookup_contents>> | |
DECLARE | |
_search VARCHAR := 'something'; --what are you looking for? | |
_limit INTEGER := 1000000; | |
_total_columns INTEGER := 0; | |
_total_read INTEGER := 0; | |
_mark INTEGER; | |
_text_columns REFCURSOR; | |
_text_column RECORD; | |
_address_columns REFCURSOR; |
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
DECLARE @search_column VARCHAR(255); | |
DECLARE @search_value VARCHAR(255); | |
DECLARE @search_type INT; /* 1: specific column 2: string columns 3: numeric columns */ | |
SET @search_column = 'SEARCHING_COLUMN_NAME'; --wrap with %% for wider search | |
SET @search_value = 'Any value'; --wrap with %% for wider search | |
SET @search_type = 1; | |
DECLARE @containing_tables TABLE | |
( |
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
/* | |
Replicates all data from the remote database to the local database. The local contents are removed, all current local data is erased and not recoverable. | |
You have to set the value for @LINKED_SERVER_NAME as your local Linked Server name for the remote SQL Server instance. | |
*/ | |
print 'Starting replication...'; | |
--Control for structure alterations over the process | |
declare @CONTROL_TABLES table | |
( | |
TABLE_NAME varchar(255) NOT NULL, | |
CONSTRAINT_NAME varchar(255) NULL, |
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
/** | |
* Identify a numeric value. | |
* | |
* @param value Value to be evaluated. | |
* @param digits May use digits or not. | |
* @return True when the value is a numeric representation. | |
*/ | |
public static boolean isNumeric(String value, boolean digits) | |
{ | |
String unmarked = value; |
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
/** | |
* Formats the amount of time in a friendly way. | |
* | |
* @param millis Amount of time in milliseconds. | |
* @param nicly When the amount of time is less than 1 minute, the message will be cool. | |
* @return Friendly description of the amount of time. | |
*/ | |
public static String friendlyAmountTime(long millis, boolean nicly) | |
{ | |
long hours = TimeUnit.MILLISECONDS.toHours(millis); |
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
/** | |
* Extract the XML content, human friendly, of the <b>JAXBElement</b> object. | |
* | |
* @param object Object JAXBElement | |
* @return XML content | |
* @throws Exception Will be thrown always when object is not a valid JAXB instance. | |
*/ | |
public static String extractXMLFromJAXBObject(Object object) throws Exception | |
{ | |
try |
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
var options = ["<option value='2'>Green</option>","<option value='1'>Red</option>","<option value='3'>Blue</option>"]; | |
options.sort(function (option1, option2) | |
{ | |
var name1 = option1.toUpperCase(); | |
var name2 = option2.toUpperCase(); | |
name1 = name1.substr((name1.indexOf(">") + 1)).substr(0, name1.substr((name1.indexOf(">") + 1)).indexOf("<")); | |
name2 = name2.substr((name2.indexOf(">") + 1)).substr(0, name2.substr((name2.indexOf(">") + 1)).indexOf("<")); | |
return name1.localeCompare(name2); |
NewerOlder