Skip to content

Instantly share code, notes, and snippets.

@jhonsore
jhonsore / jsrsasign-latest-all-min.js
Last active December 10, 2024 20:28
Jwt js <---> php
/*
* jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license
*/
/*!
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.9.0
*/
@jhonsore
jhonsore / maskNumber.js
Created March 28, 2019 11:01
Money utils
var maskNumber = {
mask: Number,
min: 0,
normalizeZeros: false,
thousandsSeparator: '.'
};
var el = document.getElementById('number-mask');
var item = new IMask(el, maskNumber);
@jhonsore
jhonsore / addClass.js
Last active April 23, 2019 16:17
Js Snippets
(function(){
window.addClass = function(__args__){
var d = __args__.item,
c = __args__.class;
if (d.classList)
d.classList.add(c);
else
d.className += ' '+__args__.class;
}
})();
@jhonsore
jhonsore / FileLoader.js
Created January 9, 2019 15:35
File uploder js
(function () {
"use strict";
var self;
var counter;
var JS_EXT = 'js';
var CSS_EXT = 'css';
var HEAD = document.getElementsByTagName("head")[0];
var RESPONSE = {
timeout: { code: '101', 'message': 'Timeout reached'},
<?php
namespace Library\Utils;
class Json
{
public static function encode($source, $flag = null)
{
if ($flag)
{
return json_encode($source, $flag);
@jhonsore
jhonsore / Item.js
Created November 1, 2018 19:30
React Components #1 (List item with image)
import React from 'react';
import
{
TouchableOpacity,
View,
StyleSheet,
Image,
Text
} from 'react-native';
@jhonsore
jhonsore / README.txt
Created October 19, 2018 23:25
Communicating between android and react native
#FOUND ON
https://dev.to/ryohlan/how-to-pass-initial-props-from-android-native-2k2
@jhonsore
jhonsore / Component.js
Created October 19, 2018 23:21
iOS custom native module
import React from "react";
import {
NativeModules
} from "react-native";
export default class Component extends React.Component {
componentDidMount() {
//calling native method
NativeModules.Device.getDeviceName((err ,name) => {
console.log(err, name);
@jhonsore
jhonsore / MyUploader.js
Created September 3, 2018 14:28
React Native Uploader Class
import React from 'react';
import
{
Image,
View,
TouchableOpacity
} from 'react-native';
import Uploader from './utils/upload/Uploader';
@jhonsore
jhonsore / file.js
Last active September 28, 2018 17:21
Encrypt/ decrypt -> js/php
//npm install --save @types/crypto-js
//npm i -S crypto-js
var key = CryptoJS.enc.Hex.parse("0123456789abcdef0123456789abcdef");
var iv = CryptoJS.enc.Hex.parse("abcdef9876543210abcdef9876543210");
var secret = JSON.stringify({obj:true, obj1:1,obj2:{obj3:3}});
//crypted
var encrypted = CryptoJS.AES.encrypt(secret, key, {iv:iv});
//and the ciphertext put to base64