Author: Chris Lattner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let calendar = Calendar(identifier: .gregorian) | |
// Daylight Saving Time ends in 2017 on Nov 5th, 2:00 AM in the United States. | |
// Let's instantiate some `Date`s around that. | |
let nov4_1am = calendar.date(from: DateComponents(year: 2017, month: 11, day: 4, hour: 1))! | |
let nov4_2am = calendar.date(from: DateComponents(year: 2017, month: 11, day: 4, hour: 2))! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* parallelize: reads commands from stdin and executes them in parallel. | |
The sole argument is the number of simultaneous processes (optional) to | |
run. If omitted, the number of logical CPUs available will be used. | |
Build: gcc -pthread parallelize.c -o parallelize | |
Demo: (for i in {1..10}; do echo "echo $i ; sleep 5" ; done ) | ./parallelize | |
By Marco Arment, released into the public domain with no guarantees. |