Skip to content

Instantly share code, notes, and snippets.

View krishnakumar4a4's full-sized avatar
💭
I like to talk tech

Krishna Kumar Thokala krishnakumar4a4

💭
I like to talk tech
View GitHub Profile
@krishnakumar4a4
krishnakumar4a4 / wsproxy.go
Created September 15, 2022 13:46
Working websocket proxy implementation in Golang using httputil package
// Starts a websocket proxy
func StartWebSocketProxy() error {
// Create Reverse Proxy instance
reverseProxy := httputil.NewSingleHostReverseProxy(&url.URL{})
reverseProxy.ModifyResponse = func(response *http.Response) error {
if response.StatusCode == 101 {
log.Println("Received websocket upgrade response")
}
return nil
package main
import (
"fmt"
"sync"
"time"
"runtime"
)
func main() {
@krishnakumar4a4
krishnakumar4a4 / DerbySetupReadme.md
Created December 25, 2019 07:19
Derby db setup
@krishnakumar4a4
krishnakumar4a4 / http_client_stats.go
Created September 5, 2019 16:03
TCP level read and write stats using standard golang HTTP client
package main
import (
"context"
"fmt"
"net"
"net/http"
"time"
)
@krishnakumar4a4
krishnakumar4a4 / sync_map
Created February 13, 2019 14:29
check golang sync map about race conditions
package main
import (
"fmt"
"sync"
)
var t sync.Map
func main() {
@krishnakumar4a4
krishnakumar4a4 / multi_dim_array_manip.go
Created January 26, 2019 01:51
Appending elements inside multidimensional arrays in golang using slices
package main
import (
"fmt"
)
func main() {
// Inner dimension cannot be extended if given length
v := [3][3][]int{}
@krishnakumar4a4
krishnakumar4a4 / find_files_by_extension.rs
Created January 1, 2019 09:54
recursively read files in a directory [Rust]
use std::fs;
use std::path::Path;
extern crate regex;
use regex::Regex;
fn main() {
get_files(local_index_file_path, vec!["^*.caidx$".to_owned(), "^*.caibx$".to_owned()]);
get_files(local_chunks_file_path, vec!["^*.cacnk$".to_owned()]);
}
@krishnakumar4a4
krishnakumar4a4 / tsung_sample.xml
Created December 26, 2018 05:02
Sample tsung configuration
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd" [] >
<tsung loglevel="debug" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true"/>
</clients>
<servers>
<server host="127.0.0.1" port="8001" type="tcp"></server>
</servers>
<monitoring>
@krishnakumar4a4
krishnakumar4a4 / main.rs
Created October 12, 2018 15:30
Run os commands with rust
extern crate libc;
use std::process::{Command,Stdio};
fn main() {
println!("Hello, world!");
unsafe {
println!("Euid is {}",libc::geteuid());
}
println!("ps output {:?}",Command::new("ps").arg("-efl").output().unwrap());
let ps_cmd = Command::new("ps").arg("-efl").stdout(Stdio::piped()).spawn().expect("Error ps cmd");

Keybase proof

I hereby claim:

  • I am krishnakumar4a4 on github.
  • I am krishnakumart (https://keybase.io/krishnakumart) on keybase.
  • I have a public key ASAqiFScjvlwVKPf5vqzB6RmqOm3TZKt7mZZcV5PRrn1Hgo

To claim this, I am signing this object: