Skip to content

Instantly share code, notes, and snippets.

View xettri's full-sized avatar
🍻
Chill And Code

Bharat Rawat xettri

🍻
Chill And Code
View GitHub Profile
@xettri
xettri / bvalid.h
Created January 28, 2020 20:50
Data validation in c++. A simple way to check type of data
#include <bits/stdc++.h>
using namespace std;
class bvalid
{
public:
template <class T>
string typeOf(T var) {
string ty = typeid(var).name();
string r;
if(ty == "i"){
@xettri
xettri / http-clone-server.py
Created February 21, 2020 07:31
http clone server
from http.server import BaseHTTPRequestHandler, HTTPServer
from requests import Session
import webbrowser
from cgi import parse_header, parse_multipart
from urllib.parse import parse_qs
from socketserver import ThreadingMixIn
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
}
@xettri
xettri / fibonacci_series_dynamic_with_array.py
Created March 18, 2020 10:40
One of fastest way for Fibonacci series
r = 1000
m = []
def fibo(n):
if len(m) == 0:
m[:r] = [0] * r;
if n == 1 or n == 2:
m[n] = n
return n
else:
a1 = m[n - 1]
@xettri
xettri / ubuntu-remove-cache.sh
Created April 22, 2020 11:49
bash file to clear system ram cache, swap and remove packages cache
su -c "echo 3 >'/proc/sys/vm/drop_caches' && swapoff -a && swapon -a && printf '\n%s\n' 'Ram cache and swap Cleared'" root
apt-get clean
apt-get autoremove --purge
[
{ offset: 'GMT-11:00', label: 'Niue (GMT-11:00)', name: 'Pacific/Niue' },
{ offset: 'GMT-11:00', label: 'Pago Pago (GMT-11:00)', name: 'Pacific/Pago_Pago' },
{ offset: 'GMT-10:00', label: 'Hawaii Time (GMT-10:00)', name: 'Pacific/Honolulu' },
{ offset: 'GMT-10:00', label: 'Rarotonga (GMT-10:00)', name: 'Pacific/Rarotonga' },
{ offset: 'GMT-10:00', label: 'Tahiti (GMT-10:00)', name: 'Pacific/Tahiti' },
{ offset: 'GMT-09:30', label: 'Marquesas (GMT-09:30)', name: 'Pacific/Marquesas' },
{ offset: 'GMT-09:00', label: 'Alaska Time (GMT-09:00)', name: 'America/Anchorage' },
{ offset: 'GMT-09:00', label: 'Gambier (GMT-09:00)', name: 'Pacific/Gambier' },
{ offset: 'GMT-08:00', label: 'Pacific Time (GMT-08:00)', name: 'America/Los_Angeles' },
[
{ offset: 'GMT-11:00', label: 'Niue (GMT-11:00)', name: 'Pacific/Niue' },
{ offset: 'GMT-11:00', label: 'Pago Pago (GMT-11:00)', name: 'Pacific/Pago_Pago' },
{ offset: 'GMT-10:00', label: 'Hawaii Time (GMT-10:00)', name: 'Pacific/Honolulu' },
{ offset: 'GMT-10:00', label: 'Rarotonga (GMT-10:00)', name: 'Pacific/Rarotonga' },
{ offset: 'GMT-10:00', label: 'Tahiti (GMT-10:00)', name: 'Pacific/Tahiti' },
{ offset: 'GMT-09:30', label: 'Marquesas (GMT-09:30)', name: 'Pacific/Marquesas' },
{ offset: 'GMT-09:00', label: 'Alaska Time (GMT-09:00)', name: 'America/Anchorage' },
{ offset: 'GMT-09:00', label: 'Gambier (GMT-09:00)', name: 'Pacific/Gambier' },
{ offset: 'GMT-08:00', label: 'Pacific Time (GMT-08:00)', name: 'America/Los_Angeles' },
@xettri
xettri / chrome-ubuntu.txt
Created May 30, 2020 01:22
Command to upgrade chrome in Ubuntu
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
# Install
sudo apt-get install google-chrome-stable
# Update
sudo apt-get --only-upgrade install google-chrome-stable
@xettri
xettri / compress-image.js
Created September 22, 2020 22:10
Compress image using NodeJs
const fs = require("fs");
const imagemin = require("imagemin");
const mozjpeg = require("imagemin-mozjpeg");
const imageminWebp = require('imagemin-webp');
const sharp = require("sharp");
const isJpg = require("is-jpg");
const NEED_FORMAT = "jpeg";
const convertToFormat = async (input) => {
@xettri
xettri / resize-image.py
Created September 22, 2020 23:41
Resize and compress image using python
from __future__ import division
from PIL import Image, ImageOps
import os, sys
HEIGHT = 675
WIDTH = 540
QUALITY = 60
OUTPUT_TYPE = "jpeg"
def getSize(i):
from __future__ import division
from PIL import Image, ImageOps
import os, sys
import uuid
import requests
from io import BytesIO
#========================
HEIGHT = 675
WIDTH = 540