Skip to content

Instantly share code, notes, and snippets.

everyone.forEach(function(person) {
if (person === you) person.inviteFriends();
person.go();
});
console.log('Все идут!');
@skovalyov
skovalyov / time-format.coffee
Created February 7, 2013 14:51
Module time-format with span() method that formats the time span between now and the date specified in a "Facebook way".
## Public API
module.exports =
# <code>span()</code> formats the time span between now and the date specified in a "Facebook way".
#
# Examples:
#
# May 18, 2011 at 5:11AM
# December 25 at 8:43PM
# Friday at 3:53PM
@skovalyov
skovalyov / rmdir.coffee
Created January 23, 2013 14:05
Recursive sync rmdir based on JavaScript implementation from https://gist.github.com/2367067
fs = require "fs"
path = require "path"
rmdir = (dir) ->
list = fs.readdirSync dir
for item in list
filename = path.join dir, item
stat = fs.statSync filename
if filename in [".", ".."]
# Skip
@skovalyov
skovalyov / pet-project.conf
Created October 22, 2012 16:10
Nginx configuration to deploy Node application in subdomain
upstream pet_project {
server localhost:3000;
}
server {
listen 80;
server_name pet-project.myhost;
location / {
alias /opt/demo/pet-project/public/;
@skovalyov
skovalyov / format-json.coffee
Created September 18, 2012 12:25
JSON format command line utility
fs = require "fs"
inFile = process.argv[2] # Read the input file name from the 1st command line parameter.
outFile = process.argv[3] # Read the output file name from the 2nd optional command line parameter.
fs.readFile inFile, "utf8", (err, data) -> # Read the input file content.
if err
console.log err # Log error to console.
else
try
@skovalyov
skovalyov / pet-project.conf
Created July 12, 2012 21:31
Nginx configuration to deploy Node application in subfolder
upstream pet_project {
server localhost:3000;
}
server {
listen 80;
server_name frontend;
location /demo/pet-project {
alias /opt/demo/pet-project/public/;
@skovalyov
skovalyov / AutoScrollManager.as
Created June 5, 2012 22:25
Automatically scroll container to make the focused child visible
package {
import flash.display.InteractiveObject;
import flash.events.EventDispatcher;
import flash.events.FocusEvent;
import flash.events.TimerEvent;
import flash.geom.Point;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
@skovalyov
skovalyov / AuthenticationManagerUsage.as
Created June 5, 2012 22:22
ActionScript singleton usage example
AuthenticationManager.instance.authenticate(usernameTextInput.text, passwordTextInput.text);
@skovalyov
skovalyov / AuthenticationManagerInstance.as
Created June 5, 2012 22:21
ActionScript singleton implementation example
package {
internal class AuthenticationManagerInstance extends EventDispatcher {
public function AuthenticationManagerInstance() {
super();
}
public function authenticate(username : String, password : String) : void {
// Authentication routine.
@skovalyov
skovalyov / AuthenticationManager.as
Created June 5, 2012 22:20
ActionScript singleton facade example
package {
public class AuthenticationManager {
public static var instance : AuthenticationManagerInstance = new AuthenticationManagerInstance();
}
}