Skip to content

Instantly share code, notes, and snippets.

View junaidrahim's full-sized avatar

Junaid Rahim junaidrahim

View GitHub Profile
@junaidrahim
junaidrahim / gcdn.cpp
Created September 13, 2018 11:23
GCD of n numbers
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
vector<int> parse_string_to_int(string input,const char* t){ // "1,2,3" => [1,2,3]
char array[input.length()+1];
strcpy(array, input.c_str()); // converting the string into a char[]
@junaidrahim
junaidrahim / encrypt.c
Created November 1, 2018 18:18
Simple Atbash Encryptor in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char atbash_encrypt(char input){
if(input == ' '){
return ' ';
}
char small_letters[26] = {'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'};
@junaidrahim
junaidrahim / spam.py
Created June 6, 2019 05:57
A simple spammer in python
import pyautogui
import time
msg = input("Enter the message: ")
n = input("How many times ?: ")
print("t minus")
count = 5
while(count != 0):
@junaidrahim
junaidrahim / binary_search.cpp
Last active June 11, 2019 15:01
Binary Search
#include <vector>
#include "../include/binary_search.hpp"
int binary_search(std::vector<int> array, int x){
int l = 0;
int r = array.size() - 1;
while (l <= r) {
int m = (l + r) / 2;
@junaidrahim
junaidrahim / test.cpp
Created June 11, 2019 15:06
test.cpp file for the medium post
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include <vector>
#include "../include/binary_search.hpp"
std::vector<int> arr = {10,20,30,40,50,60,70,80,90,100};
TEST_CASE("Testing Binary Search") {
// testing for existing terms
@junaidrahim
junaidrahim / sections.cpp
Created June 11, 2019 15:40
Test cases and sections from the catch2 github repo
TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
std::vector<int> v( 5 );
REQUIRE( v.size() == 5 );
REQUIRE( v.capacity() >= 5 );
SECTION( "resizing bigger changes size and capacity" ) {
v.resize( 10 );
@junaidrahim
junaidrahim / bdd_style_spec.cpp
Created June 11, 2019 15:44
BDD style specification for catch2 medium post
SCENARIO( "vectors can be sized and resized", "[vector]" ) {
GIVEN( "A vector with some items" ) {
std::vector<int> v( 5 );
REQUIRE( v.size() == 5 );
REQUIRE( v.capacity() >= 5 );
WHEN( "the size is increased" ) {
v.resize( 10 );
@junaidrahim
junaidrahim / App.js
Last active March 16, 2020 14:42
React Loader Example 1
import React from "react";
import Loader from "react-loader-spinner";
const App = () => {
return (
<div>
<Loader
type="Puff"
color="#00BFFF"
height={100}
@junaidrahim
junaidrahim / App.js
Created March 16, 2020 14:18
React Loader Example 2
import React, { useState } from "react";
import Loader from "react-loader-spinner";
const App = () => {
const [spinnerLoading, setSpinnerLoading] = useState(true);
return (
<div style={{ textAlign: "center" }}>
<br></br>
<br></br>
@junaidrahim
junaidrahim / server.go
Last active March 18, 2020 07:35
API Example
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there")