Skip to content

Instantly share code, notes, and snippets.

View abhillman's full-sized avatar
🥰

Aryeh Hillman abhillman

🥰
View GitHub Profile
@abhillman
abhillman / python311
Last active November 3, 2023 04:53
Wrapped version of Python 3.11 for allowing nix-managed python with IntelliJ/PyCharm
#!/bin/bash
# Use of python311 with dependencies, binaries, and other aspects of the environment with nix under IntelliJ.
# Instruct IntelliJ to use this script by specifying a path to this file as the "system" python interpreter.
# Make sure this file is named `python311` (IntelliJ may otherwise reject it) executable by running `chmod +x ...``.
#
# If a `shell.nix` file is located in the same path as this wrapper script, its contents will be used in addition to
# the dependencies listed below via `-p`.
#
# Copyright (C) 2032 Aryeh Hillman ([email protected])
# Permission to copy and modify is granted under the AGPLv3 license
@abhillman
abhillman / nix.lorri.plist
Last active January 3, 2023 07:39
systemd for nix's lorri daemon
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>nix.lorri</string>
<key>ProgramArguments</key>
<array>
<string>lorri</string>
<string>daemon</string>
import Network.HTTP.Conduit (simpleHttp)
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Lazy.Char8 as C
import Text.XML.HXT.Core
import Data.List
urbanDictionaryURL :: String
urbanDictionaryURL = "https://www.urbandictionary.com/random.php"
getRandomUrbanEntry :: IO String
@abhillman
abhillman / remove_comments.py
Created November 24, 2014 03:03
Little program to remove c-like comments given from input via standard in
#!/usr/bin/python
# Little program to remove c-like comments from input given via standard in
import fileinput
from sys import stdout
COMMENT_OPEN = False
OPEN_COMMENT = '/*'
CLOSE_COMMENT = '*/'
OPEN_COMMENT_IDX = 0
CLOSE_COMMENT_IDX = 0
{-
Module: urban.hs
Description: Grabs example sentences for a random term from Urban Dictionary
Copyright: June 18, 2014
License: MIT
Maintainer: [email protected]
Stability: experimental
Portability: portable
@abhillman
abhillman / JSONMiddleware.py
Last active April 20, 2016 06:04
Django Middleware to add request.JSON to any HTTP requests that (1) are ajax and (2) are application/json content type.
from django.utils import simplejson
class JSONMiddleware(object):
def process_request(self, request):
request.JSON = None
if request.is_ajax():
if request.META.get('CONTENT_TYPE').count('application/json'):
try:
request.JSON = simplejson.loads(request.body)
except simplejson.JSONDecodeError: