A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| #!/usr/bin/env bash | |
| # Bash script to automate Vim+Tmux install as written about here: | |
| # http://fideloper.com/mac-vim-tmux | |
| # Test if Git is installed. | |
| # Installing Git is not the job of this script | |
| git --version 2>&1 >/dev/null | |
| GIT_IS_INSTALLED=$? |
RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.
On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.
So, many developers have started going straight t
Here I'm trying to understand what happens when I run
./hello
#include | #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netdb.h> | |
| #include <unistd.h> | |
| #include <fcntl.h> | |
| #include <sys/epoll.h> | |
| #include <errno.h> |
| // this is the background code... | |
| // listen for our browerAction to be clicked | |
| chrome.browserAction.onClicked.addListener(function (tab) { | |
| // for the current tab, inject the "inject.js" file & execute it | |
| chrome.tabs.executeScript(tab.ib, { | |
| file: 'inject.js' | |
| }); | |
| }); |
| import java.util.ArrayList; | |
| class Solution | |
| { | |
| public int solution(int[] H) | |
| { | |
| // rules | |
| /* | |
| * so when we find two indices that are of the same height, we can use the same block, providing all the values in-between are higher. | |
| * |
| MIT License | |
| Copyright (c) 2014 Piotr Kuczynski | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWAR |
| // The biggest 64bit prime | |
| #define P 0xffffffffffffffc5ull | |
| #define G 5 | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <assert.h> | |
| #include <stdlib.h> | |
| // calc a * b % p , avoid 64bit overflow |
| describe vs. context in rspec | |
| http://lmws.net/describe-vs-context-in-rspec | |
| In Rspec world, you often see people using both “describe” blocks and “context” blocks together, like this | |
| describe "launch the rocket" do | |
| context "all ready" do | |
| end | |
| context "not ready" do |