Skip to content

Instantly share code, notes, and snippets.


Ashik Nesin AshikNesin

View GitHub Profile
View browser-detect.js
function detect() {
if (typeof navigator !== 'undefined') {
return parseUserAgent(navigator.userAgent);
return getNodeVersion();
function detectOS(userAgentString) {
var rules = getOperatingSystemRules();
View Sidebar.js
import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
import classNames from "classnames";
class Sidebar extends React.Component {
constructor(props) {
this.state = {
showMenu: false
AshikNesin /
Created Apr 8, 2018 — forked from cecilemuller/
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

AshikNesin / file-upload-local-url.js
Created Mar 21, 2018
Get URL of the selected file
View file-upload-local-url.js
$('#file-upload').change(function(e) {
const file =[0]
AshikNesin / base64-form-data.js
Last active May 23, 2021
Base64 image to multipart/form-data
View base64-form-data.js
const base64 = 'data:image/png;base64,....' // Place your base64 url here.
.then(res => res.blob())
.then(blob => {
const fd = new FormData();
const file = new File([blob], "filename.jpeg");
fd.append('image', file)
// Let's upload the file
// Don't set contentType manually →
AshikNesin / chrome-extension.js
Created Jul 19, 2017
Chrome Extension Close Current Page
View chrome-extension.js
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
AshikNesin / model-stop-video.js
Created Jun 16, 2017
Stop video if the model is closed
View model-stop-video.js
var src = $(this).find('iframe').attr('src');
$(this).on('click', function(){
$(this).find('iframe').attr('src', '');
$(this).find('iframe').attr('src', src);
View validateEmail.js
// regex from
const EMAIL_REGEX = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
const validateEmail = email => {
return email
&& email.length < 255
&& EMAIL_REGEX.test(email);
export default validateEmail;
AshikNesin / async-await-playground.js
Created May 4, 2017
[Playground] Asynchronous JavaScript with async/await course
View async-await-playground.js
const fetch = require('node-fetch')
const fetchGitHubUser = async (handle) => {
const url = `${handle}`
const response = await fetch(url)
const body = await response.json()
if (response.status !== 200){
throw Error(body.message)