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
def add_job(self, job_type, job_id=None, on_duplicate='overwrite', | |
timestamp=None, distribute=None, **data): | |
""" | |
Add a new job to execute | |
:param job_type: string with the name of the job | |
:param job_id: job identifier, if not set, then a new random unique id | |
will be generated | |
:param on_duplicate: action on identifier duplicate, can be "overwrite" | |
or "discard" |
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
""" | |
Groups (clusters) similar lines together from a text file | |
using k-means clustering algorithm. | |
Also does some simple cleaning (such as removing white space and replacing numbers with (N)). | |
Example: | |
python cluster_lines.py --clusters 20 invalid_dates.txt |
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
# Configure a canvas element for high-def screens (retina) | |
highDefCanvas = (canvas, context) -> | |
pixel_ratio = window.devicePixelRatio | |
if pixel_ratio | |
width = canvas.width | |
height = canvas.height | |
canvas.width = width * pixel_ratio | |
canvas.height = height * pixel_ratio | |
canvas.style.width = "#{width}px" | |
canvas.style.height = "#{height}px" |
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
def main(): | |
import aksfjaslkdfj | |
aksfjaslkdfj.blahblah | |
blah + blah2 | |
blah3() |
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
select { | |
case <- messageListener: | |
newData = c.GetMessages(offset) | |
listener <- newData | |
case <- time.After(ChannelTimeoutSec * time.Second): | |
listener <- ReturnDataEmpty | |
} |
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
type Account struct { | |
balance float64 | |
... | |
sync.Mutex | |
} | |
func (a *Account) Deposit(amount float64) { | |
a.Lock() | |
defer a.Unlock() |
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 "sync" | |
type Channel struct { | |
... | |
messages []*Message | |
listeners []chan *Message | |
sync.Mutex | |
} | |
... |
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
// JavaScript that solves http://regex.alf.nu/ | |
// Run in Chrome or Firefox console | |
// Enjoy ;-) | |
// Some people, when confronted with a problem, think | |
// “I know, I'll use regular expressions.” | |
// Now they have two problems. | |
for(var lvl in levels) { | |
var fn = function(lvl) { |
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
// JavaScript that solves http://regex.alf.nu/ | |
// Run in Chrome or Firefox console | |
// Enjoy ;-) | |
// Some people, when confronted with a problem, think | |
// “I know, I'll use regular expressions.” | |
// Now they have two problems. | |
for(var lvl in levels) { | |
var fn = function(lvl) { |
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
@pytest.yield_fixture | |
def v5_api_data(): | |
with resources.project_ctx() as project, \ | |
resources.item_ctx() as task1, \ | |
resources.item_ctx() as task2, \ | |
resources.item_ctx() as in_history: | |
with resources.note_ctx(item_id=task1.id) as note_task_1,\ | |
resources.note_ctx(item_id=in_history.id) as note_task_3: |