Skip to content

Instantly share code, notes, and snippets.

@whargrove
whargrove / obsidian-web-clipper.js
Last active November 18, 2023 14:14 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@whargrove
whargrove / timer.go
Created June 16, 2019 03:06
Better token refresher
package main
import (
"log"
"math/rand"
"time"
"github.com/google/uuid"
)
(maintenance/unicorn)vino$ bundle exec cap staging deploy
DEBUG [fcd7244e] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.0 ] as blog@blog-stage.weshargrove.com
DEBUG [fcd7244e] Command: [ -d ~/.rbenv/versions/2.2.0 ]
DEBUG [fcd7244e] Finished in 0.915 seconds with exit status 0 (successful).
Please enter branch (maintenance/unicorn):
INFO Local branch is in sync with remote; proceeding with deploy.
INFO [53a65e42] Running /usr/bin/env mkdir -p /tmp/blog/ as blog@blog-stage.weshargrove.com
DEBUG [53a65e42] Command: ( RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.0 /usr/bin/env mkdir -p /tmp/blog/ )
INFO [53a65e42] Finished in 0.149 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/blog/git-ssh.sh 0.0%
@whargrove
whargrove / rbenv-install.sh
Created December 18, 2014 22:41
rbenv-installer
#!/usr/bin/env bash
# Verify Git is installed:
if [ ! $(which git) ]; then
echo "Git is not installed, can't continue."
exit 1
fi
if [ -z "${RBENV_ROOT}" ]; then
RBENV_ROOT="$HOME/.rbenv"
@whargrove
whargrove / stdout-stderr.log
Created August 4, 2014 20:22
Exception logs from stdout-stderr.log
Aug 04, 2014 1:01:24 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /webapps/ldc-b4-BBLEARN threw load() exception
java.security.AccessControlException: access denied ("java.util.PropertyPermission" "jboss.i18n.generate-proxies" "write")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.System.setProperty(System.java:782)
at org.hibernate.cfg.PropertyContainer.<clinit>(PropertyContainer.java:61)
at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:231)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:664)
@whargrove
whargrove / grade.java
Created July 31, 2014 16:37
XssFilterRequestWrapper + oauth_body_hash
// First get the body from the HttpServletRequest
String body = readBody(request);
// Verify request oauth_body_hash
verifyOAuthBodyHash(body, oauthParameters, hmacSigner) // oauthParameters and hmacSigner are created in this servlet but omitted from this gist
// request is handled from doPost() that encapsulates this gist
private String readBody(HttpServletRequest request) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
StringBuilder body = new StringBuilder();
require 'openssl'
require 'base64'
def gather_args
args = Array.new
# Only accepts two arguments
raise if ARGV.length > 2
ARGV.each do |a|
@whargrove
whargrove / ❨╯°□°❩╯︵┻━┻.rb
Created May 1, 2014 02:02
❨╯°□°❩╯︵┻━┻
class Emote
def self.❨╯°□°❩╯︵┻━┻
puts "Calm down, bro"
end
end
Emote.❨╯°□°❩╯︵┻━┻
@whargrove
whargrove / io.rb
Created April 22, 2014 05:51
Takes pairs of time and returns total seconds for the duration of pairs and a parsed version of the whole duration
require 'time'
class Io
def self.get_duration(array)
# only evaluate if there are an even number of items in the array
if array.length.even?
# iterate through each argument
i_ary = []
array.each do |arg|
@whargrove
whargrove / ruby-build.20140413204436.39252.log
Created April 14, 2014 04:09
Ruby 2.1.1 ruby-build build failed log
/var/folders/tl/09xh_cbj5zz81f1c3tyn53zm0000gn/T/ruby-build.20140413204436.39252 ~
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 15092388
Connection: keep-alive
Date: Thu, 03 Apr 2014 17:56:51 GMT
Last-Modified: Mon, 24 Feb 2014 13:08:59 GMT
ETag: "e57fdbb8ed56e70c43f39c79da1654b2"
Accept-Ranges: bytes
Server: AmazonS3