Skip to content

Instantly share code, notes, and snippets.

View jianingy's full-sized avatar
💭
Restoring

Jianing Yang jianingy

💭
Restoring
View GitHub Profile
def create_app():
app = Flask(__name__)
# setup database
db_api.init()
# set app debug mode
app.debug = CONF.debug
# request context
@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
;; 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))
#!/bin/sh
if [ "`id -u`" != "0" ]; then
invoke-sudo.sh $0 $@
fi
modprobe -r iwlmvm
#modprobe -r iwlwifi
#modprobe -r mac80211
#modprobe -r cfg80211
@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
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 / 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
@jianingy
jianingy / wormhole-exploit.py
Created January 27, 2016 08:38
wormhole-exploit
import requests
import click
import sys
def fail(reason):
click.echo(click.style('[!] %s' % reason, fg='red'), err=True)
sys.exit(111)
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 6021920 272424 5282908 0 0 7 11 10 41 2 1 97 0 0
0 0 0 6020864 272424 5283004 0 0 0 86 527 2188 0 1 99 0 0
0 0 0 6015928 272424 5288764 0 0 0 0 480 1838 1 1 98 0 0
0 0 0 6015780 272424 5288700 0 0 0 30 561 2150 1 1 99 0 0
0 0 0 6015160 272424 5289108 0 0 0 550 618 1899 1 1 98 0 0
@jianingy
jianingy / python-logging.conf
Last active March 3, 2016 09:53
python-logging.conf
[loggers]
keys=root,business,business_debug
[handlers]
keys=console,business,business_debug,general
[formatters]
keys=tornado
[logger_root]