• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 02:24
CET 08:24
KST 16:24
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Rongyi Cup S3 - RO16 Preview3herO wins SC2 All-Star Invitational12SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0
Community News
Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)22Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7
StarCraft 2
General
PhD study /w SC2 - help with a survey! herO wins SC2 All-Star Invitational Oliveira Would Have Returned If EWC Continued StarCraft 2 not at the Esports World Cup 2026 [Short Story] The Last GSL
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone
Brood War
General
Fantasy's Q&A video [ASL21] Potential Map Candidates BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion Gypsy to Korea
Tourneys
[Megathread] Daily Proleagues Azhi's Colosseum - Season 2 Small VOD Thread 2.0 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Current Meta Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Game Theory for Starcraft
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Beyond All Reason Awesome Games Done Quick 2026!
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Canadian Politics Mega-thread NASA and the Private Sector
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
How Esports Advertising Shap…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2720 users

The Big Programming Thread - Page 981

Forum Index > General Forum
Post a Reply
Prev 1 979 980 981 982 983 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
December 12 2018 01:34 GMT
#19601
I did something similar in my Flask project.

Dockerfile

Docker compose

IIRC the main thing was in the Docker compose file, under web: volumes. That automatically updates from my /flask directory in the project to the /app directory in the container.

I did notice a problem that I would have to run into the same code twice before it took effect, so there should be a better way.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Manit0u
Profile Blog Joined August 2004
Poland17625 Posts
Last Edited: 2018-12-12 09:47:19
December 12 2018 02:36 GMT
#19602
On December 12 2018 10:34 WarSame wrote:
I did something similar in my Flask project.

Dockerfile

Docker compose

IIRC the main thing was in the Docker compose file, under web: volumes. That automatically updates from my /flask directory in the project to the /app directory in the container.

I did notice a problem that I would have to run into the same code twice before it took effect, so there should be a better way.


Can it be because python creates those intermediate .pyc files?

I'm not entirely sure how flask creates cache and stuff. PHP server, rails, mongrel, sinatra etc. all pick up changes to files immediately (unless you turn off their file watcher).
Time is precious. Waste it wisely.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
December 12 2018 14:59 GMT
#19603
I am not sure, I just accepted it
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
R1CH
Profile Blog Joined May 2007
Netherlands10341 Posts
December 12 2018 16:17 GMT
#19604
Most Python app servers will need relaunching to detect source code changes.
AdministratorTwitter: @R1CH_TL
TL+ Member
Manit0u
Profile Blog Joined August 2004
Poland17625 Posts
Last Edited: 2018-12-14 12:38:26
December 14 2018 10:00 GMT
#19605
So, I completely forgot to post Dockerfile and docker-compose...
Here they are:

+ Show Spoiler [Dockerfile] +


FROM ruby:2.3.6

# Install APT dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
cmake \
curl \
git \
mysql-client \
openssh-client \
sqlite3 \
wget

ENV LC_ALL=C.UTF-8

ARG TMP_DIR=/tmp/
RUN mkdir -p ${TMP_DIR} && chmod 1777 ${TMP_DIR}

