Skip to content

Instantly share code, notes, and snippets.

View kapooostin's full-sized avatar

Vladimir Kapustin kapooostin

View GitHub Profile
@kapooostin
kapooostin / recur.js
Created January 7, 2019 10:30 — forked from adleroliveira/recur.js
A Million Ways to Fold in JS Notes
// from http://forwardjs.com/university/a-million-ways-to-fold-in-js
'use strict'
const first = (xs) => xs[0]
const rest = (xs) => xs.slice(1)
const concat = (xs1, xs2) => xs1.concat(xs2)
// recursion
const sum = (xs) => {
Number.prototype.toPhrase=function(c)
// сумма прописью для чисел от 0 до 999 триллионов
// можно передать параметр "валюта": RUB,USD,EUR (по умолчанию RUB)
{
var x=this.roundTo(2);
if (x<0 || x>999999999999999.99) return false;
var currency='RUB';
if (typeof(c)=='string')
currency=c.trimAll().toUpperCase();
@kapooostin
kapooostin / -README.md
Created May 1, 2017 08:10 — forked from jirutka/-README.md
How to use terminal on Windows and don’t go crazy…

How to use terminal on Windows without going crazy…

Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.

Install stuff

  1. Download and install Git for Windows* with:
    • [✘] Use Git from the Windows Command Prompt
  • [✘] Checkout as-is, commit Unix-style line endings
@kapooostin
kapooostin / gist:88db03d0d09553e66f40
Created October 21, 2015 05:00 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@kapooostin
kapooostin / gist:1252970297db2d8ccf50
Last active August 29, 2015 14:27 — forked from taylorotwell/gist:db67dd369b00022850b4
Mac Yosemite Dev Machine Setup

XCode

  • Install XCode from App Store.
  • Open XCode and agree to terms and conditions.

XCode CLI Tools

  • xcode-select --install

Install Homebrew

The Laracasts PHPStorm theme - modified.

This is a slightly modified version of the great Laracasts PHPStorm theme. I've added some styles for Verions Control (add, modified, deleted line...) and fixed some missing things like warnings.

Download

image

Mac: Add to ~/Library/Preferences/WebIde80/colors

@kapooostin
kapooostin / foo.js
Last active August 29, 2015 14:13 — forked from benhowdle89/foo.js
var _vent = require('./vent.js').shared();
_vent.trigger('blah');
<?php
namespace Codeception\Module;
use Codeception\Util\Framework;
use Codeception\TestCase;
use Codeception\Util\Connector\Universal;
use Codeception\Configuration;
use Symfony\Component\BrowserKit\Response;
use Laravel\Routing\Router;
@kapooostin
kapooostin / _nested-grids-mixins.less
Last active August 29, 2015 14:03
Arbitrary nested grids in Bootstrap
// Generate the extra small columns
.make-xs-column(@columns; @gutter: @grid-gutter-width; @columns-total: @grid-columns) {
position: relative;
float: left;
width: percentage((@columns / @columns-total));
min-height: 1px;
padding-left: (@gutter / 2);
padding-right: (@gutter / 2);
}
.make-xs-column-offset(@columns; @columns-total: @grid-columns) {
var MyApp = angular.module('MyApp');
MyApp.factory('msgBus', ['$rootScope', function($rootScope) {
var msgBus = {};
msgBus.emitMsg = function(msg, data) {
data = data || {};
$rootScope.$emit(msg, data);
};
msgBus.onMsg = function(msg, func, scope) {
var unbind = $rootScope.$on(msg, func);
if (scope) {