Skip to content

Instantly share code, notes, and snippets.

@fsouza
fsouza / gerar.php
Created May 6, 2011 02:32
Script usado para salvar estáticos do Dev in Cachu (feião :P)
<?php
require('libs/Smarty.class.php');
require('util.php');
$smarty = new Smarty;
$smarty->assign('titulo', 'Avalia&ccedil;&atilde;o');
$html = $smarty->fetch('avaliacao.tpl');
save_cached_content($html, 'avaliacao.html');
@fsouza
fsouza / navigate.py
Created May 7, 2011 01:22
A script that navigates on a Wordpress blog, visiting all posts, and a customized collection of links (using splinter)
from splinter.browser import Browser
def navigate_on_blog(blog_url, entry_selector, previous_selector, *link_selectors):
browser = Browser('webdriver.firefox')
browser.visit(blog_url)
browser.find_by_css(entry_selector).first.click()
while (browser.is_element_present_by_css(previous_selector)):
element = browser.find_by_css(previous_selector).first
print 'Clicking %s... ' % element['href'],
@fsouza
fsouza / decorators.py
Created May 17, 2011 01:23
Decorator for using django-htmlmin on Flask views.
from functools import wraps
from htmlmin.minify import html_minify
def minified_response(function):
@wraps(function)
def minified_view(*args, **kwargs):
return_value = function(*args, **kwargs)
if type(return_value) == unicode:
return html_minify(return_value.encode('utf-8'))
return return_value
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<title>Page Title</title>
<style type="text/css" media="screen">
.selected {
background: blue;
}
</style>
package variables
import (
"fmt"
)
func main() {
number := 200
fmt.Println(number)
number = 50
package main
import (
"fmt"
"math"
)
func GenerateCompleteSequence(number uint) chan uint {
channel := make(chan uint)
go func(){
package main
import (
"fmt"
"http"
)
func main() {
}
package main
import (
"fmt"
"http"
)
func CleanCache(blogUrl string) {
content := make([]byte, 1000000)
client := new(http.Client)
package main
import (
"fmt"
"http"
)
func CleanCache(blogUrl string) {
content := make([]byte, 1000000)
client := new(http.Client)
// caracfun.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
char *replicar(char letra, int n)
{
char *str;