Skip to content

Instantly share code, notes, and snippets.

View webarthur's full-sized avatar
✌️

Arthur Ronconi webarthur

✌️
View GitHub Profile
@webarthur
webarthur / no-sudo-docker.sh
Created September 22, 2016 00:14
remove sudo access from docker
sudo groupadd docker
sudo gpasswd -a username docker
sudo service docker restart
@webarthur
webarthur / routes.php
Last active October 3, 2016 16:35
Small php router function
<?php
function routes($path, $routes) {
foreach ($routes as $route) {
// regular expressio to detect path tags
$tagsregex = '/(\{([\w]+)\})/';
// regular expression to test route
$regex = '/' . str_replace('/', '\\/', "^{$route[0]}$") . '/';
@webarthur
webarthur / .htaccess
Created September 3, 2016 01:21
Configure Laravel public dir as root path
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
@webarthur
webarthur / post-receive
Created August 25, 2016 01:38
git pull with www-data
# file: .git/hooks/post-receive
#!/bin/sh
export GIT_WORK_TREE=/var/www/domain.com/htdocs
cd $GIT_WORK_TREE
sudo -u www-data git checkout -f
# file: visudo
Defaults!/usr/bin/git env_keep=GIT_WORK_TREE
webarthur ALL=(www-data) NOPASSWD: /usr/bin/git
webarthur ALL=(www-data) NOPASSWD: /bin/chmod
@webarthur
webarthur / pure-slidedown-slideup.css
Last active December 7, 2024 09:59
Pure CSS slidedown / slideup animation using transform translateY
.slide-up, .slide-down {
overflow:hidden;
}
.slide-up > div, .slide-down > div {
transform: translateY(-100%);
transition: .4s ease-in-out;
}
.slide-down > div {
transform: translateY(0);
}
@webarthur
webarthur / async-gists.js
Last active September 4, 2016 17:43
Dynamically embedding Gists
document.addEventListener("DOMContentLoaded", function(event) {
document.write = function (code) {
var gistURL, div, a, style;
// create a <div> element to search gist url
div = document.createElement('div')
div.innerHTML = code
@webarthur
webarthur / gulpfile.js
Last active July 25, 2016 18:42
gulp-file-include, exemplo avançado
var gulp = require('gulp')
, markdown = require('markdown')
, fileinclude = require('gulp-file-include');
// importa json para variável
var app = require('./package.json')
// task principal
gulp.task('default', function() {
gulp.src(['index.html'])
@webarthur
webarthur / index.html
Last active July 25, 2016 21:36
Exemplo de HTML com include usando Gulp + gulp-file-include
@@include('header.html')
<article>
<header>
<h1>Título do artigo</h1>
</header>
<section>
<h3>Subtítulo do artigo</h3>
<p>Mussum Ipsum, cacilds vidis litro abertis. Nullam volutpat risus nec leo commodo, ut interdum diam laoreet.</p>
@webarthur
webarthur / gulpfile.js
Created July 25, 2016 17:42
Includes HTML com ajuda do plugin gulp-file-include para Gulp
var gulp = require('gulp')
, fileinclude = require('gulp-file-include');
gulp.task('default', function() {
gulp.src(['index.html'])
.pipe(fileinclude())
.pipe(gulp.dest('./'));
});
@webarthur
webarthur / routes.js
Created July 24, 2016 14:40
Roteador javascript com pushState
var routes = (function(history){
// configura função pushState para checar rotas
var pushState = history.pushState;
history.pushState = function(state) {
typeof(history.onpushstate) == "function" && history.onpushstate({state: state});
setTimeout(routes.check, 10);
return pushState.apply(history, arguments);
};