Skip to content

Instantly share code, notes, and snippets.

View wescleymatos's full-sized avatar
:octocat:
I'm ready!

Wescley Matos wescleymatos

:octocat:
I'm ready!
View GitHub Profile
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);
/**
* Função para validar sequencia de digitos de Renavam
*
* @link http://blog.victorjabur.com/2010/05/28/renavam_veiculos_java/ Função baseada em uma de java retirada desse link
* @param string|int renavam Sequencia de digitos do renavam
* @return boolean
*/
function verificaRenavam( renavam ) {
var d = renavam.split("");
@wescleymatos
wescleymatos / index.html
Created July 29, 2015 14:18 — forked from cauerego/example.html
jquery validate CPF, a brazilian document equivalent to social security - try: http://jsbin.com/gist/873308#preview ( originally at http://jsbin.com/agida4/16/edit )
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script class="jsbin" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js" type="text/javascript"></script>
<script src="jquery.validate.cpf.js"></script>
<script type="text/javascript">
$(function () {
var $cpf = $("#id_cpf").attr("name");
var $params = {debug:false, rules:{}, messages:{}};
@wescleymatos
wescleymatos / CarController.cs
Created February 12, 2016 16:28 — forked from johnnyreilly/CarController.cs
Unit testing ModelState using Moq
using System.Web.Mvc;
namespace MyApp
{
public class CarController : Controller
{
//...
public ActionResult Edit(CarModel model)
{
@wescleymatos
wescleymatos / index.html
Created February 19, 2016 20:42 — forked from k33g/index.html
Vue.js + ES6
<div id="demo">
<h1>{{bob.fields.firstName}} {{bob.fields.lastName}}</h1>
</div>
<ul id="humans-list">
<li v-repeat="humans">
{{fields.firstName}} {{fields.lastName}}
</li>
</ul>
<snippet>
<content><![CDATA[public function get${1/(.*)/\u$1/}()
{
return \$this->${1:$SELECTION};
}
public function set${1/(.*)/\u$1/}(\$$1)
{
return \$this->$1 = \$$1;
}
@wescleymatos
wescleymatos / es7-async-await.js
Created September 27, 2017 06:31 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@wescleymatos
wescleymatos / thinced.js
Created October 2, 2017 20:03 — forked from varmais/thinced.js
Geolocation to Promise wrap example
var getPosition = function (options) {
return new Promise(function (resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
getPosition()
.then((position) => {
console.log(position);
})
@wescleymatos
wescleymatos / .gitlab-ci.yml
Created January 12, 2018 12:12 — forked from zerda/.gitlab-ci.yml
Gitlab CI for ASP.Net Core project
image: microsoft/aspnetcore-build:1.1
variables:
PROJECT_DIR: "app"
cache:
key: "$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME"
paths:
- .nuget/