Skip to content

Instantly share code, notes, and snippets.

@thinkjson
thinkjson / getCluster.js
Created April 9, 2019 14:45 — forked from CaptainJiNX/getCluster.js
Example of auto discovery for aws elasticache
const Memcached = require('memcached');
const configClient = new Memcached('xyz123.cfg.cache.amazonaws.com:11211');
configClient.command(configGetCluster);
function configGetCluster() {
return {
command: 'config get cluster',
callback: handleClusterResponse
@thinkjson
thinkjson / list.md
Last active February 27, 2021 02:02 — forked from notwaldorf/list.md
Meownica's packing list

Meownica's thinkjson's packing list

From Monica: I travel a lot so I'm down to like 30 minutes of packing per any kind of trip. I always bring one carry-on suitcase for any trips up to 2 weeks (that I never check in unless forced) -- I have an Away suitcase because it's got a built-in (removable) battery, and amazing wheels.

🚨

  • 🆔Wallet & Passport
  • 💧Travel water bottle
  • 📖A book
  • 💊Melatonin/Benadryl to sleep on planes
@thinkjson
thinkjson / comfort_ratio.txt
Created March 31, 2018 13:01
Comfort ratio
alias(
multiplySeries(
scale(nest_metrics.current_humidity, 0.016),
scale(nest_metrics.current_temperature, 0.0128)
),
"indoor"
)
alias(
multiplySeries(
@thinkjson
thinkjson / speedtest_process.py
Created March 24, 2018 11:35
Process speedtest.py results as statsd counters
import csv
import sys
reader = csv.reader(sys.stdin)
Server,Sponsor,Server,Timestamp,Distance,Ping,Download,Upload = reader.next()
print "speedtest.ping:%s|c" % Ping
print "speedtest.download:%s|c" % Download
print "speedtest.upload:%s|c" % Upload
@thinkjson
thinkjson / Dockerfile
Created February 5, 2018 13:31
Dockerfile to run the async demo from the async port of urllib3 using Python 3
FROM python:3.6-stretch
WORKDIR /application
RUN apt-get update && apt-get install unzip
RUN curl -O https://vorpus.org/~njs/tmp/async-urllib3-demo.zip && unzip -j async-urllib3-demo.zip
RUN pip install trio twisted[tls] urllib3-2.0.dev0+bleach.spike.proof.of.concept.dont.use-py2.py3-none-any.whl
ENTRYPOINT [ "python" ]
CMD [ "async-demo.py" ]
@thinkjson
thinkjson / sample_output.txt
Created December 17, 2017 15:08
Task queue simulation that demonstrates Generics, Polymorphism, class.name and toString
Task fulfilled: {"created_time":"2017-12-17T15:01:43.888Z","start_time":"2017-12-17T15:01:43.900Z","fulfilled_time":"2017-12-17T15:01:43.910Z","payload":6801125450,"result":[1,2,5,7,10,14,25,35,50,70,175,350,487,974,2435,3409,4870,6818,12175,17045,24350,34090,39901,79802,85225,170450,199505,279307,399010,558614,997525,1396535,1995050,2793070,6982675,13965350,19431787,38863574,97158935,136022509,194317870,272045018,485794675,680112545,971589350,1360225090,3400562725,6801125450],"type":"FactorTask"}
Task fulfilled: {"created_time":"2017-12-17T15:01:43.912Z","start_time":"2017-12-17T15:01:43.925Z","fulfilled_time":"2017-12-17T15:01:43.926Z","payload":6777023714,"result":[8589934592],"type":"PowerOfTwoTask"}
Task fulfilled: {"created_time":"2017-12-17T15:01:43.926Z","start_time":"2017-12-17T15:01:43.939Z","fulfilled_time":"2017-12-17T15:01:43.945Z","payload":6580717680,"result":[1,2,3,4,5,6,8,10,12,15,16,17,20,23,24,30,34,40,46,48,51,60,68,69,80,85,92,102,115,120,136,138,170,184,204,230,240,255,272,276,340,345,36
@thinkjson
thinkjson / race.ts
Created December 15, 2017 22:11
Promise.race example
function race(player: string) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(player);
}, Math.random() * 20)
})
}
Promise.race([
race('Bob'),
@thinkjson
thinkjson / iterator.ts
Created December 15, 2017 21:53
ES6 Iterables
class Multiplier implements Iterable<number> {
constructor(public number: number) {
}
[Symbol.iterator]() {
let number = this.number;
return {
next(): IteratorResult<number> {
number *= Math.random() * 2;
@thinkjson
thinkjson / arrow.ts
Created December 15, 2017 20:52
Having a little too much fun with typescript, ES6 Promises, and arrow functions
class Person {
private lifespan: number;
private life: number;
private YEAR_IN_SECONDS: number = 100;
constructor(public name: string, public age: number) {
this.lifespan = Math.floor(Math.random() * 40 + 60);
}
liveLife = () => {
@thinkjson
thinkjson / proposal.md
Last active October 12, 2017 00:24
This is a proposal for identifying and retaliating against abusers on the Twitter platform. Using a combination of sentiment analysis and mechanical turk, the system can flag abusive tweets and report repeat offenders in real time. This is a proposal for the abuse system that should have been built into Twitter. Comments welcome.

Abusive tweet storms and DDoS

Abusive tweet storms brought on by a Twitter user with a significant amount of followers using their influence to intimidate or verbally abuse another Twitter user bears some striking similarities to a DDoS attack. If you frame the problem in terms of a DDoS attack, then many mitigation techniques used against DDoS attacks can also be used against these Twitter attacks.

Identification of abusive tweets

By opting in, users can submit their replies for analysis by the system. Using sentiment analysis, abusive tweets can be identified programmatically, and confirmed using a mechanical turk like system. In order to broaden the scope of the analysis, the abusive user's other replies are analyzed and catalogued, being