Scala with Futures:
import java.util.UUID
import scala.concurrent.Future
trait User {
def isAdmin: Boolean
def id: UUIDScala with Futures:
import java.util.UUID
import scala.concurrent.Future
trait User {
def isAdmin: Boolean
def id: UUID2019 update: this essay has been updated on my personal site, together with a followup on how to get started
2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!
If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.
You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos
This is a collection of scripts to restore a full GHTorrent MongoDB database from the dumps available
at http://ghtorrent-downloads.ewi.tudelft.nl.
To do the restore:
Open a MongoDB terminal and run the createCollections.js script to create the necessary collections.
You can block_compressor to either snappy or zlib to make your databases compressed. I am using
none here, as I am using compression at the filesystem level.
Run restore-cummulative-dumps.sh to restore the cummulative dumps. Wait 3-4 days.
| package main | |
| import ( | |
| "context" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| "os/signal" |
| var CryptoJS = require('crypto-js') | |
| var request = require('request-promise') | |
| /* | |
| * npm install crypto-js request-promise request | |
| * node wx_t1t_hack.js | |
| */ | |
| // export function testEncription(msg, fullKey) { | |
| // var fullKey = fullKey.slice(0, 16) |
| package justinhj.concurrency | |
| import java.util.concurrent.TimeoutException | |
| import java.util.{Timer, TimerTask} | |
| import scala.concurrent.duration.FiniteDuration | |
| import scala.concurrent.{ExecutionContext, Future, Promise} | |
| import scala.language.postfixOps | |
| object FutureUtil { |
| import java.util.concurrent._ | |
| import akka.dispatch.{Dispatcher, ExecutorServiceDelegate} | |
| import config.Config | |
| import helpers.ScalaLogger | |
| class ExecutionContextMonitor()(implicit metricsService: MetricsClient, config: Config) { | |
| private val log = ScalaLogger.get(this.getClass) | |
| private val scheduler = Executors.newSingleThreadScheduledExecutor() |
| import java.util.concurrent._ | |
| import akka.dispatch.{Dispatcher, ExecutorServiceDelegate} | |
| import config.Config | |
| import helpers.ScalaLogger | |
| class ExecutionContextMonitor()(implicit metricsService: MetricsClient, config: Config) { | |
| private val log = ScalaLogger.get(this.getClass) | |
| private val scheduler = Executors.newSingleThreadScheduledExecutor() |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
| //const tpl = makeTemplate('hello ${name}') | |
| //const name = 'world'; | |
| //tpl({name}); | |
| const makeTemplate = (templateString) => { | |
| return (templateData) => new Function(`{${Object.keys(templateData).join(',')}}`, 'return `' + templateString + '`')(templateData); | |
| } |