Skip to content

Instantly share code, notes, and snippets.

View williampsena's full-sized avatar

William Sena williampsena

View GitHub Profile
function randomString()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
#/bin/bash
SOURCE=$1
TARGET=$2
mkdir -p $TARGET
echo "Extracting 7z files from $SOURCE to $TARGET"
7z x "$SOURCE/*.7z" -o"$TARGET"
# how to use -> extract-7z-files.sh /tmp/source /tmp/target
---
- hosts: home
vars:
host_port: 80
expose_port: 9000
portainer_endpoint: "http://localhost:{{ host_port }}/api"
tasks:
- name: Ensure portainer container is running
@williampsena
williampsena / js-call-apply.es6.js
Created June 5, 2016 23:53
Javascript Call and Apply - ES6
function notifyClient(message) {
alert(message);
}
function sendMail(customer, total) {
notifyClient.call(this, `TODO: Send mail, (${String(customer.id)}, ${String(total)})`);
}
function getDeals() {
var product = arguments[0];
@williampsena
williampsena / js-call-apply.es5.js
Last active June 5, 2016 23:52
Javascript Call and Apply - ES5
function notifyClient(message) {
alert(message);
}
function sendMail(customer, total) {
notifyClient.call(this, 'TODO: Send mail, (' + String(customer.id) + ', ' + String(total) + ')');
}
function getDeals() {
var product = arguments[0];
function isNotificationEnabled() {
if(!window.Notification) {
console.log('Oooh no! Your browser is too old!');
return false;
}
return true;
}
function RequestPermission(callback){
function RequestPermission(callback){
callback = callback || function(status) {
console.log('Status da permissão: ' + status);
callback(status === "granted");
};
Notification.requestPermission(callback);
}
function SendNotification(message, callback){
function RequestPermission(callback){
callback = callback || function(status) {
console.log('Status da permissão: ' + status);
callback(status === "granted");
};
Notification.requestPermission(callback);
}
@williampsena
williampsena / notification-api-compatibility.js
Last active March 28, 2016 02:12
Notification API - Permission
function isNotificationEnabled() {
if(!window.Notification) {
console.log('Oooh no! Your browser is too old!');
return false;
}
return true;
}