Skip to content

Instantly share code, notes, and snippets.

View khaledAX's full-sized avatar

Khaled Monsoor khaledAX

View GitHub Profile
from jira import JIRA
import pandas as pd
import pdb
from collections import defaultdict
import datetime
import pprint
class ImportJiraAnalyticsData:
@kmonsoor
kmonsoor / http_status_codes.js
Created February 12, 2018 11:41
Node.js HTTP Status codes
// $ node
// > process.version;
// 'v8.9.4'
// > http.STATUS_CODES
{ '100': 'Continue',
'101': 'Switching Protocols',
'102': 'Processing',
'200': 'OK',
'201': 'Created',
@kmonsoor
kmonsoor / get_credential_service_account.py
Last active December 6, 2018 12:58
Python get_credential() for Google service_account() with *.json secret. ⭐ this gist if acts as useful, as a 👍
def get_credential_service_account():
from oauth2client.service_account import ServiceAccountCredentials
SERVICE_ACC_CREDENTIAL = 'your-service-account-secrets-file.json'
scopes = ['https://www.googleapis.com/auth/drive']
pprint("Request for credential received");
try:
credentials = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACC_CREDENTIAL, scopes=scopes)
pprint(credentials)
return credentials
@mpj
mpj / rulething.html
Created September 10, 2016 16:49
Code from episode
<html>
<head>
<style>
.row div {
height: 8px;
display: inline-block;
width: 8px;
}
.row div.active {
background-color: red;
@kmonsoor
kmonsoor / UploadWithProgress.cs
Created August 3, 2016 14:23
C#.NET : WebClient : Upload file to web API while monitoring progress
using System;
using System.IO;
using System.Net;
using System.Web;
public class UploadWithProgress
{
public static double PercentUploaded;
public static string FilePath;
public static string Result;
@kmonsoor
kmonsoor / .gitconfig
Last active April 12, 2016 14:09
My Git Configuration
[user]
email = me@mydomain.com
name = Khaled Monsoor
[credential "https://github.com"]
username = kmonsoor
[alias]
s = status
c = commit
f = fetch

Using pg.connect is the way to go in a web environment.

PostgreSQL server can only handle 1 query at a time per conenction. That means if you have 1 global new pg.Client() connected to your backend your entire app is bottleknecked based on how fast postgres can respond to queries. It literally will line everything up, queuing each query. Yeah, it's async and so that's alright...but wouldn't you rather multiply your throughput by 10x? Use pg.connect set the pg.defaults.poolSize to something sane (we do 25-100, not sure the right number yet).

new pg.Client is for when you know what you're doing. When you need a single long lived client for some reason or need to very carefully control the life-cycle. A good example of this is when using LISTEN/NOTIFY. The listening client needs to be around and connected and not shared so it can properly handle NOTIFY messages. Other example would be when opening up a 1-off client to kill some hung stuff or in command line scripts.

@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin