Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
A different error message! Finally some progress!

Pradip Caulagi caulagi

🎧
A different error message! Finally some progress!
View GitHub Profile
@caulagi
caulagi / findUser.js
Created Feb 28, 2021
Find a user asynchronously from the database. If that succeeds, return the user. Else return the error
View findUser.js
User.findOne({ email: email }, function (err, user) {
if (err) { return done(err) }
if (!user) {
return done(null, false, { message: ‘Unknown user’ })
}
if (!user.authenticate(password)) {
return done(null, false, { message: ‘Invalid password’ })
}
return done(null, user)
})
@caulagi
caulagi / tonic-trace.txt
Created Dec 23, 2020
there is no reactor running
View tonic-trace.txt
thread 'main' panicked at 'there is no reactor running, must be called from the context of Tokio runtime', /Users/pradip.caulagi/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/io/driver/mod.rs:204:14
stack backtrace:
0: rust_begin_unwind
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
1: core::panicking::panic_fmt
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
2: core::option::expect_failed
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/option.rs:1226
3: core::option::Option<T>::expect
at /Users/pradip.caulagi/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:346
View gist:94d082100c307e1b39128ca82ac43a17
$ kubectl -n capg-system get pod capg-controller-manager-68869d55b7-nkhjm -o yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2020-11-11T19:41:14Z"
generateName: capg-controller-manager-68869d55b7-
labels:
cluster.x-k8s.io/provider: infrastructure-gcp
control-plane: capg-controller-manager
pod-template-hash: 68869d55b7
@caulagi
caulagi / readme-gen.html
Created Feb 29, 2020
Create images for README's
View readme-gen.html
<!DOCTYPE html>
<html>
<head>
<title>Mermite</title>
<style>
div {
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 22px;
line-height: 1;
opacity: 0.70;
View gist:81fcac40fc79063f14455dcb096d64e4
Finished dev [unoptimized + debuginfo] target(s) in 1.56s
Running `target/debug/frontend-server`
thread 'main' panicked at 'no current reactor', /Users/pradip.caulagi/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.6/src/io/driver/mod.rs:243:21
stack backtrace:
0: 0x106200065 - std::sys_common::at_exit_imp::push::h0636e6b5f7616352
1: 0x10621ae90 - core::fmt::ArgumentV1::show_usize::hca33af0aed7db5c5
2: 0x1061fba5b - std::io::Write::write_fmt::he6837371b9a45188
3: 0x106201da3 - std::panicking::default_hook::{{closure}}::h708e66cfeb0483ba
4: 0x106201aaa - std::panicking::default_hook::h39ea8ddf674c04ec
5: 0x10620246b - <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get::hf147e9d6b92d24d8
View no-current-reactor
Finished dev [unoptimized + debuginfo] target(s) in 0.18s
Running `target/debug/frontend-server`
thread 'main' panicked at 'no current reactor', /Users/pradip.caulagi/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.6/src/io/driver/mod.rs:243:21
stack backtrace:
0: std::sys_common::at_exit_imp::push
1: core::fmt::ArgumentV1::show_usize
2: std::io::Write::write_fmt
3: std::panicking::default_hook::{{closure}}
4: std::panicking::default_hook
5: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
View fibonacci_await.py
import asyncio
async def fibonacci(n, marker):
print(f'Marker: {marker}')
if n < 2:
return 1
return await fibonacci(n-1, marker) + await fibonacci(n-2, marker)
View fluent-bit.conf
[SERVICE]
Flush 1
Daemon Off
Log_Level debug
Parsers_File parsers.conf
[INPUT]
Name tail
Path /var/log/containers/*.log
Parser docker
@caulagi
caulagi / cherry-sentry-integration.py
Created Mar 12, 2018
Example cherrypy sentry integration
View cherry-sentry-integration.py
def register_sentry():
cherrypy.tools.report_to_sentry = cherrypy.Tool('before_error_response', report_to_sentry)
cherrypy.config.update({
'tools.report_to_sentry.on': True
})
def report_to_sentry():
sentry_dsn = settings.sentry_dsn
if not sentry_dsn:
@caulagi
caulagi / py-snippets.md
Last active Feb 6, 2018
Illustrative python snippets
View py-snippets.md

A list of python snippets I find interesting

  • The Python standard library has an implementation of Counter that is typically used to find the most common items in a a collection, with their count. I find the implement of collections.Counter instructive in general. I especially like the implementation of most_commonlink. I find it interesting how most_common determines which method to use for efficiency reasons (based on n).

  • In heapq module (standard library), implemention of nsmallestlink. In general, the heapq module has awesome comments. This is true for nsmallest method also. Also, I like how this method is lazy (stores only k items irrespective of input) and generic (the optional key).