Skip to content

Instantly share code, notes, and snippets.

View patbonecrusher's full-sized avatar
:octocat:

Patrick Laplante patbonecrusher

:octocat:
View GitHub Profile
@patbonecrusher
patbonecrusher / JS-LINQ.js
Created June 30, 2016 01:19 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
@patbonecrusher
patbonecrusher / nginx-non-transparent-ssl-proxy.md
Created December 1, 2016 16:47 — forked from dannvix/nginx-non-transparent-ssl-proxy.md
Guide to set up nginx as non-transparent SSL proxy, which subsitutes strings in the server responses

Use nginx as Non-Transparent SSL Proxy

Introduction

Many mobile apps have back-end API servers. They usually rely on the API replies to determine whether certain information is supposed to be shown. If the API responses could be manipulated on the fly, we may easily fool an unmodified app to expose some private data.

This manual guides you to set up nginx as non-transparent SSL proxy, which just subsitutes strings in the server responses (i.e. man-in-the-middle attack ourself). For both server-side (their API servers) and client-side (your device), the whole process is almost transparent.

@patbonecrusher
patbonecrusher / better-nodejs-require-paths.md
Created May 9, 2017 01:28 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@patbonecrusher
patbonecrusher / cheatsheet.cpp
Created August 26, 2017 22:01 — forked from satwikkansal/cheatsheet.cpp
C++ STL cheatsheet for competitive progrmming
/*
This a header file that includes every standard library.
You can use it to save time.
NOTE: This header file may not be recognized by compilers
other than gcc.
*/
#include <bits/stdc++.h>
/*
//Use this if the above header file doesn't work.
@patbonecrusher
patbonecrusher / image2base64.js
Created September 13, 2017 17:57 — forked from jfsiii/image2base64.js
Convert a remote image to Base64-encoded string
// Uses [request](https://github.com/mikeal/request)
// /?url=http://nodejs.org/logo.png
// /?uri=http://nodejs.org/logo.png
// /?url=http://nodejs.org/logo.png&cb=cbName
// /?url=http://nodejs.org/logo.png&callback=cbName
var fs = require('fs');
var url = require('url');
var http = require('http');
var request = require('request');
@patbonecrusher
patbonecrusher / async-examples.js
Created September 27, 2017 00:41 — forked from developit/async-examples.js
Async Array utilities in async/await. Now available as an npm package: https://github.com/developit/asyncro
/** Async version of Array.prototype.reduce()
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => {
* acc[v] = await (await fetch(v)).json();
* return acc;
* }, {});
*/
export async function reduce(arr, fn, val, pure) {
for (let i=0; i<arr.length; i++) {
let v = await fn(val, arr[i], i, arr);
if (pure!==false) val = v;
@patbonecrusher
patbonecrusher / rabbitmq.txt
Created December 13, 2017 21:07 — forked from sdieunidou/rabbitmq.txt
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
@patbonecrusher
patbonecrusher / Free O'Reilly Books.md
Created December 19, 2017 03:36 — forked from augbog/Free O'Reilly Books.md
Free O'Reilly Books

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@patbonecrusher
patbonecrusher / homebrew.md
Created January 3, 2018 23:54 — forked from indiesquidge/homebrew.md
How to and Best of Homebrew

Homebrew

How To

Homebrew is a package management system for OS X. You can read more about it here, or simply run

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

to install it.

@patbonecrusher
patbonecrusher / .envrc
Created June 19, 2018 02:10 — forked from gudleik/.envrc
Node.js direnv setup
# Either use node version specified in package.json
use node package.json
# Or a specific version
use node 5.0.0
# Rest of direnv setup..
export FOO=BAR