Skip to content

Instantly share code, notes, and snippets.

View zaingz's full-sized avatar
🤔
thinking...

Zain Zafar zaingz

🤔
thinking...
View GitHub Profile
class Queue {
constructor() {
this.items = [];
}
isEmpty() {
return this.items.length == 0;
}
class Stack {
constructor() {
this.items = [];
this.top = null;
}
getTop() {
if (this.items.length == 0)
return null;
return this.top;
class Node {
constructor (data) {
this.data = data
this.nextNode = null
}
}
class LinkedList {
constructor(){
import { useState, useEffect } from 'react'
import axios, { CancelToken } from 'axios'
export default function useFetch (options) {
const [data, setData] = useState(null)
const [isLoading, setIsLoading] = useState(false)
const [error, setError] = useState(null)
useEffect(_ => {
const source = CancelToken.source();
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'csv'
require "pathname"
require "http"
@zaingz
zaingz / sms.rb
Last active August 2, 2017 13:41
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'csv'
require "pathname"
require "em-http-request"
require "date"
package com.zaingz.test;
import java.util.LinkedList;
import java.util.Queue;
public class NestedArrays {
public static void main(String[] args) {
//sample for this output [[1,2,[3]],4] -> [1,2,3,4]
Object[] objArr = new Object[2];
@zaingz
zaingz / include_guards_insertion.rb
Created January 11, 2016 11:49
This SCRIPT finds all the .h files in a current directory and add include guard macro on the basis of filename.
def update_file(file_name, incl)
file = File.open(file_name, "r")
data = file.read
file.close
unless data.include? "#ifndef"
final_data = "#ifndef #{incl}\n#define #{incl}\n#{data}\n#endif\n/*Include guards add by Zain*/"
file = File.open(file_name, "w+")
file.write(final_data)
file.close