Skip to content

Instantly share code, notes, and snippets.

Vladimir Kapustin kapooostin

Block or report user

Report or block kapooostin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kapooostin
kapooostin / recur.js
Created Jan 7, 2019 — forked from adleroliveira/recur.js
A Million Ways to Fold in JS Notes
View recur.js
// 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) => {
View gist:7a85c0e32079a74a11a7e42f02124e46
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 — forked from jirutka/-README.md
How to use terminal on Windows and don’t go crazy…
View -README.md

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 Oct 21, 2015 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
View gist:88db03d0d09553e66f40
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 Aug 29, 2015 — forked from taylorotwell/gist:db67dd369b00022850b4
Mac Yosemite Dev Machine Setup
View gist:1252970297db2d8ccf50

XCode

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

XCode CLI Tools

  • xcode-select --install

Install Homebrew

View gist:182cd958ac4635d65eb8

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

View foo.js
var _vent = require('./vent.js').shared();
_vent.trigger('blah');
View LaravelHelper.php
<?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 Aug 29, 2015
Arbitrary nested grids in Bootstrap
View _nested-grids-mixins.less
// 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) {
View main.js
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) {
You can’t perform that action at this time.