Skip to content

Instantly share code, notes, and snippets.

@isopropylcyanide
isopropylcyanide / littlechecker.py
Last active January 7, 2024 16:50 — forked from rajarsheem/littlechecker.py
A little code checker tool in python for Java,C,Cpp. Handles compile error, runtime error, accepted, wrong, TLE.
import os
import filecmp
import re
codes = {200: 'success', 404: 'file_name not found',
400: 'error', 408: 'timeout'}
class program:
"""Class that handles all nitty gritties of a user program"""
# Find the partition that contains messages from this connector name. Usually by grepping
kafkacat -C -Z -b localhost -t <connect.offsets.topics> -o <number> | grep "servername"
# Set an null offset.
echo '["<connector-name",{"server":"<servername>"}]|' \|
kafkacat -P -Z -b localhost -t <connect.offsets.topics> -K \|
-p <partition>
@isopropylcyanide
isopropylcyanide / Bash script to create user accounts.
Last active January 26, 2023 09:39 — forked from thimbl/script.sh
Shell script to create user accounts
#!/bin/bash
ROOT_UID=0
SUCCESS=0
E_USEREXISTS=70
# Run as root, of course. (this might not be necessary, because we have to run the script somehow with root anyway)
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script."
exit $E_NOTROOT
@isopropylcyanide
isopropylcyanide / ObjectMapperUtil.java
Created June 20, 2018 10:20
Nested Property Object Mapper. Using reflection, takes an object and returns a map<string, string> where key is all the properties (nested inclusive) and value is the object value
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.IntStream;
import org.apache.commons.lang3.ClassUtils;
@isopropylcyanide
isopropylcyanide / connector-snapshot-override-index.sql
Last active February 25, 2022 19:30
connector-snapshot-override-index.sql
-- myTable has over millions of rows
-- create index on a column first
create index idx_updated_at on `myDatabase.myTable`(updated_at);
-- now the column can be safely used as an override
-- "snapshot.select.statement.overrides.myDatabase.myTable":
-- "select * from `myDatabase.myTable` where updated_at > \"2021-02-01 18:00:00\"",
{
"info": {
"_postman_id": "cb2d48b5-a05b-4f9b-85d7-50f2d1f35f23",
"name": "JWT Auth",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Register a User",
"request": {
{
"info": {
"_postman_id": "cb2d48b5-a05b-4f9b-85d7-50f2d1f35f23",
"name": "JWT Auth",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Register a User",
"request": {
@isopropylcyanide
isopropylcyanide / a.patch
Created October 17, 2021 17:11
Patch for protected banner status
diff --git a/main.go b/main.go
index 3d28cfa..ad7a3c2 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "database/sql"
"time"
@isopropylcyanide
isopropylcyanide / add_banners.go
Created October 17, 2021 17:10
Demo app that writes few entries to mysql without a protected status
package main
import (
"time"
"github.com/segmentio/ksuid"
"github.com/tjarratt/babble"
"go.uber.org/zap"
"gorm.io/driver/mysql"
@isopropylcyanide
isopropylcyanide / add_banners_protected.go
Last active October 17, 2021 17:10
Demo app that writes few entries to mysql using a protected status set per business logic
package main
import (
"database/sql"
"time"
"github.com/segmentio/ksuid"
"github.com/tjarratt/babble"
"go.uber.org/zap"