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 / rhel_build_make
Created June 11, 2016 18:05
While doing make in build dir of nerves_system_br
g++ -c -O2 -I/root/nerves_system_br-0.5.1/rpi_build/host/usr/include -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include -I/root/nerves_system_br-0.5.1/rpi_build/host/usr/include -I/root/nerves_system_br-0.5.1/rpi_build/host/usr/include -I/root/nerves_system_br-0.5.1/rpi_build/host/usr/include -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/../libbacktrace -o errors.o -MT errors.o -MMD -MP -MF ./.deps/errors.TPo ../../gcc/errors.c
rm -f mm_malloc.h
cat ../../gcc/config/i386/pmm_malloc.h > mm_malloc.h
TARGET_CPU_DEFAULT="" \
HEADERS="auto-host.h ansidecl.h" DEFINES="USED_FOR_TARGET " \
/bin/sh ../../gcc/mkconfig.sh tconfig.h
(echo "@set version-GCC 4.9.3"; \
if [ "" = "ex
@krishnakumar4a4
krishnakumar4a4 / thread_number.rs
Created December 30, 2017 17:12
Extending thread implementation to get unique identifier directly
use std::thread;
use std::thread::JoinHandle;
use std::thread::ThreadId;
fn main() {
let handle = thread::spawn(||{
println!("Spawned thread {:?}",thread::current().id());});
let handle2 = thread::spawn(||{
println!("Spawned thread2 {:?}",thread::current().id());
@krishnakumar4a4
krishnakumar4a4 / complex_struct_serialization.rs
Created January 10, 2018 02:03
Shows how a struct holding complex datatypes can be serialized using serde library. Fixed problems with lifetimes.
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
#[derive(Serialize, Debug)]
struct DetailRecord {
id: i32,
description: String,
@krishnakumar4a4
krishnakumar4a4 / private_type_leak.rs
Created January 10, 2018 13:39
can't leak private type error and how i fixed it
pub fn insert_details(handle: Connection, details: &Details) -> Vec<Result<i32>>{
let dris = details.detail_record_ids;
//Check if the corresponding detailrecord entries are present in DetailRecord table
dris.iter().map(|detail_record| {
//Break and err if one of the insert fails
handle.execute("INSERT INTO Details (detail_record_ids) VALUES (?1)",&[&detail_record.id])
}).collect()
}
//Following error
@krishnakumar4a4
krishnakumar4a4 / Cargo.toml
Created January 28, 2018 07:44
Corrected version of ring agreement usage
[package]
name = "ring-pk-example"
version = "0.1.0"
authors = ["Krishna Kumar <krishnakumar4a4@gmail.com>"]
[dependencies]
ring = "^0.12"
untrusted = "^0.5"
@krishnakumar4a4
krishnakumar4a4 / main.rs
Created February 17, 2018 02:15 — forked from jaysonsantos/main.rs
rust ring example
extern crate ring;
use ring::aead::*;
use ring::pbkdf2::*;
use ring::rand::SystemRandom;
fn main() {
// The password will be used to generate a key
let password = b"nice password";
@krishnakumar4a4
krishnakumar4a4 / Ansible-Vault how-to.md
Created February 23, 2018 09:13 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

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:

@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");
@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>