Skip to content

Instantly share code, notes, and snippets.

🌏
Making the world a better place (with F#)

njlr njlr

🌏
Making the world a better place (with F#)
Block or report user

Report or block njlr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View monads.md
Without do-notation With do-notation
Lazy - Haskell
Strict C++ Where the Magic Happens
View 5-minutes-to-buck.md

5 Minutes to Buck

0. What tools will I need?

🚨 This tutorial was written with Linux in mind. Windows and macOS users, please refer to Facebook's setup instructions.

You will need GCC / Clang, a text editor and Buck.

You probably have the first two, so here's how to install Buck for Linux:

View vscode-buck-highlighting.md
  1. Open your User settings
  2. Add an language mapping from "BUCK" to "python" like so:
{
  "files.associations": {
    "BUCK": "python"
  }
}
View encapsulation-in-java.md

Encapsulation in Java ☕

Today we are going to learn about encapsulation using Java!

OK! Let's write a vector class...

public class Vector2 {
    public float x;
    public float y;
View keybase.md

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:

View optimization-when-currying.js
// 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;
}
View errors-in-js.js
// 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
View coinhive.js
(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;
View parse-csv.js
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 Jan 15, 2018
Example showing how to use Node.js, PDF.js and Superagent together
View pdf-js-node-example.js
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 });
You can’t perform that action at this time.