# Zeromq
ARG LINUX_LIBZMQ_VERSION=4.0.5
RUN ZMQ_TMP_DIR=${TMP_DIR}/zmq/ && \
mkdir -p ${ZMQ_TMP_DIR} && \
wget [url=http://download.zeromq.org/zeromq-${LINUX_LIBZMQ_VERSION}.tar.gz]http://download.zeromq.org/zeromq-${LINUX_LIBZMQ_VERSION}.tar.gz[/url] \
-O ${ZMQ_TMP_DIR}/zeromq-${LINUX_LIBZMQ_VERSION}.tar.gz && \
tar -xvzf ${ZMQ_TMP_DIR}/zeromq-${LINUX_LIBZMQ_VERSION}.tar.gz -C ${ZMQ_TMP_DIR} && \
cd ${ZMQ_TMP_DIR}/zeromq-${LINUX_LIBZMQ_VERSION} && \
./configure && make && make install && ldconfig && \
test ${ZMQ_TMP_DIR} && test -d ${ZMQ_TMP_DIR} && rm -rf ${ZMQ_TMP_DIR}

# Mongrel
ARG LINUX_MONGREL_VERSION=1.9.2
RUN MONGREL_TMP_DIR=${TMP_DIR}/mongrel/ && \
mkdir -p ${MONGREL_TMP_DIR} && \
wget [url=https://github.com/mongrel2/mongrel2/releases/download/${LINUX_MONGREL_VERSION}/mongrel2-v${LINUX_MONGREL_VERSION}.tar.bz2]https://github.com/mongrel2/mongrel2/releases/download/${LINUX_MONGREL_VERSION}/mongrel2-v${LINUX_MONGREL_VERSION}.tar.bz2[/url] \
-O ${MONGREL_TMP_DIR}/mongrel2-v${LINUX_MONGREL_VERSION}.tar.bz2 && \
tar -xvjf ${MONGREL_TMP_DIR}/mongrel2-v${LINUX_MONGREL_VERSION}.tar.bz2 -C ${MONGREL_TMP_DIR} && \
cd ${MONGREL_TMP_DIR}/mongrel2-v${LINUX_MONGREL_VERSION}/ && \
make -C ${MONGREL_TMP_DIR}/mongrel2-v${LINUX_MONGREL_VERSION} && \
make -C ${MONGREL_TMP_DIR}/mongrel2-v${LINUX_MONGREL_VERSION} install && \
test ${MONGREL_TMP_DIR} && test -d ${MONGREL_TMP_DIR} && rm -rf ${MONGREL_TMP_DIR}

ARG USER_ID=1000
ARG GROUP_ID=1000
RUN groupadd -r dev --gid ${GROUP_ID} && \
useradd --no-log-init --system --create-home --uid ${USER_ID} --gid ${GROUP_ID} dev
USER dev
RUN mkdir -p /home/dev/.ssh

ENV LINES=${LINES}
ENV COLUMNS=${COLUMNS}
WORKDIR /home/dev/app
ENTRYPOINT /bin/bash



+ Show Spoiler [docker-compose] +


version: '3.5'

services:
engine:
build:
context: "."
dockerfile: Dockerfile
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
environment:
LINES: ${LINES}
COLUMNS: ${COLUMNS}
LANG: en_US.UTF-8
DOCKER_LOCAL: 'true'
entrypoint: /bin/bash
command: "-c 'trap : TERM INT; sleep infinity & wait'"
ports:
- "6767:6767"
volumes:
- "${SSH_KEY_PATH}:/home/dev/.ssh/id_rsa:ro"
- "${SSH_PUBLIC_KEY_PATH}:/home/dev/.ssh/id_rsa.pub:ro"
- "${KNOWN_HOSTS_PATH}:/home/dev/.ssh/known_hosts:ro"
- ./:/home/dev/app/:cached
networks:
- infrastructure

networks:
infrastructure:
external: true



Edit:

Bonus

Time is precious. Waste it wisely.
Manit0u
Profile Blog Joined August 2004
Poland17625 Posts
Last Edited: 2018-12-14 16:03:58
December 14 2018 16:03 GMT
#19606
Holy crap! Today, after 2 years of working with it I've discovered something new about Ruby. You can actually create this kind of hash:
{ nil => 'some value' }

This is fucking absurd...
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
December 15 2018 00:04 GMT
#19607
I was checking things that are using up a lot of space on my computer.

My AMD folder is 10gb
and frankly i don't even remember installing any updates or anything after I initially installed my video drivers

what in the world is going on there? is it like auto updating and then just saving the old folders for eternity or something?
Manit0u
Profile Blog Joined August 2004
Poland17625 Posts
December 15 2018 10:46 GMT
#19608
On December 15 2018 09:04 travis wrote:
I was checking things that are using up a lot of space on my computer.

My AMD folder is 10gb
and frankly i don't even remember installing any updates or anything after I initially installed my video drivers

what in the world is going on there? is it like auto updating and then just saving the old folders for eternity or something?


Usually when you download drivers and update them it unpacks them to intermediate folder first and then leaves them there.
Time is precious. Waste it wisely.
Excludos
Profile Blog Joined April 2010
Norway8231 Posts
December 15 2018 12:04 GMT
#19609
On December 15 2018 19:46 Manit0u wrote:
Show nested quote +
On December 15 2018 09:04 travis wrote:
I was checking things that are using up a lot of space on my computer.

My AMD folder is 10gb
and frankly i don't even remember installing any updates or anything after I initially installed my video drivers

what in the world is going on there? is it like auto updating and then just saving the old folders for eternity or something?


Usually when you download drivers and update them it unpacks them to intermediate folder first and then leaves them there.


Always get rid of temporary files when updating or installing a client.

That said I'm having a similar issue right now myself. The whole pipe is a bit complicated, but the gist is that I'm ending up with some software being run on a VM at regular intervals, but unable to delete itself once it's done. It's also unable to delete any previous versions of itself as every run has a different generated user, and you don't have access to other user's files.

This is all done through Azure Data Factory as well, so I have very limited options to do anything with. I can't, for instance, just log onto the VM and delete the files manually either (Not that I'd want to, this is suppose to work without human interaction).
mantequilla
Profile Blog Joined June 2012
Turkey781 Posts
December 15 2018 21:20 GMT
#19610
On December 15 2018 09:04 travis wrote:
I was checking things that are using up a lot of space on my computer.

My AMD folder is 10gb
and frankly i don't even remember installing any updates or anything after I initially installed my video drivers

what in the world is going on there? is it like auto updating and then just saving the old folders for eternity or something?


I use a tiny program called SpaceSniffer time to time, it visualizes what is wasting space pretty good. Sometimes I notice those kind of weird things otherwise I'd overlook.
Age of Mythology forever!
mantequilla
Profile Blog Joined June 2012
Turkey781 Posts
December 17 2018 09:56 GMT
#19611
On December 12 2018 10:34 WarSame wrote:
I did something similar in my Flask project.

Dockerfile

Docker compose

IIRC the main thing was in the Docker compose file, under web: volumes. That automatically updates from my /flask directory in the project to the /app directory in the container.

I did notice a problem that I would have to run into the same code twice before it took effect, so there should be a better way.


umm, a weird thing I noticed when trying to do this is,

volumes are mapped to host machine. Since I work on windows, there is an intermediate linux vm running inside hyper-v. The real host for my docker containers is that linux vm So any volume I create is not in my host machine but in that virtual machine. So I am not able to do this :/
Age of Mythology forever!
zatic
Profile Blog Joined September 2007
Zurich15359 Posts
December 17 2018 10:27 GMT
#19612
Is there an elegant way to join random date slices into fewer, longer date slices?

I have X startdate-enddate periods that can range from 1 day to many years. I want to join any overlapping periods and remove periods that lie within another period. In the end I want one list of periods with no overlaps. I can come up with some complicated semi-brutforce:

sort by start date
go over every period
search back through result from current period for overlaps
delete / join overlaps
add to / replace in result

Maybe there is no good way but it seems like such a straightforward thing to do and I feel stupid for not finding a more elegant way.
ModeratorI know Teamliquid is known as a massive building
slmw
Profile Blog Joined October 2010
Finland233 Posts
December 17 2018 10:58 GMT
#19613
Sort period by start date, then:
1. Find the first (next) period and save its start date and end date into some variables as "current period"
2. For every following period that starts before the "current period" ends, update it accordingly (move end date if the following period ends later than "current period")
3. Add "current period" to result and jump to (1.).
Acrofales
Profile Joined August 2010
Spain18199 Posts
December 17 2018 12:26 GMT
#19614
On December 17 2018 19:27 zatic wrote:
Is there an elegant way to join random date slices into fewer, longer date slices?

I have X startdate-enddate periods that can range from 1 day to many years. I want to join any overlapping periods and remove periods that lie within another period. In the end I want one list of periods with no overlaps. I can come up with some complicated semi-brutforce:

sort by start date
go over every period
search back through result from current period for overlaps
delete / join overlaps
add to / replace in result

Maybe there is no good way but it seems like such a straightforward thing to do and I feel stupid for not finding a more elegant way.

Depending on your data this may not be possible (or rather, you may end up with a single "period", which may or may not be what you want).

slmw gave a good O(n log n) algorithm for doing it (well, O(n) for the interesting bit. The worst case complexity is from sorting).
AKnopf
Profile Blog Joined March 2011
Germany259 Posts
Last Edited: 2018-12-17 15:15:17
December 17 2018 15:12 GMT
#19615
Edit: Forget it. I'm stupid
The world - its a funny place
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
December 17 2018 18:04 GMT
#19616
You can also do it in SQL pretty easily. Something like this:

--Get list of date overlaps
select *
from #DateTable a
inner join #DateTable b
on b.StartDate <= a.EndDate --match on overlap
and b.EndDate >= a.StartDate --match on overlap
and b.Id > a.Id --Ensure we get an overlap just once
and (b.StartDate != a.StartDate or b.EndDate != a.EndDate) -- If two dates are both exact, might want to handle that separately


Once you have the list, you'll just need to do an update and determine how to remove the overlaps.
Manit0u
Profile Blog Joined August 2004
Poland17625 Posts
Last Edited: 2018-12-18 10:35:08
December 18 2018 08:40 GMT
#19617
On December 18 2018 03:04 enigmaticcam wrote:
You can also do it in SQL pretty easily. Something like this:

--Get list of date overlaps
select *
from #DateTable a
inner join #DateTable b
on b.StartDate <= a.EndDate --match on overlap
and b.EndDate >= a.StartDate --match on overlap
and b.Id > a.Id --Ensure we get an overlap just once
and (b.StartDate != a.StartDate or b.EndDate != a.EndDate) -- If two dates are both exact, might want to handle that separately


Once you have the list, you'll just need to do an update and determine how to remove the overlaps.


You can use CASE WHEN to update it

Edit:

Also this...


date_ranges_1 = [
Sat, 15 Dec 2018..Mon, 17 Dec 2018,
Fri, 14 Dec 2018..Mon, 17 Dec 2018,
Thu, 13 Dec 2018..Mon, 17 Dec 2018,
Wed, 12 Dec 2018..Mon, 17 Dec 2018,
Tue, 11 Dec 2018..Mon, 17 Dec 2018
]
date_ranges_2 = [
Mon, 17 Dec 2018..Thu, 20 Dec 2018,
Sun, 16 Dec 2018..Thu, 20 Dec 2018,
Sat, 15 Dec 2018..Thu, 20 Dec 2018,
Wed, 19 Dec 2018..Sun, 23 Dec 2018,
Thu, 20 Dec 2018..Sun, 23 Dec 2018
]

res = date_ranges_1.map do |a|
latest_ending = date_ranges_2.select { |b| a.include?(b.first) }.max_by { |b| b.last }

if latest_ending.nil?
a
else
a.last < latest_ending.last ? (a.first..latest_ending.last) : a
end
end

res => [
Sat, 15 Dec 2018..Thu, 20 Dec 2018,
Fri, 14 Dec 2018..Thu, 20 Dec 2018,
Thu, 13 Dec 2018..Thu, 20 Dec 2018,
Wed, 12 Dec 2018..Thu, 20 Dec 2018,
Tue, 11 Dec 2018..Thu, 20 Dec 2018
]


Is something like that you want?

You can also do something like that:


date_ranges_1.map do |a|
earliest_starting = date_ranges_2.select { |b| a.include?(b.last) }.min_by { |b| b.first } || a
latest_ending = date_ranges_2.select { |b| a.include?(b.first) }.max_by { |b| b.last } || a

earliest_starting.first..latest_ending.last
end
Time is precious. Waste it wisely.
Acrofales
Profile Joined August 2010
Spain18199 Posts
December 18 2018 10:29 GMT
#19618
On December 18 2018 03:04 enigmaticcam wrote:
You can also do it in SQL pretty easily. Something like this:

--Get list of date overlaps
select *
from #DateTable a
inner join #DateTable b
on b.StartDate <= a.EndDate --match on overlap
and b.EndDate >= a.StartDate --match on overlap
and b.Id > a.Id --Ensure we get an overlap just once
and (b.StartDate != a.StartDate or b.EndDate != a.EndDate) -- If two dates are both exact, might want to handle that separately


Once you have the list, you'll just need to do an update and determine how to remove the overlaps.

You obviously leave optimization there to your db engine, but it looks like the naive implementation there is O(n^2), and I'm not sure it's sargable (I guess it probably is, with separate indexes on both startdate and enddate, so it should actually also be O(n log n)). Would, in general, the SQL implementation of this really be better than just getting the sorted list from the DB and doing it in whatever language you're using?

I always wonder that when ppl try to do computation in SQL
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2018-12-18 18:10:45
December 18 2018 18:06 GMT
#19619
On December 18 2018 17:40 Manit0u wrote:
You can use CASE WHEN to update it

Yep! I was just being lazy and didn't bother to figure out what that would look like.

On December 18 2018 19:29 Acrofales wrote:You obviously leave optimization there to your db engine, but it looks like the naive implementation there is O(n^2), and I'm not sure it's sargable (I guess it probably is, with separate indexes on both startdate and enddate, so it should actually also be O(n log n)). Would, in general, the SQL implementation of this really be better than just getting the sorted list from the DB and doing it in whatever language you're using?

I always wonder that when ppl try to do computation in SQL

I posted it mainly for informational purposes. I depends entirely on your implementation and where your data is. If it's starting in a database and it's large with proper indexing, I think a SQL query would definitely be faster than pulling it onto a client, running local code against it, and sending back the results. But that's not always the case for everyone
bangsholt
Profile Joined June 2011
Denmark138 Posts
December 18 2018 19:47 GMT
#19620
On December 18 2018 19:29 Acrofales wrote:
I always wonder that when ppl try to do computation in SQL


I always wonder why people want to transfer data to a client only for the client to filter and sort it.

It's almost like a SQL database has WHERE and GROUP BY
Prev 1 979 980 981 982 983 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
Rongyi Cup S3 - Group B
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 231
Nina 197
StarCraft: Brood War
Larva 152
Zeus 137
Shuttle 57
NotJumperer 21
Noble 14
Dota 2
monkeys_forever399
febbydoto107
League of Legends
JimRising 810
C9.Mang0466
Super Smash Bros
Mew2King89
Other Games
summit1g6672
gofns2639
WinterStarcraft535
Organizations
Other Games
gamesdonequick1229
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 10 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
Replay Cast
1h 36m
RongYI Cup
3h 36m
Maru vs Cyan
Solar vs Krystianer
uThermal 2v2 Circuit
4h 36m
BSL 21
7h 36m
Replay Cast
16h 36m
Wardi Open
1d 6h
Monday Night Weeklies
1d 9h
OSC
1d 16h
Replay Cast
2 days
WardiTV Invitational
2 days
[ Show More ]
Replay Cast
3 days
WardiTV Invitational
3 days
The PondCast
4 days
Korean StarCraft League
5 days
Replay Cast
6 days
Liquipedia Results

Completed

Escore Tournament S1: W5
OSC Championship Season 13
Tektek Cup #1

Ongoing

C-Race Season 1
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Rongyi Cup S3
Underdog Cup #3
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025

Upcoming

Escore Tournament S1: W6
Escore Tournament S1: W7
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.