Skip to content

Instantly share code, notes, and snippets.

use Mojolicious::Lite;
use Text::Markdown qw/markdown/;
get '/' => sub {
my $self = shift;
$self->render('index');
};
get '/markdown' => sub {
my $self = shift;
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ck</groupId>
<artifactId>bioweb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>bio</name>
<description></description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@s4553711
s4553711 / Postgre-recursive-query-example
Created October 31, 2014 07:43
以下昰一個Recursive query的範例,只使用到一個表node,其中以id及parent組成其樹狀目錄結構的資訊。
WITH RECURSIVE node_rec(id, name, parent, type) as (
-- Non-recursive term
(
select id, name, parent, type from node where id = 566
)
UNION ALL
-- Recursive Term
-- Here I use 'UNION ALL' statement so that the duplicate result will be included.
-- You can choose to use 'UNION' instead of 'UNION ALL' to get distinct data.
(
@s4553711
s4553711 / gist:9afe5bcbc3902a663232
Created October 31, 2014 09:19
使用Sequence的值作為及將要新增欄位的值
-- Show current sequence val
select currval('nodefolder_id_seq'::regclass);
-- Let insert the data with currval as value
BEGIN;
insert into node (name,parent,type, project_id)
values ('TEST_Name',null,1,currval('nodefolder_id_seq'::regclass));
COMMIT;
-- Reference
@s4553711
s4553711 / gist:2f0a9032abe59a4da7c2
Created December 16, 2014 02:31
Call angular js from legacy code
// Source: http://stackoverflow.com/questions/10490570/call-angular-js-from-legacy-code
var scope = angular.element($('#todoList')[0]).scope()
// The original behavior of click will add up a variable with 1 and show it on the view, but it fact it doesn't update the veiw until
// user click the UI to trigger this function
scope.clikc();
// If I do it in this way, the result will the same with my expect
scope.$apply(function() {
scope.click();
});
[alias]
tree = "forest --pretty=format:\"%C(red)%h %C(magenta)(%ar) %C(blue)%an %C(reset)%s\" --style=15 --reverse --all"
messageBox.show = function(infoNodeId, PositionNodeId) {
var title = jstree().messageBoxTitle(infoNodeId);
var content = jstree().messageBoxText(infoNodeId, PositionNodeId);
};
//------
contextMenu.delete_node = function(node) {
this.popupMessage.show(node.id, node.id);
this.popupMessage.loading.done(function(){
@s4553711
s4553711 / ColInfo.java
Created July 1, 2015 06:34
Compare two list with type ColInfo
package ibms.gp.bioinfo.monitor.util;
import org.apache.commons.lang.builder.HashCodeBuilder;
public class ColInfo {
private String name;
private String type;
private String modifier;
public ColInfo (String name, String type, String modifier) {
@s4553711
s4553711 / DiscardServer.java
Created June 19, 2016 16:41
A netty server example
package com.ck.server;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.FixedRecvByteBufAllocator;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
@s4553711
s4553711 / Receiv.java
Created June 27, 2016 15:39
RabbitMQ simple example
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Envelope;
import com.rabbitmq.client.AMQP;
import java.util.concurrent.TimeoutException;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Consumer;
import com.rabbitmq.client.DefaultConsumer;