Skip to content

Instantly share code, notes, and snippets.

@rcrowley
rcrowley / bad-side-effects-on-mac-osx.sh
Last active August 29, 2015 13:56
A protip for authors of shell programs. I use this pattern *all the time* for working in a temporary directory and cleaning it up after I'm done but a quirk in how shells interpret failures in command substitution caused a program like these to remove my coworker's home directory when he ran said program on Mac OS X, which doesn't have `mktemp -d`.
set -e
# Looks clever, is short, but removes your working directory on Mac OS X
# where `mktemp -d` fails.
cd "$(mktemp -d)"
trap "rm -rf \"$PWD\"" EXIT INT QUIT TERM
# ...

IV. Реализация денежно-кредитной политики в 2014-2016 годах

IV.1. Политика валютного курса

Банк России в 2014 году продолжит проводить курсовую политику, не препятствуя формированию тенденций в динамике курса рубля, обусловленных действием фундаментальных макроэкономических факторов, неустанавливая каких-либо фиксированных ограничений на уровень курса национальной валюты. При этом в течение данного периода Банк России будет осуществлять постепенное повышение гибкости курсообразования, в том числе путем сокращения объемов интервенций Банка России, направленных на сглаживание колебаний обменного курса рубля, а также увеличения чувствительности границ операционного интервала к объему совершенных Банком России интервенций, тем самым создавая условия для адаптации участников рынка к колебаниям валютного курса, вызванным внешними шоками.

В 2014 году будет завершена работа по созданию условий для перехода крежиму плавающего валютного курса, который предполагает отказ отиспользования операционных ориентиров кур

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
.article {
margin: 25px;
color: #333;
font: georgia, serif;
}
@grantm
grantm / gist:4367372
Last active December 10, 2015 02:28
Ever forgotten the ':' after the hostname of an scp command?
# a useful addition to anyone's .bashrc
#
# Note, you don't want this function in effect on the remote host side of the scp transfer,
# so make sure to only define it for interactive shells, e.g.: wrap with: if [ ! -z "$PS1" ]
function scp() {
if echo "$@" | grep -q ':'
then
/usr/bin/scp "$@"
else
@ianb
ianb / assert.js
Last active December 16, 2015 17:19
assert() for Javascript
function AssertionError(msg) {
this.message = msg || "";
this.name = "AssertionError";
}
AssertionError.prototype = Error.prototype;
/* Call assert(cond, description1, ...)
An AssertionError will be thrown if the cond is false. All parameters will be logged to the console,
and be part of the error.
*/
@groundwater
groundwater / SSE.md
Last active December 18, 2015 00:48

Server-Sent Events

I recommend using SSEs like an event-stream only. Do not send data through the stream, only events the client may be interested in. Clients can obtain data they are interested in by making additional HTTP calls to the server.

This keeps the data accessible via HTTP; it does not shard our API into two pieces, one HTTP-based, and one websocket based. We can check any of our endpoints with CURL, and all our routes are stateless. Even our event-stream is relatively stateless, because the server can fire-and-forget events as they occur.

Websockets are fragile. Their protocol is complciated, and the most popular websocket library socket.io is prone to memory leaks. Websockets do not cross proxies well, and debugging websocket issues is a large effort.

Суть бага в Webpack v1.12.11

Шаг 1

Есть модуль A, который импортирует модуль B В процессе первого(!) импорта модуля B происходит его инициализация, которая в коде вебпака происходит следующим образом:

/******/ 		// Check if module is in cache
/******/ if(installedModules[moduleId])
(function(){
var log = console.log;
console.log = function(str) {
var css = 'background: linear-gradient(to right, red, yellow, lime, aqua, blue, fuchsia, red); color: white; font-weight: bold;';
var args = Array.prototype.slice.call(arguments);
args[0] = '%c' + args[0];
args.splice(1,0,css);
var speech = new SpeechSynthesisUtterance();
@pdamoc
pdamoc / TableSort.elm
Created February 16, 2016 17:15
TableSort
import Html exposing (..)
import Html.Events exposing (onClick)
import StartApp.Simple exposing (start)
-- Generic
type alias HeadItem a =
{ sorter: (a -> a -> Basics.Order)
, toHtml : (a -> Html)
@shvechikov
shvechikov / upprint.py
Created February 27, 2012 09:11
UnicodePrettyPrinter
# -*- coding: utf-8 -*-
import sys
from pprint import PrettyPrinter
class UnicodePrettyPrinter(PrettyPrinter):
"""Unicode-friendly PrettyPrinter
Prints:
- u'привет' instead of u'\u043f\u0440\u0438\u0432\u0435\u0442'