Skip to content

Instantly share code, notes, and snippets.

View tassoevan's full-sized avatar
🏠
Working from home

Tasso Evangelista tassoevan

🏠
Working from home
View GitHub Profile
@tassoevan
tassoevan / .htaccess
Created March 21, 2013 20:01
.htaccess snippets
# ------------------------------------------------------------------------------
# Redirecionar para mobile a partir do agente de usuário
# ------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://m.example.com/ [L,R=302]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@tassoevan
tassoevan / init.js
Last active December 15, 2015 20:48
Basic jQuery plugins initialization
// Basic jQuery plugins initialization
var MyNamespace = MyNamespace || {};
MyNamespace.applyPlugins = function(parent) {
if (!parent)
parent = $('body');
$('[data-focus=auto]', parent).focus();
var richEdits = $('textarea[data-rich=true]');
@tassoevan
tassoevan / example.php
Created May 6, 2013 00:08
Easy access to \Respect\Validation\Validator class
<?php
// Author's recommendation
use Respect\Validation\Validator as v;
$number = 123;
v::numeric()->validate($number); //true
// The author method can be a little uncomfortable, because
// the 'v' alias will be present in all source code and it
// is meaningless according OOP.
@tassoevan
tassoevan / serialization.php
Created July 19, 2013 00:34
A more reliable method to serialize closures.
<?php
/**
* Serializes a closure as string
* @param \Closure $closure
* @return string
*/
function serializeClosure(\Closure $closure) {
$ref = new ReflectionFunction($closure);
$tokens = token_get_all(file_get_contents($ref->getFileName()));
@tassoevan
tassoevan / parse-url.js
Last active December 20, 2015 04:19
Parsing URLs with DOM
function parseURL(url)
{
var a = document.createElement('a');
a.href = url;
return {
'href': a.href
, 'scheme': a.protocol
, 'host': a.host
, 'port': a.port
, 'path': a.pathname
@tassoevan
tassoevan / gist:6423407
Created September 3, 2013 12:42
jQuery Theme for Twitter Bootstrap 3
body {
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
-ms-font-smoothing: antialiased;
font-smoothing: antialiased;
-moz-text-shadow: 0 0 1px rgba(0, 0, 0, 0.01);
-ms-text-shadow: 0 0 1px rgba(0, 0, 0, 0.01);
text-shadow: 0 0 1px rgba(0, 0, 0, 0.01);
@tassoevan
tassoevan / LICENSE
Created December 18, 2013 13:20
MIT license for forked project
Original work Copyright (c) 2013 Acme Corp
Modified work Copyright (c) 2013 Tasso Evangelista
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
@tassoevan
tassoevan / share.sh
Created December 24, 2013 16:22
Shares the folder `<path>` with sharing name `<sharing>` and `<comment>` in your network.
# Shares the folder <path> with sharing name <sharing> and <comment> in your network
sudo net usershare add <sharing> <path> <comment> everyone:F guest_ok=y
@tassoevan
tassoevan / transparent-window.py
Last active November 3, 2017 03:16
Transparent window for WebView (WebKit) in Python (in progress)
import sys
from gi.repository import Gtk, Gdk, WebKit
class WebKitWindow(Gtk.Window):
scrolls = None
webView = None
def __init__(self, url, transparent=False):
Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL, title='')
self.scrolls = Gtk.ScrolledWindow()