Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import os
import sys
import subprocess
if len(sys.argv) > 1:
files = []
for arg in sys.argv[1:]:
if os.path.exists(arg):
p = os.path.abspath(arg).replace('\\', '\\\\').replace('"', '\\"')
@anthonyjsmith
anthonyjsmith / rem
Created September 10, 2018 13:19
Send files to Trash on Mac, imitating shell command rm as closely as possible. Based on https://apple.stackexchange.com/a/162354/105139 and https://gist.github.com/dabrahams/14fedc316441c350b382528ea64bc09c
#!/usr/bin/env python
import os
import sys
import subprocess
if len(sys.argv) > 1:
files = []
for arg in sys.argv[1:]:
if os.path.exists(arg):
p = os.path.abspath(arg).replace('\\', '\\\\').replace('"', '\\"')
@anthonyjsmith
anthonyjsmith / gist:53fccd30ee0873b06c8b
Created November 25, 2014 16:39
Non-expiring flash
# Visit:
# /main/set_flash
# /main/show_no_flash (as many times as you like)
# /main/show_flash ... and it shows the flash message
# (Rails 4.1.8, Ruby 2.1.1)
# app/controllers/main_controller.rb
class MainController < ApplicationController
def show_flash
render inline: flash[:notice] || "Flash is blank!"
@anthonyjsmith
anthonyjsmith / gist:ebd665736e8b008b455d
Created October 29, 2014 14:28
rbenv install 1.9.2-p320 log (ruby-build 20141028)
/var/folders/l0/_plw_97n7_58gh3pw0frb6n40000gp/T/ruby-build.20141029142311.82144 ~
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 11338691
Connection: keep-alive
Date: Tue, 28 Oct 2014 21:07:15 GMT
Last-Modified: Fri, 23 May 2014 08:14:39 GMT
ETag: "5ef5d9c07af207710bd9c2ad1cef4b42"
Accept-Ranges: bytes
Server: AmazonS3