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
# Quick snippet to connect to a Jupyter notebook server running inside a Modal container, | |
# especially useful for exploring the contents of Modal shared volumes. | |
# This uses https://github.com/ekzhang/bore to expose the server to the public internet. | |
# | |
# Steps | |
# ----- | |
# 1. (Recommended) Change `JUPYTER_TOKEN` to a different value; default is 1234. | |
# 2. `modal run jupyter-bore.py` | |
# 3. Find the `bore.pub` URL printed in the logs, and navigate to it using your browser. |
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
# | |
# -- An improved version of this code is now in the aioresult library -- | |
# | |
# https://github.com/arthur-tacca/aioresult | |
# | |
# | |
# - aioresult has a ResultCapture class similar to the one below | |
# - It also has a Future class that allows manually setting the result, which shares a base class with ResultCapture | |
# - There is a utility function with a similar effect to StartableResultCapture below (but much simpler) | |
# - There are utility functions wait_any(), wait_all() and to_channel() (which also work with Future instances) |
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 bash | |
help() { | |
cat <<EOF | |
Options: | |
- cc-disable | |
Disable charging control | |
- cc-home | |
Charging control to Home mode (40%-70%) | |
- cc-work |
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
;; | |
;; 28.07.2017 | |
;; Charles Wang | |
;; | |
;;;;;;; Tweaks for Org & org-latex ;;;;;; | |
(defvar cw/org-last-fragment nil | |
"Holds the type and position of last valid fragment we were on. Format: (FRAGMENT_TYPE FRAGMENT_POINT_BEGIN)" | |
) |
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
gem 'stackprof', require: false | |
gem 'ruby-prof', require: false |
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
/* | |
ArrayUtil exposes a set of helper methods for working with | |
ReadableArray (by React Native), Object[], and JSONArray. | |
MIT License | |
Copyright (c) 2020 Marc Mendiola | |
Permission is hereby granted, free of charge, to any person obtaining a copy |
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(query_start, clock_timestamp()), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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 | |
def on_starting(server): | |
""" | |
Attach a set of IDs that can be temporarily re-used. | |
Used on reloads when each worker exists twice. | |
""" | |
server._worker_id_overload = set() |
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
#!/bin/bash | |
# This script should be located on each Jenkins slave, and the jenkins user should have permission to run it with sudo | |
# Attempts to cleanly stop and remove all containers, volumes and images. | |
docker ps -q | xargs --no-run-if-empty docker stop | |
docker ps -q -a | xargs --no-run-if-empty docker rm --force --volumes | |
docker volume ls -q | xargs --no-run-if-empty docker volume rm | |
docker images -a -q | xargs --no-run-if-empty docker rmi -f | |
# Stops the docker service, unmounts all docker-related mounts, removes the entire docker directory, and starts docker again. |
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
private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException { | |
WritableMap map = new WritableNativeMap(); | |
Iterator<String> iterator = jsonObject.keys(); | |
while (iterator.hasNext()) { | |
String key = iterator.next(); | |
Object value = jsonObject.get(key); | |
if (value instanceof JSONObject) { | |
map.putMap(key, convertJsonToMap((JSONObject) value)); | |
} else if (value instanceof JSONArray) { |
NewerOlder