Skip to content

Instantly share code, notes, and snippets.

@jcarroyo
jcarroyo / clean_code.md
Created October 22, 2018 16:42 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@jcarroyo
jcarroyo / Jenkinsfile
Created August 10, 2018 14:47 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage concurrency constraints, ...
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
/*
Please make sure to add the following environment variables:
HEROKU_PREVIEW=<your heroku preview app>
HEROKU_PREPRODUCTION=<your heroku pre-production app>
HEROKU_PRODUCTION=<your heroku production app>
@jcarroyo
jcarroyo / Jenkinsfile
Created July 25, 2018 03:00
Demo pipeline for library project
pipeline{
agent any
tools{
jdk 'jdk_1.8.0'
maven 'mvn_3.5.4'
}
stages{
stage ('Initialize') {
steps {
bat '''
@jcarroyo
jcarroyo / installService.bat
Created July 23, 2018 16:27
Artifactory installation script for Windows (fixed script)
@echo off & cls & echo.
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
@jcarroyo
jcarroyo / settings.xml
Created July 22, 2018 17:42
Configuración básica para ejecución de SonarQube en entorno local mediante token
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cdainfo</groupId>
<artifactId>demotest</artifactId>
<version>1.0-SNAPSHOT</version>
@jcarroyo
jcarroyo / passport.js
Last active May 31, 2016 00:51
Node.js passport configuration
//https://scotch.io/tutorials/easy-node-authentication-setup-and-local
class PassportConfiguration {
constructor(passport) {
var LocalStrategy = require('passport-local').Strategy;
var FacebookStrategy = require('passport-facebook').Strategy;
var UserDA = require('../data').UserDA;
var config = require('./config.json');
passport.serializeUser((user, done) => {
done(null, user.id);
@jcarroyo
jcarroyo / client.js
Created April 6, 2016 02:09
Node.js send file with pure socket (low level transfer)
var net = require('net');
var socket = new net.Socket();
socket.connect(5000, "127.0.0.1");
var fs = require('fs');
var path = require('path');
var packets = 0;
var buffer = new Buffer(0);
socket.on('data', function(chunk){
packets++;
@jcarroyo
jcarroyo / client.js
Created April 6, 2016 02:02
Chat server and client v2
var net = require('net');
var socket = new net.Socket();
var port = 5000;
var host = "127.0.0.1";
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
@jcarroyo
jcarroyo / strict.js
Created March 20, 2016 14:00
Importance "use strict"
"use strict"
var path = "C:/"
var file = "custom.txt";
var filePath = "C:/default.txt"
if(file){
filepath = path + file;
}
console.log(filePath);