Skip to content

Instantly share code, notes, and snippets.

$ psql -d postgres
postgres=# create role "app_name" login createdb;
postgres=# \q
The first line is in your terminal, the next two are inside psql. Then do your rake db:create.

The User user is possibly a default but user is already taken for other purposes in PostgreSQL so 
you'd have to quote it to preserve the case if you wanted to use User as a username:

postgres=# create role "User" login createdb;
@Kolenov
Kolenov / application_helper.rb
Created December 28, 2017 22:22 — forked from attilagyorffy/application_helper.rb
Responsive Images in Rails applications
module ApplicationHelper
def responsive_image_tag(image, options = {})
content_tag(:picture) do
concat content_tag(:source, nil, media: '(max-width: 768px)', srcset: image.url(:thumbnail_mobile))
concat content_tag(:source, nil, media: '(max-width: 960px)', srcset: image.url(:thumbnail_tablet))
concat image_tag(image.url(:thumbnail_desktop), options)
end
end
end
@Kolenov
Kolenov / bs-config.js
Created December 31, 2017 11:47
BrowserSync config: serve static assets, and proxy the HTML
/**
* BrowserSync config: serve static assets, and proxy the HTML
*
* Let's say we have the codebase for the front-end of a website,
* and we want to develop CSS/JS or debug against the HTML of
* a remote development, staging or production server.
*
* Using BrowserSync (2.4 needed), we want to serve to our browser(s):
* - the distant HTML pages and content images from the server
* - local static assets (including or changes)

XMLHttpRequest

var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://example.com/', true);
xhr.withCredentials = true;
xhr.send();
fetch('https://example.com', {
@Kolenov
Kolenov / ngrok-copy
Created February 15, 2018 00:37 — forked from mlsteele/ngrok-copy
Copy the url of the active ngrok connection to the clipboard.
#!/usr/bin/env bash
# Copy the url of the active ngrok connection to the clipboard.
# Usage:
# ngrok-copy # copies e.g. https://3cd67858.ngrok.io to clipboard.
# ngrok-copy -u # copies e.g. http://3cd67858.ngrok.io to clipboard.
if [[ "$1" == "-u" ]]; then
NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "http://.*?ngrok.io" -oh`
else
NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "https://.*?ngrok.io" -oh`
@Kolenov
Kolenov / svg-blur.html
Created April 17, 2018 12:59
svg blur
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur in="SourceGraphic" stdDeviation="14"></feGaussianBlur>
</filter>
</defs>
</svg>
.svgblur{
filter: url(#blur);
@Kolenov
Kolenov / social-icons.svg
Last active May 4, 2018 08:17
SVG Sprite for Plei
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kolenov
Kolenov / snippets.js
Last active April 21, 2023 13:56
react
// Conditional Rendering with enums
function Notification({ text, state }) {
return (
<div>
{{
info: <Info text={text} />,
warning: <Warning text={text} />,
error: <Error text={text} />,
}[state]}
</div>
@Kolenov
Kolenov / perlbrew_libgcc_s.txt
Created December 4, 2018 10:27 — forked from Dreyer/perlbrew_libgcc_s.txt
[perlbrew] ld: library not found for -lgcc_s.10.4
$ cd /usr/local/lib
$ sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib
$ sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.4.dylib

Genearate and add to the OsX Keychain the self-signed certificate for Create React App

Usage example

For localhost and ip 0.0.0.0 by default

create_certificate_for_domain.sh