Skip to content

Instantly share code, notes, and snippets.

View jianingy's full-sized avatar
💭
Restoring

Jianing Yang jianingy

💭
Restoring
View GitHub Profile
@jianingy
jianingy / ChiSquare.c
Created November 19, 2015 04:17
ChiSquare Feature Selection
#ifndef CHI_SQUARE_SELECTOR_H_
#define CHI_SQUARE_SELECTOR_H_
#include "FeatureSelector.h"
namespace zdcp {
class ChiSquareSelector: public FeatureSelector {
protected:
#if 0
for access_log in /export/logback/www*/app_m_access.log.2015-04-*.gz; do
(
csv_file="`mktemp $root/tmp/access_log-XXXXXX.csv`"
: > $csv_file
echo "processing $access_log -> $csv_file"
$root/scripts/parse_access_log_v2.py --source xxxxxxxx --access-log $access_log > $csv_file
echo "\COPY m_access_log FROM '$csv_file' WITH CSV" | connect_postgres
rm -f $csv_file
) &
done
@jianingy
jianingy / with_lock.sh
Last active August 29, 2015 14:20
Prevent process from running when lock file exists.
#!/bin/bash
# filename : with_local.sh
# created at : 2015-05-04 11:28:24
# author : Jianing Yang <jianingy.yang@gmail.com>
if [ "$#" -lt 2 ]; then
echo "Usage: $(basename $0) lockfile command"
echo "Prevent process from running when lock file exists."
echo
#!/bin/sh
if [ "`id -u`" != "0" ]; then
invoke-sudo.sh $0 $@
fi
modprobe -r iwlmvm
#modprobe -r iwlwifi
#modprobe -r mac80211
#modprobe -r cfg80211
;; An Example of Emacs Script
;; Find all kernel processes
(defmacro |> (x &rest funcs)
`(reduce #'(lambda (z f) (apply f (list z))) (list ,@funcs) :initial-value ,x))
(|> (shell-command-to-string "ps awux")
#'(lambda (x) (split-string x "\n"))
#'(lambda (x) (mapcar 'split-string x))
#'(lambda (x) (remove-if-not #'(lambda (x) (string-match "^\\[" (or (car (last x)) ""))) x))
@jianingy
jianingy / layout
Created January 23, 2015 10:11
sample
(ns sqlcharts.core.layouts
(:require [clojure.string :as string]
[hiccup.page :refer :all]
[noir.validation :as vali]))
(defn navbar-top
[]
[:nav.navbar.navbar-default.navbar-static-top
[:div.container
[:div.navbar-header
def create_app():
app = Flask(__name__)
# setup database
db_api.init()
# set app debug mode
app.debug = CONF.debug
# request context
@jianingy
jianingy / burst.go
Created September 3, 2014 03:58
Generate Lots Of Small Files for FS Testing Purpose
/*
* filename : burst.go
* created at : 2014-09-02 11:19:13
* author : Jianing Yang <jianingy.yang@gmail.com>
*/
package main
import (
"flag"
"fmt"
PATH=/opt/uw-imap/bin:/usr/local/bin:/usr/bin:/bin
MAILDIR=$HOME/mailbox
LOGFILE=$HOME/.procmail.log
LOCKFILE=$HOME/.mail.lock
:0 :.me.lock
* ^To:\s+jianing.yang
| dmail +INBOX
:0 :.INBOX.lock
poll [mailserver] protocol IMAP
user "jianing.yang" is jianing.yang here password '[password]'
options fetchall ssl mda "/usr/bin/procmail -f %F -d %T";