Skip to content

Instantly share code, notes, and snippets.

View mauriciodarocha's full-sized avatar

Mauricio Rocha mauriciodarocha

View GitHub Profile
@mauriciodarocha
mauriciodarocha / HttpServer.cs
Created May 29, 2023 20:12 — forked from define-private-public/HttpServer.cs
A Simple HTTP server in C#
// Filename: HttpServer.cs
// Author: Benjamin N. Summerton <define-private-public>
// License: Unlicense (http://unlicense.org/)
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Threading.Tasks;
@mauriciodarocha
mauriciodarocha / launch.json
Created June 13, 2021 23:54
Debug jsx test files in VSCode with Jest
{
"version": "0.2.0",
"configurations": [
{
"name": "1 - Debug CRA Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
"runtimeArgs": [
"--inspect-brk",
@mauriciodarocha
mauriciodarocha / formatNumberBR.js
Last active April 20, 2021 16:05
Formata o número com separação decimal no formato para o Brasil. "839,66,123,1,234,560.0000000001" => "839.661.231.234.560,0000000001"
/**
Converte número separados por vírgulas p/ pontos, e decimal por vírgula.
string valor
Ex. formatNumberBR("839,66,123,1,234,560.0000000001") => "839.661.231.234.560,0000000001"
*/
function formatNumberBR(valor) {
return valor.replace(/\./g, '|').replace(/,/g, '').replace(/(\d)(?=((\d{3})+)(?:\|))/g, '$1.').replace(/\|/g, ',');
}
public class MyClass {
public static void main(String args[]) {
String results = FizzBuzz(1,20);
System.out.println(results);
}
public static String FizzBuzz(int k, int l){
String n = "";
for(int i=k;i<=l;i++){
if(i%3==0)
@mauriciodarocha
mauriciodarocha / delayApp.js
Last active August 23, 2018 03:01
delay loading of app
/** 201808222232 */
var delayApps = (function ($, window, document, undefined) {
return function (apps,delay) {
var _apps = "function"===typeof apps ? [apps] : apps instanceof Array ? apps : undefined;
if("undefined"===typeof apps&&!(apps instanceof Array)) { return false; }
var _self = this;
var _delay = delay || 10000;
var __timeout = _self.setTimeout(function () {
"object"===typeof console&&"function"===typeof console.log&&console.log('Starting apps.');
$.each(_apps,function (ndx,_app) {
@mauriciodarocha
mauriciodarocha / dummy-web-server.py
Created September 16, 2016 02:28 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
var adicionarProduto = function(sku,qtd,seller){
var id = sku;
var quantity = qtd||1;
var seller_id = seller||1;
var product = {
id: id,
quantity: quantity,
seller: seller_id
};
@mauriciodarocha
mauriciodarocha / MetaObject.php
Created May 30, 2016 23:27 — forked from CHH/MetaObject.php
PHP does Meta Programming too! (Requires PHP 5.4)
<?php
namespace CHH;
trait MetaObject
{
protected static $__metaClass;
static function setMetaClass(MetaClass $metaClass)
{
@mauriciodarocha
mauriciodarocha / gist:5321317
Last active December 15, 2015 20:49
Google Conversion Tag Image. Insere imagem para google ad services.
<script type="text/javascript">
$(document).ready(function (param) {
place_google_conversion_img_tag();
});
var place_google_conversion_img_tag = function () {
// não passa deste ponto se não for a página "finaliza-compra"
if(!$('body').hasClass("finaliza-compra")) return false;
// não passa deste ponto se já foi inserida a tag.
@mauriciodarocha
mauriciodarocha / fix_sku_selection.js
Created February 19, 2013 15:04
Conserta a seleção de sku pelo "Label". Faz o on/off funcionar. Para usar coloque dentro de uma função e execute a mesma ao entrar na página de produto.
var _removeUnavaliableStyle = window.removeUnavaliableStyle;
// function override
window.removeUnavaliableStyle = function (selector)
{
// fix on/off label style
if(typeof selector=="undefined")
jQuery(".topic label").removeClass("sku-picked");
_removeUnavaliableStyle(selector);
}