Skip to content

Instantly share code, notes, and snippets.

View krescruz's full-sized avatar

Cresencio cruz krescruz

View GitHub Profile
@krescruz
krescruz / IBMiCallCLfromSP.sql
Created July 21, 2018 00:09
IBM i Create store procedure for calling CLP (Programming Control language)
CREATE PROCEDURE MYLIB.SPNAME(
IN @P1 CHAR(10),
)
LANGUAGE CL
NOT DETERMINISTIC
NO SQL
EXTERNAL NAME MYLIB.MYCL
PARAMETER STYLE GENERAL;
@krescruz
krescruz / IBMiCookies.cl
Created July 20, 2018 22:35
IBMi a series of command for survival
/* Create file csv in file system from database table */
CPYTOIMPF FROMFILE(MYLIB/MYFILE) TOSTMF('path/filename.csv') STMFCCSID(*PCASCII) RMVBLANK(*BOTH) FLDDLM(',') RCDDLM(*CRLF)
/*Edit a stream file or a database file.*/
EDTF STMF('MyCloud/csvmf16_3.csv')
/*Start FTP Client*/
STRTCPSVR SERVER(*FTP)
@krescruz
krescruz / encryp_file_gpg.py
Created February 1, 2018 23:37
Encrypting files using GNU Privacy Guard (GnuPG or GPG) - Command line example
import sys
import gnupg
def main():
path_home = sys.argv[1]
path_file_input = sys.argv[2]
path_file_output = sys.argv[3]
gpg = gnupg.GPG(gnupghome=path_home)
key = gpg.list_keys()
@krescruz
krescruz / dispatch-promises.js
Created December 20, 2017 18:48
Loading in action using chain promises whit Redux
/*
* Status Loading
* Actions types
*/
const activatedLoading = () => ({
type: 'LOADING_ACTIVATED',
status: true
})
@krescruz
krescruz / config-axios.js
Created December 20, 2017 18:29
Config Cross Site Request Forgery Protection CSRF in axios for django
import axios from 'axios'
/**
* Config global for axios/django
*/
axios.defaults.xsrfHeaderName = "X-CSRFToken"
axios.defaults.xsrfCookieName = 'csrftoken'
export default axios
@krescruz
krescruz / config-env.js
Created December 20, 2017 18:21
Use of conditional variable in development using nodejs
/**
* Example: Base URL to consume REST API only in development
*/
let API_URL = 'https://krescruz.com/api' //URL PRODUCTION
if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development') {
API_URL = 'http://localhost:8000/api' //URL DEVELOPMENT
}
export const API_URL_BASE = API_URL
@krescruz
krescruz / notify.js
Created December 20, 2017 18:10
Notify example whit react toastify 🚀
import { toast } from 'react-toastify'
const POSITION = toast.POSITION.BOTTOM_RIGHT
export const saved = (msg) => {
const detail = msg || 'Saved successful'
toast.success(detail, { position: POSITION })
}
export const invalidForm = (msg) => {
@krescruz
krescruz / BsModalSimple.js
Created December 20, 2017 17:48
React modal with bootstrap component
import React, { Component } from 'react'
import PropTypes from 'prop-types'
class BsModalSimple extends Component {
onCloseModal() {}
render() {
@krescruz
krescruz / MaskedInput.js
Created December 20, 2017 16:51
React masked input
import React, { Component } from 'react'
import MaskedInputBase from 'react-maskedinput'
class MaskedInput extends Component {
getValue() {
const value = this.refs.masked.mask.getRawValue()
return value.replace(/[\s,_]/g, '')
}