Skip to content

Instantly share code, notes, and snippets.

@uris77
uris77 / example_bad_local_journalism.md
Last active August 10, 2021 14:42
Example of Bad Local Journalism

On August 7, 2021, Breaking Belize News published an article titled Cholesterol drug could reduce COVID-19 infection by up to 70 per cent says study. I will use this article to illustrate some lazy and, at best, misleading journalism in Belize.

The first thing that jumped at me because of its absence was no reference to the data source. The best we get is according to a study carried out by researchers in the United Kingdom, Italy, and Denmark. The research published on Friday, August 6, in Frontiers in Pharmacology, was led by the University of Birmingham and Keele University in the UK and the San Raffaele Scientific Institute in Italy. The University of Copenhagen in Denmark and the University of Liverpool in the UK also collaborated with the research., but the author does not provide a link to the actual source he read, nor the name of the research paper. It makes

@uris77
uris77 / go-precommit
Created February 29, 2020 22:42
Git precommit hook for Go
#!/usr/bin/env bash
fmtcount=`git ls-files | grep '.go$' | xargs gofmt -l 2>&1 | wc -l`
if [ $fmtcount -gt 0 ]; then
echo "Some files aren't formatted, please run 'go fmt ./...' to format your source code before committing"
exit 1
fi
vetcount=`go vet ./... 2>&1 | wc -l`
if [ $vetcount -gt 0 ]; then
echo "Some files aren't passing vet heuristics, please run 'go vet ./...' to see the errors it flags and correct your source code before committing"
exit 1
@uris77
uris77 / gateway.yml
Created October 26, 2019 01:06
API Gateway: Configure Response
Resources:
GatewayResponseDefault4XX:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: 'ApiGatewayRestApi'
@uris77
uris77 / apigatewayS3serverless.yml
Created October 8, 2019 14:00
Example of API Gateway + S3 proxy
service: fileStorageServices
custom:
accountId: <your acc id>
bucketName: <your bucket name>
HostedZoneId: <hosted zone id>
authFunctionName: <auth fn name>
provider:
name: aws
runtime: dotnetcore1.0
stage: ${opt:stage} #read from console input
@uris77
uris77 / clj-save-image.clj
Last active June 3, 2016 20:53
Example of saving an image with clojure
```
(ImageIO/write cropped "jpg" (clojure.java.io/file "a/dir" "Screenshot.jpg"))
```
@uris77
uris77 / sample-routes.clj
Created December 17, 2015 20:53
Example of wrapping routes in ring
def app-routes
(routes
#service-routes
(wrap-routes #'restricted-service-routes middleware/wrap-auth)
(wrap-routes #'home-routes middleware/wrap-csrf)
(route/not-found
(:body
(error-page {:status 404
:title "page not found"})))))
@uris77
uris77 / postgres_tips.md
Created November 25, 2015 17:17
Postgres Tips

Force a user to have a default schema other than public:

ALTER USER <user> SET search_path=<schema>;

Grant permissions to a schema for a user:

GRANT ALL PRIVILEGES ON SCHEMA <schema> to <user>;
@uris77
uris77 / google.clj
Created October 10, 2015 21:37 — forked from jwhitlark/google.clj
Combine friend, oauth2, and JWT token processing.
(ns foo.auth.google
(:require [clojure.string :as str]
[clojure.java.io :as io]
[clojure.data.json :as json]
[clojure.logging :refer :all]
[friend-oauth2.util :refer [format-config-uri]]
[friend-oauth2.workflow :as oauth2])
(:import [java.security.cert CertificateFactory]
[org.apache.commons.codec.binary Base64]))
@uris77
uris77 / helm-clojure-headlines.el
Created October 7, 2015 16:35 — forked from tjg/helm-clojure-headlines.el
helm-clojure-headlines
(defun helm-headlines (headline buffer-name good-regex exception-regex)
"Display headlines for the current file.
Displays lines where good-regex matches, except for those
which also match exception-regex."
;; Fixes bug where the current buffer sometimes isn't used
(setq helm-current-buffer (current-buffer))
;; https://groups.google.com/forum/#!topic/emacs-helm/YwqsyRRHjY4
(jit-lock-fontify-now)
@uris77
uris77 / emacs_tips.md
Last active April 6, 2016 14:16
Emacs Tips for Clojure
  • Move to previous function beginning-of-defun
  • Move to next function next-defun where :
(defun next-defun ()
  (interactive)
  (end-of-defun 2)
  (beginning-of-defun 1))
  • Repeat a character n times with C-u n <character>. For example, to insert ; 50 times: