Skip to content

Instantly share code, notes, and snippets.

View shubham7298's full-sized avatar
:octocat:
On a coding spree

Shubham Singh shubham7298

:octocat:
On a coding spree
View GitHub Profile
@shubham7298
shubham7298 / Query_params.js
Created August 29, 2018 04:56
Generating Query Params
var params = {
a : any.value,
b : other.value
}; // Add any no. of parameters you want to pass separated using "."
function paramsChange(params){
var queryString = $.param(params);
var queryString = Object.keys(params).map((key) => {
@shubham7298
shubham7298 / QueryString.js
Created August 29, 2018 04:58
Retreiving Values from URL Query
function getQueryStringValue (key) {
return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
}
// Would write the value of the QueryString-variable called name to the console
var quer = getQueryStringValue("a");
@shubham7298
shubham7298 / server.py
Created August 30, 2018 11:53
Socket Programming in Python(server)
# Save as server.py
# Message Receiver
import os
from socket import *
host = ""
port = 13000
buf = 1024
addr = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
UDPSock.bind(addr)
@shubham7298
shubham7298 / client.py
Created August 30, 2018 11:54
Socket Programming in Python(client)
# Save as client.py
# Message Sender
import os
from socket import *
host = "" # set to IP address of target computer
port = 13000
addr = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
while True:
data = raw_input("Enter message to send or type 'exit': ")
@shubham7298
shubham7298 / cors_firebase.txt
Created December 27, 2018 12:10
CORS in firebase cloud functions
const cors = require('cors')({origin: true});
exports.sample = functions.https.onRequest((req, res) => {
cors(req, res, () => {
res.send('Passed.');
});
});
@shubham7298
shubham7298 / email_validate.js
Created December 28, 2018 08:49
Validate email in JS using regex
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
@shubham7298
shubham7298 / singleton.cpp
Last active January 18, 2019 16:51
Attempt to make singleton class in C++
#include<iostream>
using namespace std;
class Singleton
{
private:
static Singleton obj;
Singleton(){
cout<<"Constructor does not get called";
}
@shubham7298
shubham7298 / squah.md
Created January 18, 2019 18:04 — forked from shellkore/squah.md
squash your commits

SQUASH

Whenever you want to squash last commits in a single commit:-

first check your log

git log

CASE 1: your head is at the commit in which you want others to be squashed

import cv2
import numpy as np
import os
import matplotlib.pyplot as plt
from scipy.spatial import distance
folder='cats'
f=os.listdir(folder)
cats=[]
@shubham7298
shubham7298 / index.html
Created February 22, 2019 11:01
BLE Eddystone scanners
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no
initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<title>Sahayak</title>
<script>