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
require 'puma/plugin' | |
module GracefulShutdown | |
# Configures puma to gracefully shutdown karafka producer | |
# Related documentation: https://karafka.io/docs/Producing-messages/#producer-shutdown | |
# Usage: | |
# | |
# (at the end of config/puma.rb) | |
# | |
# GracefulShutdown::SetupPuma.new.call(self) |
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
# Spec producer client used to buffer messages that we send out in specs | |
class KafkaProducerClient < WaterDrop::Producer::DummyClient | |
attr_accessor :messages | |
# Sync fake response for the message delivery to Kafka, since we do not dispatch anything | |
class SyncResponse | |
# @param _args Handler wait arguments (irrelevant as waiting is fake here) | |
def wait(*_args) | |
false | |
end |
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
const geometry = {}; | |
// for all the functions below, assume screen coordinates: the x-axis is rightward, the y-axis is downward | |
// finds a point with the lowest vertical position (leftmost wins in case of a tie) | |
geometry.lowestPoint = (points) => points.reduce((lowest, point) => { | |
if (point[1] > lowest[1]) { | |
return point; | |
} | |
if (point[1] === lowest[1] && point[0] < lowest[0]) { |
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
/* eslint-disable no-console */ | |
const config = require('../graphql-schema-linter.config.js') | |
// Aaa prefix is used to put this rule on top of the list | |
// which is required for excludes to work properly | |
// This rule allows to add exclusions (defined in graphql-schema.config.js) | |
function AaaWithExcludes (context) { | |
const stack = [] |
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 * as React from 'react'; | |
import { Button, Text, TextInput, View, StyleSheet } from 'react-native'; | |
import Constants from 'expo-constants'; | |
// You can import from local files | |
import AssetExample from './components/AssetExample'; | |
// or any pure javascript modules available in npm | |
import { Card } from 'react-native-paper'; |
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
// WebSocketFactory.d.ts | |
export function newWebSocket( url: String ): WebSocket; | |
// WebSocketFactory.js | |
exports.newWebSocket = function( url ) { | |
if (CC_JSB) { | |
return new WebSocket( url, [], "ssl_cert.pem" ); | |
} | |
else { | |
return new WebSocket( url ); |
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
build_prompt () { | |
local lhs=$1 | |
local rhs=$2 | |
local save='\e[s' # Save cursor position | |
local rest='\e[u' # Restore cursor to save point | |
# Strip ANSI commands before counting length | |
# From: https://www.commandlinefu.com/commands/view/12043/remove-color-special-escape-ansi-codes-from-text-with-sed | |
rhs_stripped=$(sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" <<<"$rhs") | |
echo "\[${save}\e[${COLUMNS:-$(tput cols)}C\e[${#rhs_stripped}D${rhs}${rest}\]${lhs}" | |
} |
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
04-09 13:31:07.813: D/WebSocket.cpp(20710): WebSocket thread start, helper instance: 0xd19ad4e0 | |
04-09 13:31:07.820: D/WebSocket.cpp(20710): scheme: ws, host: echo.websocket.org, port: 0, path: | |
04-09 13:31:07.926: D/WebSocket.cpp(20710): WebSocket (0xce292b00) Unhandled websocket event: 32 | |
04-09 13:31:07.926: D/WebSocket.cpp(20710): WebSocket (0xce292b00) Unhandled websocket event: 29 | |
04-09 13:31:08.166: D/WebSocket.cpp(20710): WebSocket (0xce292b00) Unhandled websocket event: 24 | |
04-09 13:31:08.277: D/WebSocket.cpp(20710): WebSocket (0xce292b00) Unhandled websocket event: 2 | |
04-09 13:31:08.277: D/WebSocket.cpp(20710): onConnectionOpened...: 0xce292b00, client protocols: , server selected protocol: | |
04-09 13:31:08.286: D/WebSocket.cpp(20710): Safely done, msg(2)! | |
04-09 13:31:08.287: D/WebSocket.cpp(20710): msg(2) append: 0 + 4 = 4 | |
04-09 13:31:08.287: D/WebSocket.cpp(20710): msg(2) was totally sent! |
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
// what I carelessly wrote | |
BigInteger value = ciphertext[0]; | |
BigInteger p, o; | |
if (value.equals(ciphertext[1])) { // << here's careless fail. Never should've done it | |
BigInteger[] factors = factorize(value); | |
p = factors[0]; | |
o = factors[1]; | |
} else { | |
p = gcd(value, ciphertext[1]); | |
o = value.divide(p); |
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
#include <functional> | |
#include <optional> | |
#include <vector> | |
#include <iostream> | |
template<typename T> | |
using Receiver = std::function<void( T )>; | |
template<typename T, typename U> | |
using Transformer = std::function<U( T )>; |
NewerOlder