Skip to content

Instantly share code, notes, and snippets.

Avatar

Zalazar Gonzalez Gustavo mzalazar

  • Buenos Aires, Argentina
View GitHub Profile
View pg.singleton.ts
import { Pool } from 'pg'
import * as dotenv from 'dotenv'
import { colors } from 'colors'
dotenv.config()
export class DatabasePool {
constructor() {
if (!!DatabasePool.instance) {
return DatabasePool.instance;
}
View SQL_Query_Interview_Questions.sql
/* Database table install instructions */
https://dev.mysql.com/doc/employee/en/employees-installation.html
/* Return employee record with max salary */
SELECT *
FROM employee
WHERE salary = (SELECT MAX(salary) FROM employee)
/* Select highest salary in employee table */
SELECT MAX(salary)
@mzalazar
mzalazar / upload.js
Created Nov 21, 2018
Upload a file from node.js
View upload.js
const FormData = require('form-data')
const request = require('request')
let form = new FormData()
let filename = `/myData/data.gz`
form.append('file', fs.createReadStream(filename))
let options = {
url: `http://myServer/uploadFile`,
method: 'POST',
formData: {
View redis_write_stream.js
var Writable = require('stream').Writable;
var util = require('util');
var redis = require('./redis');
var async = require('async');
module.exports = RedisWriteStream;
function RedisWriteStream(client_id, broadcast_id, options) {
if (!(this instanceof RedisWriteStream)) return new RedisWriteStream(options);
View datatables
/* Initialize datatables */
datatable = $('#dt_users').dataTable({
// Tabletools options:
// https://datatables.net/extensions/tabletools/button_options
fixedHeader: true,
processing: true,
serverSide: true,
stateSave: true,
ajax: {
url : '/api/users',
View index.php
if ($_REQUEST['attempt'] >= 3 && empty($_GET['lp'])) {
// Check recaptcha
$secret = '6Lcb8yYUAAAAAI_TS_c88LNH4_gcud1Ay6ZdO71A';
$code = $_REQUEST['g-recaptcha-response'];
$verify = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$code}");
$response = json_decode($verify);
if ($response->success != true) {
$msg = '<div class="rows error">';
$msg .= '<h3>Error</h3>';
$msg .= '<p>Demasiados intentos fallidos, pruebe nuevamente</p>';
You can’t perform that action at this time.