Skip to content

Instantly share code, notes, and snippets.

@avjpl
avjpl / links.md
Created November 21, 2016 20:35 — forked from g0t4/links.md
Starting Point Files for Jenkins2 Getting Started course
@avjpl
avjpl / app.js
Created December 14, 2016 10:39 — forked from ezekielchentnik/app.js
import express from 'express';
const app = express();
if (IS_DEV) {
require('piping')();
}
//express routes, etc.
export default app;
@avjpl
avjpl / sandbox-mocha.js
Created April 13, 2017 17:08 — forked from jgable/sandbox-mocha.js
Sinon Sandbox Example
var sinon = require('sinon'),
Widget = require('../../widget');
describe('My widget', function () {
var sandbox;
beforeEach(function () {
// Create a sandbox for the test
sandbox = sinon.sandbox.create();
});
@avjpl
avjpl / install_openresty_in_mac.md
Created April 25, 2017 13:43 — forked from ejlp12/install_openresty_in_mac.md
Install openresty in Mac OS-X

Install 3scale self managed API gateway (openresty) in Mac OS-X

brew update
brew install pcre openssl

wget http://openresty.org/download/ngx_openresty-1.9.7.2.tar.gz
tar xzvf ngx_openresty-1.9.7.2.tar.gz
cd ngx_openresty-1.9.7.2
@avjpl
avjpl / destructuring.js
Created May 12, 2017 08:17 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@avjpl
avjpl / app.js
Created July 18, 2017 19:45 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@avjpl
avjpl / droplet.tf
Created August 31, 2017 16:32
Simple Terraform script for Digital Ocean
resource "digitalocean_droplet" "web" {
image = "ubuntu-16-04-x64"
name = "webserver"
region = "lon1"
size = "512mb"
}
@avjpl
avjpl / postgres-cheatsheet.md
Created October 7, 2018 13:15 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@avjpl
avjpl / Sidebar-test.jsx
Created December 18, 2018 13:12 — forked from stipsan/Sidebar-test.jsx
Testing with Jest: Tip #5
import renderer from 'react-test-renderer'
import Sidebar from '../Sidebar'
jest.mock('react-router-dom', () => ({
Link: 'Link',
Route: ({ children, path }) => children({ match: path === '/somewhere' })
}))
it('should render correctly', () => {
const component = renderer.create(<Sidebar />)
@avjpl
avjpl / logMousePosition.js
Created July 3, 2019 07:07
Simple hook example to log mouse position
import React, { useEffect, useState } from "react";
const logMousePosition = e => {
console.log({
x: e.clientX,
y: e.clientY,
});
};
const Position = () => {