Skip to content

Instantly share code, notes, and snippets.

View Hirurg103's full-sized avatar
🏠
Working from home

Дмитрий Hirurg103

🏠
Working from home
View GitHub Profile
class WidgetsController < ApplicationController
class TestDocument < Prawn::Document
def to_pdf
text "Hello World!"
render
end
end
def index
output = TestDocument.new.to_pdf

Capybara

save_and_open_page

Matchers

have_button(locator)

Capybara

save_and_open_page

Matchers

have_button(locator)
class A
def a
"a"
end
end
module M
def a
"m"
end
<?php
function to_str($prefix) {
$parent_str = $prefix . $this->text . PHP_EOL
if(empty($this->children)) {
return $parent_str;
} else {
return $parent_str . array_map(function($node) use ($prefix) {
return $node->to_str($prefix . ' ');
}, this->children).join();
class C
def method_missing(name, *args)
name.to_s.end_with?('=') ? instance_variable_set("@#{ name[0..-2] }", args[0]) : instance_variable_get("@#{ name }")
end
end
function benchmark(times, fun) {
var accumulatedTime = 0;
var meanTime = 0;
(function measureOnce(i) {
var startTime, endTime;
if(i <= 0) {
meanTime = accumulatedTime / times;
} else {
curryN = (f, n) ->
if n <=1
f
else
(firstArg) ->
curryN(
->
f.apply null, [firstArg].concat Array.prototype.slice.call(arguments),
n-1
)
@Hirurg103
Hirurg103 / .spacemacs
Last active February 27, 2016 14:51
Spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (i.e. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
@Hirurg103
Hirurg103 / postgresql_cheat_sheet.md
Last active February 24, 2017 23:11
PostgreSQL cheat sheet

Create role, DB and connect to DB

Switch to the posthres Linux account

~$ sudo -i -u postgres

Create role db_name

~$ createuser -U username -W --interactive