Skip to content

Instantly share code, notes, and snippets.

View rajaishwary's full-sized avatar
:octocat:
Focusing

Aishwary Raj rajaishwary

:octocat:
Focusing
View GitHub Profile
@rajaishwary
rajaishwary / download_image.py
Created September 10, 2019 07:30 — forked from mjdietzx/download_image.py
Download image from url and save as file
import io
from PIL import Image # https://pillow.readthedocs.io/en/4.3.x/
import requests # http://docs.python-requests.org/en/master/
# example image url: https://m.media-amazon.com/images/S/aplus-media/vc/6a9569ab-cb8e-46d9-8aea-a7022e58c74a.jpg
def download_image(url, image_file_path):
r = requests.get(url, timeout=4.0)
if r.status_code != requests.codes.ok:
@rajaishwary
rajaishwary / Redis.sh
Created August 19, 2019 21:57 — forked from nrollr/Redis.sh
Install Redis via Homebrew
#!/bin/bash
brew install redis # Install Redis using Homebrew
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents # Enable Redis autostart
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist # Start Redis server via launchctl
# homebrew.mxcl.redis.plist contains reference to redis.conf file location: /usr/local/etc/redis.conf
redis-server /usr/local/etc/redis.conf # Start Redis server using configuration file, Ctrl+C to stop
redis-cli ping # Check if the Redis server is running
@rajaishwary
rajaishwary / gist:3baa2b90655f16683b2889d66bb29cdb
Created August 2, 2017 14:49
[React-Native] Open navigation GMaps by default if exists otherwise open Apple maps
openMaps(lat, long) {
//Try to open GMaps by default if exists otherwise open Apple maps
Linking.canOpenURL(`comgooglemaps://?saddr=My+Location&daddr=${lat},${long}`).then(supported => {
if (supported) {
Linking.openURL(`comgooglemaps://?saddr=My+Location&daddr=${lat},${long}`);
} else {
Linking.openURL(`http://maps.apple.com/?daddr=${lat},${long}`);
}
}).catch(err => console.error('An error occurred', err));
}
@rajaishwary
rajaishwary / gcd.cpp
Last active August 29, 2015 14:14 — forked from mycodeschool/gcd.cpp
#include<algorithm>
using namespace std;
int euclid_gcd(int a, int b)
{
while (b != 0)
{
int r = a % b;
a = b;
// Stack - Array based implementation.
// Creating a stack of integers.
#include<stdio.h>
#define MAX_SIZE 101
int A[MAX_SIZE]; // integer array to store the stack
int top = -1; // variable to mark top of stack in array
// Push operation to insert an element on top of stack.
// Stack - Object oriented implementation using arrays
#include <iostream>
using namespace std;
#define MAX_SIZE 101
class Stack
{
private:
int A[MAX_SIZE]; // array to store the stack
int top; // variable to mark the top index of stack.
/*
C++ Program to check for balanced parentheses in an expression using stack.
Given an expression as string comprising of opening and closing characters
of parentheses - (), curly braces - {} and square brackets - [], we need to
check whether symbols are balanced or not.
*/
#include<iostream>
#include<stack>
#include<string>
using namespace std;
/* Queue - Circular Array implementation in C++*/
#include<iostream>
using namespace std;
#define MAX_SIZE 101 //maximum size of the array that will store Queue.
// Creating a class named Queue.
class Queue
{
private:
int A[MAX_SIZE];
/* Doubly Linked List implementation */
#include<stdio.h>
#include<stdlib.h>
struct Node {
int data;
struct Node* next;
struct Node* prev;
};
/*Queue - Linked List implementation*/
#include<stdio.h>
#include<stdlib.h>
struct Node {
int data;
struct Node* next;
};
// Two glboal variables to store address of front and rear nodes.
struct Node* front = NULL;
struct Node* rear = NULL;