Skip to content

Instantly share code, notes, and snippets.

@pradeepbn
pradeepbn / check_ge_appt_schedule.py
Last active September 11, 2022 23:39
GE appointment schedule checker
import os
import time
import requests
from datetime import datetime
import subprocess
TTP_TIME_FORMAT = '%Y-%m-%dT%H:%M'
NOTIF_MESSAGE="New slot opened at {start}"
@pradeepbn
pradeepbn / testBKAPI.java
Created November 16, 2021 01:47
Test client to reproduce the shutdown sequence issue
import org.apache.bookkeeper.client.*;
import org.apache.bookkeeper.client.LedgerEntry;
import org.apache.bookkeeper.client.api.LedgerEntries;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@pradeepbn
pradeepbn / gist:a033cae7171f9e6da9a7f92737f843b9
Created November 16, 2021 01:25
Diff to reproduce shutdown sequence issue
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java
index 4af6eec83..23dd02bd3 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java
@@ -37,10 +37,7 @@ import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import java.util.Optional;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.RejectedExecutionException;
@pradeepbn
pradeepbn / tensorflow_debugging_example.py
Last active April 28, 2018 09:12
Example to show how to use tf.Print and tfdbg
import tensorflow as tf
from tensorflow.python import debug as tf_debug
a = tf.constant([1.0, 4.0], shape=[2,1])
b = tf.constant([2.0, 3.0], shape=[1,2])
c = tf.add(tf.matmul(a,b), tf.constant([5.0, 6.0]))
d = tf.Print(c, [c, 2.0], message="Value of C is:")
sess = tf_debug.LocalCLIDebugWrapperSession(sess)
with tf.Session() as sess:
sess.run(d)
@pradeepbn
pradeepbn / lua_script.lua
Created July 31, 2016 03:16
Leverage multiple Crawlera sessions using lua script
function get_session_id(session_table)
if #session_table <= 100 then
-- Crawlera C10 package supports only 100 sessions
return session_table[math.random(1,100)]
else
return session_table[0]
end
end
function add_session_id(session_table, session_id)
@pradeepbn
pradeepbn / settings.py
Created July 25, 2016 09:31
Scrapy settings
BOT_NAME = 'BusinessContacts'
SPIDER_MODULES = ['BusinessContacts.spiders']
NEWSPIDER_MODULE = 'BusinessContacts.spiders'
# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'BusinessContacts (+http://www.yourdomain.com)'
# Obey robots.txt rules
@pradeepbn
pradeepbn / lua_source.lua
Created July 25, 2016 09:25
Lua script for splash
lua_source = """
function main(splash)
local host = "proxy.crawlera.com"
local port = 8010
local user = "<API_KEY>"
local password = ''
local session_header = "X-Crawlera-Session"
local session_id = "create"
splash:on_request(function (request)
class A
{
public:
A();
~A();
virtual void Afoo();
}
class A1 : public A
{