Skip to content

Instantly share code, notes, and snippets.

View postgresql_cheats.sql
-- PostgreSQL cheat sheet
--postgres is set up to use local.6 which is syslog'd to sflog001
--slow query log is /var/log/localmessages
--config files are always in /data/friend/*.conf
--vacuums are set via cfengine, we use both manual and auto. vacuums/analyze help with frozen id's being recouped, and thus TX'id's not going over 2b thus causing massing shutdown/reset. Fix it to exp/imp high TX tables.
--to log into psql: psql -U postgres -d <DB> (usually friend)
View blockstack ID
Verifying my Blockstack ID is secured with the address 1EqA3rUVJbCUATQowatgcADNYUoQALhyza https://explorer.blockstack.org/address/1EqA3rUVJbCUATQowatgcADNYUoQALhyza
@elifarley
elifarley / ec2-host-from-tag-to-env-vars.sh
Last active Dec 15, 2016 — forked from marcellodesales/ec2-host-from-tag-to-env-vars.sh
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
View ec2-host-from-tag-to-env-vars.sh
######
# Author: Marcello de Sales (marcello.desales@gmail.com)
# Description: Create Environment Variables in EC2 Hosts from EC2 Host Tags
#
### Requirements:
# * Install jq library (sudo apt-get install -y jq)
# * Install the EC2 Instance Metadata Query Tool (http://aws.amazon.com/code/1825)
#
### Installation:
# * Add the Policy EC2:DescribeTags to a User
@elifarley
elifarley / hgbkp-jenkins.hgignore
Last active Apr 13, 2017 — forked from abayer/jenkins-git-backup.sh
Script for backing up Jenkins home to a Mercurial (Hg) repository.
View hgbkp-jenkins.hgignore
# Moved to https://github.com/elifarley/docker-jenkins-uidfv/blob/master/hgbkp-jenkins.hgignore
@elifarley
elifarley / logback.xml
Last active Jan 27, 2017
Logback configuration with JSON output when run in a container
View logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true" scanPeriod="120 seconds" packagingData="false">
<if condition='p("HOME").startsWith("/app")'><then> <!-- Docker -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<!--<timeZone>UTC</timeZone>-->
<timeZone>Brazil/East</timeZone>
<includeContext>false</includeContext>
<includeCallerData>false</includeCallerData>
@elifarley
elifarley / Kotlin + Spring Data + MS SQL
Last active Oct 24, 2018
Kotlin + Spring Data + MS SQL - Insert rows via stored procedure using Spring Data; Select using native SQL query
@elifarley
elifarley / dt2asbigint.sql
Created Jan 8, 2016
DateTime2 to BigInt - MS SQL
View dt2asbigint.sql
-- Monotonic function that returns a bigint representing a given datetime2.
CREATE FUNCTION dt2asbigint(@dt datetime2) RETURNS BIGINT WITH SCHEMABINDING AS
BEGIN
declare @twoAsBigInt bigint = 2
declare @bytesInDate int = 3
declare @bitsInTime int = 8 * (8 - @bytesInDate)
declare @bigdatetime binary(9) = cast(@dt as binary(9))
declare @bigdate bigint = cast(reverse(substring(@bigdatetime, 7, @bytesInDate)) as binary(3))
@elifarley
elifarley / opb58enc-mssql.sql
Last active Mar 16, 2018 — forked from micahwalter/base58.sql
Order-Preserving Base-58
View opb58enc-mssql.sql
-- num <= 430804206899405823: <= 10 digits
-- num > 430804206899405823: 11 digits
CREATE FUNCTION opb58enc (@num bigint) RETURNS char(11) WITH SCHEMABINDING AS
BEGIN
DECLARE @alphabet char(58) = '0123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz'
DECLARE @encoded varchar(11)
DECLARE @divisor bigint
DECLARE @mode int = 0
SET @encoded = ''
View onename.md