Skip to content

Instantly share code, notes, and snippets.

View sandy98's full-sized avatar

Domingo Ernesto Savoretti sandy98

View GitHub Profile
@sandy98
sandy98 / ajax-file-download.js
Created July 3, 2021 03:11 — forked from jasonweng/ajax-file-download.js
handle file download from AJAX POST
// XMLHttpRequest
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
if (this.status === 200) {
var filename = "";
var disposition = xhr.getResponseHeader('Content-Disposition');
if (disposition && disposition.indexOf('attachment') !== -1) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
@sandy98
sandy98 / calculadora-de-cuil.markdown
Last active May 27, 2019 18:25
Calculadora de CUIL
@sandy98
sandy98 / index.html
Last active April 19, 2018 16:50
Vue.js Test I
<div id="app">
<h2>{{ title }}</h2>
<p>
<span class= "bordered">
{{ count }}
</span>
&nbsp;&nbsp;&nbsp;
<button v-on:click="count += 10">
+ 10
</button>
@sandy98
sandy98 / hanoi.clj
Created February 7, 2016 11:12
Tower of Hanoi - Clojure(script) version.
(defn hanoi
([n] (hanoi n 1 2 3 '()))
([n from aux to moves]
(if (= 1 n) (cons (list from to) moves)
(let [moves (hanoi (dec n) aux from to moves)]
(let [moves (cons (list from to) moves)]
(let [moves (hanoi (dec n) from to aux moves)]
moves))))))
@sandy98
sandy98 / dump-1452058050251.cljs
Created January 6, 2016 05:27
ClojureScript REPL dump
cljs.user=> (+ 3 4)
7
cljs.user=> (char 9812)
"♔"
cljs.user=> (unicode 65)
ERROR - Cannot read property 'call' of undefined
cljs.user=> (map char (range 9812 9824))
("♔" "♕" "♖" "♗" "♘" "♙" "♚" "♛" "♜" "♝" "♞" "♟")
@sandy98
sandy98 / uno_connector.py
Last active July 15, 2021 01:17
Utility class to handle LibreOffice spreadsheets from python-uno
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import uno
from com.sun.star.beans import PropertyValue
from pythonscript import ScriptContext
import os
import sys
import time
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@sandy98
sandy98 / sqrt.py
Created May 2, 2012 08:29
Square root (method by Hal Abelson in SICP MIT course) - Python and Scheme version.
def average(v1, v2):
return (v1 + v2) / 2.0
def square(n):
return n * n
def sqrt(n):
def improve(guess):
return average(guess, n / guess)
def good_enough(guess):
@sandy98
sandy98 / test_timer.coffee
Created April 27, 2012 23:42
Testing Iced CoffeeScript
#!/usr/bin/env iced
# only Iced CoffeeScript (http://maxtaco.github.com/coffee-script/) will be able
# to run this, as await and defer are not yet included in
#mainstream CoffeeScript, at least, as of 2012-04-27
acum = 0
interval = parseInt(process.argv[2]) or 1000
console.log "Starting counter"
for n in [1..5]
await setTimeout(defer(), interval)
@sandy98
sandy98 / factorial.clj
Created May 24, 2011 19:11
Simple Clojure snippets
(defn factorial [n]
(reduce * (range 1 (inc n))))