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
function stringToColor(str) { | |
// Predefined set of colors | |
const colors = ['#FF5733', '#33FF57', '#3357FF', '#F833FF', '#FF8333', '#33FFF8']; | |
// Simple hash function | |
let hash = 0; | |
for (let i = 0; i < str.length; i++) { | |
const char = str.charCodeAt(i); | |
hash = ((hash << 5) - hash) + char; | |
hash = hash & hash; // Convert to 32bit integer |
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
CREATE OR REPLACE FUNCTION time_histogram( | |
start_time timestamp, | |
end_time timestamp | |
) | |
RETURNS TABLE(bucket timestamp) AS $$ | |
DECLARE diff_hours int; | |
BEGIN | |
diff_hours = abs(extract(epoch from end_time - start_time) / 3600) | |
raise notice 'diff hours: ', diff_hours; |
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
WITH RECURSIVE pg_inherit(inhrelid, inhparent) AS | |
(select inhrelid, inhparent | |
FROM pg_inherits | |
UNION | |
SELECT child.inhrelid, parent.inhparent | |
FROM pg_inherit child, pg_inherits parent | |
WHERE child.inhparent = parent.inhrelid), | |
pg_inherit_short AS (SELECT * FROM pg_inherit WHERE inhparent NOT IN (SELECT inhrelid FROM pg_inherit)) | |
SELECT table_schema | |
, TABLE_NAME |
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
static bool IsLoopbackOrPrivate([NotNull] IPAddress clientIp) | |
{ | |
// RFC for private networks: | |
// http://www.faqs.org/rfcs/rfc1918.html | |
byte[] bytes = clientIp.GetAddressBytes(); | |
switch(bytes[0]) | |
{ | |
case 10: | |
return 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
Alligator | |
Anteater | |
Armadillo | |
Axolotl | |
Badger | |
Bat | |
Beaver | |
Buffalo | |
Camel | |
Capybara |
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
airhead | |
allah | |
altar | |
anal | |
anus | |
aryan | |
ass | |
ass lick | |
asshole | |
asshole cleaner |
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
sudo apt-get update | |
sudo apt-get upgrade -y | |
# install hfs tools (for macos extended journaled) | |
sudo apt-get install hfsplus hfsutils hfsprogs | |
sudo reboot | |
# get device id | |
df -h | |
# example: |
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
# https://github.com/dotnet/diagnostics/issues/573#issuecomment-543886037 | |
# dotnet tools are currently available as part of SDK so we need to create them in an sdk image | |
# and copy them to our final runtime image | |
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS tools-install | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-sos | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-trace | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-dump | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-counters |
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
select version(); | |
-- PostgreSQL 9.6.12 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.2.0) 8.2.0, 64-bit | |
SHOW server_version; | |
-- 9.6.12 | |
SELECT current_setting('server_version_num'); | |
-- 90612 | |
select current_setting('server_version'); |
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
function text_replace() { | |
case "${OSTYPE}" in | |
darwin*) PLATFORM="OSX" ;; | |
linux*) PLATFORM="LINUX" ;; | |
bsd*) PLATFORM="BSD" ;; | |
*) PLATFORM="UNKNOWN" ;; | |
esac | |
if [[ "${PLATFORM}" == "OSX" || "${PLATFORM}" == "BSD" ]]; then | |
find $1 -type f -name $2 -exec sed -i "" "s/$3/$4/g" {} + |
NewerOlder