Skip to content

Instantly share code, notes, and snippets.

Avatar

Vlad GURDIGA gurdiga

View GitHub Profile
@gurdiga
gurdiga / Makefile
Last active Jun 7, 2020
PhotoBucket export
View Makefile
.ONESHELL:
MAKEFLAGS=
export CURL_PARAMS=--silent --connect-timeout 5 --retry-delay 0 --retry 5
start: list-albums # download-photos
list-albums:
@function main() {
list_albums "/albums/c111/SandraDodd"
@gurdiga
gurdiga / vlad.sudoers
Created Oct 10, 2019
`sudo` configuration to skip password for specific commands
View vlad.sudoers
vlad ALL = (ALL) NOPASSWD: /usr/bin/sntp
vlad ALL = (ALL) NOPASSWD: /usr/sbin/lsof
vlad ALL = (ALL) NOPASSWD: /usr/local/sbin/mtr
vlad ALL = (ALL) NOPASSWD: /sbin/ifconfig
vlad ALL = (ALL) NOPASSWD: /usr/local/bin/gdu
@gurdiga
gurdiga / update_phpbb_from
Last active Sep 23, 2019
A script to automate the update phpBB3 from a given download URL. Accepts the download URL as its single argument.
View update_phpbb_from
#!/bin/bash
# https://sipb.mit.edu/doc/safe-shell/
set -xeuf -o pipefail
archive_url="$1"
archive_name=`basename $archive_url`
wget --no-verbose $archive_url
mv $archive_name tmp
@gurdiga
gurdiga / optimizely.mk
Created Aug 16, 2019
The Makefile I used to mangle some Optimizely logs
View optimizely.mk
default:
Make what?
sync: download upload
download:
time aws --profile mx-optimizely s3 sync s3://optimizely-export-ng/10629356/10629356/2.0/2019/08/14/ 2019/08/14/
download-day:
test -z "$(DAY)" && (echo "Give me a DAY, please. Something like DAY=08/21." && exit 1) || \
@gurdiga
gurdiga / export-notes-to-plain-text.scpt
Created Jul 23, 2019
Export Apple Notes to plain text
View export-notes-to-plain-text.scpt
tell application "Notes"
repeat with eachNote in notes in folder "Log"
tell eachNote
set content to body as text
set {year:y, month:m, day:d, hours:h, minutes:n} to creation date
set m to m as number
set d to d as number
set n to n as number
set h to h as number
@gurdiga
gurdiga / getCookieByName.js
Last active Feb 25, 2016
A little function to get a cookie by name. Useful to debug from the the browser console.
View getCookieByName.js
function getCookieByName(name) {
return unescape(
(document.cookie.split(/; /g)||[])
.filter(function(pair) {
return pair.split('=')[0] === name;
})[0]
.split('=')[1]
);
}
View per-directory-bash-history.md

Per-directory Bash history (w/o aliasing cd)

I use Bash’s PROMPT_COMMAND variable:

The value of the variable PROMPT_COMMAND is examined just before Bash prints each primary prompt. If PROMPT_COMMAND is set and has a non-null value, then the value is executed just as if it had been typed on the command line.

The source code should be pretty straight forward, but if not, please ask in the comments. Put this in your .bashrc or similar:

# per-directory Bash history
View JS interface composition with promises.md

JS interface composition with promises

Inspired by Mr. Robert C. Martin’s episodes on SOLID principles that I’ve watched lately, and by the idea of “programming to interfaces” I’ve tried to come up with a schema that would allow me to have the concerns separated, but still composable.

These are a few modules from an Angular project.

So, I have an AuthenticationService module that does user account house-keeping:

// app/authentication-service/authentication-service.js
(function() {
View random-password.js
function randomPassword(lenght) {
function random() {
return parseFloat('.' + crypto.getRandomValues(new Uint32Array(1))[0]);
}
var characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
password = '',
i;
for (i = 0; i < 10; i++)
View transcode.sh
mencoder dvd:// -mc 0 -noskip -ovc copy -oac copy -nosub -aid 131 -o Desktop/transcoded.avi
You can’t perform that action at this time.