Skip to content

Instantly share code, notes, and snippets.

View cezinha's full-sized avatar

Celina Uemura cezinha

View GitHub Profile
@cezinha
cezinha / sleep.js
Created September 10, 2020 11:39
JS Sleep with Promise
/* example:
console.time('sleep');
await sleep(3000);
console.timeEnd('sleep');
*/
export const sleep = async (timer) => new Promise((resolve) => {
setTimeout(() => resolve("done"), timer);
});
class TextSized extends StatelessWidget {
const TextSized({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
final String text = "Text in one line";
final TextStyle textStyle = TextStyle(
fontSize: 30,
color: Colors.white,
);
@cezinha
cezinha / convert.js
Last active January 22, 2025 16:35
Convert \uXXXX ASCII to Unicode format
var data = "\\u00e3o\\u00e9\\u00e7\\u00e9\\u00e2\\u00e3o\\u00e7\\u00e3\\u00e0\\u00e3";
function convertData(data) {
let hexDecode = (str) => {
let j;
let hexes = str.match(/.{1,4}/g) || [];
let back = "";
for(j = 0; j<hexes.length; j++) {
back += String.fromCharCode(parseInt(hexes[j], 16));
}
@cezinha
cezinha / test-q.js
Created January 5, 2018 13:20
Example using Q.allSettled and Q.nfcall
'use strict'
const _ = require('lodash');
const request = require('request');
const Q = require('q');
Q.allSettled(_.map(["http://127.0.0.1", "http://www.test.com"], (url) => Q.nfcall(request.get, url)))
.then(results => {
for (let result of results) {
@cezinha
cezinha / query.js
Created June 1, 2017 21:08
Elastic Search query with filter and aggregations
{
"query": {
"bool": {
"must": [
{
"match": {
"valid": "false"
}
},
{
@cezinha
cezinha / calc_century.js
Created April 17, 2017 13:08
calculate century of year
// calculate century of year
// usage: calcCentury(1500)
function calcCentury(year) {
var cent = (year - (year%100)) /100;
if (year%100 > 0) { sec++; }
return cent;
}
@cezinha
cezinha / gulpfile.js
Created March 12, 2015 21:39
gulpfile - browser-sync + compass
var gulp = require('gulp');
var browserSync = require('browser-sync');
var compass = require('gulp-compass');
var reload = browserSync.reload;
// Start the server
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./"
@cezinha
cezinha / replaceSprite.js
Last active August 29, 2015 14:14
Replace Sprite for Print
function replaceSprite(selector){
var $selector = $(selector);
var back_position = $selector.css('background-position');
if (navigator.userAgent.search("MSIE") >= 0) {
var back_x = $selector.css('background-position-x'),
back_y = $selector.css('background-position-y'),
back_position = back_x+" "+back_y;
}
@cezinha
cezinha / WordPress-JSONP-+-AngularJS.markdown
Created August 29, 2013 14:53
A Pen by Celina Uemura.
@cezinha
cezinha / jsdoit.css
Created August 16, 2013 18:09
forked: cezinha blog widget
@import url(http://fonts.googleapis.com/css?family=Amaranth:400,700);
body { background-color: #DDDDDD; font: 30px 'Amaranth', sans-serif; }
#widget-cezinha{
background:#efefef;
-moz-border-radius: 0.25em;
border-radius: 0.25em;
padding:10px 5px 5px 5px;
}
#widget-cezinha h3{margin:0;padding:5px 10px;clear:both;overflow:hidden}
#widget-cezinha h3 a{font-size:14px;text-decoration:none;}