Skip to content

Instantly share code, notes, and snippets.

Avatar
🌎

Aswin C officialcjunior

🌎
View GitHub Profile
@officialcjunior
officialcjunior / linked-list.rs
Created Jul 11, 2021
Implementation of a singly linked list in Rust using smart pointers(Box)
View linked-list.rs
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 / golden-section-method.py
Created Jan 1, 2021
Python script to find the minimize unimodal expressions using the golden section method | optimization technique
View golden-section-method.py
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 Jan 1, 2021
Python script to minimize unimodal expressions using Fibonacci method
View fibonacci-method.py
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 Sep 21, 2020
I use this script to sync my fork with the upstream (original repo).
View git-update.sh
#!/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 / frama-c.md
Last active Oct 9, 2021
A small how-to on installing frama-c, the source code analyzer on Unix systems.
View frama-c.md

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 / vce-calculator.py
Created Jul 21, 2020
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.
View vce-calculator.py
#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 / shitposter.py
Created May 31, 2020
shitposter.py posts a shitpost on Mastodon.
View shitposter.py
# shitposter.py
# Requirements : Toot https://github.com/ihabunek/toot and a Unix-like system
import urllib.request
import random
import subprocess
word_url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
response = urllib.request.urlopen(word_url)
@officialcjunior
officialcjunior / gitlab-mr-automation-script.py
Last active May 31, 2020
Create a Merge Reqest in Gitlab from the terminal.
View gitlab-mr-automation-script.py
import subprocess
import os
branch_name=input("Enter the target branch name, I mean, => target-repository:")
title=input("Enter the title or the Merge Request\n")
description=input("Enter description \n")
bool_origin=input("Is this branch already added in remote? (y/n) \n")
if bool_origin=='n':
origin = input("Input the branch name \n")
@officialcjunior
officialcjunior / 1244B.c
Created Mar 24, 2020
Solution to 1244B of the codeforces problemset
View 1244B.c
#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];
View Avial-downloader.md

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.