Skip to content

Instantly share code, notes, and snippets.

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() {
@gurdiga
gurdiga / gist:2155982
Created March 22, 2012 04:36
sed css minification
sed \
-e ':a;N;$!ba;s/\n//g' \
-e 's/ {/{/g' \
-e 's/: /:/g' \
-e 's/;}/}/g' \
-e 's/{ /{/g' \
-e 's/; /;/g' \
css/style.css
@gurdiga
gurdiga / gist:2356487
Created April 11, 2012 02:37
batch transcode with vlc
for file in *.mkv; do out=`basename "$file" .mkv`.mp4; cvlc "$file" :sout="#transcode{vcodec=h264,scale=0.5}:std{access=file,mux=ps,dst='$out'}" vlc://quit; done
@gurdiga
gurdiga / gist:2411479
Created April 18, 2012 06:34
Skype start on Debian
bash -c 'LD_PRELOAD=/usr/lib32/libv4l/v4l2convert.so ~/skype_static-2.2.0.35/skype'
table#projectstatus {
width: auto;
margin: 1em 4px !important;
border-top: 1px #bbb solid!important;
}
table#projectstatus+table {
display: none;
}
#sslock, #ab_ctl_ss {
display: none;
}
@gurdiga
gurdiga / 999.md.css
Last active December 16, 2015 08:58
Personalized Web Options
.a0e7c1ec9e018,
.header_numbersTop,
.banner,
#header_numbersRich,
#m__numbers-placeholder-vertical,
#m__numbers-placeholder-rich,
#m__directadvert-horizontal,
#m__directadvert-vertical,
iframe {
display: none !important;
@gurdiga
gurdiga / github.com.css
Created April 18, 2013 02:01
Personalized Web Options ^https://github.com
@media print {
.pagehead, .frame-meta, .meta, #footer, .header {
display: none;
}
article.entry-content {
font-side: x-small;
}
}
@gurdiga
gurdiga / mama.md.css
Last active December 16, 2015 08:58
Personalized Web Options ^http://mama.md
#header_bar+script+div,
.numbers_main_right,
#point_informer {
display: none;
}
@gurdiga
gurdiga / rutracker.org.css
Last active December 16, 2015 08:58
Personalized Web Options ^http://rutracker.org/
iframe,
#bn-bot-wrap,
#owo-idx-6,
#logo td.tCenter,
#bn-tio-1 {
display: none;
}