Skip to content

Instantly share code, notes, and snippets.

@beginor
beginor / snowflake-id.sql
Last active April 21, 2025 07:21
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@mekya
mekya / build.gradle
Last active July 30, 2017 10:07
Export War file from Eclipse Web Project with Gradle -- hope it saves some time for gradle newbies like me
//Export War file from Eclipse Web Project with Gradle
// we need to use war plugin
apply plugin: 'war'
//default webAppDirName in gradle is not "WebContent" but
// it is default in eclise so change it according to eclipse layout
// it encapsulates all files under webAppDirName
webAppDirName = 'WebContent'
@breskeby
breskeby / build.gradle
Created April 25, 2014 08:33
log java compiler warnings with gradle
tasks.withType(JavaCompile){
def warnLogFile = file("$buildDir/${name}Warnings.log")
logging.addStandardErrorListener(new StandardOutputListener(){
void onOutput(CharSequence output){
warnLogFile << output
}
})
}
@rmetzler
rmetzler / gist:2947828
Created June 18, 2012 10:43
find all non UTF-8 encoded files
find . -type f | xargs -I {} bash -c "iconv -f utf-8 -t utf-16 {} &>/dev/null || echo {}" > utf8_fail