Skip to content

Instantly share code, notes, and snippets.

View shelling's full-sized avatar

shelling shelling

View GitHub Profile
@shelling
shelling / retrieve.sh
Created February 16, 2012 02:35
template of getopt in shell
#!/bin/bash
qamode="false"
action=$1
shift
case "$action" in
start|stop)
;;
*)
@shelling
shelling / config.ru
Created January 5, 2012 08:15
redirect browser to post
require 'rubygems'
require 'sinatra/base'
class App < Sinatra::Base
get "/" do
redirect "/hello.html"
end
post "/" do
class LDAPAdapter
def initialize(options={})
@config = options.select do |key, value|
[:uid].include? key
end
@server = options.select do |key, value|
[:host, :port, :base].include? key
end
use lib qw(lib);
use Plack::Builder;
use Mojo::Server::PSGI;
builder {
return sub {
$ENV{MOJO_APP} ||= 'Hello';
Mojo::Server::PSGI->new->run(@_)
}
}
#include <iostream>
#include <boost/multi_array.hpp>
using namespace std;
typedef boost::multi_array<double, 2> array2d;
typedef array2d::index index2d;
int main(int argc, char **argv) {
array2d hello(boost::extents[20][25]);
#!/usr/bin/env ruby
require "rubygems"
require "rrd"
file = "rrd/10.31.22.55_queue_com.trendmicro.spn.fbs20.HouseCall_001.03.rrd"
RRD::Wrapper.graph("temp.png",
"DEF:Pending=#{file}:NumMsgs82ff1e7ab6ff:LAST",
"DEF:Enqueue=#{file}:NumMsgsInd604c03a7d:LAST",
@shelling
shelling / .gitignore
Created October 25, 2011 02:45
use Objective-C in Linux environment
a.out
*.o
*.d
import org.jsoup.Jsoup;
import org.jsoup.nodes.*;
import org.jsoup.select.*;
public class HelloParser {
public static void main(String[] args) {
try {
Document doc = Jsoup.parse("<html><body><p class=content>內容</p></body></html>");
Element p = doc.select("p.content").first();
#include <iostream>
using namespace std;
class DBClient { // DBClient for production
public:
virtual bool connect() { // should be virtual, this may be the disadvantage.
return true;
}
};
require("coffee-script")
square = (x) -> x * x
for i in [1..10]
do (i) ->
console.log(square(i));
fib = (x) ->