Skip to content

Instantly share code, notes, and snippets.

@mayneyao
mayneyao / notion2blog.js
Last active July 19, 2024 02:12
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@fasiha
fasiha / no-hackerrank.md
Last active August 7, 2023 11:47
A prospective employer invited me to do a HackerRank test. Here's my proposed alternative.

Well, that was unexpected. In the following, I’m trying to follow Jon Evans’ advice from “The Terrible Technical Interview”.


To: recruitment@EmployerABC.com
From: Ahmed Fasih
Subject: Re: Programming Test Invitation

Hi there! Thanks for offering to let me take a HackerRank test for ABC, I appreciate the vote of confidence.

@Audhil
Audhil / AppExtensionFuncs.kt
Last active January 27, 2024 09:48
XML generation with Kotlin extension functions
// XML generation by code
// based on https://www.schibsted.pl/blog/back-end/readable-xml-kotlin-extensions/
fun XmlSerializer.document(docName: String = "UTF-8",
xmlStringWriter: StringWriter = StringWriter(),
init: XmlSerializer.() -> Unit): String {
startDocument(docName, true)
xmlStringWriter.buffer.setLength(0) // refreshing string writer due to reuse
setOutput(xmlStringWriter)
init()
endDocument()
@lattner
lattner / TaskConcurrencyManifesto.md
Last active July 21, 2024 05:08
Swift Concurrency Manifesto
@brannondorsey
brannondorsey / one_liners.md
Last active July 8, 2022 05:07
One Liners

Count the number of unique characters in a file

# https://unix.stackexchange.com/questions/5010/how-can-i-count-the-number-of-different-characters-in-a-file
# works for linux. There is a variation for MacOS in the link ^
sed 's/\(.\)/\1\n/g' text.txt | sort | uniq -c # sort -nr # uncomment this to sort the list by frequency

Replace a string in all instances of files in a directory

{
// you may set specific environment variables here
// e.g "env": { "PATH": "$HOME/go/bin:$PATH" }
// in values, $PATH and ${PATH} are replaced with
// the corresponding environment(PATH) variable, if it exists.
//"env": {"GOPATH": "$HOME/Projects/go:$HOME/Projects/go/src/github.com/originalilluminaughty/watchly/local/", "PATH": "$GOPATH/bin:$PATH" },
"env": {"GOPATH": "$HOME/Projects/go/:$HOME/Projects/go/src/github.com/skizzehq/skizze/:$HOME/Projects/go/src/github.com/skizzehq/skizze/vendor", "PATH": "$GOPATH/bin:$PATH" },
@sfcgeorge
sfcgeorge / packed-pixels-switchresx.md
Created December 9, 2015 16:13
Packed Pixels HiDPI Retina using SwitchResX

On OS X the Packed Pixels display won't automatically show up as "Retina" or "HiDPI" resolution, instead the OS will use the full resolution of the display making everything tiny. This can be changed using the 3rd party app (non-free) SwitchResX.

First, download SwitchResX.

You can play with the resolutions for the Packed Pixels which is probably listed as Color LCD (2). However not all of the HiDPI resolutions work due to an OS X bug. If you are happy with any of the ones that do work then stop here, else continue.

If you're on El Capitan or later you need to disable System Integrity Protection (temporarily) to add a custom resolution for Packed Pixels. Follow the instructions from SwitchResX creator.

Now add a Custom Resolution that is "scaled". It must be 2 pixels bigger or smaller than the native resolution in one direction (this is the OS X quirk). I found bigger makes it slightly blurry so go w

@madhums
madhums / gin_html_render.go
Last active August 18, 2022 07:53
render html templates in gin (go)
// Package GinHTMLRender provides some sugar for gin's template rendering
//
// This work is based on gin contribs multitemplate render https://github.com/gin-gonic/contrib/blob/master/renders/multitemplate
//
// Usage
//
// router := gin.Default()
//
// // Set html render options
// htmlRender := GinHTMLRender.New()
@samritchie
samritchie / gist:01d75d19639dc576a502
Created May 30, 2015 02:09
Basic Alamofire RAC extension
/**
* Adapted from https://github.com/indragiek/AlamofireRACExtensions
*/
public func get<T>(url: String, f: (AnyObject -> Result<T, NSError>)) -> SignalProducer<T, NSError> {
return SignalProducer { sink, disposable in
let request = Alamofire.request(.GET, hostname + url)
.responseJSON { (request, response, responseObject, error) in
if let error = error {
sendError(sink, error)
} else if let response = response {
@tuxfight3r
tuxfight3r / tcp_flags.txt
Last active July 19, 2024 21:00
tcpdump - reading tcp flags
##TCP FLAGS##
Unskilled Attackers Pester Real Security Folks
==============================================
TCPDUMP FLAGS
Unskilled = URG = (Not Displayed in Flag Field, Displayed elsewhere)
Attackers = ACK = (Not Displayed in Flag Field, Displayed elsewhere)
Pester = PSH = [P] (Push Data)
Real = RST = [R] (Reset Connection)
Security = SYN = [S] (Start Connection)