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
#!/bin/bash | |
grep -h 'blog' httpd/data/access*|grep -v '^76.124.247.181'|grep -v 'www.google.com'|grep -v 'spider'| | |
awk '{ | |
split($0, a, "\"") | |
$6 = a[2] | |
$7 = $(NF - 1) | |
$8 = $NF | |
printf("%s %s,%s,\"%s\"\n",$4,$5,$1,$6) | |
}' |
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
# Iptables works from top down. So you want to put your accepts last | |
# | |
*filter | |
:INPUT ACCEPT [0:0] | |
:FORWARD ACCEPT [0:0] | |
:OUTPUT ACCEPT [0:0] | |
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT | |
-A INPUT -p icmp -j ACCEPT | |
-A INPUT -i lo -j ACCEPT | |
# Amazon AWS can block port 22, so keep open. |
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
#!/usr/bin/env python | |
""" | |
Created by mchirico@gmail.com | |
""" | |
import os,time,sys,signal,getopt,popen2,re,curses,datetime,random | |
import thread,threading | |
lock = threading.Lock() |
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
echo "<callDate>"|awk 'BEGIN{cmd="date +%Y-%m-%d_%H:%M:%S"} /<callDate>/{cmd|getline D; close(cmd); print D,$1}' |
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
df.dropna(how='all') #drop only if ALL columns are NaN | |
df.dropna() #drop all rows that have any NaN values | |
df.dropna(thresh=2) #Drop row if it does not have at least two values that are **not** NaN | |
df.dropna(subset=[1]) #Drop only if NaN in specific column | |
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
""" | |
Some commands in Python Pandas to do the following: | |
1. Read in a file | |
2. Get a list of the headers | |
3. Change a header (rename) | |
4. Drop one of the headers (just happends to be the one we renamed) | |
5. Apply a function to each one of the rows | |
6. Merge it with another DataFrame (pm) | |
7. Assuming it has a datetime index, write out |
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
# Kaggle knowledge | |
# Using Google maps | |
# Adapted from Ben Hamner's code | |
# Ref https://www.kaggle.com/benhamner/sf-crime/san-francisco-top-crimes-map?scriptVersionId=11462 | |
# | |
# | |
library(dplyr) | |
library(ggmap) | |
library(ggplot2) |
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
from keras.layers.core import Dense, Activation | |
model.add(Dense(input_dim=100, output_dim=64, init="uniform")) | |
model.add(Activation("relu")) | |
model.add(Dense(input_dim=64, output_dim=64, init="uniform")) | |
model.add(Activation("softmax")) | |
model.add(Dense(input_dim=64, output_dim=10, init="uniform")) | |
model.add(PReLU((hn,))) |
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
/* | |
The Dropbox Developer blogs example has an error in the code | |
https://blogs.dropbox.com/developers/2015/05/try-out-swiftydropbox-the-new-swift-sdk-for-dropbox-api-v2/#.VYh2ane5W_4.twitter | |
*/ | |
// AppDelegate.swift | |
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { | |
if let authResult = Dropbox.handleRedirectURL(url) { |
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
#!/bin/bash | |
# First, just build the training set. | |
echo "1 'example1 | a b c" > train.vw | |
echo "2 'example2 | x y z" >> train.vw | |
echo "3 'example3 | a x c" >> train.vw | |
echo "4 'example4 | x x a" >> train.vw | |
echo 'Our training set train.vw' | |
cat train.vw |