Skip to content

Instantly share code, notes, and snippets.

@ashramwen
ashramwen / .gitignore
Created February 9, 2021 08:56 — forked from andreasonny83/.gitignore
Gitignore template for JavaScript projects
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Runtime data
pids
*.pid
@ashramwen
ashramwen / detect-history-state.js
Last active January 28, 2021 03:10 — forked from rudiedirkx/detect-history-state.js
Detect pushState and replaceState
var _wr = function(type) {
var orig = history[type];
return function() {
var rv = orig.apply(this, arguments);
var e = new Event(type);
e.arguments = arguments;
window.dispatchEvent(e);
return rv;
};
};
@ashramwen
ashramwen / download-file.js
Created October 6, 2020 02:51 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@ashramwen
ashramwen / gh-pages-deploy.md
Last active June 5, 2020 02:43 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the build directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@ashramwen
ashramwen / git-delete-local-tag.sh
Created March 3, 2020 03:48 — forked from canhnt/git-delete-local-tag.sh
Delete local tags that do not exist in remote
git fetch --prune origin "+refs/tags/*:refs/tags/*"
@ashramwen
ashramwen / jsnote.js
Created September 24, 2017 13:11 — forked from mason276752/jsnote.js
你平常不會用到的js
str1 = "http://www.google.tw/search?q=中文";
obj = {
get a(){return '1';},
set b(value){this.c = value;},
c:1
};
class Cls{
constructor(name){
console.log("hello",name);
if (typeof(new.target)==='function')