Skip to content

Instantly share code, notes, and snippets.

View cinic's full-sized avatar

Alexandr Andreev cinic

View GitHub Profile
@cinic
cinic / node-and-npm-in-30-seconds.sh
Created August 29, 2017 15:40 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@cinic
cinic / nginx.conf
Created August 9, 2017 09:31 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
'use strict';
const path = require('path');
const webpack = require('webpack');
const production = process.env.NODE_ENV === 'production';
const babelPlugins = ['jsx-tagclass'];
const babelProdPlugins = babelPlugins.concat(
['transform-react-constant-elements', 'transform-react-inline-elements']
@cinic
cinic / TestSetupExampleCRAEnzymeChaiMocka.md
Created December 15, 2016 08:12 — forked from busypeoples/TestSetupExampleCRAEnzymeChaiMocka.md
Mocha/Chai/Enyzme test setup with create-react-app

Basic setup for using Enzyme/Mocha/Chai with create-react-app

This is a temporary solution. Might change in the near future, this depends on how create-react-app will implement testing.

create-react-app quick-test-example

cd quick-test-example

npm run eject
@cinic
cinic / union select.sql
Last active October 21, 2016 00:07
Nested select with union
SELECT id, x
FROM (
SELECT id, x
FROM test
WHERE x='y'
LIMIT 1
) t1
UNION ALL
SELECT id, x
FROM (
@cinic
cinic / docker.sh
Last active October 20, 2016 20:58
Ubuntu 16 Docker install script
#!/bin/bash
TMP_DIR=`mktemp --directory`
LIST_FILE=$TMP_DIR/docker.list
DOCKER_GROUP="docker"
apt-get update
apt-get install apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
@cinic
cinic / README.md
Created March 14, 2016 22:05 — forked from jhilden/README.md
Setup for using i18n-js together with react-rails i18n-js for server side prerendering

When using react-rails for an internationalized app it makes a lot of sense to use i18n-js for translations, so that you can reuse the the strings from your rails app's .yml files (and all the tooling & services that exist around that).

When you use the prerender feature of react-rails you face 2 problems:

  • The first is that translation.js & i18n.js from i18n-js need to be loaded inside the server-side JS prerendering processes, which is achieved by loading them inside the components.js.
  • The second problem is the server processes need to be aware of the current locale of each HTTP request. This is done by adding a custom renderer and using the before_render hook to configure i18n-js accordingly for each render call.
@cinic
cinic / deploy.rb
Created January 20, 2016 15:43 — forked from chuckbjones/deploy.rb
Generate static html files at deploy time in Rails 3.x
# define a method to run rake tasks
def run_rake(task, options={}, &block)
rake = fetch(:rake, 'rake')
rails_env = fetch(:rails_env, 'production')
command = "cd #{current_path} && #{rake} #{task} RAILS_ENV=#{rails_env}"
run(command, options, &block)
end
@cinic
cinic / .gitignore
Created January 20, 2016 01:10 — forked from WattsInABox/.gitignore
Generate Static HTML Website Using Ruby on Rails
# Ignore static version of the site (used to upload error pages to S3 for Heroku errors)
/out
@cinic
cinic / support_cyrillic.sh
Created November 17, 2015 20:49 — forked from vladimir-e/support_cyrillic.sh
Support cyrillic / russian input in rails console and IRB
$ brew install openssl readline
$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install 2.0.0-p353