Skip to content

Instantly share code, notes, and snippets.

View zclfly's full-sized avatar

Changling Zhou zclfly

View GitHub Profile
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
  1. General Background and Overview

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

@zclfly
zclfly / app.rb
Created October 7, 2013 15:41 — forked from cpatni/app.rb
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
Anomaly detection, creating baselines, and determining statistical outliers in argus data with argus-clients May 21, 2013mbrownnycLeave a commentGo to comments Updated July 2nd, 2013: See the below Update section for a summary. previously: June 7th: Craig Merchant asked about utilizing appbyte ratios (aka “abr”, aka “abratio”) and I’ve appended the current back and forth to the PDF.   Carter covered how to use argus data and the argus-clients to data mine to find evidence of an APT1 infection within your network in a series of Emails to the argus-info mailing list some time ago. The email thread started to get really twisted and is it quite difficult to read in the threaded gmane interface available for the argus-info mailing list. In effort to make this thread more useful, I have created a PDF of the emails with some attempt to visibly separate the command and output (updated June 7th, 2013) so that it is easier to read. It was created for printing, not for viewing on a computer screen, although you can do
#!/bin/bash
# A sample firewall shell script
IPT="/sbin/iptables"
SPAMLIST="blockedip"
SPAMDROPMSG="BLOCKED IP DROP"
SYSCTL="/sbin/sysctl"
BLOCKEDIPS="/root/scripts/blocked.ips.txt"
 
# Stop certain attacks
echo "Setting sysctl IPv4 settings..."
# 1. Make sure you have nginx sub module compiled in
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module'
# 2. add two directives below at HTTP level
# nginx.conf
http {
# ......
sub_filter '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); } img { _filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=0); -webkit-filter: grayscale(100%); } </style>';