Skip to content

Instantly share code, notes, and snippets.

View Parassharmaa's full-sized avatar
🎯
Focusing

Paras Sharma Parassharmaa

🎯
Focusing
View GitHub Profile
@Parassharmaa
Parassharmaa / promise_example.js
Last active July 2, 2017 11:49
Promise in node
const https = require('https');
let user = (name) => {
const url = `https://www.instagram.com/${name}/?__a=1`;
//return promise
return new Promise((resolve, reject) => {
const request = https.get(url, response => {
if (response.statusCode < 200 || response.statusCode > 299) {
//reject promise on error
reject(new Error('Failed to load page, status code: ' + response.statusCode));
@Parassharmaa
Parassharmaa / callback.js
Created July 2, 2017 11:42
Asynchronous nature of javascript
const https = require("https")
// https request to api server
https.get("https://api.github.com/users/parassharmaa", (response) => {
//callback function which is asynchronous and non-blocking
console.log(response.statusCode);
})
@Parassharmaa
Parassharmaa / image-processing-numpy.ipynb
Created July 11, 2017 09:47
Image Processing in numpy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Parassharmaa
Parassharmaa / Dockerfile
Last active August 15, 2017 15:29
Docker : Python Flask Deployment
FROM python:3.4
RUN pip install Flask==0.10.1 uWSGI==2.0.8
WORKDIR /app
COPY app /app
CMD ["uwsgi", "--http", "0.0.0.0:9090", "--wsgi-file", "/app/server.py", \
"--callable", "app", "--stats", "0.0.0.0:9191"]
@Parassharmaa
Parassharmaa / algorithms.py
Created September 6, 2017 17:41
Experiments with algorithms (Divide and conquer, Knapsack)
import timeit
from random import randint
def selection_sort(l):
for i in range(len(l)):
j = i
for k in range(i+1, len(l)):
if l[k] < l[j]:
j = k
l[i], l[j] = l[j], l[i]
@Parassharmaa
Parassharmaa / Output.txt
Last active September 7, 2017 16:39
Loops vs. Recursion
Testing for 100 items
-----
Time Take by loop: 8.668698137626052e-05
Time Take by recursion: 0.00011143798474222422
Testing for 100 items
-----
Time Take by loop: 8.37119878269732e-05
Time Take by recursion: 0.00011085800360888243
Testing for 10000 items
-----
@Parassharmaa
Parassharmaa / conf
Created December 16, 2017 09:12
Configuration for reverse proxy nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name <domain_name>.com www.<domain_name>.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
@Parassharmaa
Parassharmaa / export_mongodb.py
Last active January 21, 2023 16:34
Python script to export MongoDB collections to JSON file
import os
host = ""
username = ""
password = ""
directory_to_export = ""
database = ""
all_collections = []
@Parassharmaa
Parassharmaa / Settings.js
Created January 22, 2018 10:46
React Settings UI/UX
import React, { Component } from 'react';
import { AppRegistry, TextInput, View,Text, StyleSheet, Switch, TouchableOpacity } from 'react-native';
export default class UselessTextInput extends Component {
constructor(props) {
super(props);
this.state = {
emailOpt: true,
pushOpt: true
};
@Parassharmaa
Parassharmaa / BowTie.java
Last active February 13, 2018 11:22
Practice: Java Programs
public class BowTie {
public static void main(String args[]) {
int n = Integer.parseInt(args[0]);
for(int i=0; i<2*n+1; i++) {
for(int j=0; j<2*n+1; j++) {
if ((j>i && j<2*n-i) || (j>(2*n-i) && j<i && i>n))
System.out.print(" . ");
else
System.out.print(" * ");
}