Skip to content

Instantly share code, notes, and snippets.

@a-h
a-h / disablecaching.go
Created August 20, 2019 08:15
Disable caching and sniffing via HTTP headers
func DisableCachingAndSniffing(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate;")
w.Header().Set("pragma", "no-cache")
w.Header().Set("X-Content-Type-Options", "nosniff")
next.ServeHTTP(w, r)
})
}
@a-h
a-h / setup.tf
Last active October 9, 2024 03:11
Terraform - Creating an Instance with an S3 Bucket Policy
# Create an IAM role for the Web Servers.
resource "aws_iam_role" "web_iam_role" {
name = "web_iam_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
@a-h
a-h / dft.go
Created August 6, 2024 09:13 — forked from r9y9/dft.go
Discrete Fourier Transform in Go
package main
import "math"
import "fmt"
func DFT_naive (input []float64) ([]float64, []float64) {
real := make([]float64, len(input))
imag := make([]float64, len(input))
arg := -2.0*math.Pi/float64(len(input))
for k := 0; k < len(input); k++ {
@a-h
a-h / main.templ
Created August 1, 2024 19:36
Example of server side DataTables usage
package main
import (
"encoding/json"
"fmt"
"net/http"
)
templ page() {
<!DOCTYPE html>
@a-h
a-h / main.templ
Created August 1, 2024 19:27
Example of server-side passing data via attribute
package main
import (
"fmt"
"net/http"
)
templ page(data any) {
<!DOCTYPE html>
<html>
@a-h
a-h / 01-simple.test.js
Last active December 31, 2023 09:07
Testing styled Material UI components with Enzyme
import React from 'react';
import { shallow } from 'enzyme';
const Item = text => <p>Item {text}</p>;
const Composition = ({ showB }) => (
<p>
<Item text="A" />
{showB && <Item text="B" />}
</p>);
@a-h
a-h / two-cols-header.vue
Last active November 22, 2023 10:57
slidev two columns with header layout
<!--
Usage:
```md
---
layout: two-cols-header
---
This shows up across both
::left::
# Left
This shows on the left
@a-h
a-h / MorphiaSetupAndTearDown.java
Last active May 21, 2023 07:28
Morphia Integration Testing
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import org.bson.Document;
import org.mongodb.morphia.AdvancedDatastore;
import org.mongodb.morphia.Morphia;
import org.mongodb.morphia.logging.MorphiaLoggerFactory;
import org.mongodb.morphia.logging.slf4j.SLF4JLoggerImplFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@a-h
a-h / go.csv
Created January 6, 2017 15:23
Github Go Projects January 2017
We can't make this file beautiful and searchable because it's too large.
repo_name
jaredwilkening/goconfig
piger/dulbecco
zemirco/uuid
kevinburke/sll
fd0/probe
maciekmm/go-steam
pyros2097/gdx
JalfResi/gobeanstalk
whosthatknocking/runc
@a-h
a-h / buildspec.yml
Last active November 3, 2022 08:31
Build Go with private dependencies on AWS CodeBuild
version: 0.2
env:
parameter-store:
build_ssh_key: "build_ssh_key"
phases:
install:
commands:
- mkdir -p ~/.ssh