如何在另一个要点中嵌入一个要点

时间:2017-04-11 15:53:10

标签: shell github markdown gist github-flavored-markdown

正如标题所说,你如何将一个要点(一个shell脚本)嵌入到另一个要点(降价文件)中?

  • js已禁用,因此不会嵌入脚本
  • github' s {%gist id %}不起作用。

有办法吗? 感谢

1 个答案:

答案 0 :(得分:0)

嵌入式要点是通过内联import java.io.IOException; import java.util.StringTokenizer; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.FloatWritable; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public class FlightAnalyse { public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable>{ private final static IntWritable one = new IntWritable(1); private Text delayOrNot = new Text(); public void map(Object key, Text value, Context context ) throws IOException, InterruptedException { String[] columns = value.toString().split(","); if(columns.length > 5){ int actualDepTime = 0; int scheduledDepTime = 0; try{ actualDepTime = (int) Double.parseDouble(columns[4]); scheduledDepTime = (int) Double.parseDouble(columns[5]); } catch(NumberFormatException nfe){ return; } //convert time to minutes actualDepTime = ((int) actualDepTime/100) * 60 + actualDepTime%100; scheduledDepTime = ((int) scheduledDepTime/100) * 60 + scheduledDepTime%100; int diff = actualDepTime - scheduledDepTime; //if the differecen is less than 5 minutes if(diff <= 5 && diff >= -5) delayOrNot.set("NotDelay"); else delayOrNot.set("Delay"); context.write(delayOrNot, one); } } } public static class IntSumReducer extends Reducer<Text,IntWritable,Text,IntWritable> { private IntWritable result = new IntWritable(); public void reduce(Text key, Iterable<IntWritable> values, Context context ) throws IOException, InterruptedException { int sum = 0; for (IntWritable val : values) { sum += val.get(); } result.set(sum); context.write(key, result); } } public static class Reduce extends Reducer<Text,IntWritable,Text,FloatWritable> { private FloatWritable result = new FloatWritable(); Float persentage = 0f; Float numOfonTime = 0f; Float count = 0f; public void reduce(Text key, Iterable<IntWritable> values, Context context ) throws IOException, InterruptedException { for (IntWritable val : values) { count += val.get(); if(key.toString() == "NotDelay") numOfonTime += val.get(); } persentage = numOfonTime/count; result.set(persentage); Text sumText = new Text("persentage: "); context.write(sumText, result); } } public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = Job.getInstance(conf, "Flight Analysis"); job.setJarByClass(FlightAnalyse.class); job.setMapperClass(TokenizerMapper.class); job.setCombinerClass(IntSumReducer.class); job.setReducerClass(Reduce.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); FileInputFormat.addInputPath(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); } } 标记添加的<iframe>,例如from the GitHub Blog announcing embedded gists

embedded gist #DOM

你能用希望得到的最好的想法是用多个文件(你can do easily)制作一个要点,然后用链接或文本引用另一个文件。

或者,更好的是,选择其他发布平台,例如GitHub页面(如果您已经使用gists)。如果你正在将代码信息嵌入到其他人中,那么可能想要的东西更加灵活和可定制。