Skip to content

Instantly share code, notes, and snippets.

View karlpokus's full-sized avatar
💭
wohoo!

carl-fredrik grimberg karlpokus

💭
wohoo!
View GitHub Profile
@karlpokus
karlpokus / stripexif.js
Created August 24, 2017 07:34
Strip EXIF from metadata from image file
// https://stackoverflow.com/questions/27638402/strip-exif-data-from-image
// includes fiddle
function removeExif(res, cb) {
const dv = new DataView(res);
let offset = 0;
let recess = 0;
const pieces = [];
let i = 0;
@karlpokus
karlpokus / vue_test.md
Created May 24, 2017 09:25
vue testing with tape

How to convert a SFC to something I can require?

  • bundle.js does not work
  • need to compile each part of the SFC individually

vue loader

  • vue loader vue-loader is a loader for Webpack that can transform Vue components written in the following format into a plain JavaScript module vue-loader will parse the file, extract each language block, pipe them through other loaders if necessary, and finally assemble them back into a CommonJS module whose module.exports is a Vue.js component options object.
  • vue loader configs
@karlpokus
karlpokus / unix_networking.md
Created May 22, 2017 10:49
unix networking

netcat

Duplex between to terminals

# start
$ nc -l 1234
# listen
$ nc 127.0.0.1 1234

Transfer files

@karlpokus
karlpokus / wp-on-do.md
Created May 15, 2017 15:57
wp on DO - setup

setup

  • one-click install
  • sensitive file: wp-config.php
  • new db user, OS user, wp user
  • add ssh keys && Disable Password Authentication
  • do mysql_secure_installation
  • wp REST api
  • http://ip/wp-login.php
  • dir: /var/www/html
  • The "ufw" firewall is enabled. All ports except for 22, 80, and 443 are BLOCKED.
@karlpokus
karlpokus / mongo_scale.md
Last active May 15, 2017 15:23
mongodb - maintenance, scaling, monitoring

Scale

  • replica sets scales reads
  • sharding scales read and writes

replica sets

  • backup
  • primary and secondary members
  • oplog requires a replica set

primary member

@karlpokus
karlpokus / react_readme.md
Last active May 3, 2017 17:03
react for dummies

react for dummies

  • docs
  • JSX produces React "elements" via React.createElement()
  • wrap JSX in parens to get multiple lines
  • element != component
  • ok to have multiple root nodes
  • React elements are immutable
  • components are like functions. They accept arbitrary inputs (called "props") and return React elements describing what should appear on the screen.

Functional and Class Components

@karlpokus
karlpokus / upload_compat.js
Last active March 21, 2017 08:24
client file upload - closure and promises
// assume <input id="files" type="file" multiple/>
var files = document.getElementById('files');
files.addEventListener('change', processFiles, false);
function processFiles() {
readFiles(this.files, upload);
}
function readFiles(files, cb) {
var payloads = [];
@karlpokus
karlpokus / mysql.js
Last active March 2, 2017 10:11
mysql - api, node, security for dummies
// pkg: mysql
// https://github.com/mysqljs/mysql#performing-queries
var mysql = require('mysql'),
connection = mysql.createConnection({
host:'localhost',
user:'bixa',
password:'pwd',
database:'foo'
});
@karlpokus
karlpokus / headless_pi.md
Created February 10, 2017 15:30
Setup raspberry pi 3 in headless mode