Skip to content

Instantly share code, notes, and snippets.

View AshikNesin's full-sized avatar

Ashik Nesin AshikNesin

View GitHub Profile
@AshikNesin
AshikNesin / export.js
Created April 20, 2022 19:19 — forked from katoen/export.js
Export Wallet by BudgetBakers records to JSON
// Source for Jake Archibald's idb https://github.com/jakearchibald/idb/blob/v3.0.2/build/idb.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.idb = {}));
}(this, function (exports) { 'use strict';
function toArray(arr) {
return Array.prototype.slice.call(arr);
}
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))
});
@AshikNesin
AshikNesin / base64-form-data.js
Last active December 19, 2023 06:08
Base64 image to multipart/form-data
const base64 = 'data:image/png;base64,....' // Place your base64 url here.
fetch(base64)
.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 → https://github.com/github/fetch/issues/505#issuecomment-293064470
@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;