Skip to content

Instantly share code, notes, and snippets.

View vpArth's full-sized avatar

Alexander Deider vpArth

  • https://github.com/skyeng
  • Russia, Novosibirsk
View GitHub Profile
@vpArth
vpArth / dripstat
Last active August 29, 2015 14:00
function Miner(incr, dripK, delay) {
var that = this;
this.incr = incr || localStats.bps*1e3;
this.dripK = dripK || 0.5;
this.delay = delay || 100;
document.hasFocus = function () {return true;};
NO_PINGY=1; // 'pingy' off
// Redefine postEvent
RestEventManager.prototype.postEventData = function(e,t,next)
Reusing an AngularJS Directive core code. The idea is to:
** 1. conceal the actual directive behaviour in a separate JS "class",
** 2. store that in an Angular service,
** 3. inject that service into an Angular directive,
** 4. just have the directive factory function return the constructed instance of the "class".
That is to separate the directive core code from the actual directive factory.
Then one actually wants to inherit a directive core "class" from another. It's not really a matter of JS inheritance, but more on how to inject one into the other by means of Angular modules, without actually instantiating none of them until needed,
@vpArth
vpArth / 0_reuse_code.js
Created June 20, 2014 17:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@vpArth
vpArth / commenting.vimrc
Created November 16, 2014 15:36
Vim Snippets
" Toggle comment line
" Ctrl+/
let s:comment_map = {
\ "c": '//',
\ "cpp": '//',
\ "go": '//',
\ "java": '//',
\ "javascript": '//',
\ "php": '//',
#include <map>
#include <iostream>
#include <signal.h>
#include <unistd.h>
class Strategy
{
public:
virtual void use(void) = 0;
};
@vpArth
vpArth / Symfony2 + FOSRestBundle.md
Created September 15, 2015 15:07 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

// http://www.multiplayerpiano.com/
var TEMP = 210; // bpm
function tap(note, part, next) {
MPP.piano.play(note, 1, MPP.client.getOwnParticipant(), 0);
setTimeout(function(){
MPP.piano.stop(note, MPP.client.getOwnParticipant(), 0);
next();
}, 60e3/(TEMP*part)*4);
@vpArth
vpArth / _service.md
Created December 7, 2015 15:41 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@vpArth
vpArth / php5mod.py
Last active July 14, 2016 12:38
Ansible modules
#!/usr/bin/python
import os.path
import re
from subprocess import call
DOCUMENTATION = '''
module: php5mod
short_description: Wraps php5enmod/php5dismod functionality
description: