Skip to content

Instantly share code, notes, and snippets.

// Add this to your Scaffold in dashboard.dart
floatinActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => NewRecording()),
);
},
child: Icon(Icons.add),
import 'package:flutter/material.dart';
class NewRecording extends StatefulWidget {
@override
_NewRecordingState createState() => _NewRecordingState();
}
class _NewRecordingState extends State<NewRecording> {
@override
void initState() {
@emostar
emostar / numbers.txt
Created February 29, 2020 20:16 — forked from NotSoSuper/numbers.txt
almost all the police numbers in the U.S (to blacklist from calling services) prefix: +1
423-279-3200
440-564-7014
845-677-7300
904-266-4468
315-393-1555
918-423-5858
440-293-4555
701-577-1212
765-584-6891
863-291-5200
@emostar
emostar / redis-sentinel
Created April 14, 2018 19:06 — forked from DeviaVir/redis-sentinel
An init.d script for redis sentinel, to have it run as a daemon instead of in a screen. (Tested on CentOS 6)
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@emostar
emostar / build_curl.md
Created September 7, 2016 19:35 — forked from bertrandmartel/build_curl.md
Build Curl for Android NDK

Build libcurl for android NDK

Libcurl requires openssl and zlib to be fully operationnal

  • Step 1 : cross compile zlib
  • Step 2 : cross compile openssl
  • Step 3 : cross compile curl with zlib/openssl external link

Prerequisites :

@emostar
emostar / command.sh
Created October 29, 2011 23:19 — forked from felixge/command.sh
Bash stuff for fighting a weak DOS attack
# Here a few bash one-liners that helped me analyze / fight a weak DOS attack against debuggable.com. Mostly for future reference.
# The attacker was opening lots of tcp connections without sending data, I believe it's called a SYN flood, see: http://tools.ietf.org/html/rfc4987#section-3.2
# Step 0: Check what is going on at port 80
$ netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c
# Step 1: Increase the number of available fds
$ ulimit -n 32000
# Step 2: Restart your webserver, for me: