Skip to content

Instantly share code, notes, and snippets.

@roscopecoltran
roscopecoltran / app.py
Created November 19, 2017 18:57 — forked from lost-theory/app.py
flask: show request time in template
import time
from flask import Flask, request, g, render_template
app = Flask(__name__)
app.config['DEBUG'] = True
@app.before_request
def before_request():
g.request_start_time = time.time()

Recently, GitHub introduced the change in how atx headers are parsed in Markdown files.

##Wrong

Correct

While this change follows the spec, it breaks many existing repositories. I took the README dataset which we created at source{d} and ran a simple

# ---- Base Node ----
FROM node:carbon AS base
# Create app directory
WORKDIR /app
# ---- Dependencies ----
FROM base AS dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
# install app dependencies including 'devDependencies'
@roscopecoltran
roscopecoltran / example.goscript
Created February 8, 2018 17:07
goscript - run Go golang in scripts!
#!./goscript
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("hello");
@roscopecoltran
roscopecoltran / Dockerfile
Created February 15, 2018 21:50 — forked from jamesandersen/Dockerfile
Multi-stage Dockerfile
# BUILD the app in first stage
FROM jamesandersen/alpine-golang-opencv3:edge
RUN apk --no-cache add git
WORKDIR /go/src/github.com/jamesandersen/gosudoku
COPY . .
RUN go get github.com/nytimes/gziphandler
RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."
# Start from a *NEW* image in the second stage
@roscopecoltran
roscopecoltran / pwnd.js
Created February 27, 2018 15:03 — forked from jgrahamc/pwnd.js
Cloudflare Workers that adds an "Cf-Password-Pwnd" header to a POST request indicating whether the 'password' field appears in Troy Hunt's database of pwned passwords.
addEventListener('fetch', event => {
event.respondWith(fetchAndCheckPassword(event.request))
})
async function fetchAndCheckPassword(req) {
if (req.method == "POST") {
try {
const post = await req.formData();
const pwd = post.get('password')
const enc = new TextEncoder("utf-8").encode(pwd)
@roscopecoltran
roscopecoltran / webpack4upgrade.md
Created March 19, 2018 01:28 — forked from gricard/webpack4upgrade.md
Just some notes about my attempt to upgrade to webpack 4

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ [email protected]
added 1 package, removed 20 packages and updated 4 packages in 13.081s

Cool! Ok...

@roscopecoltran
roscopecoltran / rabbitmq_go_sample.go
Created April 11, 2018 14:52 — forked from sohamkamani/rabbitmq_go_sample.go
An example of a simple pub-sub workflow for rabbitmq in go
package queue
import (
"fmt"
"log"
"github.com/streadway/amqp"
)
var conn *amqp.Connection
@roscopecoltran
roscopecoltran / knuth.go
Created May 8, 2018 07:18 — forked from quux00/knuth.go
Knuth Fisher-Yates shuffle for Go (golang)
// implements Knuth or Fisher-Yates shuffle
package knuth
import (
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UTC().UnixNano())
@roscopecoltran
roscopecoltran / Matrix.md
Created May 27, 2018 17:50 — forked from nadavrot/Matrix.md
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of