Skip to content

Instantly share code, notes, and snippets.

View christian-fei's full-sized avatar

Christian christian-fei

View GitHub Profile
export default function route(name, config={}) {
let {url} = config
url = url || `/${name}`
url = normalizeRouteUrl(url)
const normalizedRouteName = normalizeRouteName(name)
const nameCap = normalizedRouteName[0].toUpperCase() + normalizedRouteName.slice(1)
const controller = `${nameCap}Ctrl as vm`
const templateUrl = `controllers/${nameCap}Ctrl.html`
return {
name,
module.exports = function(s){
var u='toUpperCase'
return s.replace(/(\b((?:(?!by|for|and|of|vs|v|email|example|com|camelCase|(t |s )|iPhone))[a-z]))/g,function(m){
console.log( '-- ', arguments )
return m[u]()
}).replace(/(\b((?=(and|of)$)[a-z]))/g, function(m){
return m[u]()
})
}
@christian-fei
christian-fei / notes.md
Last active August 29, 2015 14:23
mock roles not objects
jQuery(document).ready(function() {
var attributes = {}
attributes["IT"] = 'data-amazon-it';
attributes["GB"] = 'data-amazon-gb';
var url = "http://freegeoip.net/json/";
jQuery.getJSON(url, function(data) {
var code = data.country_code;
jQuery('[data-amazon]').each(function(index, link) {
link = jQuery(link);
vagrant@pomodoro:/vagrant/services/pomodoro$ docker restart pomodoro-api && docker inspect pomodoro-a
"IPAddress": "172.17.0.23",
vagrant@pomodoro:/vagrant/services/pomodoro$ docker restart pomodoro-api && docker inspect pomodoro-api | grep IPAddress
"IPAddress": "172.17.0.24",
vagrant@pomodoro:/vagrant/services/pomodoro$ docker restart pomodoro-api && docker inspect pomodoro-api | grep IPAddress
"IPAddress": "172.17.0.25",
vagrant@pomodoro:/vagrant/services/pomodoro$ docker restart pomodoro-api && docker inspect pomodoro-api | grep IPAddress
"IPAddress": "172.17.0.26",

Codice difficile da testare

Codice è difficile da testare quando si ha parti di codice che:

  • ha variabili (stato) globali, Singletons
  • metodi statici che forzano test su grandi parti di codice, che potenzialmente ha una connessione al database etc.
  • troppi conditionals

Come si scrive codice testabili

@christian-fei
christian-fei / xpex.md
Last active August 29, 2015 14:07
Extreme Programming Explained

Quali sono i rischi di un progetto software?

  • il software non rispecchia i requisiti del business per mancanza di comunicazione e costante feedback. Non solve il problema del business.
  • dopo la messa in produzione il problema da risolvere lato business è cambiato.
  • il costo di modifica a seguito di un cambiamento diventa elevato, se non rischioso perchè vari componenti del software sono connessi tra di loro ed i test non sono sufficienti per garantire la stabilità del sistema.
  • i programmatori che lavorano da mesi sullo stesso progetto (da soli) si sono stancati del progetto e manca l'entusiasmo
  • feature prioritarie lato business non vengono consegnate, o dopo feature secondarie
  • le date di release non vengono mantenute dai programmatori, perchè il progetto è sfuggito di mano
  • il progetto viene cancellato dopo varie release non centrate
  • il progetto diventa complicato, difficile da mantenere. e logicamente "non c'è tempo per rifattorizzare"
@christian-fei
christian-fei / nginx.conf
Last active August 29, 2015 14:06 — forked from thoop/nginx.conf
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name and in the rewrite rule) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
#!/bin/bash
while true
do
clear
echo "====================================================="
ps ax | grep $1 | grep -v grep | grep -v "mp "
echo "="
ps ax | grep $1 | grep -v grep | grep -cv "mp "
echo "=====================================================";
echo "Press ctrl+c to stop"