Skip to content

Instantly share code, notes, and snippets.

View jbro885's full-sized avatar
💭
I am Securing Infrastructure

jbbro88501 jbro885

💭
I am Securing Infrastructure
View GitHub Profile
@jbro885
jbro885 / postgres_queries_and_commands.sql
Created December 20, 2020 21:52 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@jbro885
jbro885 / interestcalc
Created January 22, 2021 09:16 — forked from jc245410/interestcalc
Simple or Compound interest calculator
% Calculate Compound or simple interest
%
% _____________________
% input data and ---> | calculate interest | -----> output interst
% type of interest |_____________________|
%
%
clear
clc
%simple interest
@jbro885
jbro885 / install_ruby_and_rails.md
Created February 11, 2021 16:54 — forked from apirak/install_ruby_and_rails.md
Install ruby and rails on OSX, Linux and Windows

Install Ruby and Rails

Ruby now come preinstalled on many Linux distributions, and Mac OS X includes Ruby). Try typing ruby -v at a command prompt--you may be pleasantly surprised.

If you don't already have Ruby on your system or if you'd like to upgrade to a newer version (remembering that this couse describes Ruby 1.9), you can install it pretty simply. What you do next depends on your operating system.

Install Ruby on Windows

  1. Download http://railsinstaller.org/ from Apple Application Store :
@jbro885
jbro885 / player.js
Created September 8, 2021 02:28 — forked from queerviolet/player.js
Player inquirer loop for choose your own adventure.
"use strict";
var inquirer = require('inquirer');
var game = require('./game.source');
// play(node: Node) -> Promise<Node>
function play(node) {
if (!node.connections.length) {
console.log(node.text);
@jbro885
jbro885 / pearson-hashing.c
Created September 11, 2021 03:58 — forked from darccio/pearson-hashing.c
Pearson hashing (just for fun). Includes Ruby and Golang versions for RFC 3074 and original variants.
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
/*
* Pearson hashing (from Wikipedia)
*
* Pearson hashing is a hash function designed for fast execution on processors with 8-bit registers.
* Given an input consisting of any number of bytes, it produces as output a single byte that is strongly
* dependent on every byte of the input. Its implementation requires only a few instructions, plus a
@jbro885
jbro885 / pearson-hashing.js
Created September 11, 2021 03:59 — forked from thejsj/pearson-hashing.js
Pearson Hashing Function
'use strict'
// Ideally, this table would be shuffled...
// 256 will be the highest value provided by this hashing function
let table = [...new Array(256)].map((_, i) => i)
const hash8 = (message, table) => {
return message.split('').reduce((hash, c) => {
return table[(hash + c.charCodeAt(0)) % (table.length - 1)]
}, message.length % (table.length - 1))
@jbro885
jbro885 / base32crock.js
Created September 11, 2021 04:41 — forked from sergeevabc/base32crock.js
Base32 Crockford's edition https://github.com/agnoster/base32-js 0123456789abcdefghjkmnpqrtuvwxyz
(function () {
var alphabet = '0123456789abcdefghjkmnpqrtuvwxyz';
var alias = {
o: 0,
i: 1,
l: 1,
s: 5
};
var lookup = function () {
var table = {};
@jbro885
jbro885 / README.md
Created September 11, 2021 17:09 — forked from neeleshn/README.md
Node JS file to count words in a file

Objective:

This JavaScript program takes a text file as input and returns count of each word in sorted order.

How to Run:

~$ npm install ~$ node index.js [path-to-file]

Sample Input:

~$ ~$ npm install

@jbro885
jbro885 / countLines.js
Created September 11, 2021 17:11 — forked from eqperes/countLines.js
Node.js: Count the number of lines in a file
const countLines = function(filePath, callback) {
// function copied from http://stackoverflow.com/questions/12453057/node-js-count-the-number-of-lines-in-a-file
// with very few modifications
let i;
let count = 0;
fs.createReadStream(filePath)
.on('error', e => callback(e))
.on('data', chunk => {
for (i=0; i < chunk.length; ++i) if (chunk[i] == 10) count++;
})
/**
* WordCounter.js
* a command-line tool by eloytoro
*
* How to use:
*
* $ node word-counter.js <dir>
* - Count the word occurrences among all the files within the given directory directory.
* - It will split the task between 3 workers, each of which could run completely standalone
* by communicating to the main server using TCP sockets if it exposes its address publicly