Skip to content

Instantly share code, notes, and snippets.

View AshikNesin's full-sized avatar

Ashik Nesin AshikNesin

View GitHub Profile
function detect() {
if (typeof navigator !== 'undefined') {
return parseUserAgent(navigator.userAgent);
}
return getNodeVersion();
}
function detectOS(userAgentString) {
var rules = getOperatingSystemRules();
@AshikNesin
AshikNesin / Sidebar.js
Created July 17, 2018 06:53
React Sidebar
import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
import classNames from "classnames";
class Sidebar extends React.Component {
constructor(props) {
super(props);
this.state = {
showMenu: false
@AshikNesin
AshikNesin / letsencrypt_2017.md
Created April 8, 2018 09:46 — forked from cecilemuller/letsencrypt_2020.md
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 mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@AshikNesin
AshikNesin / file-upload-local-url.js
Created March 21, 2018 13:14
Get URL of the selected file
$('#file-upload').change(function(e) {
const file = e.target.files[0]
console.log(URL.createObjectURL(file))
});
<VirtualHost *:80>
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=308,L]
</VirtualHost>
@AshikNesin
AshikNesin / chrome-extension.js
Created July 19, 2017 06:44
Chrome Extension Close Current Page
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
chrome.tabs.remove(tabs[0].id);
});
@AshikNesin
AshikNesin / model-stop-video.js
Created June 16, 2017 06:50
Stop video if the model is closed
$(document).ready(function(){
$('.modal').each(function(){
var src = $(this).find('iframe').attr('src');
$(this).on('click', function(){
$(this).find('iframe').attr('src', '');
$(this).find('iframe').attr('src', src);
});
@AshikNesin
AshikNesin / esnextbin.md
Created June 15, 2017 07:06
esnextbin sketch
@AshikNesin
AshikNesin / validateEmail.js
Created May 27, 2017 06:38 — forked from oscarmorrison/validateEmail.js
ES6 email validation
// regex from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
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
AshikNesin / async-await-playground.js
Created May 4, 2017 13:00
[Playground] Asynchronous JavaScript with async/await course
// https://egghead.io/courses/asynchronous-javascript-with-async-await
const fetch = require('node-fetch')
const fetchGitHubUser = async (handle) => {
const url = `https://api.github.com/users/${handle}`
const response = await fetch(url)
const body = await response.json()
if (response.status !== 200){
throw Error(body.message)