Skip to content

Instantly share code, notes, and snippets.

View ryanthegiantlion's full-sized avatar

Ryan Harmuth ryanthegiantlion

View GitHub Profile
@ryanthegiantlion
ryanthegiantlion / pmcs.MD
Last active January 30, 2019 12:17
postman test cheat sheet

Various variables are made available by postman runtime and can be references in the test script. Common ones are responseCode and responseBody and responseTime

  • Parse response body var data = JSON.parse(responseBody);

  • Test Format tests["Test Name"] = {condition} e.g tests["Has token"] = data.data.login != null;

  • Response times tests["Response time is less than 500ms"] = responseTime < 500;

@ryanthegiantlion
ryanthegiantlion / postgres_performance.MD
Last active January 27, 2023 12:05
A starting point for analysis of postgres performance

Resetting pg_stat_database and pg_stat_all_tables

To reset below states

select pg_stat_reset();
SELECT pg_stat_statements_reset()
{
"waves": [
{
"_id": "5805bc78a64d73001b8fcdc6",
"user": "5805b6a5a64d73001b8fcda6",
"content": "Let's make some waves!",
"track": "5805bc78a64d73001b8fcdc4",
"date": "2016-10-18T06:08:35.000Z",
"__v": 0,
"geo": {
show dbs // list all indexes
use <db>
show collections
db.collection.find(<query>) // find given optional query
db.directmessages.remove({}) // delete all
> use mydb;
> db.dropDatabase();
db.foo.update({}, {$set: {lastLookedAt: Date.now() / 1000}}, { multi: true } // update all
@ryanthegiantlion
ryanthegiantlion / startstuffs.md
Last active October 29, 2016 08:45
start services on me mac

mongo:

mongod

redis:

redis-server

rabbit:

rabbitmq-server

ES:

@ryanthegiantlion
ryanthegiantlion / curl_post_osx
Last active September 28, 2016 07:23
curl post osx
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"userName": "ryan", "platform":"android", "pushToken":"egO6G6CoxZE:APA91bFqN90Lb0n4TfNC02dXJ0vMT7uQ33WqFBG_FU5AC1dW_5PX1t9yFdA6gBxG_THDHdkkFdSZXq05PCABiIfAHUhu9ky-4vq8MOJdMUIZ1p4RvwiTVcAqnBGi3je19cO7TporEgjx"}' http://localhost:8082/users/
// setup
1. if you want the worker to be in a separate project and separately deployed: heroku create <projectname>
2. if separate project created in step 1: heroku addons:attach <addonname>
// subscriber
var redis = require('redis');
var RedisChannels = require('./constants/redisChannels')
import sys
T = int(sys.stdin.readline().strip())
xor_bits = (1 << 32) - 1
for i in xrange(T):
N = int(sys.stdin.readline().strip())
print N ^ xor_bits
## solution 1 using arrays
# import sys
# line = sys.stdin.readline().strip()
# linearr = []
# for c in line:
# linearr.append(c)
# # print linearr