Skip to content

Instantly share code, notes, and snippets.

View JoshuaFox's full-sized avatar

Joshua Fox JoshuaFox

View GitHub Profile

Keybase proof

I hereby claim:

  • I am joshuafox on github.
  • I am joshuafox (https://keybase.io/joshuafox) on keybase.
  • I have a public key ASA7NpqoM0BdtWHpgHjB6Ik6N0BEku6OCSVgwgq3BIAnBwo
@JoshuaFox
JoshuaFox / PubSubThreads.java
Last active October 27, 2020 01:19
Limiting the number of threads used by PubSub publisher
//Thanks to ajaaym https://github.com/googleapis/java-pubsub/issues/27#issuecomment-538508100
final ExecutorProvider fixedExecutorProvider = FixedExecutorProvider.create(
new ScheduledThreadPoolExecutor(1)); //adjust the size
Publisher publisher =
Publisher.newBuilder("topic_name")
.setExecutorProvider(fixedExecutorProvider)
.setChannelProvider(
PublisherStubSettings.defaultGrpcTransportProviderBuilder()
.setExecutorProvider(fixedExecutorProvider)
.setChannelConfigurator(
@JoshuaFox
JoshuaFox / FourExecutorThreads.java
Last active June 16, 2020 14:23
Reduce the number of executor threads used by PubSub Publisher
ExecutorProvider executorProvider =
InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(4).build();
Publisher.Builder builder =
Publisher.newBuilder(ProjectTopicName.of(proj, topic)).setExecutorProvider(executorProvider);
resource.type="datastore_database"
protoPayload.methodName="google.datastore.admin.v1.DatastoreAdmin.ExportEntities"
~ % dig joshuafox.com
;; ANSWER SECTION:
joshuafox.com. 3600 IN A 185.199.109.153
joshuafox.com. 3600 IN A 185.199.108.153
joshuafox.com. 3600 IN A 185.199.110.153
joshuafox.com. 3600 IN A 185.199.111.153
@JoshuaFox
JoshuaFox / Squares.java
Created August 14, 2022 18:27
Java loop
public static List<Integer> main() {
List<Integer> result = new ArrayList<>();
for (int i = 0; i < 4; i++) {
result.add(i * i);
}
return result;
}
@JoshuaFox
JoshuaFox / Squares.java
Created August 14, 2022 18:27
Java loop
public static List<Integer> main() {
List<Integer> result = new ArrayList<>();
for (int i = 0; i < 4; i++) {
result.add(i * i);
}
return result;
}
@JoshuaFox
JoshuaFox / Squares.java
Created August 14, 2022 18:29
Java loop
public static List<Integer> main() {
List<Integer> result = new ArrayList<>();
for (int i = 0; i < 4; i++) {
result.add(i * i);
}
return result;
}
@JoshuaFox
JoshuaFox / Squares.clj
Last active August 14, 2022 18:48
Squares.clj
(defn square [x] (* x x))
(defn squares [] (map square (range 4)))