Skip to content

Instantly share code, notes, and snippets.

@guilhermepontes
guilhermepontes / shuffle.js
Last active October 29, 2023 01:41
Shuffle Array - JavaScript ES2015, ES6
// original gist
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5);
// fully random by @BetonMAN
const shuffleArray = arr => arr
.map(a => [Math.random(), a])
.sort((a, b) => a[0] - b[0])
.map(a => a[1]);
shuffleArray([1, 2, 3]) //[3, 1, 2]
@mishrsud
mishrsud / SQL-join-cheat-sheet.md
Last active December 20, 2021 03:15
SQL Joins Cheat Sheet
abdominocardiac abdominocardi.ac
autotractor autotr.actor
cephalotractor cephalotr.actor
cocontractor cocontr.actor
coenactor coen.actor
cornfactor cornf.actor
counteractor counter.actor
effractor effr.actor
idemfactor idemf.actor
lithofractor lithofr.actor
@rbrigden
rbrigden / startupy_domains.txt
Last active June 7, 2024 05:09
Every english word that is currently available for registration as a full domain (TLD included).
abdominocardi.ac
autotr.actor
cephalotr.actor
cocontr.actor
coen.actor
cornf.actor
counter.actor
effr.actor
idemf.actor
lithofr.actor
@AtulKsol
AtulKsol / psql-error-fix.md
Last active April 10, 2024 07:41
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@betweenbrain
betweenbrain / read-files.js
Created December 5, 2016 22:35
Node.js read multiple files, write into one
var fs = require('fs');
var Promise = require('promise');
var promises = [];
var readline = require('readline');
var readFile = function (file) {
return new Promise(function (resolve, reject) {
var lines = [];
var rl = readline.createInterface({
input: fs.createReadStream('./logs/' + file)
@joshmarinacci
joshmarinacci / 1.html
Last active February 20, 2021 14:54 — forked from stephenlb/1.html
Enter Chat and press enter
<div><input id=input placeholder=you-chat-here /></div>
Chat Output
<div id=box></div>
<script src=https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.11.min.js></script>
<script>(function(){
var pubnub = new PubNub({ publishKey : 'demo', subscribeKey : 'demo' });
function $(id) { return document.getElementById(id); }
@pefianco
pefianco / stridecorevalues.md
Last active January 29, 2017 05:40
Consulting Pillars

Stride Core Values

Humility

  • Admit that you might be wrong
  • Admit what you don’t know
  • Make the team’s success your success
  • Bring your pair along with you and double check your assumptions when you can’t
  • Bring the team along with you, solutions with team buy in are more valuable than going rogue, even when you’re right
  • Listen to feedback and take ownership of action items
@vasanthk
vasanthk / System Design.md
Last active July 15, 2024 10:23
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@DenisCarriere
DenisCarriere / mls.py
Created December 14, 2015 19:04
MLS Scraper
import geocoder
import requests
import unicodecsv as csv
import time
container = {}
g = geocoder.google("New Brunswick, Canada")
url = "https://www.realtor.ca/api/Listing.svc/PropertySearch_Post"
PropertySearchType = {