Skip to content

Instantly share code, notes, and snippets.

View memandip's full-sized avatar
🎯
Focusing

Mandip Tharu memandip

🎯
Focusing
  • Kathmandu, Nepal
View GitHub Profile
@memandip
memandip / uninstall bloatware
Created March 9, 2020 07:09
Uninstall system apps android
# start usb debugging mode
# type adb shell which will open adb console
# pm list packages
# pm uninstall -k --user 0 'packagename'
@memandip
memandip / print.js
Created January 10, 2020 08:57
Print Preview (JS)
let myWindow = window.open('', 'PRINT', 'height=auto,width=auto')
myWindow.document.write('
<!doctype html>
<head>
<title>My github homepage</title>
</head>
<body>
<h1>Stay tuned.</h1>
</body>
</html>
@memandip
memandip / doctrine_full_name_search
Last active December 12, 2019 05:45
Search by full name (first middle last) Doctrine Query
@memandip
memandip / youtubeplayer.html
Last active September 1, 2019 07:19
Pause Youtube Video on link click
<!DOCTYPE html>
<html>
<head>
<title>YouTube Video Pause</title>
<style type="text/css">
.col-md-8{
width: 75%;
float:left;
}
.col-md-4{
@memandip
memandip / io-wss
Created July 31, 2019 06:08
Socket.io https websocket server with custom web socket url
const fs = require('fs')
const https = require('https')
const app = require('express')()
var privateKey = fs.readFileSync('./privatekey.pem', 'utf8')
var certificate = fs.readFileSync('./certificate.pem', 'utf8')
const credentials = {key: privateKey, cert: certificate}
const httpsServer = https.createServer(credentials, app)
@memandip
memandip / index.html
Last active July 26, 2019 12:26
Send file with websocket
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Node JS WebSocket Upload</title>
</head>
@memandip
memandip / nginx-proxy-websocket
Last active July 26, 2019 08:50
Nginx configuration to configure reverse proxy for websocket
server {
root projectDirectory;
# example root /var/www/html/myAwesomeProject/public;
index index.html;
server_name domain_name;
location /chat/socket {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@memandip
memandip / index.html
Created July 25, 2019 12:18
Ajax based file upload in nodejs with express-fileupload
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Node JS File Upload</title>
</head>
@memandip
memandip / filedownload.php
Created July 10, 2019 08:52
PHP file download
<?php
$filename = 'filepath.html';
$path = __DIR__ . '/web/uploads/';
$download_file = $path . $filename;
if (file_exists($download_file)) {
$extension = explode('.', $filename);
$extension = $extension[count($extension) - 1];
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
header('Accept-Ranges: bytes');
@memandip
memandip / getPrevCursorWord.html
Last active July 8, 2019 06:48
Get nearest word of the cursor position in textbox
<!DOCTYPE html>
<html lang="en">
<head>
<title>Get Nearest word of cursor</title>
</head>
<body>
<input id="textArea" type="text"/>
<br />