Skip to content

Instantly share code, notes, and snippets.

View poonai's full-sized avatar
🦑
Confused

Poonai poonai

🦑
Confused
  • kumari kandam
  • 08:33 (UTC +05:30)
  • X @poonai_
View GitHub Profile
@poonai
poonai / main.rs
Created May 24, 2022 08:50
prime number profiling
use std::fs::File;
use std::io::Write;
use pprof::protos::Message;
#[inline(never)]
fn is_prime_number1(v: usize, prime_numbers: &[usize]) -> bool {
@poonai
poonai / x.go
Last active March 30, 2022 07:26
helper method to send slack message
package x
import (
"os"
"github.com/slack-go/slack"
"go.uber.org/zap"
)
var api = slack.New(os.Getenv("SLACK_TOKEN"))
@poonai
poonai / lib.rs
Created November 22, 2021 18:24
OPA wasm example in RUST
use anyhow::Error;
use wasmtime::{ Engine, Extern, Func, Instance, Memory, MemoryType, Module, Store, Trap, TypedFunc, AsContextMut};
/// OpenPolicy is used to load the compiled wasm module in Rust runtime.
pub struct OpenPolicy{
// global ctx of wasm policy. TODO: can be reused.
engine: Engine,
// loaded wasm module TODO: can be reused.
module: Module,
// wasm module with all the neccessary import.
delay marshar 02m18s
withour delay 02m31s
delat marshal with pool 02m35s
@poonai
poonai / gist:911578fcf8ea8a679b46a3155f6e6525
Created February 6, 2020 10:30
Bulk loader optimaztion numbers
previous 2m45s
keys/10 shard 2m50s
keys/20 shard 03m07s
keys/15 shard 03m05s
keys/8 shard 03m04s
@poonai
poonai / bench.go
Last active September 2, 2019 15:40
sync bench
package main
import (
"crypto/rand"
"encoding/hex"
"io/ioutil"
"os"
"sync"
"testing"
)
@poonai
poonai / proxy.sh
Last active December 7, 2018 06:26
echo "[Boto]" >> /etc/boto.cfg
echo "https_validate_certificates= False" >> /etc/boto.cfg
wget https://raw.githubusercontent.com/elazarl/goproxy/master/ca.pem
mv ca.pem ca.crt
cp ca.crt /usr/local/share/ca-certificates
update-ca-certificates
@poonai
poonai / worker.rs
Last active September 17, 2018 09:21
simple worker in rust
extern crate chan_signal;
use chan_signal::Signal;
use std::sync::mpsc;
use std::sync::mpsc::{Receiver, Sender};
use std::thread;
enum ReceiveMessage {
Work(Box<Fn() + Send>),
End,
}
@poonai
poonai / bpf.c
Created August 21, 2018 17:25 — forked from msantos/bpf.c
Example of using bpf to capture packets
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <err.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@poonai
poonai / kuberenetes-cloud-test.sh
Created March 21, 2018 12:23
local kubernetes cluster to test the changes
sudo su -
apt-get install -y gcc make socat git
# Install etcd
curl -L https://github.com/coreos/etcd/releases/download/v3.0.17/etcd-v3.0.17-linux-amd64.tar.gz -o etcd-v3.0.17-linux-amd64.tar.gz && tar xzvf etcd-v3.0.17-linux-amd64.tar.gz && /bin/cp -f etcd-v3.0.17-linux-amd64/{etcd,etcdctl} /usr/bin && rm -rf etcd-v3.0.17-linux-amd64*
#Install go
sudo curl -O https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
sudo tar -xvf go1.9.1.linux-amd64.tar.gz
sudo mv go /usr/local