Skip to content

Instantly share code, notes, and snippets.

View ryanthegiantlion's full-sized avatar

Ryan Harmuth ryanthegiantlion

View GitHub Profile
@ryanthegiantlion
ryanthegiantlion / createfirewallrules_permissive.sh
Created December 24, 2015 19:26
Firewall rules I would use temporarily on elasticsearch host, temporarily allowing all outgoing traffic originating from the host
# flush existing rules
iptables -F
ip6tables -F
# ssh rule. always add this first !
# TODO: Consider rate limiting? (e.g http://www.digitalsanctuary.com/tech-blog/debian/using-iptables-to-prevent-ssh-brute-force-attacks.html)
# Still need to read up on implications...
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A OUTPUT -p tcp --sport ssh -j ACCEPT
@ryanthegiantlion
ryanthegiantlion / createfirewallrules_restrictive.sh
Created December 24, 2015 19:29
Firewall rules I used on my single node elasticsearch instance
# flush existing rules
iptables -F
ip6tables -F
# ssh rule. always add this first !
# TODO: Consider rate limiting? (e.g http://www.digitalsanctuary.com/tech-blog/debian/using-iptables-to-prevent-ssh-brute-force-attacks.html)
# Still need to read up on implications...
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A OUTPUT -p tcp --sport ssh -j ACCEPT
@ryanthegiantlion
ryanthegiantlion / createwebsite.sh
Created February 14, 2016 16:53
create static website on s3 with awscli
aws s3 mb s3://test-website
aws s3 website s3://test-website --index-document index.html --error-document error.html
echo '{"Version":"2012-10-17", "Statement": [{ "Sid": "Allow Public Access to All Objects", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::test-website/*"}]}' > policy.json
aws s3api put-bucket-policy --bucket test-website --policy file://policy.json
aws s3 sync website-source-folder s3://test-website
## solution 1 using arrays
# import sys
# line = sys.stdin.readline().strip()
# linearr = []
# for c in line:
# linearr.append(c)
# # print linearr
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
// 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')
@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/
@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:

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