Skip to content

Instantly share code, notes, and snippets.

@jasonsnell
jasonsnell / gist:5033421
Created February 25, 2013 21:19
Macworld/IDG Markdown to HTML AppleScript
--Macworld Markdown to HTML script
--by Jason Snell <jsnell@macworld.com>
--Markdown and SmartyPants by John Gruber <http://daringfireball.net/projects>
--Version 10: Added Euro support and forced Unicode for output file
--Version 11: Output now opens as new document in source window.
--Version 12: Makes sure the output document is set to source language of HTML
--Version 13: Support for [[jump]] tag
--Version 14: Rewrite iLife ‘09 style tags to proper ’09 style.
--Version 15: Support pound symbol
@rwilcox
rwilcox / bbedit_select_sentence.applescript
Created May 30, 2012 13:04
Select Sentence in BBEdit
tell application "BBEdit"
tell text of front text document
-- first, find the end of the previous sentence
-- the \ is because we need to escape the . from grep
-- (we are searching for a period, not "any character" which is what a period
-- normally means in grep
-- however, Applescript also uses the \ as an escape character for its purposes
set deviceID to (do shell script "diskutil list | awk '/YourBootcampPartition/ {print $NF}'")
do shell script "sudo bless -device /dev/" & deviceID & " -legacy -setBoot -nextonly"
tell application "Finder" to restart
@micxjo
micxjo / day15.py
Last active December 7, 2018 21:36
import sys
from os import abort
from ortools.constraint_solver import pywrapcp
def day15(path, calorie_total=None):
solver = pywrapcp.Solver('AOC Day 15')
values = range(0, 100)
@soemarko
soemarko / theme.html
Created November 26, 2011 16:18
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@kunishi
kunishi / gist:cdfaa582ffcbe06f9da41c312f374406
Created October 4, 2017 03:28
pyenv install 3.6.2 failed on HighSierra
BUILD FAILED (OS X 10.13 using python-build 20160602)
Inspect or clean up the working tree at /var/folders/nq/5pyc_js10jz0kq7wps9b5gkm0000gn/T/python-build.20171004122245.24032
Results logged to /var/folders/nq/5pyc_js10jz0kq7wps9b5gkm0000gn/T/python-build.20171004122245.24032.log
Last 10 log lines:
import pip
File "/var/folders/nq/5pyc_js10jz0kq7wps9b5gkm0000gn/T/tmpr17v5c3y/pip-9.0.1-py2.py3-none-any.whl/pip/__init__.py", line 26, in <module>
File "/var/folders/nq/5pyc_js10jz0kq7wps9b5gkm0000gn/T/tmpr17v5c3y/pip-9.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 27, in <module>
File "/var/folders/nq/5pyc_js10jz0kq7wps9b5gkm0000gn/T/tmpr17v5c3y/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 35, in <module>
--
-- open currently open URL in Safari in Chrome
-- forked from https://gist.github.com/3151932
--
property theURL : ""
tell application "Safari"
set theURL to URL of current tab of window 1
end tell
if appIsRunning("Google Chrome") then
@hwayne
hwayne / requirements.md
Last active July 21, 2021 17:09
PBT / Example Testing comparison problem

You are writing simple budgeting softare. A Budget consists of a total limit, represented as a positive integer, and a dictionary of category limits, represented as a map from strings to integers. For example:

{
  "total_limit": 50,
  "category_limits": {
    "food": 10,
    "rent": 11,
    "candles": 49
 }
@lysender
lysender / htmx-allow-400-errors-swap-for-validation-errors.md
Created August 19, 2023 13:49
HTMX - Allow HTTP error 400 and 422 swap content to enable showing validation errors

Still a newbie to HTMX.

I was writing some form submit interaction and realized that HTMX won't swap/render if the HTTP status code is not 2xx.

For 404, 500 or 503 errors, I think it's fair enough.

For my use case, I'm returning error 400 or 422 for validation errors. I'm returning the form back with some error decorations for example.

According to the docs, I can change that behavior.

#!/usr/bin/env python3
"""
Apply database patches.
Applied patches are recorded in the schema_patch table of the database.
The dsn to connect to defaults to a local one (empty connection string). It can
be chosen using the command line or an environment variable. Patches
application is interactive by default.