iandaicsu的博客
iandaicsu · 共 51 篇文章
[crontab] 在bash中加载cron环境以进行debug
自动加载crontab的运行env,并在bash中加载crontab的环境,对script进行测试 http://stackoverflow.com/questions/2135478/how-to-simulate-the-environment-cron-executes-a-script-with Add this to your cron: 30 08 * * * env > ~/cronenv After it runs, do this: env - `cat ~/cronenv` /bin/sh 在cron中加载rvm环境 http://rvm.io/integration/c…
2013-09-18 16:59 · Linux · 评论(0)
[CSS] 学习笔记float
float 属性定义元素在哪个方向浮动。 float主要的用途: 1 图片周围包围文字 (类似于word编辑中得图片浮动效果,除了图片本身占据的位置用来显示,其他位置都被其他元素占据了) 2 浮动可用于创建全部网页布局,例如sidebar float造成的效果: 1 自身向左(右)浮动 2 因为自身的浮动,导致下面一行的元素跳到上面一行。 3 要消除对下面一行的影响,要使用 div { clear: both; } 代码示例: side bar and float https://tutsplus.com/lesson/floats-and-a-simple-layout/ 参考链接: CS…
2013-09-02 15:56 · CSS · 评论(0)
[HTML] Meta tag viewpoint
Meta tag viewpoint 简易的 cross-device layout 方法 <meta name="viewport" content="width=device-width, initial-scale=1">
2013-09-02 15:55 · html · 评论(0)
[HTML] Form method: Get and Post
Notes on GET: Appends form-data into the URL in name/value pairs The length of a URL is limited (about 3000 characters) Never use GET to send sensitive data! (will be visible in the URL) Useful for form submissions where a user want to bookmark the result GET is better for non-secure data, like que…
2013-09-02 15:54 · 评论(0)
[CSS] 伪元素after和属性position:absolute以及display:block之间的关系
为什么after伪元素之后content无法应用高度和宽度? 1) 想要给after的内容加上大于字体本身的宽度和高度,并给加上背景色 <div class='test'></div> .test { width:100px; height:100px; background: green; } .test:after { content:"12"; background:grey; width:50px; height:50px; } 显示范围只有“12”这部分,而没有50px * 50px的框。 因为after之后的元素默认display为inline,所以无法响应width和heigh…
2013-09-02 15:51 · CSS · 评论(0)
javascript/ jQuery Best Practise
JS代码的良好的结构 https://tutsplus.com/lesson/slides-and-structure/ 理解 JS 的 new 和 prototype 普通创建对象 var person = new Object(); person.firstName = "John"; person.lastName = "Deo"; person.sayHi = function(){ return "Hi there"; }; 使用Factory Function 创建对象 var createPerson = function(fristName, lastName) { retu…
2013-07-24 17:25 · javascript · 评论(0)
nginx +unicorn + gollum 搭建 wiki
STEP 1 创建一个新用户,用户文件夹权限755 STEP 2 检查现有系统,关闭Apache的httpd服务,如果有 STEP 3 更新yum,安装gollum要求的gem --->https://github.com/gollum/gollum STEP 4 新建一个wiki directory, 并 git init . & commit. Gollum只会读取commit之后的文件。 STEP 5 配置 Nginx /etc/nginx/conf.d/default.conf location / { # 反向代理配置,连接localhost:4567的web服务器 proxy_s…
2013-05-24 17:29 · Linux · 评论(0)
nginx配置
Nginx Nginx如何处理一个请求 http://nginx.org/cn/docs/http/request_processing.html Nginx 配置文件 /etc/nginx/nginx.conf user nginx; # 使用该配置的用户,其他用户没有权限 worker_processes 1; # 开启的nginx进程数量 error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; # nginx 运行的时候存放process id的文件 events { worker_connections 1024; } …
2013-05-24 16:53 · Linux · 评论(0)
Amazon Linux + Passenger + Nginx Module + Rails
版本信息: Amazon Linux Paseenger 4.0.2 Rails 3.2.13 STEP 1 新建一个rails用户,将用户权限改为755,以便于设置Nginx Root /app/public 不会产生permission deny的问题。public文件夹能够被所有用户访问是不够的,需要所有父文件夹都具有可执行权限。 sudo useradd {wheel} rails_user ----- wheel 是某个用户组,给予rails_user以sodu权限 optional: [sudo usermod -a -G wheel gollum (如果要使用已有用户,追加已有…
2013-05-23 15:27 · Ruby · 评论(0)
Ruby进程(3) Process.fork 和 Ruby 1.9.2 中的新方法 Process.spawn的区别
简单来说:Process.spawn = Process.fork + exec Process.fork allows you to run ruby code in another process. Process.spawn allows you to run another program in another process. Basically Process.spawn is like using Process.fork and then calling exec in the forked process, except that it gives you more opt…
2013-03-28 18:00 · Ruby · 评论(0)
Ruby线程
Thread.new([arg, ...]) { ... } Thread.start([arg, ...]) { ... } Thread.fork([arg, ...]) { ... } 生成线程,并开始对块进行计算. 参数会被原封不动地传递给块. 这就可以在启动线程的同时,将值传递给该线程所固有的局部变量. 返回生成的线程. Thread.join 挂起当前线程,直到self线程终止运行为止. 若self因异常而终止时, 将会当前线程引发同样的异常. 若某线程内发生了异常,且没有被线程内的 rescue 捕捉到时,通常该线程会被停掉,而不会发出警告。但是,如果这时正好有其它线程因Thr…
2013-03-28 17:55 · Ruby · 评论(0)
Ruby进程(2) Process创建和回收 --- Process.fork, Process.wait和Process.detach
Process.fork{} 当block为空的时候,fork会返回2次结果,一次是在父进程中,返回子进程的pid,一次是在子进程中,返回nil。 Creates a subprocess. If a block is specified, that block is run in the subprocess, and the subprocess terminates with a status of zero. Otherwise, the fork call returns twice, once in the parent, returning the process ID of …
2013-03-28 17:47 · Ruby · 评论(0)
Ruby进程(1) Process.fork 和 Kernel#exec, Kernel#system and Backticks(%x) 比较(Linux)
1 同样都是创建子进程 Process.fork{ } 是非阻塞的执行,创建的子进程与父进程并发运行,需要使用Process.wait或者Process.detach来防止产生zommbie process Kernel#exec, Kernel#system and Backticks(%x)阻塞的执行,调用者将等待被调用的返回 2 Kernel#exec, Kernel#system and Backticks(%x) 区别 Kernel#exec 用新创建的子进程取代原来的进程 exec('ls ~') # Nothing after this command is executed …
2013-03-28 17:08 · Ruby · 评论(0)
require & require_relative
Ruby 1.9.x开始,require 同一文件夹中的文件提示 in `require': no such file to load 错误。 解决方式: 1、用 require_relative : require_relative 'xxx.rb' 2、往 $: 中加入目录路径: $:.unshift File.dirname __FILE__ require 'xxx.rb' 3、或者运行ruby的时候加 -I. 参数 ruby -I. xxx.rb ---------------------------------------------- 引述豆友@knight_stalker 的…
2013-03-19 10:31 · Ruby · 评论(0)