Skip to content

Instantly share code, notes, and snippets.

View jardix22's full-sized avatar

Joseph Ramos jardix22

  • WeKnow
  • Puno, Perú
View GitHub Profile
@jardix22
jardix22 / example.php
Last active July 24, 2018 04:10
Nested array validation
<?php
if (!empty($data['image']) && !empty($data['image']['entity']) && !empty($data['image']['entity']['fid'])) {
$fid = $data['image']['entity']['fid'];
}
@jardix22
jardix22 / impure_pure.js
Created June 20, 2017 14:47
Impure and pure functions
// Impure function
const b = 10
const impureFunction = (a) => {
return a + b;
}
impureFunction(4)
############################
## TERMINAL CUSTOMIZATION ##
############################
# Function to handle current git branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# Show git branch on underlined path
var ElHelper = require('../helpers.js'),
path = require('path'),
project = {
name: 'Sample Website',
domain: 'http://localhost:3010',
picture: path.resolve(__dirname, '../../files/logo.png')
};
var userInfo = ElHelper.user.getSample('tester');
var organizationInfo = ElHelper.organization.getSample();
var a = new Boolean(validator.isEmail(item[settings.name].toString()));
var b = !!validator.isEmail(item[settings.name].toString());
// -- wrong email = demo@demo
console.log("a: ", a); // a: {}
console.log("b: ", b); // b: false
console.log("a || 'Invalid email.': ", a || 'Invalid email.'); // a || 'Invalid email.': {}
server {
server_name tracker.io;
listen 80;
root /home/joseph/taller/el-tracker;
try_files $uri @nodejs;
location @nodejs {
proxy_set_header X-Real-IP $remote_addr;
Structure of tests directories in El-tracker
----------------------------------------------
el-tracker/test/config/ --> Configurations files
el-tracker/test/config/Karma.conf.js
el-tracker/test/config/protractor.conf.js
el-tracker/test/config/mocha-runner.js
el-tracker/test/lib/
el-tracker/test/frontend/ ---> Frontend test directory
el-tracker/test/frontend/e2e
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
}
app.configure(function() {
app.use(express.bodyParser());
project.createExecutionCDN = function (projectId, extensionDir) {
var deferred = Q.defer();
var filePath = path.join(extensionDir, 'project', projectId + '.js');
var defaultCdnPath = path.join(extensionDir, 'execution.js');
// verify if exist cdn-project-id.js file
fs.exists(filePath, function (exists) {
// Handler if the project cdn not exist.
if (!exists) {
-------- Project X
<!-- load cdn de execution -->
<script src="http://el-tracker.com/cdn/projectId"></script>
------- project.router.js
>> path: /cdn/:projectId
- get param projectId
- verify if exist project?