Skip to content

Instantly share code, notes, and snippets.

View thelinuxpoint's full-sized avatar
🧑‍🔧
Developing

Prakash Choudhary thelinuxpoint

🧑‍🔧
Developing
  • India
  • 17:56 (UTC +05:30)
View GitHub Profile
puts "Hello World" # this function append a new line character
print "Hello World" # this function doesn't
# declearing global variable with $ before variable
$global_var = 2
# declearing constants with Upper case Letters
CONST = 4
# declearing Integer
x = 1
# declearing Floating point integer
y = 1.2
# declearing String
z = "this is a string"
# Defining a Funcion Normally
def foo()
1 # if there is no semicolon at the last line then the last line is return as function's return value
end # this denotes the function has ended
# Defining Function with Arguements
def sum(x,y)
x+y # x+y is returned
end
# Defining Function with Arguements without paranthesis
#!/usr/bin/python3
def cool():
print("Sha Bang Example")
cool()
#!/bin/bash
# write the complete path
read -p "Search For File: " x;
# -a flag to see if file exists
if [ -a $x ] ; then
echo "File Exists"
else
echo "File Not Found"
fi
#!/bin/bash
read -p "Type Two numbers with spaces : " x y
if [ $x -gt $y ] ; then
echo "$x is greater than $y"
elif [ $y -gt $x ] ; then
echo "$y is greater than $x"
elif [ $x -eq $y ] ; then
echo "$x is equal to $y"
#!/bin/bash
echo -n "Enter the name of an animal: "
read ANIMAL
echo -n "The $ANIMAL has "
case $ANIMAL in
horse | dog | cat) echo -n "four";;
man | kangaroo ) echo -n "two";;
*) echo -n "an unknown number of";;
esac
#!/bin/bash
echo "Select any one interface :";
interface=""
for iface in $(ifconfig | cut -d ' ' -f1| tr ':' '\n' | awk NF)
do
interface+="$iface"
interface+=" "
done
# it splits strings using whitespace as delimeter and shows us which one to select using digits
[A]
2975c.v.fwmrm.net=127.0.0.1
2mdn.net=127.0.0.1
ad.doubleclick.net=127.0.0.1
ad-g.doubleclick.net=127.0.0.1
ad.mo.doubleclick.net=127.0.0.1
ads.doubleclick.net=127.0.0.1
adservice.google.com=127.0.0.1
ads.youtube.com=127.0.0.1
ad.youtube.com=127.0.0.1
@thelinuxpoint
thelinuxpoint / ext.rs
Last active July 20, 2022 19:09
Rust STM32f103c8 external interrupt demo
#![no_std]
#![no_main]
use panic_halt;
use cortex_m::asm::delay;
use cortex_m_rt::entry; // The runtime
use embedded_hal::digital::v2::OutputPin; // the `set_high/low`function
use stm32f1xx_hal::{delay::Delay, pac, prelude::*}; // STM32F1 specific functions
use stm32f1xx_hal::usb::{Peripheral, UsbBus};