This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rec { | |
pkgs = import <nixpkgs> {}; | |
python3 = pkgs.python39.withPackages (ps: with ps; [ setuptools wheel twine ]); | |
v502 = pkgs.fetchzip { | |
url = "https://github.com/hsluv/hsluv-python/archive/refs/tags/v5.0.2.zip"; | |
sha256 = "sha256-8uzDL8VWJmoH5Hnj+PZ3I1U1KdD5wyd/veM5LplHHGQ="; | |
}; | |
v501 = pkgs.fetchzip { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import subprocess | |
import json | |
import glob | |
from pathlib import Path | |
RCLONE_REMOTE = 'my-s3-remote' | |
S3_BUCKET = 'my-ses-email-bucket' | |
RCLONE_REMOTE_S3 = f'{RCLONE_REMOTE}:{S3_BUCKET}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Export a Sentry project's issues to CSV.""" | |
import argparse | |
import asyncio | |
import csv | |
import logging | |
import sys | |
from typing import Any, Dict, List, Optional, Tuple, Union |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import stat | |
import tempfile | |
import subprocess | |
shebang_prefix = '#!/usr/bin/env DUMMY=x' | |
shebang_suffix = ' python\n' | |
shebang_length_min = len(shebang_prefix) + len(shebang_suffix) | |
TEST_FILE_HANDLE, TEST_FILE = tempfile.mkstemp('.py') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; lein new mies-node edn-vs-json | |
; vim edn-vs-json/src/edn_vs_json/core.cljs | |
; lein cljs build once | |
; node run.js | |
(ns edn-vs-json.core | |
(:require | |
[cljs.nodejs :as nodejs] | |
[cljs.reader :as reader] | |
[clojure.string :as string])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import png | |
from husl import * | |
def mix(h1, h2, t): | |
return h1 * t + h2 * (1 - t) | |
def spiral(radius, degree, number): | |
n = 1.0 / number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Asynchronous coding takes a bit of time to wrap your head around. | |
// I can't know for sure, but I think you misunderstand the general | |
// nature of a callback function. 'ajax.post' doesn't wait for the | |
// request to complete before returning, if it did so, there wouldn't | |
// be any need for a callback. **If you want something to happen AFTER | |
// the request completes, you have to put it in the callback function.** | |
// Don't think of a callback as some kind of icing on the cake, it is | |
// literally the continuation of your program's logic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post '/api/verify', (req, res) -> | |
fail = -> | |
res.json status: 'failure' | |
if not req.body? | |
fail() | |
opts = { | |
host: "https://verifier.login.persona.org" | |
path: "/verify" | |
method: 'POST' | |
regectUnauthorized: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyResource(ModelResource): | |
# Workaround for this issue: | |
# https://github.com/toastdriven/django-tastypie/issues/518 | |
def hydrate(self, bundle): | |
for field_name, field_obj in self.fields.items(): | |
if field_name == 'resource_uri': | |
continue | |
if not field_obj.blank and not bundle.data.has_key(field_name): | |
raise ApiFieldError("The '%s' field has no data and doesn't allow a default or null value." % field_name) | |
return bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CompanyResource(ModelResource): | |
class Meta: | |
resource_name = 'companies' | |
api_name = 'v1' | |
detail_uri_name = 'domain' | |
queryset = Company.objects.all() | |
def prepend_urls(self): | |
return [ | |
url(r"^(?P<resource_name>%s)/(?P<domain>[\w\d_.-]+)/$" % | |
self._meta.resource_name, |
NewerOlder