Skip to content

Instantly share code, notes, and snippets.

💭
Build systems for people, not for fun

Daniil Yaroslavtsev daniilyar

💭
Build systems for people, not for fun
Block or report user

Report or block daniilyar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@daniilyar
daniilyar / Get disk space is used by schema or table in Oracle DB
Created Apr 30, 2014
Gets the real disk space amount is used by schema or table in Oracle DB
View Get disk space 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
View gist:31b0592b8b3423184649
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
View gist:9e6b41d12ee88b2b041d
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
View gist:4b13c68f19d902625abe
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,
View NPE case Redundat Return
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 Nov 30, 2014
Example code of how NOT to use redundant Map whenr generating ast tree JSON
View gist:cf07a850939970ddde74
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 Dec 8, 2014
How to make camel redirect requests in a maximum
View gist:1c01da493747dc8dabd2
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 Feb 26, 2015
output of rs.status() from PRIMARY host
View gist:630bc6fe7723ed06f243
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 Feb 28, 2015
eclipse.ini template for Scala developemnt
View eclipse.ini
-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 Mar 20, 2015
Debian /etc/init.d launch script for pgpool. Tested on Ubuntu 14.04 LTS (at Amazon EC2)
View pgpool2_etc_init.d_debian
#! /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
You can’t perform that action at this time.