Skip to content

Instantly share code, notes, and snippets.

View akapitula's full-sized avatar
🎯
Focusing

Alex Kapitula akapitula

🎯
Focusing
View GitHub Profile
@akapitula
akapitula / remove_connected_user_oracle_RDS
Last active October 4, 2016 13:39
remove connected user oracle RDS
# In any database editor run SQL:
SELECT SID, SERIAL#, STATUS
FROM V$SESSION
WHERE USERNAME = '<SCHEME>';
# then in SQLPlus:
exec rdsadmin.rdsadmin_util.kill(SID, SERIAL#);
# drop it:
drop user <username> cascade;
@akapitula
akapitula / docker-compose.yml
Last active October 5, 2016 15:39
docker configuration network
echo "#
# This docker-compose file can deploy a whole Linkcare application.
# You should create a local.php and configure it for ws
# The frontend is automatically configured with the attached ws endpoint
client:
image: linkcare${APP_NAME}_client
ports:
- "${VIRTUAL_PORT_FRONTEND}:3000"
volumes:
- /var/www/${APP_NAME}/frontend:/var/www/html/docs
@akapitula
akapitula / Clear unused docker images and containers
Created November 4, 2016 11:15
Clear unused docker images and containers
#NOTE: before running commands check output list to remove
# remove untagged docker images:
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
#remove stopped docker containers:
docker rm $(docker ps -q -f status=exited)
// to export and import Oracle database user as an alternative to old imp/exp utility can be used next commands:
// In sql editor run:
// export dump file in Oracle storage
DECLARE
hdnl NUMBER;
BEGIN
hdnl := DBMS_DATAPUMP.open( operation => 'EXPORT', job_mode => 'SCHEMA', job_name=>null);
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'dumpfile.dump', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.add_file( handle => hdnl, filename => 'dumplog.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_log_file);
DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''EXPORTED DB USER'')');
# GIVEN TWO CONTROLLERS, CatsController and DogsController:
class CatsController < ApplicationController
before_action :set_cat, only: [:show, :edit, :update, :destroy]
def new
@cat = Cat.new
end
Write a function called sumIntervals/sum_intervals that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once.
Intervals
Intervals are represented by a pair of integers in the form of an array. The first value of the interval will always be less than the second value. Interval example: [1, 5] is an interval from 1 to 5. The length of this interval is 4.
Overlapping Intervals
List containing overlapping intervals:
[
[1, 4],