├── .gitignore ├── 404.html ├── History.markdown ├── README.md ├── Rakefile ├── _config.yml ├── _includes ├── JB │ ├── analytics │ ├── analytics-providers │ │ ├── getclicky │ │ ├── google │ │ ├── mixpanel │ │ └── piwik │ ├── categories_list │ ├── comments │ ├── comments-providers │ │ ├── disqus │ │ ├── facebook │ │ ├── intensedebate │ │ └── livefyre │ ├── liquid_raw │ ├── pages_list │ ├── posts_collate │ ├── setup │ ├── sharing │ └── tags_list └── themes │ └── twitter │ ├── default.html │ ├── page.html │ ├── post.html │ └── settings.yml ├── _layouts ├── category_archive.html ├── default.html ├── page.html └── post.html ├── _plugins └── debug.rb ├── _posts ├── 2011-01-12-prime.md ├── 2014-04-20-githubpages.md ├── 2014-04-21-future.md ├── 2014-04-23-chinese-messy-code.md ├── 2014-04-23-finish-jekyll.md ├── 2014-04-24-directory.md ├── 2014-04-25-python-code.md ├── 2014-04-27-install-jekyll.md ├── 2014-05-03-view_render.md ├── 2014-05-10-template.md └── 2014-05-20-collect_color.md ├── archive.html ├── assets └── themes │ └── twitter │ ├── bootstrap │ ├── css │ │ └── bootstrap.2.2.2.min.css │ └── img │ │ ├── card_bg.jpg │ │ ├── date_label_bg.png │ │ ├── date_label_small_bg.png │ │ ├── glyphicons-halflings-white.png │ │ ├── glyphicons-halflings.png │ │ ├── shadow_bg.png │ │ ├── shadow_middle_bg.png │ │ └── shadow_small_bg.png │ ├── css │ ├── img │ │ ├── body_bg.jpg │ │ ├── body_bg.png │ │ ├── body_bg1.png │ │ ├── card_bg.jpg │ │ ├── date_label_bg.png │ │ ├── date_label_small_bg.png │ │ ├── postbg.jpg │ │ └── shadow_bg.png │ ├── prettify.css │ └── style.css │ └── js │ └── prettify.js ├── atom.xml ├── categories.html ├── changelog.md ├── image └── collect_color.jpg ├── index.md ├── pages.html ├── pygments.css ├── rss.xml ├── sitemap.txt └── tags.html /.gitignore: -------------------------------------------------------------------------------- 1 | _site/* 2 | _theme_packages/* 3 | 4 | Thumbs.db 5 | .DS_Store 6 | 7 | !.gitkeep 8 | 9 | .rbenv-version 10 | .rvmrc 11 | -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | Sorry this page does not exist =( 2 | -------------------------------------------------------------------------------- /History.markdown: -------------------------------------------------------------------------------- 1 | ## HEAD 2 | 3 | ### Major Enhancements 4 | 5 | ### Minor Enahncements 6 | * Add `drafts` folder support (#167) 7 | * Add `excerpt` support (#168) 8 | * Create History.markdown to help project management (#169) 9 | 10 | ### Bug Fixes 11 | 12 | ### Site Enhancements 13 | 14 | ### Compatibility updates 15 | * Update `preview` task 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #jekylll blog 2 | 3 | * 基于jekyll的blog 4 | * 使用了bootstrap框架 5 | * 使用font-awesome进行修饰 6 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "rubygems" 2 | require 'rake' 3 | require 'yaml' 4 | require 'time' 5 | 6 | SOURCE = "." 7 | CONFIG = { 8 | 'version' => "0.3.0", 9 | 'themes' => File.join(SOURCE, "_includes", "themes"), 10 | 'layouts' => File.join(SOURCE, "_layouts"), 11 | 'posts' => File.join(SOURCE, "_posts"), 12 | 'post_ext' => "md", 13 | 'theme_package_version' => "0.1.0" 14 | } 15 | 16 | # Path configuration helper 17 | module JB 18 | class Path 19 | SOURCE = "." 20 | Paths = { 21 | :layouts => "_layouts", 22 | :themes => "_includes/themes", 23 | :theme_assets => "assets/themes", 24 | :theme_packages => "_theme_packages", 25 | :posts => "_posts" 26 | } 27 | 28 | def self.base 29 | SOURCE 30 | end 31 | 32 | # build a path relative to configured path settings. 33 | def self.build(path, opts = {}) 34 | opts[:root] ||= SOURCE 35 | path = "#{opts[:root]}/#{Paths[path.to_sym]}/#{opts[:node]}".split("/") 36 | path.compact! 37 | File.__send__ :join, path 38 | end 39 | 40 | end #Path 41 | end #JB 42 | 43 | # Usage: rake post title="A Title" [date="2012-02-09"] [tags=[tag1,tag2]] [category="category"] 44 | desc "Begin a new post in #{CONFIG['posts']}" 45 | task :post do 46 | abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts']) 47 | title = ENV["title"] || "new-post" 48 | tags = ENV["tags"] || "[]" 49 | category = ENV["category"] || "" 50 | category = "\"#{category.gsub(/-/,' ')}\"" if !category.empty? 51 | slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') 52 | begin 53 | date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d') 54 | rescue => e 55 | puts "Error - date format must be YYYY-MM-DD, please check you typed it correctly!" 56 | exit -1 57 | end 58 | filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}") 59 | if File.exist?(filename) 60 | abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n' 61 | end 62 | 63 | puts "Creating new post: #{filename}" 64 | open(filename, 'w') do |post| 65 | post.puts "---" 66 | post.puts "layout: post" 67 | post.puts "title: \"#{title.gsub(/-/,' ')}\"" 68 | post.puts 'description: ""' 69 | post.puts "category: #{category}" 70 | post.puts "tags: #{tags}" 71 | post.puts "---" 72 | post.puts "{% include JB/setup %}" 73 | end 74 | end # task :post 75 | 76 | # Usage: rake page name="about.html" 77 | # You can also specify a sub-directory path. 78 | # If you don't specify a file extention we create an index.html at the path specified 79 | desc "Create a new page." 80 | task :page do 81 | name = ENV["name"] || "new-page.md" 82 | filename = File.join(SOURCE, "#{name}") 83 | filename = File.join(filename, "index.html") if File.extname(filename) == "" 84 | title = File.basename(filename, File.extname(filename)).gsub(/[\W\_]/, " ").gsub(/\b\w/){$&.upcase} 85 | if File.exist?(filename) 86 | abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n' 87 | end 88 | 89 | mkdir_p File.dirname(filename) 90 | puts "Creating new page: #{filename}" 91 | open(filename, 'w') do |post| 92 | post.puts "---" 93 | post.puts "layout: page" 94 | post.puts "title: \"#{title}\"" 95 | post.puts 'description: ""' 96 | post.puts "---" 97 | post.puts "{% include JB/setup %}" 98 | end 99 | end # task :page 100 | 101 | desc "Launch preview environment" 102 | task :preview do 103 | system "jekyll serve -w" 104 | end # task :preview 105 | 106 | # Public: Alias - Maintains backwards compatability for theme switching. 107 | task :switch_theme => "theme:switch" 108 | 109 | namespace :theme do 110 | 111 | # Public: Switch from one theme to another for your blog. 112 | # 113 | # name - String, Required. name of the theme you want to switch to. 114 | # The theme must be installed into your JB framework. 115 | # 116 | # Examples 117 | # 118 | # rake theme:switch name="the-program" 119 | # 120 | # Returns Success/failure messages. 121 | desc "Switch between Jekyll-bootstrap themes." 122 | task :switch do 123 | theme_name = ENV["name"].to_s 124 | theme_path = File.join(CONFIG['themes'], theme_name) 125 | settings_file = File.join(theme_path, "settings.yml") 126 | non_layout_files = ["settings.yml"] 127 | 128 | abort("rake aborted: name cannot be blank") if theme_name.empty? 129 | abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path) 130 | abort("rake aborted: '#{CONFIG['layouts']}' directory not found.") unless FileTest.directory?(CONFIG['layouts']) 131 | 132 | Dir.glob("#{theme_path}/*") do |filename| 133 | next if non_layout_files.include?(File.basename(filename).downcase) 134 | puts "Generating '#{theme_name}' layout: #{File.basename(filename)}" 135 | 136 | open(File.join(CONFIG['layouts'], File.basename(filename)), 'w') do |page| 137 | if File.basename(filename, ".html").downcase == "default" 138 | page.puts "---" 139 | page.puts File.read(settings_file) if File.exist?(settings_file) 140 | page.puts "---" 141 | else 142 | page.puts "---" 143 | page.puts "layout: default" 144 | page.puts "---" 145 | end 146 | page.puts "{% include JB/setup %}" 147 | page.puts "{% include themes/#{theme_name}/#{File.basename(filename)} %}" 148 | end 149 | end 150 | 151 | puts "=> Theme successfully switched!" 152 | puts "=> Reload your web-page to check it out =)" 153 | end # task :switch 154 | 155 | # Public: Install a theme using the theme packager. 156 | # Version 0.1.0 simple 1:1 file matching. 157 | # 158 | # git - String, Optional path to the git repository of the theme to be installed. 159 | # name - String, Optional name of the theme you want to install. 160 | # Passing name requires that the theme package already exist. 161 | # 162 | # Examples 163 | # 164 | # rake theme:install git="https://github.com/jekyllbootstrap/theme-twitter.git" 165 | # rake theme:install name="cool-theme" 166 | # 167 | # Returns Success/failure messages. 168 | desc "Install theme" 169 | task :install do 170 | if ENV["git"] 171 | manifest = theme_from_git_url(ENV["git"]) 172 | name = manifest["name"] 173 | else 174 | name = ENV["name"].to_s.downcase 175 | end 176 | 177 | packaged_theme_path = JB::Path.build(:theme_packages, :node => name) 178 | 179 | abort("rake aborted! 180 | => ERROR: 'name' cannot be blank") if name.empty? 181 | abort("rake aborted! 182 | => ERROR: '#{packaged_theme_path}' directory not found. 183 | => Installable themes can be added via git. You can find some here: http://github.com/jekyllbootstrap 184 | => To download+install run: `rake theme:install git='[PUBLIC-CLONE-URL]'` 185 | => example : rake theme:install git='git@github.com:jekyllbootstrap/theme-the-program.git' 186 | ") unless FileTest.directory?(packaged_theme_path) 187 | 188 | manifest = verify_manifest(packaged_theme_path) 189 | 190 | # Get relative paths to packaged theme files 191 | # Exclude directories as they'll be recursively created. Exclude meta-data files. 192 | packaged_theme_files = [] 193 | FileUtils.cd(packaged_theme_path) { 194 | Dir.glob("**/*.*") { |f| 195 | next if ( FileTest.directory?(f) || f =~ /^(manifest|readme|packager)/i ) 196 | packaged_theme_files << f 197 | } 198 | } 199 | 200 | # Mirror each file into the framework making sure to prompt if already exists. 201 | packaged_theme_files.each do |filename| 202 | file_install_path = File.join(JB::Path.base, filename) 203 | if File.exist? file_install_path and ask("#{file_install_path} already exists. Do you want to overwrite?", ['y', 'n']) == 'n' 204 | next 205 | else 206 | mkdir_p File.dirname(file_install_path) 207 | cp_r File.join(packaged_theme_path, filename), file_install_path 208 | end 209 | end 210 | 211 | puts "=> #{name} theme has been installed!" 212 | puts "=> ---" 213 | if ask("=> Want to switch themes now?", ['y', 'n']) == 'y' 214 | system("rake switch_theme name='#{name}'") 215 | end 216 | end 217 | 218 | # Public: Package a theme using the theme packager. 219 | # The theme must be structured using valid JB API. 220 | # In other words packaging is essentially the reverse of installing. 221 | # 222 | # name - String, Required name of the theme you want to package. 223 | # 224 | # Examples 225 | # 226 | # rake theme:package name="twitter" 227 | # 228 | # Returns Success/failure messages. 229 | desc "Package theme" 230 | task :package do 231 | name = ENV["name"].to_s.downcase 232 | theme_path = JB::Path.build(:themes, :node => name) 233 | asset_path = JB::Path.build(:theme_assets, :node => name) 234 | 235 | abort("rake aborted: name cannot be blank") if name.empty? 236 | abort("rake aborted: '#{theme_path}' directory not found.") unless FileTest.directory?(theme_path) 237 | abort("rake aborted: '#{asset_path}' directory not found.") unless FileTest.directory?(asset_path) 238 | 239 | ## Mirror theme's template directory (_includes) 240 | packaged_theme_path = JB::Path.build(:themes, :root => JB::Path.build(:theme_packages, :node => name)) 241 | mkdir_p packaged_theme_path 242 | cp_r theme_path, packaged_theme_path 243 | 244 | ## Mirror theme's asset directory 245 | packaged_theme_assets_path = JB::Path.build(:theme_assets, :root => JB::Path.build(:theme_packages, :node => name)) 246 | mkdir_p packaged_theme_assets_path 247 | cp_r asset_path, packaged_theme_assets_path 248 | 249 | ## Log packager version 250 | packager = {"packager" => {"version" => CONFIG["theme_package_version"].to_s } } 251 | open(JB::Path.build(:theme_packages, :node => "#{name}/packager.yml"), "w") do |page| 252 | page.puts packager.to_yaml 253 | end 254 | 255 | puts "=> '#{name}' theme is packaged and available at: #{JB::Path.build(:theme_packages, :node => name)}" 256 | end 257 | 258 | end # end namespace :theme 259 | 260 | # Internal: Download and process a theme from a git url. 261 | # Notice we don't know the name of the theme until we look it up in the manifest. 262 | # So we'll have to change the folder name once we get the name. 263 | # 264 | # url - String, Required url to git repository. 265 | # 266 | # Returns theme manifest hash 267 | def theme_from_git_url(url) 268 | tmp_path = JB::Path.build(:theme_packages, :node => "_tmp") 269 | abort("rake aborted: system call to git clone failed") if !system("git clone #{url} #{tmp_path}") 270 | manifest = verify_manifest(tmp_path) 271 | new_path = JB::Path.build(:theme_packages, :node => manifest["name"]) 272 | if File.exist?(new_path) && ask("=> #{new_path} theme package already exists. Override?", ['y', 'n']) == 'n' 273 | remove_dir(tmp_path) 274 | abort("rake aborted: '#{manifest["name"]}' already exists as theme package.") 275 | end 276 | 277 | remove_dir(new_path) if File.exist?(new_path) 278 | mv(tmp_path, new_path) 279 | manifest 280 | end 281 | 282 | # Internal: Process theme package manifest file. 283 | # 284 | # theme_path - String, Required. File path to theme package. 285 | # 286 | # Returns theme manifest hash 287 | def verify_manifest(theme_path) 288 | manifest_path = File.join(theme_path, "manifest.yml") 289 | manifest_file = File.open( manifest_path ) 290 | abort("rake aborted: repo must contain valid manifest.yml") unless File.exist? manifest_file 291 | manifest = YAML.load( manifest_file ) 292 | manifest_file.close 293 | manifest 294 | end 295 | 296 | def ask(message, valid_options) 297 | if valid_options 298 | answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer) 299 | else 300 | answer = get_stdin(message) 301 | end 302 | answer 303 | end 304 | 305 | def get_stdin(message) 306 | print message 307 | STDIN.gets.chomp 308 | end 309 | 310 | #Load custom rake scripts 311 | Dir['_rake/*.rake'].each { |r| load r } 312 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | # This is the default format. 2 | # For more see: http://jekyllrb.com/docs/permalinks/ 3 | permalink: /:year/:month/:day/:title 4 | markdown: rdiscount 5 | exclude: [".rvmrc", ".rbenv-version", "README.md", "Rakefile", "changelog.md"] 6 | highlighter: pygments 7 | #mardown: redcarpet 8 | 9 | safe: false 10 | # Themes are encouraged to use these universal variables 11 | # so be sure to set them if your theme uses them. 12 | # 13 | title : 寂寞先生 14 | tagline: Site Tagline 15 | author : 16 | name : 陈佳伟 17 | email : blah@email.test 18 | github : username 19 | twitter : username 20 | feedburner : feedname 21 | 22 | # The production_url is only used when full-domain names are needed 23 | # such as sitemap.txt 24 | # Most places will/should use BASE_PATH to make the urls 25 | # 26 | # If you have set a CNAME (pages.github.com) set your custom domain here. 27 | # Else if you are pushing to username.github.io, replace with your username. 28 | # Finally if you are pushing to a GitHub project page, include the project name at the end. 29 | # 30 | production_url : http://enml.github.io/blog 31 | 32 | # All Jekyll-Bootstrap specific configurations are namespaced into this hash 33 | # 34 | JB : 35 | version : 0.3.0 36 | 37 | # All links will be namespaced by BASE_PATH if defined. 38 | # Links in your website should always be prefixed with {{BASE_PATH}} 39 | # however this value will be dynamically changed depending on your deployment situation. 40 | # 41 | # CNAME (http://yourcustomdomain.com) 42 | # DO NOT SET BASE_PATH 43 | # (urls will be prefixed with "/" and work relatively) 44 | # 45 | # GitHub Pages (http://username.github.io) 46 | # DO NOT SET BASE_PATH 47 | # (urls will be prefixed with "/" and work relatively) 48 | # 49 | # GitHub Project Pages (http://username.github.io/project-name) 50 | # 51 | # A GitHub Project site exists in the `gh-pages` branch of one of your repositories. 52 | # REQUIRED! Set BASE_PATH to: http://username.github.io/project-name 53 | # 54 | # CAUTION: 55 | # - When in Localhost, your site will run from root "/" regardless of BASE_PATH 56 | # - Only the following values are falsy: ["", null, false] 57 | # - When setting BASE_PATH it must be a valid url. 58 | # This means always setting the protocol (http|https) or prefixing with "/" 59 | BASE_PATH : /blog 60 | 61 | # By default, the asset_path is automatically defined relative to BASE_PATH plus the enabled theme. 62 | # ex: [BASE_PATH]/assets/themes/[THEME-NAME] 63 | # 64 | # Override this by defining an absolute path to assets here. 65 | # ex: 66 | # http://s3.amazonaws.com/yoursite/themes/watermelon 67 | # /assets 68 | # 69 | ASSET_PATH : False 70 | 71 | # These paths are to the main pages Jekyll-Bootstrap ships with. 72 | # Some JB helpers refer to these paths; change them here if needed. 73 | # 74 | archive_path: /archive.html 75 | categories_path : /categories.html 76 | tags_path : /tags.html 77 | atom_path : /atom.xml 78 | rss_path : /rss.xml 79 | 80 | # Settings for comments helper 81 | # Set 'provider' to the comment provider you want to use. 82 | # Set 'provider' to false to turn commenting off globally. 83 | # 84 | comments : 85 | provider : disqus 86 | disqus : 87 | short_name : jekyllbootstrap 88 | livefyre : 89 | site_id : 123 90 | intensedebate : 91 | account : 123abc 92 | facebook : 93 | appid : 123 94 | num_posts: 5 95 | width: 580 96 | colorscheme: light 97 | 98 | # Settings for analytics helper 99 | # Set 'provider' to the analytics provider you want to use. 100 | # Set 'provider' to false to turn analytics off globally. 101 | # 102 | analytics : 103 | provider : google 104 | google : 105 | tracking_id : 'UA-50637568-1' 106 | getclicky : 107 | site_id : 108 | mixpanel : 109 | token : '_MIXPANEL_TOKEN_' 110 | piwik : 111 | baseURL : 'myserver.tld/piwik' # Piwik installation address (without protocol) 112 | idsite : '1' # the id of the site on Piwik 113 | 114 | # Settings for sharing helper. 115 | # Sharing is for things like tweet, plusone, like, reddit buttons etc. 116 | # Set 'provider' to the sharing provider you want to use. 117 | # Set 'provider' to false to turn sharing off globally. 118 | # 119 | sharing : 120 | provider : false 121 | 122 | # Settings for all other include helpers can be defined by creating 123 | # a hash with key named for the given helper. ex: 124 | # 125 | # pages_list : 126 | # provider : "custom" 127 | # 128 | # Setting any helper's provider to 'custom' will bypass the helper code 129 | # and include your custom code. Your custom file must be defined at: 130 | # ./_includes/custom/[HELPER] 131 | # where [HELPER] is the name of the helper you are overriding. 132 | 133 | -------------------------------------------------------------------------------- /_includes/JB/analytics: -------------------------------------------------------------------------------- 1 | {% if site.safe and site.JB.analytics.provider and page.JB.analytics != false %} 2 | 3 | {% case site.JB.analytics.provider %} 4 | {% when "google" %} 5 | {% include JB/analytics-providers/google %} 6 | {% when "getclicky" %} 7 | {% include JB/analytics-providers/getclicky %} 8 | {% when "mixpanel" %} 9 | {% include JB/analytics-providers/mixpanel %} 10 | {% when "piwik" %} 11 | {% include JB/analytics-providers/piwik %} 12 | {% when "custom" %} 13 | {% include custom/analytics %} 14 | {% endcase %} 15 | 16 | {% endif %} -------------------------------------------------------------------------------- /_includes/JB/analytics-providers/getclicky: -------------------------------------------------------------------------------- 1 | 12 | 13 | -------------------------------------------------------------------------------- /_includes/JB/analytics-providers/google: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_includes/JB/analytics-providers/mixpanel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_includes/JB/analytics-providers/piwik: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_includes/JB/categories_list: -------------------------------------------------------------------------------- 1 | {% comment %}{% endcomment %} 19 | 20 | {% if site.JB.categories_list.provider == "custom" %} 21 | {% include custom/categories_list %} 22 | {% else %} 23 | {% if categories_list.first[0] == null %} 24 | {% for category in categories_list %} 25 |
{{text | replace:"|.", "{" | replace:".|", "}" | replace:">", ">" | replace:"<", "<" }}
31 | {% endif %}
32 | {% assign text = nil %}
--------------------------------------------------------------------------------
/_includes/JB/pages_list:
--------------------------------------------------------------------------------
1 | {% comment %}{% endcomment %}
22 |
23 | {% if site.JB.pages_list.provider == "custom" %}
24 | {% include custom/pages_list %}
25 | {% else %}
26 | {% for node in pages_list %}
27 | {% if node.title != null %}
28 | {% if group == null or group == node.group %}
29 | {% if page.url == node.url %}
30 | #{obj.class}\n#{obj.pretty_inspect}" 33 | end 34 | 35 | end # DebugFilter 36 | end # Jekyll 37 | 38 | Liquid::Template.register_filter(Jekyll::DebugFilter) -------------------------------------------------------------------------------- /_posts/2011-01-12-prime.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | title: js-算出某值以内的质数 4 | category : 技术分享 5 | tagline: "Supporting tagline" 6 | tags : [javascript,算法] 7 | published: true 8 | --- 9 | {% include JB/setup %} 10 | # js 算出某值以内的质数 11 | --- 12 | 13 |
14 | //算出 num 以内的所有质数 15 | 16 | function prime(num){ 17 | var list = []; 18 | for(var i = 2; i <= num; i++){ list.push(i); } //create a Array 19 | 20 | for(var i = 0; i < list.length; i++){ 21 | for(var j = 2; j < list[i]; j++){ 22 | if(list[i] % j == 0){ 23 | list.splice(i,1); //delete the non prime number.it will change the index of other elements 24 | j = 2; //由于splice导致list[i+1]的index变为i,因此把j置为2以便对list[i+1]进行重新计算 25 | } 26 | } 27 | } 28 |-------------------------------------------------------------------------------- /_posts/2014-04-20-githubpages.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | title: GitHub基础入门 4 | category : 技术分享 5 | tagline: "Supporting tagline" 6 | tags : jekyll, github 7 | published: false 8 | --- 9 | {% include JB/setup %} 10 | 11 | # GitHub Pages(像黑客一样写博客) 12 | 13 | `技术` 14 | 15 | --- 16 | 17 | 是的,之前github的名字其实早已经如雷贯耳,只是我对它望而生畏,始终不敢去触碰它。因为它咋一看上去冷冰冰的,眼之所及,皆为代码;并且又找不到能详细却直观地描述它的理念的教程,所以我始终无从下手。 18 | 19 | 终于,两天前看到**Blogging like a hacker**这篇文章,决定试试搭建一个基于**github pages**的blog,遂开始尝试。 20 | 21 | 22 | 23 | 首先下载`github`的windows客户端,客户端很简约,这个非常值得称赞。客户端登录后会直接跟你github账号进行绑定同步,因此你能直观的看到github上你的项目文件。硬着头皮尝试各种git命令,不求甚解。以前我很讨厌这种不求甚解的状态,当我在阅读一篇教程时总是希望先了解一下基本脉络,当差不多头脑里有个整体框架后再动手,这样的好处就是你知道你每一步是在做什么,成功率也比较高。但并不是每一篇教程或者每一个项目你都能很快地掌握其基本脉络,就像github。很多教程基本就是直接说输入 24 | 25 | >```git push origin master``` 26 | 27 | 之类的,但他没告诉我输入之后能干什么,会发生什么。更没有人告诉我每一次必须先commit message才能提交。所以我只能糊里糊涂地跟着教程走,不过尝试了几遍之后,也就大概理解了脉络。 28 | 29 | * github为版本控制系统。也就是说,你每一次的提交都会有相关的标记,以便进行回滚和协作。 30 | * 对于远程代码,可以通过```git clone```语句进行clone,可以clone到本地库,也可以clone到github库中。 31 | * 对于本地代码,可以通过```git remote set-url```语句绑定到对应的repository;也可以通过客户端里的public推送到github上。 32 | * 每一次push前必须先commit -m,客户端里是填写相应的summary。 -------------------------------------------------------------------------------- /_posts/2014-04-21-future.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | title: 后智能手机时代 4 | category : 扯淡 5 | tagline: "Supporting tagline" 6 | tags : [机器人, 智能眼镜] 7 | --- 8 | {% include JB/setup %} 9 | # 谁将取代智能手机 10 | --- 11 | 12 |  13 | 14 | 15 | ###**智能手表** 16 | 17 | 现在手表被炒的很热,但以目前来看,手表只是一个辅佐设备;注定手表不可能超越智能手机。手表的特点在于屏幕小,便携,查看信息快速直接;但屏幕小也是它的极限性(屏幕扩大了跟智能手机就没差别了),决定了它不适合发展成独立的终端,你能想象拿着手表刷微博看知乎发邮件吗? 18 | 19 | 20 | 21 | 除非发展出了超越平面显示的信息展现方式,比如说已经被说烂了的“全息投影”。否则手表永远只能是手机的辅佐设备。 22 | 23 | 24 | ###**智能眼镜** 25 | 26 | 这货一开始我不看好,谁tm想戴个电池cpu在太阳穴那里,而且带了几年眼镜的我表示对眼镜深痛恶绝啊。后来了解了google glass之后,我发现这货绝对是未来。不,我是说这个方向。 27 | 28 | 为什么智能眼镜有潜力取代智能手机呢?首先,我们从电子设备的发展历程可以看出,任何具有划时代的产品都是通过对人机交互方式进行革新。从命令行跨越到图形界面,从物理按键跨越到触摸,从遥控器跨越到体感声控……再看看手表,再怎么有想象力它始终只是一部小尺寸精简化的手机绑在手上,不管是现在市面上丑陋不堪的炒作产品,还是被寄予厚望的iwatch,都难以在信息展现方式上得到突破;再看看眼镜,信息是直接投射到视网膜上,信息展现方式已经不再局限于屏幕的大小,你眼前的整个视角都是屏幕,甚至可以通过调节投射的焦距而达到调节屏幕的大小,那可想像的空间可就大了: 29 | 30 | 31 | * 因为展现信息独特的视角,眼镜可以覆盖你的整个视角,它可以挡住外来的光线让你完全沉浸在数字光影之中;你可以随时随地享受不亚于甚至超越IMAX的视觉盛宴。是的,我说的不是3D眼镜。 32 | 33 | * 因为现实与虚拟的无缝结合,你去超市或者在复杂的商业街寻找餐馆,你不用再打开地图或者大众点评,你眼前就是信息与现实的结合体;如果你用过nokia的city lens,你一定知道我在说什么。你不用再厚着脸皮去找心仪的妹子要联系方式了,只要她在社交网络公开信息,你盯着她看几秒可能就已经加了她的微信或者facebook了。 34 | 35 | * 因为“所见即所得”,你所能看到的美景都可以收入囊中,不会再因为掏出手机解锁打开相机应用而错过稍众即逝的美景。当然,google glass现在因为这个产生的隐私问题而备受争议。 36 | 37 | * ……还有很大的想象空间,只是我想不出来了。但是如果做到以上3点,你完全可以抛弃你的智能机了。 38 | 39 | 40 | 以上,并不是空穴来风的天方夜谭,不信,你试着在手表上想象一下。这些是基于信息展现方式,或者说是交互方式的革新。google glass目前并不足以产生颠覆性,产品还不完善,技术也难以突破,生态更是一片荒芜,但它叩开了一个全新世界的大门,这个大门后面的世界才是未来。说实话,我更期待苹果和微软在这方面的突破。 41 | 42 | ###**机器人** 43 | 44 | 这条路任重而道远,真的要发展出人工智能的话,很可能要对现有的计算机体系、软硬架构、甚至编程思想统统进行颠覆才有可能。但是,100年后每个人身边陪着个高度智能的机器人作助手甚至伴侣应该没什么好争议的。那时候什么手机电脑手表眼镜通通可以扔掉了,人可以真正得到解放,这个随时随地跟着你的机器人就是你最好最强大的电子设备了。你要打电话,你就跟它说帮我call一下奥巴马;你要玩游戏,它转过身来可能后背就是一块触摸屏;你要写代码,哦,那时候应该不用写代码了…… 45 | -------------------------------------------------------------------------------- /_posts/2014-04-23-chinese-messy-code.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | title: "解决invalid byte sequence in GBK" 4 | description: "" 5 | category: 技术分享 6 | tags: [gbk,乱码] 7 | --- 8 | {% include JB/setup %} 9 | # 解决invalid byte sequence in GBK 10 | --- 11 | 12 | jekyll对中文的支持不太好,导致经常出现乱码甚至无法运行`jekyll server`命令。解决post内容乱码问题可以通过修改convertible.rb文件的第27行: 13 | 14 | ``` 15 | self.content = File.read(File.join(base, name)); 16 | ``` 17 | 为 18 | 19 | ``` 20 | self.content = File.read(File.join(base, name), :encoding => "utf-8"); 21 | ``` 22 | 23 | 原因File.read()可能采用系统默认编码读取文件,中文系统为GBK,但markdown文件均为utf-8编码,所以导致无法正确展现中文。 24 | 25 | 26 | 27 | 但是当我在post.html模板里面加入中文之后,`jekyll server`命令直接报错。解决办法是在运行服务器前先运行`chcp 65001`命令,即可解决。在官方找到的解决办法**Windows users: run chcp 65001 first to change the command prompt's character encoding (code page) to UTF-8 so Jekyll runs without errors.** 28 | -------------------------------------------------------------------------------- /_posts/2014-04-23-finish-jekyll.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | title: "对5天来关于jekyll的心得" 4 | description: "" 5 | category: 技术分享 6 | tags: [jekyll blog] 7 | --- 8 | {% include JB/setup %} 9 | # 完成基于jekyll的第一个blog 10 | --- 11 | 12 | 今天差不多把blog完成了,这是我第一个基于jekyll的blog,定制了主题,修改了相关配置,以及解决了中文bug。现在把这5天的心得分享一下: 13 | 14 | * 首先是中文问题,这个困扰我了很久,也花费了不少时间,不过最后总算找到解决办法。给我最大的感触就是,即使碰壁,也得硬着头皮找下去,如果放弃,那就前功尽弃了。 15 | 16 | 17 | 18 | * 然后是关于bootstrap,因为主题是基于bootstrap,所以这几天对bootstrap也有了深入的了解。Less预编译的思想其实挺方便的,只不过先前习惯了直接div+css的方式后一时难以习惯,但是,习惯是用来打破,不打破那永远都进不了步。 19 | 20 | * @media通过检测min-width和max-width来进行响应式布局,但要编写全局css时要注意,否则很容易响应不了。 21 | 22 | * \
Thanks for visiting my site.
73 | 74 |