Skip to content

Instantly share code, notes, and snippets.

View facugon's full-sized avatar

facugon facugon

View GitHub Profile
@facugon
facugon / forceDownload.js
Created January 29, 2021 14:42
force web download
page.evaluate( () => {
function onStartedDownload(id) {
console.log(`Started downloading: ${id}`);
}
function onFailed(error) {
console.log(`Download failed: ${error}`);
}
@facugon
facugon / ajaxFileDownload.js
Created January 29, 2021 12:41
ajax file download
/**
* create a link and force download
*/
function forceDownload () {
var a = document.createElement('a');
var url = window.URL.createObjectURL(data);
a.href = url;
a.download = 'myfile.pdf';
document.body.append(a);
a.click();
@facugon
facugon / encodedtitle.sh
Last active October 19, 2018 20:21
URL Encode Alternatives
title="something horrible!"
encodedtitle=`echo "$title" | jq -s -R -r @uri`
# need to install URI::Escape
#perl -MURI::Escape -e 1
#if [ $? != 0 ];
#then
# echo "installing dependencies"
# PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install URI::Escape'
@facugon
facugon / .vimrc
Created May 25, 2018 13:33
my .vimrc
" Press F2 during insert mode to enable or disable the set paste, when paste code from external non console sources
set pastetoggle=<F2>
" para el javascript indent
"let g:js_indent_log = 0
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
@facugon
facugon / .bash_aliases
Last active May 25, 2018 13:31
My .bashrc
# vi:syntax=sh
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep -n --color=auto'
@facugon
facugon / git.sh
Created February 28, 2017 15:46
Git Helpers
# git log deferences and pretty print to commit description
git log development ^master --pretty=oneline --abbrev-commit --no-merges
@facugon
facugon / FileActions.js
Last active January 20, 2017 20:14
a POC of an store using backbone.collections implementing a flux dispatcher
'use strict';
var FileActions = {
create: function(data,source){
App.EventsDispatcher.dispatch({
actionType: App.Constants.FILE_CREATE,
properties: data,
source: source
});
},
@facugon
facugon / SocketConnector.js
Last active November 24, 2016 21:43
simple socket wrapper. trigger an event on every new received socket message.
/**
* @author Facugon
* Simple socket connector.
* how to use
*
* // connect sockets and start listening to events
* SocketsConnector({
* io: window.io,
* channel:'/socket/subscribe',
* query: {
@facugon
facugon / modal.hbs
Last active January 13, 2017 01:37
modal component based on bootstrap modal
<div class="modal fade" id="modal_{{ id }}" role="dialog" tabindex="-1">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{ title }}</h4>
</div>
<div data-hook="container" class="modal-body"> </div>
@facugon
facugon / Backbone.ViewAddons.js
Created November 24, 2016 12:27
extended backbone.view with some usefull addons (some of them based on ampersand-view)
/**
* @author Facugon
*
*
* simple collection render, does not do much. do the basics.
* extend as you wish , and let me know if you can add some improvements
*
*/
function CollectionRenderer (specs) {
var View = specs.View;