Skip to content

Instantly share code, notes, and snippets.

View Schachte's full-sized avatar
🖊️
Writing goto statements

Ryan Schachte Schachte

🖊️
Writing goto statements
View GitHub Profile
@Schachte
Schachte / README.sh
Last active July 21, 2024 03:06
Realtime query selector evaluation for Playwright
python scripts/playwright_playground.py \
"https://www.google.com/search?q=cloudflare+stock+price" \
"h3" \
--timeout 1 \
--content-type text
# Output allows quick iteration
Cloudflare, Inc. (NET) Stock Price, News, Quote & History
Try new selector (q to quit): div[data-attrid="Price"]
@Schachte
Schachte / cloudflare_webhook_testing.go
Created March 18, 2024 18:15
Testing Cloudflare webhook callback server using Tunnels & Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
@Schachte
Schachte / create.sh
Last active March 10, 2023 17:55
Cloudflare Direct Creator Uploads
curl -X POST \  system
-H 'Authorization: Bearer <TOKEN>' \
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/direct_upload \
--data '{
"maxDurationSeconds": 3600
}'
@Schachte
Schachte / js
Created December 23, 2022 05:00
Lastpass Checkbox Highlighter
for (item of document.getElementsByClassName('vault-item-displayname')) {
item.click()
}
@Schachte
Schachte / .java
Created October 1, 2020 19:08
Seek & Commit Logic for Kafka Custom Offset Manager
public void seekAndCommit() {
consumer.poll(Duration.ofSeconds(1));
Set<TopicPartition> consumerPartitionAssignments = consumer.assignment();
// This is the map of partitions the consumer owns as of latest poll
Map<TopicPartition, OffsetAndMetadata> partitionToMetadataMap = new HashMap<>();
for (var entry : currentOffsets.entrySet()) {
TopicPartition partition = entry.getKey();
OffsetAndMetadata offset = entry.getValue();
if (consumerPartitionAssignments.contains(partition)) {
@Schachte
Schachte / ConsumerBatching.java
Last active March 21, 2020 07:01
Consumer batching with record count and time
import static java.util.Objects.isNull;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Predicate;
@Schachte
Schachte / LongestSubstringKDistinct.java
Last active December 18, 2024 09:41
Sliding Window Maximum Sum Subarray
import java.util.*;
class LongestSubstringKDistinct {
public static int findLength(String str, int k) {
int windowStart = 0, maxLength = 0;
Map<Character, Integer> charFrequencyMap = new HashMap<>();
for (int windowEnd = 0; windowEnd < str.length(); windowEnd++) {
char rightChar = str.charAt(windowEnd);
charFrequencyMap.put(rightChar, charFrequencyMap.getOrDefault(rightChar, 0) + 1);
@Schachte
Schachte / ..git-pr.md
Created January 26, 2018 23:39 — forked from gnarf/..git-pr.md
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
import React, {PropTypes, Component} from 'react';
import {ModalContainer, ModalDialog} from 'react-modal-dialog';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { updateZip } from '../actions/index';
import { updatePrice } from '../actions/updatePrice';
import { updateRadius } from '../actions/updateRadius';
import Yelp from 'yelp';
class ModalWindow extends Component {
for child in root:
if child.attrib['major'] == str(hex(int(major_bits[::-1], 2))) and child.attrib['minor'] == str(hex(int(minor_bits[::-1], 2))):
command_name = str(child.attrib['name'])
print 'inside of this'
for grandchild in child.getchildren():
print str(grandchild.attrib['bytes'])