Skip to content

Instantly share code, notes, and snippets.

@A
A / pomodoro-1.js
Last active August 29, 2015 14:14
Pomodoro algorythm
var session = 25 * 60 * 1000; // pomodoro session
var start = Number(new Date()); // set start time
var finish = start + session; // set finish time
function countdown () {
var now = Number(new Date());
var isFinished = (finish - now) > finish;
if (!isFinished) {
// check after 1 second
setTimeout(countdown, 1000);
@A
A / singleton.js
Last active August 29, 2015 14:14
Just js singleton pattern
'use strict';
// Dependencies
var Collection = require('./collection');
module.exports = function Singleton (...args) {
if (Singleton.instance) {
return Singleton.instance;
}
var Dispatcher = require('dispatcher');
module.exports = class View extends Backbone.View {
constructor(...args) {
this.dispatcher = dispatcher.bind(this); // Why?
super(...args);
}
save() {
@A
A / rbenv.sh
Last active August 29, 2015 14:12
# rbenv installation
$ brew update
$ brew upgrade rbenv ruby-build
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
# Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.
# Add rbenv init to your shell to enable shims and autocompletion.
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ rbenv install 2.2.0
$ rbenv global 2.2.0
$ rbenv rehash
@A
A / fiftyfootshadows.sh
Last active February 20, 2016 11:22
download all awesome desktop wallpapers from fiftyfootshadows.net
mkdir fiftyfootshadows
cd fiftyfootshadows
wget -A zip -rH --level=3 -nd \
--domains=files.fiftyfootshadows.net,fiftyfootshadows.net \
http://fiftyfootshadows.net
for i in `ls`; do unzip $i; done
mv **/*desktop.jpg ~/Pictures
cd ..
rm -rf fiftyfootshadows
@A
A / backbone-plugin.js
Last active August 29, 2015 14:11
Backbone's plugin design
'use strict';
// Dependencies
var {Model} = require('backbone');
module.exports = class PluginAdapter extends Model {
constructor(parent, options) {
this.name = options.name;
@A
A / byobu-cheatsheet.md
Last active August 29, 2015 14:09
byobu window manager cheatsheet http://byobu.co/
  • F2 Create a new window
  • F3 Move to the previous window
  • F4 Move to the next window
  • F5 Refresh all status notifications
  • F6 Detach from the session and logout
  • Shift-F6 Detach from the session, but do not logout
  • F7 Enter scrollback/search mode
  • F8 Rename the current window
  • F9 Launch the Byobu Configuration Menu
  • F12 GNU Screen's Escape Key
/**
* Mixin to use bootstrap media query breakpoints within Sass code:
* .profile-pic {
* float: left;
* width: 250px;
* @include media(lg)
* width: 100%
* @include media(md)
* width: 125px;
* }
// WTF
// Если в скопе вызывается один метод, exec() будет вызван автоматически:
db.find(1); // залогирует 1
// Если же в скопе происходит цепочка вызовов, то exec() нужно будет вызывать вручную:
db
.find(1)
.find(2)
.find(3)
.exec() // Залогирует 123
// или даже так: