Skip to content

Instantly share code, notes, and snippets.

View daniilyar's full-sized avatar
💭
Build systems for people, not only for money

Daniil Yaroslavtsev daniilyar

💭
Build systems for people, not only for money
View GitHub Profile
@daniilyar
daniilyar / Get disk space is used by schema or table in Oracle DB
Created April 30, 2014 06:32
Gets the real disk space amount is used by schema or table in Oracle DB
--select sum(Megabytes) from (
SELECT
owner, table_name, TRUNC(sum(bytes)/1024/1024) Megabytes
FROM
(SELECT segment_name table_name, owner, bytes
FROM dba_segments
WHERE segment_type = 'TABLE'
UNION ALL
SELECT i.table_name, i.owner, s.bytes
FROM dba_indexes i, dba_segments s
select FS_PERM_SEC_ID, avg(p_price) avg_price, 'DAY' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES'
and SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -1) and sysdate
group by FS_PERM_SEC_ID
UNION ALL
select FS_PERM_SEC_ID, avg(p_price) avg_price, 'WEEK' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES'
and SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -7) and sysdate
group by FS_PERM_SEC_ID
UNION ALL
select FS_PERM_SEC_ID, period, avg(p_price) avg_price from (
select FS_PERM_SEC_ID, p_price, SECURITY_PRICE_DATE, 'DAY' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES' and
SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -1) and sysdate
union all
select FS_PERM_SEC_ID, p_price, SECURITY_PRICE_DATE, 'WEEK' period
from FSDF_PRICE_EOD.FP_BASIC_BD where FS_PERM_SEC_ID = 'XQC8FD-S-ES' and
SECURITY_PRICE_DATE between sieve2.UTILS_PKG.add_businessdays(sysdate, -7) and sysdate
union all
select FS_PERM_SEC_ID, p_price, SECURITY_PRICE_DATE, 'MONTH' period
@daniilyar
daniilyar / gist:4b13c68f19d902625abe
Created September 5, 2014 21:51
supe avg_prices query
WITH dates AS (
select distinct FS_PERM_SEC_ID,
sieve2.utils_pkg.sv_businessday(sysdate-1) D0,
sieve2.utils_pkg.add_businessdays(sysdate, -5) D7,
sieve2.utils_pkg.sv_businessday(add_months(sysdate, -1)) M1,
sieve2.utils_pkg.sv_businessday(add_months(sysdate, -3)) M3,
sieve2.utils_pkg.sv_businessday(add_months(sysdate, -12)) Y1
from THEMES.SECURITIES_MAPPING_TEMP mapping
)
select dates.fs_perm_sec_id,
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
@daniilyar
daniilyar / gist:cf07a850939970ddde74
Created November 30, 2014 16:39
Example code of how NOT to use redundant Map whenr generating ast tree JSON
public static String toJson(DetailAST ast) throws IOException {
int nodeId = ROOT_NODE_ID;
Stack<Integer> parentNodeIdStack = new Stack<>();
parentNodeIdStack.push(nodeId); // root node id
DetailAST currentNode = ast;
StringWriter writer = new StringWriter();
JsonGenerator jsonGenerator = JSON_FACTORY.createJsonGenerator(writer).useDefaultPrettyPrinter();
@daniilyar
daniilyar / gist:1c01da493747dc8dabd2
Created December 8, 2014 13:23
How to make camel redirect requests in a maximum
from(url).process(processor).choice()
.when(header("location").isNull()).endChoice()
.when(header("location").contains("?")).recipientList(simple("${header.location}&bridgeEndpoint=true")).endChoice()
.otherwise().recipientList(simple("${header.location}?bridgeEndpoint=true"));
and just modify location header in processor to any url you need to redirect based on input request content
@daniilyar
daniilyar / gist:630bc6fe7723ed06f243
Created February 26, 2015 08:56
output of rs.status() from PRIMARY host
10.148.28.51:PRIMARY> rs.status()
{
"set" : "10.148.28.51",
"date" : ISODate("2015-02-25T18:35:38Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "ip-10-148-28-51:27118",
"health" : 1,
@daniilyar
daniilyar / eclipse.ini
Created February 28, 2015 20:53
eclipse.ini template for Scala developemnt
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20140603-1326
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
@daniilyar
daniilyar / pgpool2_etc_init.d_debian
Created March 20, 2015 23:41
Debian /etc/init.d launch script for pgpool. Tested on Ubuntu 14.04 LTS (at Amazon EC2)
#! /bin/sh
### BEGIN INIT INFO
# Provides: pgpool2
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start pgpool-II