Skip to content

Instantly share code, notes, and snippets.

@officialcjunior
officialcjunior / rust_blr.rs
Last active October 8, 2023 07:11
rust_blr.rs
//! Virtual Device Module
use kernel::prelude::*;
use kernel::file::{File, Operations};
use kernel::io_buffer::{IoBufferReader, IoBufferWriter};
use kernel::sync::smutex::Mutex;
use kernel::sync::{Arc, ArcBorrow};
use kernel::{miscdev, Module};
@officialcjunior
officialcjunior / Avial-downloader.md
Last active December 13, 2022 17:48
Avial-downloader

Avial-downloader

This script is to download all the songs released by the Indian alternative rock band Avial, in the highest quality possible.

Track list

  • All the songs from the studio album Avial(2008)
  • All the four singles : Aanakallan, Ayyo!, Thithithara, Arambath
  • "Chi Me Sape"- The song born after collaborating with Italian band A67.
@officialcjunior
officialcjunior / frama-c.md
Last active October 9, 2021 17:00
A small how-to on installing frama-c, the source code analyzer on Unix systems.

How to install frama-c on *nix

I had wasted almost half of a day trying to properly install frama-c on my Linux. I was surprised to see no much documentation or troubleshooting online, so that's the whole point of me putting this note as a public gist.

Ubuntu

If you read the official documentation, you'll come across the names of these two packages:

frama-c and frama-c-base

If you are on Ubuntu 18.04 LTS, you can directly install it using apt install frama-c, and it will work. You can not do this on a 20.04 LTS Focal Fossa, because apparently, it's not included in the official packages.

@officialcjunior
officialcjunior / linked-list.rs
Created July 11, 2021 08:59
Implementation of a singly linked list in Rust using smart pointers(Box)
use std::fmt;
use std::io;
// Since, we don't have `NULL` in Rust, we will use Option for
// each of the smart pointers- `Box`es. Basically, each of the Node contains a
// Some() or a None()
struct Node {
value: u32,
next: Option<Box<Node>>,
}
@officialcjunior
officialcjunior / 1244B.c
Created March 24, 2020 06:31
Solution to 1244B of the codeforces problemset
#include <stdio.h>
int main()
{
int t, n, max, i;
scanf("%d",&t); // test cases
while(t--)
{
scanf("%d",&n); // n=number of rooms
char s[n+1];
@officialcjunior
officialcjunior / golden-section-method.py
Created January 1, 2021 12:13
Python script to find the minimize unimodal expressions using the golden section method | optimization technique
import math
invphi = (math.sqrt(5) - 1) / 2 # 1 / phi
invphi2 = (3 - math.sqrt(5)) / 2 # 1 / phi^2 ig
def gssrec(f, a, b, tol=1e-5, h=None, c=None, d=None, fc=None, fd=None):
(a, b) = (min(a, b), max(a, b))
if h is None: h = b - a
if h <= tol: return (a, b)
@officialcjunior
officialcjunior / fibonacci-method.py
Created January 1, 2021 12:11
Python script to minimize unimodal expressions using Fibonacci method
import math
def fibu(n):
if n <= 1:
return n
else:
return(fibu(n-1) + fibu(n-2))
#for i in range (10):
# print (i-1, ",", fibu(i))
@officialcjunior
officialcjunior / git-update.sh
Created September 21, 2020 06:01
I use this script to sync my fork with the upstream (original repo).
#!/bin/sh
# fetches the new stuff from upstream. I hope you've added the link to the original repo as 'upstream'
git fetch upstream
git checkout master
# prunes unwanted branches
git fetch --all --prune
# merges without your master
@officialcjunior
officialcjunior / vce-calculator.py
Created July 21, 2020 14:22
A simple python script to calculate voltages and currents when using voltage divider bias. Can be useful when trying to find the DC Load Line. Here, I went with hardcoding the values, as passing by arguments can be difficult in unfortunate times.
#0.7 for Silicon and 0.3 for Germanium diodes
vbe=0.7
vcc=
vbb=
re=
rc=
rb= #*10**3
#put rb=0, if rb isn't there. same for all
@officialcjunior
officialcjunior / power_of_two.c
Last active July 1, 2020 05:19
A program to find the powers of two using bits, without a loop or any other functions.
#include <stdio.h>
int main ()
{
int n, val;
printf("Enter the value for n \n");
scanf("%d",&n);
printf("2^%d is %d \n",n,2<<(n-1));
return 0;
}