Skip to content

Instantly share code, notes, and snippets.

@nandanhere
nandanhere / kivyapp-to-apk-for-kivytimetable.ipynb
Last active January 31, 2022 05:41
KivyApp to APK For KivyTimetable.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nandanhere
nandanhere / RandomStringGenerator.swift
Created March 7, 2021 06:53
Random string generator in swift
import Foundation
func randomStringGenerator(number : Bool, whiteSpace : Bool, specialCharacters : Bool,upperCase : Bool, size : Int) -> String
{
var returnString = ""
let specialCharactersArray : [Character] = [",","<",".","?",">","/","\"","|","[","]",";",":","\'","\"",]
let numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
let letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
let uppercase = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
while(returnString.count != size){
@nandanhere
nandanhere / Combinatronics.swift
Created October 24, 2020 15:00
Combinatronics formulae in swift #Combinatronics #Swift
func factorial(_ number: Int) -> Int {
var fact = 1
for n in 1..<number {
fact = fact + fact * n
}
@nandanhere
nandanhere / Readline
Last active October 29, 2020 04:20 — forked from TheNova22/Readline
Readline Operations
// vim: syntax=swift
let line = Int(readLine()!)!
let line1 = readLine()!.split(separator: " ").map{ Int(String($0))! }
let numbers = readLine()!.components(separatedBy: [" "]).map { Int($0)! }
// to print a double / float with x precision
print(format:"%.xf",double_variable_here)
@nandanhere
nandanhere / runge_kutta_4th_order_method.swift
Created September 23, 2020 06:12
[Solve a differential equation using 4th order Runge kutta method] An algorithm to solve a Differential equation given the points of x and initial value of y #swift #differential_equations
// Solving a differential equation using 4th order runge kutta method
///ALL VARIABLES ARE TO BE IN DOUBLE
/// note the given values are an example. you can replace your own values if you want
let xes :[Double] = [0.0,0.1] // you must input the xn values you want to calculate for
var yn = 1.0 // initial value of y (y0)
@nandanhere
nandanhere / regularFalsiMethod.swift
Created September 19, 2020 10:25
[Regular Falsi Method] Algorithm to calculate the root of the given equation using swift #swift #regularfalsimethod
import Foundation
import Darwin
let e = Darwin.M_E
let pi = Double.pi
// attempt to make newton rhapson method derived algo
// note that the trignometric values are in radians
// How to represent certain functions :
/// log base 10 : log10(float)
/// log base e : log(float)
/// power to function : pow(x, y) -> gives x ^ y
@nandanhere
nandanhere / newton_rhapson_method.swift
Last active September 19, 2020 10:25
[Newton Rhapson method in swift] A simple program to print the values obtained in newton rhapson method till the desired value is met till the given precision value #swift #newton_rhapson_method #iteration
import Foundation
import Darwin
let e = Darwin.M_E
let pi = Double.pi
// attempt to make newton rhapson method derived algo
// note that the trignometric values are in radians
// How to represent certain functions :
/// log base 10 : log10(float)
/// log base e : log(float)
@nandanhere
nandanhere / Json_from_api.dart
Created July 22, 2020 17:45
How to use Future and async property to get a .json file from an api #basics #flutter
///First Obtain an api link with your key: when the api link is called a json file will be sent to the caller. the json file is in an unprocessed format so you will convert it.
///Since you are calling the api through a network, the app is subject to certain errors and linking problems, so we use something called Future, IE the state of the object is set sometime in the future.
///To declare a widget that uses a future state, we use something called a futureBuilder.Essentialy a futureBuilder takes the state of something, and if it has a future and if it has obtained it, it will update it. so you dont have to worry about setstate stuff.
import 'package:flutter/material.dart';
///Note: you need these imports to make it work
@nandanhere
nandanhere / important.c
Created June 23, 2020 12:52
Some C ideas
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
// function to check if the number entered is prime or not
int prime(int b)
{int i,truth = 1;
for(i = 2;i<(b/2);i++)
{
if(b%i == 0)