Skip to content

Instantly share code, notes, and snippets.

View hieuhani's full-sized avatar
🎯
The beginning is the end and the end is the beginning

Hieu Tran hieuhani

🎯
The beginning is the end and the end is the beginning
View GitHub Profile
@hieuhani
hieuhani / PG::Error: ERROR: new encoding (UTF8) is incompatible
Created February 26, 2017 04:38 — forked from amolkhanorkar/PG::Error: ERROR: new encoding (UTF8) is incompatible
Postgres PG::Error: ERROR: new encoding (UTF8) is incompatible
======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'
import { fromJS } from 'immutable';
import {
SIGN_IN_BY_EMAIL_REQUEST,
SIGN_IN_BY_EMAIL_SUCCESS,
SIGN_IN_BY_EMAIL_ERROR,
} from './constants';
const initialState = fromJS({
error: null,
user: null,
import { fromJS, List } from 'immutable';
import camelize from 'camelize';
import {
GET_RESTAURANT_MENUS_REQUEST,
GET_RESTAURANT_MENUS_SUCCESS,
GET_RESTAURANT_MENUS_ERROR,
SET_ACTIVE_MENU_CONTAINER_ID,
SET_ACTIVE_MENU_ITEM_ID,
PUT_UPDATE_MENU_CONTAINER_REQUEST,
PUT_UPDATE_MENU_CONTAINER_SUCCESS,
import { createSelector } from 'reselect';
const selectMenusDomain = () => (state) => state.get('menus');
const selectRestaurantMenus = () => createSelector(
selectMenusDomain(),
(menusState) => menusState.get('menus')
);
const selectActiveMenu = () => createSelector(
// Nhan ket qua la 1 array
return state.set('menus', fromJS(payload.menus));
// Them phan tu
return state.set('menus', state.get('menus').push(fromJS(payload.menu)));
// Update 1 phan tu
return state
.set('sets', state.get('sets').map((setItem) => {
if (setItem.get('id') === payload.set.id) {
import React from 'react';
import PropTypes from 'prop-types';
import Immutable from 'immutable';
import styled from 'styled-components';
import { Link } from 'react-router';
import ViewBranchListPanel from '../../components/ViewBranchListPanel';
import './styles.scss';
const TableList = styled.ul`
padding-left: 0;

Inspired by this article. Neat tricks for speeding up integer computations.

Note: cin.sync_with_stdio(false); disables synchronous IO and gives you a performance boost. If used, you should only use cin for reading input (don't use both cin and scanf when sync is disabled, for example) or you will get unexpected results.

Multiply by a power of 2

x = x << 1; // x = x * 2

0x5C9adE285d402001847E624BD64a57f0C9D467ce
# -*- coding: utf-8 -*-
#----------------------------------------------------------
# OpenERP HTTP layer
#----------------------------------------------------------
import ast
import collections
import contextlib
import datetime
import functools
import hashlib
import { createSelector } from 'reselect'
const selectGlobal = state => state.global
const selectNetworkEnabled = createSelector(selectGlobal, global => global.networkEnabled)
const selectServerConnectionStatus = createSelector(
selectGlobal,
global => global.serverConnectionStatus,
)
const selectLoginStatus = createSelector(