Skip to content

Instantly share code, notes, and snippets.

View felipsmartins's full-sized avatar
🇧🇷
loading, please wait a few seconds...

Martins, F. felipsmartins

🇧🇷
loading, please wait a few seconds...
View GitHub Profile
<?php
/**
* Reconstói todo o conteúdo HTML sob $node;
* em resumo, isso funciona como innerHTML do Javascript
*
* @param DOMNode $node
* @return string Conteúdo HTML reconstruído
*/
function dom_reconstruct(DOMElement $node){
@felipsmartins
felipsmartins / alsa-mute-unmute.py
Created June 26, 2014 16:59
Alsa mute/unmute audio - Python
#!/usr/bin/env python
#coding: utf-8
import sys
import subprocess
mute_command = 'amixer sset Master mute'
unmute_command = 'amixer sset Master unmute'
def sys_message(msg):
@felipsmartins
felipsmartins / grepcat.py
Last active August 3, 2020 21:52
find + cat + grep -i -P
#!/usr/bin/env python
# coding: utf-8
"""Pesquisador de padrões de strings em arquivos de texto.
A busca nos diretórios recursivamente é suportada.
"""
import sys
import os
import re
import argparse
import mimetypes
#!/usr/bin/env python
#coding: utf-8
"""Captura os links de download direto do portal hyuugadownloads.com.br.
$ hyuuga.py --help
"""
import sys
import os
import tempfile
import argparse
import urllib2
<?php
include ('simple_html_dom.php');
$html = file_get_html('http://172.16.1.15/web/guest/en/websys/status/getUnificationCounter.cgi');
$found = $html->find(".staticProp", 1); # retorna um objeto não iterável ou NULL
if (!$found) {
exit("Nenhum elemento encontrado!");
}
# use src/Mailer/MailerInterface
class MailerService
{
public function sendMail(MailerInterface $mailer)
{
//...
}
}
# use Illuminate\Contracts\Mailer
/* Faça um programa em Linguagem C que leia uma matriz de
ordem 100 (ou seja 100x100) composta por números inteiros positivos
e escreva qual o maior número de fibonacci da coluna coluna, onde coluna é o
numero inteiro informado pelo usuário.
*/
#include <stdio.h>
int isFibonacci(n) {
<?php
# StackOverflow related question: http://stackoverflow.com/questions/34886008/create-nested-array-by-array-of-key
# The @Gavriel's answer is pretty good!
# But it could be somewhat more "*easy to catch*" like this:
$new = $value;
foreach (array_reverse($keys) as $valueAsKey) $new = [$valueAsKey => $new];
# In fact, it's a version of @Gavbriel's answer using array_reverse() and some semantic variables.
import os
import os.path as path
htmlroot = '/home/martins/Desktop/htmltest'
asset_replacements = {
'http://symfony.com/js/v5/all.js': '{}_static/all.js',
'http://symfony.com/css/compiled/v5/all.css': '{}_static/all.css'
}
def calculate_relative_path_to_root(path, start='html'):
var searcher = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: 'http://host.com/busca?q=%QUERY',
wildcard: '%QUERY'
}
});
var typeahead = $('input.typeahead').typeahead({