Skip to content

Instantly share code, notes, and snippets.

View trash
#!/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 Sep 10, 2018
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
View rem
#!/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('"', '\\"')
View gist:53fccd30ee0873b06c8b
# 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 Oct 29, 2014
rbenv install 1.9.2-p320 log (ruby-build 20141028)
View gist:ebd665736e8b008b455d
/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