Skip to content

Instantly share code, notes, and snippets.

View elmariofredo's full-sized avatar
💭
building Cloud Native Thermostat 🔥 🥶

Mario Vejlupek elmariofredo

💭
building Cloud Native Thermostat 🔥 🥶
View GitHub Profile
@elmariofredo
elmariofredo / app\app.component.ts
Last active July 1, 2016 11:06 — forked from Hotell/app\app.component.ts
ngMetadata transclude=element terminal=true
import { Component } from 'ng-metadata/core';
import { BeerComponent } from './beer.component.ts';
import { FoamDirective } from './foam.directive.ts';
import { TasteDirective } from './taste.directive.ts';
@Component({
selector: 'my-app',
template: '<my-beer my-foam my-taste></my-beer>',
directives: [ BeerComponent, TasteDirective, FoamDirective ]
})
@elmariofredo
elmariofredo / NOTES.md
Last active February 27, 2016 10:21
ng1-migration-workshop

Guide

Prerequisites

  • finished Phone cat app by following AngulaJS Styleguide (components tree)
  • there should be one component per file. This not only makes components easy to navigate and find, but will also allow us to migrate them between languages and frameworks one at a time. In this example application, each controller, factory, and filter is in its own source file.
  • The Folders-by-Feature Structure and Modularity rules define similar principles on a higher level of abstraction: Different parts of the application should reside in different directories and Angular modules.

When an application is laid out feature per feature in this way, it can also be migrated one feature at a time. For applications that don't already look like this, applying the rules in the Angular style guide is a highly recommended preparation step. And this is not just for the sake of the upgrade - it is just solid advice in general!

@elmariofredo
elmariofredo / install-root-cert.sh
Created February 16, 2016 12:29
Simple script to install root cert from self signed server
#!/bin/bash
# Usage: $ install-root-cert.sh serve.name.local 8443
openssl s_client -showcerts -connect $1:$2 </dev/null 2>/dev/null|openssl x509 -outform PEM > ./$1.pem
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./$1.pem
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>cz.vejlupek.cleandownloads</string>
<key>ProgramArguments</key>
<array>
<string>mv</string>
<string>~/Downloads/*(mw+1) ~/.Trash</string>
function pickWinner() {
const tweets = document.querySelectorAll('.tweet-text strong')
const winnerHash = tweets[Math.floor(Math.random() * tweets.length)];
alert( '@' + winnerHash.parentElement.parentElement.parentElement.parentElement.querySelector('.username>b').innerText );
}
@elmariofredo
elmariofredo / .profile
Created December 9, 2015 00:54
NIX package manager with npm
export PATH="$PATH:$(npm config get prefix)/bin
@elmariofredo
elmariofredo / remove-javascript-files.sh
Last active November 30, 2015 17:08
Remove javascript files from typescript project
#!/bin/zsh
find . -name '*.js.map' -exec sh -c 'rm ${0%.map}.js $0' {} \;
@elmariofredo
elmariofredo / node-install.sh
Created November 6, 2015 10:33
Centos node install
# Setup NodeJS in case is not setup yet
sudo yum install tar xz -y
curl "https://nodejs.org/download/release/v5.0.0/node-v5.0.0-linux-x64.tar.xz" -o node.tar.xz
tar xf node.tar.xz
rm -f node.tar.xz
sudo mv node-v5.0.0-linux-x64 /opt/node
export PATH=/opt/node/bin:$PATH
@elmariofredo
elmariofredo / xvfb-setup.sh
Last active January 31, 2016 07:59
Setup Centos 6 with Firefox using Xvfb for karma testing
# Install necessary software
sudo yum install firefox xorg-x11-server-Xvfb dbus -y
# Set DISPLAY id, should go to /etc/profile.d/xvfb.sh
export DISPLAY=:99
# Generate machine id if doesn't already generated in /var/lib/dbus/machine-id
sudo /bin/dbus-uuidgen --ensure
# Download xvfb to /etc/init.d/xvfb
@elmariofredo
elmariofredo / xvfb
Last active November 5, 2015 11:22
xvfb init script centos
#!/bin/bash
#chkconfig: 345 95 50
#description: Starts xvfb on display 99
if [ -z "$1" ]; then
echo "`basename $0` {start|stop}"
exit
fi
case "$1" in