Skip to content

Instantly share code, notes, and snippets.

View laerciobernardo's full-sized avatar
🏠
Working from home

Laércio Bernardo laerciobernardo

🏠
Working from home
  • iUPi Tecnologia
  • Vila Nova de Gaia, Porto
  • 05:50 (UTC +01:00)
  • X @laerciobernardo
View GitHub Profile
@laerciobernardo
laerciobernardo / hexIEEEtoFloat.js
Last active January 21, 2024 14:48
Convert Hexadecimal IEEE754 to Float in Javascript
var str = '0x41FC6733';
function parseFloat(str) {
var float = 0, sign, order, mantiss,exp,
int = 0, multi = 1;
if (/^0x/.exec(str)) {
int = parseInt(str,16);
}else{
for (var i = str.length -1; i >=0; i -= 1) {
if (str.charCodeAt(i)>255) {
@laerciobernardo
laerciobernardo / app.js
Last active May 24, 2017 14:44
Setup Openshift to run localhost and online
'use strict'
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
//Handler to provider any function to parse in ObjectId
String.prototype.toObjectId = function() {
var ObjectId = (require('mongoose').Types.ObjectId);
return new ObjectId(this.toString());
$stmt = $dbh->prepare('
SELECT
*
FROM
table
ORDER BY
name
LIMIT
:limit
OFFSET
1 - Após o acesso SSH na instância da amazon efetue atualize os pacotes da distribuição
$ sudo apt-get update
$ sudo apt-get upgrade
2 - Instalar o APACHE
$ sudo apt-get install apache2 -y
3 - Instalar o MySQL
$ sudo apt-get install mysql-server mysql-client -y
const func1 = () ={
console.log("sou a func 1);
}
const func2 = () ={
console.log("sou a func 2);
}
module.exports = {
func1,
'use strict'
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
let companySchema = new Schema({
cnpj: String,
ie: String,
razaoSocial: String,
nomeFantasia: String,
endereco: {
'use strict'
const Model = require('../models/company');
const create = (obj) => {
return Model.create(obj);
};
const remove = (uid) => {
let query = {uid: uid};
return Model.remove(query);
'use strict'
const express = require('express');
const router = express.Router();
const Ctrl = require('../controllers/companyCtrl');
const callback = (data, res) => {
res.json(data);
};
const errorHandler = (err, res) => {
var filesPath = ["file:///storage/emulated/0/myfile.txt","file:///storage/emulated/0/folder", "file:///storage/emulated/0/other-file.txt"];
function processFilesPaths(filesPath) {
angular.forEach(data, function (filePath) {
window.resolveLocalFileSystemURL(filePath, function (fileEntry) {
fileEntry.file(function (file) {
vm.attachments.push(file);
});
});
});
angular.module('starter')
.factory("$fileFactory", function ($q) {
var File = function () { };
File.prototype = {
getParentDirectory: function (path) {
var deferred = $q.defer();