Skip to content

Instantly share code, notes, and snippets.

View max2320's full-sized avatar
🚀

Anderson Rocha (MAX) max2320

🚀
  • Canada
View GitHub Profile
#!/bin/bash
sudo vde_switch -d -sock /tmp/sw1 -M /tmp/sw1.mgmt
sudo slirpvde -d -s /tmp/sw1 -q
vm-file(){
sudo qemu-system-x86_64 -enable-kvm -m 3150 -vga std -soundhw hda \
-cpu host -smp 4,sockets=1,cores=2,threads=2 \
import Promise from 'promise-polyfill';
import fetchPonyfill from 'fetch-ponyfill';
if (!window.Promise) {
window.Promise = Promise;
}
const {fetch, Request, Response, Headers} = fetchPonyfill();
export default class Download {
constructor(url, name){
@max2320
max2320 / dsn.sh
Created December 13, 2017 12:14
DSN generator to postgres
#usage: $ create_dsn 'username' 'password' 'host'
create_dsn(){
USER_NAME=$1
PASSWORD=$2
HOST=$3
echo "CREATE DATABASE $USER_NAME;" >> "$USER_NAME.dsn"
echo "CREATE ROLE $USER_NAME LOGIN PASSWORD '$PASSWORD';" >> "$USER_NAME.dsn"
echo "ALTER DATABASE $USER_NAME OWNER TO $USER_NAME;" >> "$USER_NAME.dsn"
@max2320
max2320 / api.js
Last active November 6, 2017 13:39
import Connector from './connector';
export default class Api{
constructor(){
this.connector = new Connector();
}
all(onSuccess,onError){
this.connector.get(`${this.url}`)
.success(onSuccess).fail(onError);
@max2320
max2320 / map.js
Created October 10, 2017 18:03
How to implement a map algorithm in js
Array.prototype.recMap = function(callback){
var cicle = function(current, collection, fnModifier) {
console.log(current, collection, fnModifier)
if(current < collection.length){
collection[current] = fnModifier(collection[current]);
return cicle(current + 1, collection, fnModifier);
}else{
return collection;
@max2320
max2320 / brazilian-states-coordinates.rb
Created June 18, 2016 16:39
Brazilian States Coordinates (in deg)
State.find_or_create_by(id: 1, name: 'Acre', acronym: 'AC', latitude: -9.11, longitude: -70.52, zoom: 6)
State.find_or_create_by(id: 2, name: 'Alagoas', acronym: 'AL', latitude: -9.57, longitude: -36.55, zoom: 6)
State.find_or_create_by(id: 3, name: 'Amapá', acronym: 'AP', latitude: 1, longitude: -52, zoom: 6)
State.find_or_create_by(id: 4, name: 'Amazonas', acronym: 'AM', latitude: -5, longitude: -63, zoom: 6)
State.find_or_create_by(id: 5, name: 'Bahia', acronym: 'BA', latitude: -12.52, longitude: -41.69, zoom: 6)
State.find_or_create_by(id: 6, name: 'Ceará', acronym: 'CE', latitude: -5.08, longitude: -39.65, zoom: 6)
State.find_or_create_by(id: 7, name: 'Distrito Federal', acronym: 'DF', latitude: -15.795, longitude: -47.757778, zoom: 6)
State.find_or_create_by(id: 8, name: 'Espírito Santo', acronym: 'ES', latitude: -20.318889, longitude: -40.337778, zoom: 6)
State.find_or_create_by(id: 9, name: 'Goiás', acronym: 'GO', latitude: -15.933333, longitude: -50.133333, zoom: 6)
State.find_or_create_by(id: 10, na
<!DOCTYPE html>
<html>
<head>
<title>teste</title>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
</head>
<body>
<script>
function newDOM(tag){
@max2320
max2320 / wp-permission-fix
Created February 16, 2016 12:56
This bash function improve security for your wp on aws
// usage wp-permission-fix <wp dir>
wp-permissions-fix(){
sudo chown -R ubuntu:www-data $1
sudo find $1 -type d -exec chmod 755 {} \;
sudo find $1 -type f -exec chmod 644 {} \;
sudo find $1/wp-content/uploads/ -type d -exec chmod 775 {} \;
}
@max2320
max2320 / html_validator.rb
Last active January 8, 2016 19:00
HTML5 Validator support for ruby tests with rspec.
module HTMLValidator
def filled_field_is_valid(selector)
page.evaluate_script "document.querySelector('#{selector}').validity.valid"
end
def filled_field_validity(selector)
page.evaluate_script "document.querySelector('#{selector}').validity"
end
end