Skip to content

Instantly share code, notes, and snippets.

@mderazon
mderazon / export-to-csv.gs
Last active April 2, 2024 22:25
Google apps script to export to individual csv files all sheets in an open spreadsheet
/*
* script to export data in all sheets in the current spreadsheet as individual csv files
* files will be named according to the name of the sheet
* author: Michael Derazon
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var csvMenuEntries = [{name: "export as csv files", functionName: "saveAsCSV"}];
ss.addMenu("csv", csvMenuEntries);
@mderazon
mderazon / json_i18n.js
Last active March 28, 2024 09:59
JSON i18n
var traverse = require('traverse');
// filter json obj by language
var filter_language = function(language, obj) {
var result = traverse(obj).map(function(item) {
if (this.key === language) {
this.parent.update(item);
}
});
return result;
@mderazon
mderazon / mongo-dump-csv.sh
Last active November 3, 2022 16:18
Export all of Mongodb collections as csv without the need to specify fields
OIFS=$IFS;
IFS=",";
# fill in your details here
dbname=DBNAME
user=USERNAME
pass=PASSWORD
host=HOSTNAME:PORT
# first get all collections in the database
@mderazon
mderazon / convert-media.sh
Created November 1, 2016 09:37
convert images and videos screenshots to something that's nice to paste in github
if [[ "$1" == *.mp4 ]]
then
/Users/me/bin/togif "$1"
fi
if [[ "$1" == *.png ]]
then
/Users/me/bin/topic "$1"
fi
@mderazon
mderazon / youtube-to-mp3.sh
Created May 25, 2016 11:35
get a bunch of youtube videos as mp3
youtube-dl -f 140 --ffmpeg-location /usr/local/bin/ffmpeg [list of youtube urls]
for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 128k "${f%.m4a}.mp3"; done
@mderazon
mderazon / url-check.md
Last active May 30, 2020 14:30 — forked from oscarb/README.md
Formula to check if website in cell A1 in a Google Spreadsheet is up, using the W3C HTML Checker API

Validate URL in a Google Spreadsheet

Formula to check if URL in cell A1 in a Google Spreadsheet is up, using the W3C HTML Checker API

Formula

=IF(A1<>"",IF(ISERROR(FIND("non-document-error", INDEX(IMPORTDATA("https://validator.w3.org/nu/?out=json&doc=" & A1),0,2))),"✓","✗"),"")

Output

@mderazon
mderazon / .travis.yml
Last active April 13, 2020 11:05
Automatic deployment to Google Cloud Functions with Travis-ci
# Use Dockerized infrastructure
sudo: false
# Use node_js environnement
language: node_js
node_js:
- "6"
# Cache Gcloud SDK between commands
cache:
@mderazon
mderazon / ClearableAutoCompleteTextView.java
Last active November 30, 2018 16:42
a sub class of AutoCompleteTextView that has a dismiss button with OnClearListener when the clear button is clicked
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AutoCompleteTextView;
/**
* sub class of {@link android.widget.AutoCompleteTextView} that includes a clear (dismiss / close) button with
* a OnClearListener to handle the event of clicking the button
@mderazon
mderazon / get-dmarc-reports.js
Created November 22, 2017 14:59
Downloads all DMARC reports from Postmark in XML format
const req = require('superagent');
const writeFile = require('util').promisify(require('fs').writeFile);
const apiToken = process.env.API_TOKEN;
const baseUrl = 'https://dmarc.postmarkapp.com';
(async function() {
const reports = [];
// get a list of all reports by id and create time
@mderazon
mderazon / copy-clip.js
Created September 27, 2017 07:00
copy-to-clipboard-bookmarklet
var link = 'https://example.com';
var textArea = document.createElement('textarea');
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';