Skip to content

Instantly share code, notes, and snippets.

View uhtred's full-sized avatar

Daniel França uhtred

View GitHub Profile
@uhtred
uhtred / gist:a62983ce17bbc1ec803ffe43c83eb3e7
Created October 29, 2016 00:18
Angular: Order translated options
ng-options="item.key as item.name=('telecon.entity.' + item.key | translate) for item in profileEditCtrl.keys | orderBy:'name'"
@uhtred
uhtred / run.js
Created September 30, 2016 22:26
Casperjs: cache html
var fs = require('fs');
function savePage(name, content) {
console.log('savePage', name)
fs.write('pages/' + name + '.html', content, 'w');
}
const domain = 'https://algartelecom.com.br'
const pages = [
@uhtred
uhtred / lodash.toggle-array-value.js
Created September 26, 2016 20:55
Lodash: toggle array value
_.xor([1], [2]);
= [1, 2]
_.xor([1, 2], [2]);
= [1]
@uhtred
uhtred / mob-x.pitfalls.js
Created July 29, 2016 19:39
Mob-X Pitfalls
class Todo {
@observable done = true
@observable title = "test"
}
const todo = new Todo()
"done" in todo // true
todo.hasOwnProperty("done") // false
Object.keys(todo) // []
@uhtred
uhtred / gist:73568ad7480ed6aa38675b61290a50e9
Created July 22, 2016 21:44
Jquery prefilter restfull
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
if ((options.type === 'post' || options.type === 'put') && options.contentType === 'application/json') {
options.data = JSON.stringify(originalOptions.data);
}
options.url = 'baserUrl' + originalOptions.url + '?gw-app-key=' + window.config.gwAppKey;
}),
options.files.forEach((pattern) => {
files = files.concat(glob.sync(pattern))
})
<table width="600" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
<tr>
<td style="width: 600px; height: 430px; background-image: url('https://s3-sa-east-1.amazonaws.com/vivo-invitation/invitation_email/media/img/header-background-full.png');">
<!--[if gte mso 9]>
<v:image xmlns:v="urn:schemas-microsoft-com:vml" id="theImage" style='behavior: url(#default#VML); display: inline-block; position: absolute; width: 600px; height: 430px; top: 0; left: 0; border: 0; z-index: 1;' src="https://s3-sa-east-1.amazonaws.com/vivo-invitation/invitation_email/media/img/header-background-full.png" />
<v:shape xmlns:v="urn:schemas-microsoft-com:vml" id="theText" style='behavior: url(#default#VML); display: inline-block; position: absolute; width: 600px; height: 430px; top: -5; left: -10; border: 0; z-index: 2;'>
<div>
<![endif]-->
<table width="600" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse; colo
@uhtred
uhtred / validation-rules-service.js
Created June 2, 2016 20:55
JS: Validation Rules Service
{
password: [
{
code: 'RANGE',
pattern: '^.{6,20}$',
flags: 'g',
message: 'Senha deve ter no mínimo 6 e no máximo 20 caracteres'
},
{
code: 'LETTERS_NUMBERS',
git branch -d $(git branch --merged)
// util/history.js
import { Router, useRouterHistory } from 'react-router'
import { createHashHistory } from 'history'
const appHistory = useRouterHistory(createHashHistory)({ queryKey: false });
export default appHistory;
// use.js