View script.sh
# Esta não retorna resultados
curl -v -X POST \
-d \
'{"search":{"pattern":"da","target":"http://semantica.globo.com/G1/cita_a_entidade","fields":["rdfs:label","base:dados_buscaveis"],"graphs":["http://semantica.globo.com/G1/"]},"response":{"classes":[{"@type":"http://semantica.globo.com/base/Organizacao","instance_fields":["http://semantica.globo.com/base/sameAs","http://semantica.globo.com/base/data_de_fundacao","http://semantica.globo.com/base/descricao","http://semantica.globo.com/G1/genero_gramatical","http://semantica.globo.com/G1/path_topico","http://semantica.globo.com/base/twitter","http://semantica.globo.com/base/url_do_permalink","http://semantica.globo.com/base/nome_completo","http://semantica.globo.com/G1/foto_perfil","http://semantica.globo.com/base/dados_buscaveis","http://semantica.globo.com/base/sigla","http://www.w3.org/2000/01/rdf-schema#label"]},{"@type":"http://semantica.globo.com/base/Criatura","instance_fields":["http://semantica.globo.com/base/sameAs","http://semantica.globo.com/bas
View cron.sh
#!/bin/bash
# usage: cron.sh <your_command> <sleep_duration>
while :;
do
clear
date
$1
sleep $2
done
View fizzbuzz_test.rb
require 'test/unit'
require_relative 'fizzbuzz.rb'
class FizzBuzzTest < Test::Unit::TestCase
def test_given_tree_it_should_print_fizz
#given
number = 3
expected = "Fizz"
#when
result = FizzBuzz.when(number)
View tests.py
class TestFeedCollectionHandler(FeedServerTestCase):
headers = {'Content-Type': 'application/json'}
def setUp(self):
super(TestFeedCollectionHandler, self).setUp()
self.data = {'uri': 'glb.com/minhaeditoria/',
'product': 'glb-feed',
'name': 'globo feed',
'images': {},
View factory_rust.rs
pub trait Command {
fn execute(&self) -> String;
}
struct AddCmd;
struct DeleteCmd;
impl Command for AddCmd {
fn execute(&self) -> String { "It add".into() }
}
View music_folder_sorter.rb
require 'fileutils'
musics = Dir["*.mp3"]
musics.each do |music|
band_name = music.split("-").first
dir_destiny = "#{band_name}/"
Dir.mkdir(band_name) unless File.exists? band_name
FileUtils.mv music, dir_destiny
end
View udp-rust
use std::net::UdpSocket;
extern crate rustc_serialize;
use rustc_serialize::json;
use std::str;
use std::string::String;
fn main() {
match main_loop() {
Err(e) => panic!(e),
_ => ()
View iron_in_10lines.rs
extern crate iron;
use iron::prelude::*;
use iron::status;
fn main() {
Iron::new(|_: &mut Request| {
Ok(Response::with((status::Ok, "É bom esse iron!")))
}).http("localhost:3000").unwrap();
}
View collatz.rs
// Responsible for calcule Collatz Conjecture
// n -> n/2 (if n is pair) n -> 3n + 1 (if n is odd)
//
fn calcule(num: u64) -> u64 {
if num <= 1 { return 1; };
if num % 2 == 0 {
num / 2
} else{
3 * num + 1
View deamon.py
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method