Skip to content

Instantly share code, notes, and snippets.

@rafaelrozon
rafaelrozon / save_env_variable_laravel
Created January 4, 2016 18:20
set env variable using Dotenv package in Laravel 5
putenv("ENV_VARIABLE=$value_for_env_variable");
1. homestead ssh
2. php -i
3. copy output and paste in https://xdebug.org/wizard.php
4. install Xdebug
5. Xdebug settings go in fpm/php.ini. Example:
[XDebug]
zend_extension="/usr/lib/php5/20131226/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_port=9000
xdebug.profiler_enable=1
function serverRespondGet(server, api, data){
server.respondWith( "GET", api, [200, {
"Content-Type": "application/json",
"Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept",
"Access-Control-Allow-Methods" : "POST, GET, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Origin" : "*"
}, JSON.stringify(data)]
);
}
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$TEXT" ]
then
echo "$NAME"': '$(cat "$1" | sed '/^#.*/d') > "$1"
if [ -n "$DESCRIPTION" ]
then
echo "" >> "$1"
@rafaelrozon
rafaelrozon / sails_nunjucks.js
Last active November 12, 2017 00:38
Setup Nunjucks for SailsJS
module.exports.views = {
engine: {
ext: 'njk',
fn: require("consolidate").nunjucks
},
layout: 'layout',
partials: false
};
{% extends "react_template.njk" %}
{% block css %}
<link href="/temp/app/register.css" rel="stylesheet">
{% endblock %}
{% block js %}
<script src="/temp/app/register.js"></script>
{% endblock %}
@rafaelrozon
rafaelrozon / react_template.njk
Last active November 13, 2017 04:33
Basic React Template in Nunjucks
<!DOCTYPE html>
<html>
<head>
<title>React Template</title>
<!-- Viewport mobile tag for sensible mobile support -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- Default CSS -->
<link rel="stylesheet" href="/css/libs/libs.min.css">
$ psql -U postgres
$ use mydb
$ COPY (
select array_to_json(array_agg(row_to_json(t)))
from (
select *
from my_table
) t
)
TO '/path/to/file/file.json';
/root
/app
/packages
/pages
/home
/signup
/shared_components
/shared
/packages
/models
/*
Redux State
Generic structure:
module: {
data: {
resource: {
byId: {},
allIds: {},
current: 0