This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*filter | |
# Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0 | |
-A INPUT -i lo -j ACCEPT | |
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT | |
# Accept all established inbound connections | |
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# Allow all outbound traffic - you can modify this to only allow certain traffic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install libpq-dev | |
#I'm running postgresql-9.1. Match the version to that of your server. | |
sudo apt-get install postgresql-server-dev-9.1 | |
sudo apt-get install python-dev | |
#Now workon your virtualenv and pip install psycopg2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//taken from Object Oriented Javascript by Stoyan Stefanov | |
var Hero() { | |
this.occupation = "Ninja!" | |
this.say = function() { | |
return "I'm a " + this.occupation; | |
} | |
} | |
/* correct invocation of constructor function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 | |
20 | |
3 15 12 10 2 13 14 5 6 9 17 18 16 8 0 11 1 19 4 7 | |
20 | |
16 0 1 15 8 10 18 17 11 13 5 6 19 4 14 12 3 9 2 7 | |
20 | |
0 19 11 13 15 18 5 2 9 4 12 10 7 14 17 8 3 16 6 1 | |
20 | |
2 14 7 4 1 17 6 16 18 9 12 13 5 3 10 11 19 0 8 15 | |
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max_weights(a): | |
weights = [0] * (len(a) + 2) | |
for i, v in enumerate(a): | |
j = i + 2 | |
with_v = weights[j-2] + v | |
without_v = weights[j-1] | |
weights[j] = max(with_v, without_v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#For simulations | |
import random | |
class Item(object): | |
def __init__(self, value=0, weight=0): | |
self.value = value | |
self.weight = weight | |
def __repr__(self): | |
return "({value}, {weight})".format(**self.__dict__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from watchdog.observers import Observer | |
from watchdog.events import FileSystemEventHandler | |
class VHandler(FileSystemEventHandler): | |
def __init__(self): | |
FileSystemEventHandler.__init__(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#FlipPredictor | |
#A coin is drawn at random from a bag of coins of varying probabilities | |
#Each coin has the same chance of being drawn | |
#Your class FlipPredictor will be initialized with a list of the probability of | |
#heads for each coin. This list of probabilities can be accessed as self.coins | |
#in the functions you must write. The function update will be called after every | |
#flip to enable you to update your estimate of the probability of each coin being | |
#the selected coin. The function pheads may be called and any time and will | |
#return your best estimate of the next flip landing on heads. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 | 0 | |
---|---|---|
0.01 | 0.000297 | |
0.02 | 0.001176 | |
0.03 | 0.002619 | |
0.04 | 0.004608 | |
0.05 | 0.007125 | |
0.06 | 0.010152 | |
0.07 | 0.013671 | |
0.08 | 0.017664 | |
0.09 | 0.022113 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"time" | |
"os/exec" | |
) | |
func IsAppPublished(url string) bool { |