Skip to content

Instantly share code, notes, and snippets.

View junaidrahim's full-sized avatar

Junaid Rahim junaidrahim

View GitHub Profile

Keybase proof

I hereby claim:

  • I am junaidrahim on github.
  • I am junaidrahim (https://keybase.io/junaidrahim) on keybase.
  • I have a public key whose fingerprint is 590C EAEF 3016 9B63 A8E5 ADF2 D24A C616 9919 BBDD

To claim this, I am signing this object:

@junaidrahim
junaidrahim / memory_leak.cpp
Last active August 19, 2020 08:20
Memory Leak
int main(){
int *p = new int[10];
// oops forgot to delete p
return 0;
}
@junaidrahim
junaidrahim / shared_ptr_e1.cpp
Last active August 19, 2020 08:01
Shared Pointer Example 1
#include <iostream>
#include <memory>
using namespace std;
class SomeBigObject{
public:
float data[1000];
void something() {
@junaidrahim
junaidrahim / unique_ptr_e3.cpp
Last active August 19, 2020 06:41
Unique Pointer Example 3
#include <iostream>
#include <memory>
using namespace std;
class SomeBigObject{
public:
float data[1000];
void something() {
@junaidrahim
junaidrahim / unique_ptr_e2.cpp
Last active August 19, 2020 09:00
Unique Pointer Example 2
#include <iostream>
#include <memory>
using namespace std;
void DoSomething(){
unique_ptr<int[]> p = make_unique<int[]>(50);
// do some processing with the array
} // p is automatically freed when it goes out of scope.
@junaidrahim
junaidrahim / unique_ptr_e1.cpp
Last active August 19, 2020 08:59
Unique Pointer Example 1
#include <iostream>
using namespace std;
void DoSomething(){
int *p = new int[50];
// do some processing with the array
delete[] p; // free the memory
@junaidrahim
junaidrahim / fancy-fence.cpp
Last active March 24, 2020 10:34
Competitive Programming Example
#include <iostream>
using namespace std;
int main(){
int t;
cin >> t;
int a;
double n;
@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")
@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 / 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}