This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var localTime = moment.utc(YOUR_DATE).toDate(); | |
localTime = moment(localTime).format('YYYY-MM-DD HH:mm:ss'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example for haml with one field in NesteIdem, file :image | |
# js adding and removing fields. Edit and destroy nested fields without parent is not covered | |
# Our relation | |
# Parent has many NestedItems, NestedItem belongs to Parent | |
.nested-container | |
.btn.btn-default.add-nested Dodaj więcej zdjęć + | |
.nested-items | |
.nested-item{ data: { index: 0 }} | |
# input tag name will generate nested object in params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####### Function takes jQuery object as argument | |
####### currently working only for one element | |
var isInView = function($element){ | |
elementOffsetTop = $element.offset().top; | |
elementHeight = $element.outerHeight(); | |
windowTop = document.body.scrollTop; | |
windowHeight = window.innerHeight; | |
if( elementOffsetTop < (windowTop + windowHeight) | |
&& (elementOffsetTop + elementHeight) > windowTop) | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for nvm | |
export NVM_DIR="$HOME/.nvm" | |
. "$(brew --prefix nvm)/nvm.sh" | |
load-nvmrc() { | |
if [[ -f .nvmrc && -r .nvmrc ]]; then | |
nvm use | |
elif [[ $(nvm version) != $(nvm version default) ]]; then | |
echo "Reverting to nvm default version" | |
nvm use default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -U add-zsh-hook | |
load-nvmrc() { | |
local node_version="$(nvm version)" | |
local nvmrc_path="$(nvm_find_nvmrc)" | |
if [ -n "$nvmrc_path" ]; then | |
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | |
if [ "$nvmrc_node_version" != "N/A" ] && [ "$nvmrc_node_version" != "$node_version" ]; then | |
nvm use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files = Dir.glob("./src/**/*").select { |f| f.include?('.js') } | |
files.each do |f| | |
content = IO.read(f) | |
IO.write f, "// @flow \n\n#{content}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createAction = (type) => { | |
return (payload) => ({type, payload}) | |
} | |
const createReducer = (initState, handlers) => { | |
return (state = initState, action) => { | |
const actionHandler = handlers[action.type]; | |
if (actionHandler) { | |
const result = actionHandler(state, action.payload); | |
return Object.assign({}, state, result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function range(from, to) { | |
return Array.apply(null, Array(to - from + 1)).map(function (x, i) { return to - from + i; }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const fetchTransactions = () => { | |
return { | |
type: "API_FETCH", | |
config: { | |
type: ACTIONS.FETCH_TRANSACTIONS, | |
action: () => axios.get(/* sample url */), | |
transform: response => response.data.result, | |
}, | |
}; | |
}; |
OlderNewer