Skip to content

Instantly share code, notes, and snippets.

View raggi's full-sized avatar

James Tucker raggi

View GitHub Profile
raggi / gist:eb42ebb04717e055678bffdec98c3edf
Created January 4, 2024 19:46
windows copilot answers to `Do Users Write More Insecure Code with AI Assistants?` (2024/1/4)
# We use the cryptography module to implement the encryption and decryption
from cryptography.fernet import Fernet
# We define a function to generate a symmetric key
def generate_key():
# We create a Fernet instance and return its key
f = Fernet.generate_key()
return f
# We define a function to encrypt a given string using a given key
raggi / answers.txt
Created January 4, 2024 19:35
github copilot chat answers to `Do Users Write More Insecure Code with AI Assistants?` (2024/1/4)
import hashlib
import hmac
import os
# BEGIN: FILEPATH: Untitled-1
def encrypt_string(string, key):
encrypted = ""
for char in string:
encrypted += chr(ord(char) ^ key)
return encrypted
raggi / opt.service
Created January 20, 2020 02:58
service unit file sample
SecureBits=no-setuid-fixup-locked noroot-locked keep-caps
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
SystemCallFilter=@basic-io @network-io @io-event
raggi /
Created February 25, 2017 01:00
Some advice on appropriate cloudbleed response

Cloudbleed: Users can't fix themselves


Site-owners MUST invalidate all their users sessions and tokens now, and might want to consider doing so again in the not distant future.

Cloudflare domain lists

There has been a great deal of discussion about the Cloudflare domain lists that are being constructed. These lists are not really all that useful for cleaning up this mess. Let me explain.

raggi /
Created June 30, 2016 23:06

Keybase proof

I hereby claim:

  • I am raggi on github.
  • I am raggi ( on keybase.
  • I have a public key whose fingerprint is 2F4F F34C A2E1 06F6 67A6 0378 BA61 B1EC D0C6 87C3

To claim this, I am signing this object:

raggi / handler.js
Last active May 7, 2016 22:25
Modern JS event handling mixin
const Handler = Base => class extends Base {
handleEvent (evt) {
return this[`on${evt.type.replace(/^./, c => c.toUpperCase())}`](evt)
raggi / bin-compile
Created May 12, 2015 21:00
A "pure" Heroku buildpack for Golang, uses GOPATH, no Godep. Make in a repo with files under bin/detect and bin/compile
mkdir -p $CACHE_DIR
export PATH=$PATH:$CACHE_DIR/go/bin
raggi /
Last active August 29, 2015 14:13
US Airways lost bags Jan 4, 2015

If you're currently waiting for your bags, because you flew sometime since the 4th of January 2015, and you came in via SFO: go to the airport they're there!

Customer service will tell you they're "with the delivery company" (they've been telling me this for three days). They'll tell you that "once it's with the delivery company, it goes to their warehouse" - there is no warehouse, at SFO it's ONE GUY as far as I can tell. They won't give you his name (it's Eddie - dial 650 652 5600 for an amusing full mailbox and "professional response" (it's been this way for over a year AFAICT - search around for the company name)). The company is called "Sterling Baggage" (not "", which is run by Bags Inc. who are similarly knowledge-less at all public phone numbers). If you call the SFO office, the lady there will tell you "it's on it's way" (which is also a lie).

I took the risk, given I'd been told by everyone that it was "on it's way, today" for the last three days, of driving up there. I'm

raggi /
Last active March 23, 2024 11:10
Rack SSE Example
# An example of basic real-time, single-room broadcast chat using Server Sent
# Events in plain old Rack. This example does NOT use hijack, or the async
# hacks, it just relies on a well implemented threaded Rack server (at time of
# writing this will therefore only work with puma!). Other servers should be
# fixed to support this, as it is pretty critical to how Rack *should* work on
# most servers. The only spec-acceptable failure in this case is not flushing
# the content stream on each yield (for which the rack spec has no workaround
# today).
# Bugs..
p __FILE__, __dir__, eval('__FILE__', binding, __FILE__, 0), eval('__dir__', binding, __FILE__, 0)
# "dir.rb"
# "/Users/raggi"
# "dir.rb"
# nil