mirror of
https://github.com/onkelbeh/cheatsheets.git
synced 2025-06-16 07:07:37 +02:00
Jekyllization.
This commit is contained in:
parent
6916d06e48
commit
85c46a3923
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
_output
|
||||
_site
|
||||
|
4
Gemfile
4
Gemfile
@ -1,4 +0,0 @@
|
||||
source :rubygems
|
||||
|
||||
gem "proton", "~> 0.3.4"
|
||||
gem "rack-cache", "~> 1.0.0"
|
41
Gemfile.lock
41
Gemfile.lock
@ -1,41 +0,0 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
RedCloth (4.2.8)
|
||||
chunky_png (1.2.1)
|
||||
compass (0.11.5)
|
||||
chunky_png (~> 1.2)
|
||||
fssm (>= 0.2.7)
|
||||
sass (~> 3.1)
|
||||
cuba (2.0.1)
|
||||
rack
|
||||
tilt
|
||||
fssm (0.2.7)
|
||||
haml (3.1.3)
|
||||
hashie (1.0.0)
|
||||
maruku (0.6.0)
|
||||
syntax (>= 1.0.0)
|
||||
proton (0.3.4)
|
||||
RedCloth (~> 4.2.3)
|
||||
compass (~> 0.11.1)
|
||||
cuba (~> 2.0.0)
|
||||
haml (~> 3.1.1)
|
||||
hashie (~> 1.0.0)
|
||||
maruku (~> 0.6.0)
|
||||
sass (~> 3.1.1)
|
||||
shake (~> 0.1)
|
||||
tilt (~> 1.3.2)
|
||||
rack (1.3.2)
|
||||
rack-cache (1.0.2)
|
||||
rack (>= 0.4)
|
||||
sass (3.1.7)
|
||||
shake (0.1.3)
|
||||
syntax (1.0.0)
|
||||
tilt (1.3.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
proton (~> 0.3.4)
|
||||
rack-cache (~> 1.0.0)
|
12
Protonfile
12
Protonfile
@ -1,12 +0,0 @@
|
||||
# This is a Proton site.
|
||||
# Install Proton (`gem install proton`) and type `proton` for help.
|
||||
requirement: 0.2
|
||||
|
||||
# The folder where the site's source files are kept.
|
||||
site_path: .
|
||||
output_path: _output
|
||||
|
||||
# Other paths:
|
||||
layouts_path: _layouts
|
||||
extensions_path: _extensions
|
||||
partials_path: .
|
@ -1,3 +0,0 @@
|
||||
# Cheatsheets
|
||||
|
||||
This is my personal collection of cheatsheets I've made while learning things.
|
9
Rakefile
9
Rakefile
@ -1,9 +0,0 @@
|
||||
desc "Build"
|
||||
task :build do
|
||||
system "proton build"
|
||||
end
|
||||
|
||||
desc "Deploy"
|
||||
task :deploy => :build do
|
||||
system "git update-ghpages rstacruz/cheatsheets -i _output --force"
|
||||
end
|
6
_includes/foot.html
Normal file
6
_includes/foot.html
Normal file
@ -0,0 +1,6 @@
|
||||
<script src="assets/jquery.js"></script>
|
||||
<script src="assets/prettify.js"></script>
|
||||
<script>$("pre").addClass("prettyprint");</script>
|
||||
<script>prettyPrint();</script>
|
||||
</body>
|
||||
</html>
|
12
_includes/head.html
Normal file
12
_includes/head.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title></title>
|
||||
<link href="assets/style.css" rel="stylesheet" />
|
||||
<link href='http://fonts.googleapis.com/css?family=Muli:400,100' rel='stylesheet' type='text/css'>
|
||||
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400' rel='stylesheet' type='text/css'>
|
||||
</head>
|
||||
<body>
|
||||
<div class='background'></div>
|
||||
<div class='all'>
|
@ -1,25 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title></title>
|
||||
<link href="style.css" rel="stylesheet" />
|
||||
<link href='http://fonts.googleapis.com/css?family=Muli:400,100' rel='stylesheet' type='text/css'>
|
||||
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400' rel='stylesheet' type='text/css'>
|
||||
</head>
|
||||
<body>
|
||||
<div class='background'></div>
|
||||
<div class='all'>
|
||||
<h1>
|
||||
<%= page.meta.title || File.basename(page.file, '.*').capitalize %>
|
||||
<a class='back' href='.'>Index</a>
|
||||
</h1>
|
||||
<%= yield %>
|
||||
</div>
|
||||
{% include head.html %}
|
||||
|
||||
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/1.6.4/jquery.min.js'></script>
|
||||
<script src="http://cachedcommons.org/cache/prettify/1.0.0/javascripts/prettify-min.js"></script>
|
||||
<script>$("pre").addClass("prettyprint");</script>
|
||||
<script>prettyPrint();</script>
|
||||
</body>
|
||||
</html>
|
||||
<h1>
|
||||
{{ page.title }}
|
||||
<a class='back' href='.'>Index</a>
|
||||
</h1>
|
||||
|
||||
{{ content }}
|
||||
|
||||
{% include foot.html %}
|
||||
|
12
_layouts/home.html
Normal file
12
_layouts/home.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% include head.html %}
|
||||
|
||||
<h1>
|
||||
{{ page.title }}
|
||||
<a class='back' href='.'>Index</a>
|
||||
</h1>
|
||||
|
||||
{% for page in site.pages %}
|
||||
<a href="{{ page.url }}">{{ page.title }}</a>
|
||||
{% endfor %}
|
||||
|
||||
{% include foot.html %}
|
122
_prettify.scss
122
_prettify.scss
@ -1,122 +0,0 @@
|
||||
/* Tomorrow Theme */
|
||||
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||
/* Pretty printing styles. Used with prettify.js. */
|
||||
/* SPAN elements with the classes below are added by prettyprint. */
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #4d4d4c; }
|
||||
|
||||
@media screen {
|
||||
/* string content */
|
||||
.str {
|
||||
color: #718c00; }
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #8959a8; }
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
color: #8e908c; }
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #4271ae; }
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #f5871f; }
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #c82829; }
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #3e999f; }
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #c82829; }
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #4271ae; } }
|
||||
/* Use higher contrast and text-weight for printable form. */
|
||||
@media print, projection {
|
||||
.str {
|
||||
color: #060; }
|
||||
|
||||
.kwd {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.com {
|
||||
color: #600;
|
||||
font-style: italic; }
|
||||
|
||||
.typ {
|
||||
color: #404;
|
||||
font-weight: bold; }
|
||||
|
||||
.lit {
|
||||
color: #044; }
|
||||
|
||||
.pun, .opn, .clo {
|
||||
color: #440; }
|
||||
|
||||
.tag {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.atn {
|
||||
color: #404; }
|
||||
|
||||
.atv {
|
||||
color: #060; } }
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0; }
|
||||
|
||||
/* IE indents via margin-left */
|
||||
li.L0,
|
||||
li.L1,
|
||||
li.L2,
|
||||
li.L3,
|
||||
li.L4,
|
||||
li.L5,
|
||||
li.L6,
|
||||
li.L7,
|
||||
li.L8,
|
||||
li.L9 {
|
||||
/* */ }
|
||||
|
||||
/* Alternate shading for lines */
|
||||
li.L1,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L7,
|
||||
li.L9 {
|
||||
/* */ }
|
@ -1,4 +1,9 @@
|
||||
Convert mp4 to gif:
|
||||
---
|
||||
title: Animated gifs
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Convert mp4 to gif
|
||||
|
||||
mkdir -p gif
|
||||
mplayer -ao null -vo gif89a:outdir=gif $mp4
|
||||
@ -6,6 +11,6 @@ Convert mp4 to gif:
|
||||
gifsicle --colors=256 --delay=4 --loopcount=0 --dither -O3 gif/*.gif > ${mp4%.*}.gif
|
||||
rm -rf gif
|
||||
|
||||
Or a given range (-ss -endpos):
|
||||
### Or a given range (-ss -endpos)
|
||||
|
||||
mplayer -ao null -ss 0:02:06 -endpos 0:05:00 -vo gif89a:outdir=gif videofile.mp4
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
6
assets/jquery.js
vendored
Normal file
6
assets/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
33
assets/prettify.js
Normal file
33
assets/prettify.js
Normal file
@ -0,0 +1,33 @@
|
||||
window.PR_SHOULD_USE_CONTINUATION=true;window.PR_TAB_WIDTH=8;window.PR_normalizedHtml=window.PR=window.prettyPrintOne=window.prettyPrint=void 0;window._pr_isIE6=function(){var y=navigator&&navigator.userAgent&&navigator.userAgent.match(/\bMSIE ([678])\./);y=y?+y[1]:false;window._pr_isIE6=function(){return y};return y};
|
||||
(function(){function y(b){return b.replace(L,"&").replace(M,"<").replace(N,">")}function H(b,f,i){switch(b.nodeType){case 1:var o=b.tagName.toLowerCase();f.push("<",o);var l=b.attributes,n=l.length;if(n){if(i){for(var r=[],j=n;--j>=0;)r[j]=l[j];r.sort(function(q,m){return q.name<m.name?-1:q.name===m.name?0:1});l=r}for(j=0;j<n;++j){r=l[j];r.specified&&f.push(" ",r.name.toLowerCase(),'="',r.value.replace(L,"&").replace(M,"<").replace(N,">").replace(X,"""),'"')}}f.push(">");
|
||||
for(l=b.firstChild;l;l=l.nextSibling)H(l,f,i);if(b.firstChild||!/^(?:br|link|img)$/.test(o))f.push("</",o,">");break;case 3:case 4:f.push(y(b.nodeValue));break}}function O(b){function f(c){if(c.charAt(0)!=="\\")return c.charCodeAt(0);switch(c.charAt(1)){case "b":return 8;case "t":return 9;case "n":return 10;case "v":return 11;case "f":return 12;case "r":return 13;case "u":case "x":return parseInt(c.substring(2),16)||c.charCodeAt(1);case "0":case "1":case "2":case "3":case "4":case "5":case "6":case "7":return parseInt(c.substring(1),
|
||||
8);default:return c.charCodeAt(1)}}function i(c){if(c<32)return(c<16?"\\x0":"\\x")+c.toString(16);c=String.fromCharCode(c);if(c==="\\"||c==="-"||c==="["||c==="]")c="\\"+c;return c}function o(c){var d=c.substring(1,c.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));c=[];for(var a=[],k=d[0]==="^",e=k?1:0,h=d.length;e<h;++e){var g=d[e];switch(g){case "\\B":case "\\b":case "\\D":case "\\d":case "\\S":case "\\s":case "\\W":case "\\w":c.push(g);
|
||||
continue}g=f(g);var s;if(e+2<h&&"-"===d[e+1]){s=f(d[e+2]);e+=2}else s=g;a.push([g,s]);if(!(s<65||g>122)){s<65||g>90||a.push([Math.max(65,g)|32,Math.min(s,90)|32]);s<97||g>122||a.push([Math.max(97,g)&-33,Math.min(s,122)&-33])}}a.sort(function(v,w){return v[0]-w[0]||w[1]-v[1]});d=[];g=[NaN,NaN];for(e=0;e<a.length;++e){h=a[e];if(h[0]<=g[1]+1)g[1]=Math.max(g[1],h[1]);else d.push(g=h)}a=["["];k&&a.push("^");a.push.apply(a,c);for(e=0;e<d.length;++e){h=d[e];a.push(i(h[0]));if(h[1]>h[0]){h[1]+1>h[0]&&a.push("-");
|
||||
a.push(i(h[1]))}}a.push("]");return a.join("")}function l(c){for(var d=c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),a=d.length,k=[],e=0,h=0;e<a;++e){var g=d[e];if(g==="(")++h;else if("\\"===g.charAt(0))if((g=+g.substring(1))&&g<=h)k[g]=-1}for(e=1;e<k.length;++e)if(-1===k[e])k[e]=++n;for(h=e=0;e<a;++e){g=d[e];if(g==="("){++h;if(k[h]===undefined)d[e]="(?:"}else if("\\"===
|
||||
g.charAt(0))if((g=+g.substring(1))&&g<=h)d[e]="\\"+k[h]}for(h=e=0;e<a;++e)if("^"===d[e]&&"^"!==d[e+1])d[e]="";if(c.ignoreCase&&r)for(e=0;e<a;++e){g=d[e];c=g.charAt(0);if(g.length>=2&&c==="[")d[e]=o(g);else if(c!=="\\")d[e]=g.replace(/[a-zA-Z]/g,function(s){s=s.charCodeAt(0);return"["+String.fromCharCode(s&-33,s|32)+"]"})}return d.join("")}for(var n=0,r=false,j=false,q=0,m=b.length;q<m;++q){var t=b[q];if(t.ignoreCase)j=true;else if(/[a-z]/i.test(t.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,
|
||||
""))){r=true;j=false;break}}var p=[];q=0;for(m=b.length;q<m;++q){t=b[q];if(t.global||t.multiline)throw Error(""+t);p.push("(?:"+l(t)+")")}return RegExp(p.join("|"),j?"gi":"g")}function Y(b){var f=0;return function(i){for(var o=null,l=0,n=0,r=i.length;n<r;++n)switch(i.charAt(n)){case "\t":o||(o=[]);o.push(i.substring(l,n));l=b-f%b;for(f+=l;l>=0;l-=16)o.push(" ".substring(0,l));l=n+1;break;case "\n":f=0;break;default:++f}if(!o)return i;o.push(i.substring(l));return o.join("")}}function I(b,
|
||||
f,i,o){if(f){b={source:f,c:b};i(b);o.push.apply(o,b.d)}}function B(b,f){var i={},o;(function(){for(var r=b.concat(f),j=[],q={},m=0,t=r.length;m<t;++m){var p=r[m],c=p[3];if(c)for(var d=c.length;--d>=0;)i[c.charAt(d)]=p;p=p[1];c=""+p;if(!q.hasOwnProperty(c)){j.push(p);q[c]=null}}j.push(/[\0-\uffff]/);o=O(j)})();var l=f.length;function n(r){for(var j=r.c,q=[j,z],m=0,t=r.source.match(o)||[],p={},c=0,d=t.length;c<d;++c){var a=t[c],k=p[a],e=void 0,h;if(typeof k==="string")h=false;else{var g=i[a.charAt(0)];
|
||||
if(g){e=a.match(g[1]);k=g[0]}else{for(h=0;h<l;++h){g=f[h];if(e=a.match(g[1])){k=g[0];break}}e||(k=z)}if((h=k.length>=5&&"lang-"===k.substring(0,5))&&!(e&&typeof e[1]==="string")){h=false;k=P}h||(p[a]=k)}g=m;m+=a.length;if(h){h=e[1];var s=a.indexOf(h),v=s+h.length;if(e[2]){v=a.length-e[2].length;s=v-h.length}k=k.substring(5);I(j+g,a.substring(0,s),n,q);I(j+g+s,h,Q(k,h),q);I(j+g+v,a.substring(v),n,q)}else q.push(j+g,k)}r.d=q}return n}function x(b){var f=[],i=[];if(b.tripleQuotedStrings)f.push([A,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
|
||||
null,"'\""]);else b.multiLineStrings?f.push([A,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):f.push([A,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]);b.verbatimStrings&&i.push([A,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);if(b.hashComments)if(b.cStyleComments){f.push([C,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]);i.push([A,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,
|
||||
null])}else f.push([C,/^#[^\r\n]*/,null,"#"]);if(b.cStyleComments){i.push([C,/^\/\/[^\r\n]*/,null]);i.push([C,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}b.regexLiterals&&i.push(["lang-regex",RegExp("^"+Z+"(/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/)")]);b=b.keywords.replace(/^\s+|\s+$/g,"");b.length&&i.push([R,RegExp("^(?:"+b.replace(/\s+/g,"|")+")\\b"),null]);f.push([z,/^\s+/,null," \r\n\t\u00a0"]);i.push([J,/^@[a-z_$][a-z_$@0-9]*/i,null],[S,/^@?[A-Z]+[a-z][A-Za-z_$@0-9]*/,
|
||||
null],[z,/^[a-z_$][a-z_$@0-9]*/i,null],[J,/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],[E,/^.[^\s\w\.$@\'\"\`\/\#]*/,null]);return B(f,i)}function $(b){function f(D){if(D>r){if(j&&j!==q){n.push("</span>");j=null}if(!j&&q){j=q;n.push('<span class="',j,'">')}var T=y(p(i.substring(r,D))).replace(e?d:c,"$1 ");e=k.test(T);n.push(T.replace(a,s));r=D}}var i=b.source,o=b.g,l=b.d,n=[],r=0,j=null,q=null,m=0,t=0,p=Y(window.PR_TAB_WIDTH),c=/([\r\n ]) /g,
|
||||
d=/(^| ) /gm,a=/\r\n?|\n/g,k=/[ \r\n]$/,e=true,h=window._pr_isIE6();h=h?b.b.tagName==="PRE"?h===6?" \r\n":h===7?" <br>\r":" \r":" <br />":"<br />";var g=b.b.className.match(/\blinenums\b(?::(\d+))?/),s;if(g){for(var v=[],w=0;w<10;++w)v[w]=h+'</li><li class="L'+w+'">';var F=g[1]&&g[1].length?g[1]-1:0;n.push('<ol class="linenums"><li class="L',F%10,'"');F&&n.push(' value="',F+1,'"');n.push(">");s=function(){var D=v[++F%10];return j?"</span>"+D+'<span class="'+j+'">':D}}else s=h;
|
||||
for(;;)if(m<o.length?t<l.length?o[m]<=l[t]:true:false){f(o[m]);if(j){n.push("</span>");j=null}n.push(o[m+1]);m+=2}else if(t<l.length){f(l[t]);q=l[t+1];t+=2}else break;f(i.length);j&&n.push("</span>");g&&n.push("</li></ol>");b.a=n.join("")}function u(b,f){for(var i=f.length;--i>=0;){var o=f[i];if(G.hasOwnProperty(o))"console"in window&&console.warn("cannot override language handler %s",o);else G[o]=b}}function Q(b,f){b&&G.hasOwnProperty(b)||(b=/^\s*</.test(f)?"default-markup":"default-code");return G[b]}
|
||||
function U(b){var f=b.f,i=b.e;b.a=f;try{var o,l=f.match(aa);f=[];var n=0,r=[];if(l)for(var j=0,q=l.length;j<q;++j){var m=l[j];if(m.length>1&&m.charAt(0)==="<"){if(!ba.test(m))if(ca.test(m)){f.push(m.substring(9,m.length-3));n+=m.length-12}else if(da.test(m)){f.push("\n");++n}else if(m.indexOf(V)>=0&&m.replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,' $1="$2$3$4"').match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/)){var t=m.match(W)[2],p=1,c;c=j+1;a:for(;c<q;++c){var d=l[c].match(W);if(d&&
|
||||
d[2]===t)if(d[1]==="/"){if(--p===0)break a}else++p}if(c<q){r.push(n,l.slice(j,c+1).join(""));j=c}else r.push(n,m)}else r.push(n,m)}else{var a;p=m;var k=p.indexOf("&");if(k<0)a=p;else{for(--k;(k=p.indexOf("&#",k+1))>=0;){var e=p.indexOf(";",k);if(e>=0){var h=p.substring(k+3,e),g=10;if(h&&h.charAt(0)==="x"){h=h.substring(1);g=16}var s=parseInt(h,g);isNaN(s)||(p=p.substring(0,k)+String.fromCharCode(s)+p.substring(e+1))}}a=p.replace(ea,"<").replace(fa,">").replace(ga,"'").replace(ha,'"').replace(ia," ").replace(ja,
|
||||
"&")}f.push(a);n+=a.length}}o={source:f.join(""),h:r};var v=o.source;b.source=v;b.c=0;b.g=o.h;Q(i,v)(b);$(b)}catch(w){if("console"in window)console.log(w&&w.stack?w.stack:w)}}var A="str",R="kwd",C="com",S="typ",J="lit",E="pun",z="pln",P="src",V="nocode",Z=function(){for(var b=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===",">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=",
|
||||
"~","break","case","continue","delete","do","else","finally","instanceof","return","throw","try","typeof"],f="(?:^^|[+-]",i=0;i<b.length;++i)f+="|"+b[i].replace(/([^=<>:&a-z])/g,"\\$1");f+=")\\s*";return f}(),L=/&/g,M=/</g,N=/>/g,X=/\"/g,ea=/</g,fa=/>/g,ga=/'/g,ha=/"/g,ja=/&/g,ia=/ /g,ka=/[\r\n]/g,K=null,aa=RegExp("[^<]+|<!--[\\s\\S]*?--\>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|</?[a-zA-Z](?:[^>\"']|'[^']*'|\"[^\"]*\")*>|<","g"),ba=/^<\!--/,ca=/^<!\[CDATA\[/,da=/^<br\b/i,W=/^<(\/?)([a-zA-Z][a-zA-Z0-9]*)/,
|
||||
la=x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename using virtual wchar_t where break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params partial readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof debugger eval export function get null set undefined var with Infinity NaN caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END break continue do else for if return while and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None break continue do else for if return while alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END break continue do else for if return while case done elif esac eval fi function in local set then until ",
|
||||
hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true}),G={};u(la,["default-code"]);u(B([],[[z,/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],[C,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[E,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup",
|
||||
"htm","html","mxml","xhtml","xml","xsl"]);u(B([[z,/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[E,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],
|
||||
["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);u(B([],[["atv",/^[\s\S]+/]]),["uq.val"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename using virtual wchar_t where ",
|
||||
hashComments:true,cStyleComments:true}),["c","cc","cpp","cxx","cyc","m"]);u(x({keywords:"null true false"}),["json"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params partial readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ",
|
||||
hashComments:true,cStyleComments:true,verbatimStrings:true}),["cs"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ",
|
||||
cStyleComments:true}),["java"]);u(x({keywords:"break continue do else for if return while case done elif esac eval fi function in local set then until ",hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);u(x({keywords:"break continue do else for if return while and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None ",hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);
|
||||
u(x({keywords:"caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END ",hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);u(x({keywords:"break continue do else for if return while alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END ",hashComments:true,
|
||||
multiLineStrings:true,regexLiterals:true}),["rb"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof debugger eval export function get null set undefined var with Infinity NaN ",cStyleComments:true,regexLiterals:true}),["js"]);u(B([],[[A,/^[\s\S]+/]]),
|
||||
["regex"]);window.PR_normalizedHtml=H;window.prettyPrintOne=function(b,f){var i={f:b,e:f};U(i);return i.a};window.prettyPrint=function(b){function f(){for(var t=window.PR_SHOULD_USE_CONTINUATION?j.now()+250:Infinity;q<o.length&&j.now()<t;q++){var p=o[q];if(p.className&&p.className.indexOf("prettyprint")>=0){var c=p.className.match(/\blang-(\w+)\b/);if(c)c=c[1];for(var d=false,a=p.parentNode;a;a=a.parentNode)if((a.tagName==="pre"||a.tagName==="code"||a.tagName==="xmp")&&a.className&&a.className.indexOf("prettyprint")>=
|
||||
0){d=true;break}if(!d){a=p;if(null===K){d=document.createElement("PRE");d.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));K=!/</.test(d.innerHTML)}if(K){d=a.innerHTML;if("XMP"===a.tagName)d=y(d);else{a=a;if("PRE"===a.tagName)a=true;else if(ka.test(d)){var k="";if(a.currentStyle)k=a.currentStyle.whiteSpace;else if(window.getComputedStyle)k=window.getComputedStyle(a,null).whiteSpace;a=!k||k==="pre"}else a=true;a||(d=d.replace(/(<br\s*\/?>)[\r\n]+/g,"$1").replace(/(?:[\r\n]+[ \t]*)+/g,
|
||||
" "))}d=d}else{d=[];for(a=a.firstChild;a;a=a.nextSibling)H(a,d);d=d.join("")}d=d.replace(/(?:\r\n?|\n)$/,"");m={f:d,e:c,b:p};U(m);if(p=m.a){c=m.b;if("XMP"===c.tagName){d=document.createElement("PRE");for(a=0;a<c.attributes.length;++a){k=c.attributes[a];if(k.specified)if(k.name.toLowerCase()==="class")d.className=k.value;else d.setAttribute(k.name,k.value)}d.innerHTML=p;c.parentNode.replaceChild(d,c)}else c.innerHTML=p}}}}if(q<o.length)setTimeout(f,250);else b&&b()}for(var i=[document.getElementsByTagName("pre"),
|
||||
document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],o=[],l=0;l<i.length;++l)for(var n=0,r=i[l].length;n<r;++n)o.push(i[l][n]);i=null;var j=Date;j.now||(j={now:function(){return(new Date).getTime()}});var q=0,m;f()};window.PR={combinePrefixPatterns:O,createSimpleLexer:B,registerLangHandler:u,sourceDecorator:x,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:C,PR_DECLARATION:"dec",PR_KEYWORD:R,PR_LITERAL:J,PR_NOCODE:V,PR_PLAIN:z,PR_PUNCTUATION:E,PR_SOURCE:P,PR_STRING:A,
|
||||
PR_TAG:"tag",PR_TYPE:S}})()
|
327
assets/style.css
Normal file
327
assets/style.css
Normal file
@ -0,0 +1,327 @@
|
||||
body, input, td, textarea {
|
||||
font-family: Muli, Helvetica Neue, helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.5; }
|
||||
|
||||
html {
|
||||
background: #40404c;
|
||||
padding: 60px 20px; }
|
||||
|
||||
a, a:visited {
|
||||
background-color: #f4eac1;
|
||||
color: #84701e;
|
||||
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
|
||||
padding: 1px 2px;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
|
||||
border-radius: 2px;
|
||||
text-decoration: none; }
|
||||
a:hover {
|
||||
background-color: #eedd99; }
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
html {
|
||||
padding: 20px; } }
|
||||
@media screen and (max-width: 500px) {
|
||||
html {
|
||||
padding: 0; } }
|
||||
.background {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
z-index: -2;
|
||||
background: url(bg.jpg);
|
||||
background-size: 200% 200%;
|
||||
opacity: 1; }
|
||||
|
||||
.all {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
max-width: 700px;
|
||||
min-width: 400px;
|
||||
margin: 0 auto;
|
||||
padding: 40px;
|
||||
-webkit-box-shadow: 1px 0 0 rgba(0, 0, 0, 0.05), -1px 0 0 rgba(0, 0, 0, 0.05), 0 0 4px rgba(0, 0, 0, 0.1), 0 0 0 5px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: 1px 0 0 rgba(0, 0, 0, 0.05), -1px 0 0 rgba(0, 0, 0, 0.05), 0 0 4px rgba(0, 0, 0, 0.1), 0 0 0 5px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 1px 0 0 rgba(0, 0, 0, 0.05), -1px 0 0 rgba(0, 0, 0, 0.05), 0 0 4px rgba(0, 0, 0, 0.1), 0 0 0 5px rgba(0, 0, 0, 0.05);
|
||||
-webkit-border-radius: 2px;
|
||||
-moz-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
background: white;
|
||||
color: #333333; }
|
||||
|
||||
p, ul, ol, pre {
|
||||
margin: 15px 0; }
|
||||
|
||||
p {
|
||||
margin: 25px 100px 25px 0; }
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 40px 0 15px 0; }
|
||||
|
||||
h1 {
|
||||
text-align: left;
|
||||
font-size: 26pt;
|
||||
line-height: 30pt;
|
||||
color: #cccccc;
|
||||
margin: -40px -40px 40px -40px;
|
||||
padding: 40px 40px;
|
||||
border-bottom: solid 1px whitesmoke;
|
||||
font-weight: 100;
|
||||
overflow: hidden; }
|
||||
|
||||
h1 .back {
|
||||
float: right;
|
||||
display: inline-block;
|
||||
padding: 0 20px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
font-size: 9pt;
|
||||
-webkit-transition: all 100ms linear;
|
||||
-moz-transition: all 100ms linear;
|
||||
-o-transition: all 100ms linear;
|
||||
transition: all 100ms linear;
|
||||
background-color: white;
|
||||
-webkit-box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.5);
|
||||
-moz-box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.5);
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.5);
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
color: #aaaaaa;
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
|
||||
text-decoration: none; }
|
||||
h1 .back:hover {
|
||||
background-color: #fafafa;
|
||||
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #fafafa), color-stop(100%, #f5f5f5));
|
||||
background: -webkit-linear-gradient(top, #fafafa, #f5f5f5);
|
||||
background: -moz-linear-gradient(top, #fafafa, #f5f5f5);
|
||||
background: -o-linear-gradient(top, #fafafa, #f5f5f5);
|
||||
background: linear-gradient(top, #fafafa, #f5f5f5);
|
||||
-webkit-box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
-moz-box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 1px 3px rgba(0, 0, 0, 0.05); }
|
||||
h1 .back:active {
|
||||
-webkit-box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 2px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
-moz-box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 2px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 2px 2px 4px rgba(0, 0, 0, 0.1); }
|
||||
h1 .back:before {
|
||||
content: "\238b";
|
||||
margin-right: 5px;
|
||||
color: #888888; }
|
||||
|
||||
h2, h3 {
|
||||
color: #3388dd;
|
||||
font-size: 1.2em;
|
||||
padding-bottom: 10px;
|
||||
font-weight: normal; }
|
||||
|
||||
h3 {
|
||||
font-size: 1.3em; }
|
||||
|
||||
pre, code {
|
||||
font-family: Menlo, Ubuntu Mono, monaco, monospace;
|
||||
font-size: 12px;
|
||||
color: #444444; }
|
||||
|
||||
.all > pre, .all > ul {
|
||||
line-height: 1.6;
|
||||
background: #f7f7f2;
|
||||
padding: 20px;
|
||||
-webkit-box-shadow: inset 0 3px 2px -2px rgba(0, 0, 0, 0.1);
|
||||
-moz-box-shadow: inset 0 3px 2px -2px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: inset 0 3px 2px -2px rgba(0, 0, 0, 0.1);
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
|
||||
border-top: solid 1px #dddddd;
|
||||
border-bottom: solid 1px #dddddd;
|
||||
overflow-x: auto;
|
||||
margin-left: -40px;
|
||||
margin-right: -40px;
|
||||
padding: 20px 40px; }
|
||||
.all > pre::-webkit-scrollbar, .all > ul::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 10px; }
|
||||
.all > pre::-webkit-scrollbar-thumb, .all > ul::-webkit-scrollbar-thumb {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
border-radius: 5px;
|
||||
border: solid 2px #fffffb; }
|
||||
.all > pre:hover::-webkit-scrollbar-thumb, .all > ul:hover::-webkit-scrollbar-thumb {
|
||||
background: rgba(0, 0, 0, 0.2); }
|
||||
|
||||
ul, .all > ul {
|
||||
padding-left: 60px;
|
||||
list-style-type: circle; }
|
||||
|
||||
h2 {
|
||||
font-size: 1.6em;
|
||||
border-top: dotted 3px #d6e3f8;
|
||||
padding: 40px 40px 0 40px;
|
||||
margin-left: -40px;
|
||||
margin-right: -40px; }
|
||||
|
||||
h1 + h2 {
|
||||
border-top: 0;
|
||||
padding-top: 0; }
|
||||
|
||||
em {
|
||||
opacity: 0.7;
|
||||
font-size: 0.9em; }
|
||||
|
||||
h2 + pre, h3 + pre {
|
||||
margin-top: -16px; }
|
||||
|
||||
ul.pages, ul.pages li {
|
||||
list-style-type: none; }
|
||||
ul.pages li {
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
ul.pages li {
|
||||
width: 20%;
|
||||
min-width: 100px;
|
||||
float: left; }
|
||||
ul.pages a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
padding: 7px 8px;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
color: #555588;
|
||||
font-weight: normal;
|
||||
font-size: 9pt; }
|
||||
ul.pages a:before {
|
||||
content: "\203a";
|
||||
color: #999999;
|
||||
margin-right: 7px; }
|
||||
ul.pages a:visited {
|
||||
opacity: 0.8; }
|
||||
ul.pages a:hover {
|
||||
background: #eeeeff;
|
||||
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05), inset 0 0 0 3px rgba(0, 0, 0, 0.03);
|
||||
-moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05), inset 0 0 0 3px rgba(0, 0, 0, 0.03);
|
||||
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.05), inset 0 0 0 3px rgba(0, 0, 0, 0.03); }
|
||||
ul.pages li:first-letter {
|
||||
text-transform: uppercase; }
|
||||
|
||||
/* Tomorrow Theme */
|
||||
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||
/* Pretty printing styles. Used with prettify.js. */
|
||||
/* SPAN elements with the classes below are added by prettyprint. */
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #4d4d4c; }
|
||||
|
||||
@media screen {
|
||||
/* string content */
|
||||
.str {
|
||||
color: #718c00; }
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #8959a8; }
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
color: #8e908c; }
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #4271ae; }
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #f5871f; }
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #c82829; }
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #3e999f; }
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #c82829; }
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #4271ae; } }
|
||||
/* Use higher contrast and text-weight for printable form. */
|
||||
@media print, projection {
|
||||
.str {
|
||||
color: #060; }
|
||||
|
||||
.kwd {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.com {
|
||||
color: #600;
|
||||
font-style: italic; }
|
||||
|
||||
.typ {
|
||||
color: #404;
|
||||
font-weight: bold; }
|
||||
|
||||
.lit {
|
||||
color: #044; }
|
||||
|
||||
.pun, .opn, .clo {
|
||||
color: #440; }
|
||||
|
||||
.tag {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.atn {
|
||||
color: #404; }
|
||||
|
||||
.atv {
|
||||
color: #060; } }
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0; }
|
||||
|
||||
/* IE indents via margin-left */
|
||||
li.L0,
|
||||
li.L1,
|
||||
li.L2,
|
||||
li.L3,
|
||||
li.L4,
|
||||
li.L5,
|
||||
li.L6,
|
||||
li.L7,
|
||||
li.L8,
|
||||
li.L9 {
|
||||
/* */ }
|
||||
|
||||
/* Alternate shading for lines */
|
||||
li.L1,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L7,
|
||||
li.L9 {
|
||||
/* */ }
|
@ -1,4 +1,7 @@
|
||||
# Bookshelf.js
|
||||
---
|
||||
title: Bookshelf.js
|
||||
layout: default
|
||||
---
|
||||
|
||||
Model
|
||||
-----
|
||||
|
45
brew.md
45
brew.md
@ -1,45 +0,0 @@
|
||||
title: Brew
|
||||
---
|
||||
|
||||
### Commands
|
||||
|
||||
brew unlink git
|
||||
brew link git
|
||||
|
||||
brew list # List all installed
|
||||
|
||||
brew list --versions git # See what versions of `git` you have
|
||||
brew info git # List versions, caveats, etc
|
||||
brew cleanup git # Remove old versions
|
||||
brew edit git # Edit this formula
|
||||
brew home git # Open homepage
|
||||
|
||||
### Stuff
|
||||
|
||||
Nice Homebrew packages:
|
||||
|
||||
* `tig` - Git "GUI" for the console
|
||||
* `mysql`
|
||||
* `postgresql`
|
||||
* `fmdiff` - Adaptor to use Apple's FileMerge as `diff` (`git config --global merge-tool fmdiff`)
|
||||
* `cmus` - Curses-based music player
|
||||
* `cclive` - Video downloader
|
||||
|
||||
Not from brew:
|
||||
|
||||
* `DiffMerge` - nice free merge tool for OSX
|
||||
|
||||
Tmux
|
||||
----
|
||||
|
||||
Install a more-recent version that supports tmux -C
|
||||
|
||||
brew install https://github.com/adamv/homebrew-alt/raw/master/other/tmux-iterm2.rb
|
||||
|
||||
Install the wrapper for stuff to enable OSX clipboard to work
|
||||
|
||||
brew install reattach-to-user-namespace --wrap-pbcopy-and-pbpaste
|
||||
|
||||
Make sure that your VIM alias uses it
|
||||
|
||||
alias vim="reattach-to-user-namespace /Application/MacVim/Contents/MacOS/Vim"
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
title: Bundler
|
||||
----
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Gems
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: C Preprocessor
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Compiling
|
||||
|
||||
$ cpp -P file > outfile
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Canvas
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Getting the context
|
||||
|
||||
var canvas = document.getElementById('c');
|
||||
|
35
capybara.md
35
capybara.md
@ -1,17 +1,19 @@
|
||||
Navigating
|
||||
----------
|
||||
---
|
||||
title: Capybara
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Navigating
|
||||
|
||||
visit articles_path
|
||||
|
||||
Clicking links and buttons
|
||||
--------------------------
|
||||
### Clicking links and buttons
|
||||
|
||||
click 'Link Text'
|
||||
click_button
|
||||
click_link
|
||||
|
||||
Interacting with forms
|
||||
----------------------
|
||||
### Interacting with forms
|
||||
|
||||
attach_file
|
||||
fill_in 'First Name', :with => 'John'
|
||||
@ -21,8 +23,7 @@ Interacting with forms
|
||||
select
|
||||
unselect
|
||||
|
||||
Querying
|
||||
--------
|
||||
### Querying
|
||||
|
||||
Takes a CSS selector (or XPath if you're into that).
|
||||
Translates nicely into RSpec matchers:
|
||||
@ -51,8 +52,7 @@ should_not doesn't wait for a timeout from the driver
|
||||
page.has_select?
|
||||
page.has_no_select?
|
||||
|
||||
Finding
|
||||
-------
|
||||
### Finding
|
||||
|
||||
find
|
||||
find_button
|
||||
@ -61,8 +61,7 @@ Finding
|
||||
find_link
|
||||
locate
|
||||
|
||||
Scoping
|
||||
-------
|
||||
### Scoping
|
||||
|
||||
within
|
||||
within_fieldset
|
||||
@ -70,19 +69,16 @@ Scoping
|
||||
within_frame
|
||||
scope_to
|
||||
|
||||
Scripting
|
||||
---------
|
||||
### Scripting
|
||||
|
||||
execute_script
|
||||
evaluate_script
|
||||
|
||||
Debugging
|
||||
---------
|
||||
### Debugging
|
||||
|
||||
save_and_open_page
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
### Miscellaneous
|
||||
|
||||
all
|
||||
body
|
||||
@ -93,8 +89,7 @@ Miscellaneous
|
||||
wait_until
|
||||
current_path
|
||||
|
||||
Capybara RSpec matchers
|
||||
-----------------------
|
||||
### Capybara RSpec matchers
|
||||
|
||||
expect(page).to have_button
|
||||
expect(page).to have_checked_field
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Chunky PNG
|
||||
layout: default
|
||||
---
|
||||
|
||||
Loading
|
||||
|
||||
image = ChunkyPNG::Image.from_file('filename.png')
|
||||
|
@ -1,2 +1,7 @@
|
||||
---
|
||||
title: Cinema4d
|
||||
layout: default
|
||||
---
|
||||
|
||||
E R T : Move/rotate/scale
|
||||
P : snapping
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Code stuff
|
||||
layout: default
|
||||
---
|
||||
|
||||
Badges for open source projects
|
||||
|
||||
* Version badge (gems, npm): http://badge.fury.io/
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Command line stuff
|
||||
layout: default
|
||||
---
|
||||
|
||||
## List (ls)
|
||||
|
@ -1,4 +1,7 @@
|
||||
# Commander.js
|
||||
---
|
||||
title: Commander.js
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Initialize
|
||||
|
||||
|
26
config.ru
26
config.ru
@ -1,26 +0,0 @@
|
||||
# This file exists to make this project Rack-compatible.
|
||||
# You may delete it if you're not concerned about this.
|
||||
|
||||
require 'rubygems' unless defined?(::Gem)
|
||||
|
||||
# Use Bundler if possible.
|
||||
begin
|
||||
require 'bundler'
|
||||
Bundler.setup
|
||||
rescue LoadError
|
||||
gem 'proton', '0.3.2'
|
||||
end
|
||||
|
||||
# Optional: use the 'rack-cache' gem for cacheing.
|
||||
if ENV['RACK_ENV'] == 'production'
|
||||
begin
|
||||
require 'rack/cache'
|
||||
use Rack::Cache
|
||||
rescue LoadError
|
||||
end
|
||||
end
|
||||
|
||||
# Load Proton.
|
||||
require 'proton/server'
|
||||
Proton::Project.new File.dirname(__FILE__)
|
||||
run Proton::Server
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Cryptography
|
||||
layout: default
|
||||
---
|
||||
|
||||
* [PBKDF2](http://en.wikipedia.org/wiki/PBKDF2) - password-based key derivation
|
||||
function
|
||||
|
||||
|
10
curl.md
10
curl.md
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Curl
|
||||
layout: default
|
||||
---
|
||||
|
||||
Options:
|
||||
@ -23,11 +25,11 @@ Headers:
|
||||
|
||||
SSL:
|
||||
|
||||
--cacert <file>
|
||||
--capath <dir>
|
||||
--cacert <file>
|
||||
--capath <dir>
|
||||
|
||||
-E <cert> # --ecrt: Client cert file
|
||||
--cert-type # der/pem/eng
|
||||
-E <cert> # --ecrt: Client cert file
|
||||
--cert-type # der/pem/eng
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Devise
|
||||
layout: default
|
||||
---
|
||||
|
||||
[Devise](https://github.com/plataformatec/devise) is a flexible authentication
|
||||
|
2
do.md
2
do.md
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Do gem
|
||||
layout: default
|
||||
----
|
||||
|
||||
* [DAddYE/do](https://github.com/DAddYE/do)
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: docker
|
||||
layout: default
|
||||
---
|
||||
|
||||
Command line interface
|
||||
----------------------
|
||||
|
||||
@ -32,7 +37,7 @@ Prerequisites:
|
||||
- Install Vagrant (http://vagrantup.com)
|
||||
- Install go (`brew install go`)
|
||||
|
||||
Then make the Docker executable:
|
||||
Then make the Docker executable (v0.5.1?):
|
||||
|
||||
$ git clone https://github.com/dotcloud/docker.git ~/src/docker
|
||||
$ cd ~/src/docker
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Express.js
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Settings
|
||||
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
title: Firefox
|
||||
----
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Firefox 18 (Jan 2013)
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Fitness
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Target heart rate
|
||||
|
@ -1,4 +1,9 @@
|
||||
# irc.freenode.net
|
||||
---
|
||||
title: Freenode
|
||||
layout: default
|
||||
---
|
||||
|
||||
### irc.freenode.net
|
||||
|
||||
/msg nickserv identify [nick] <password>
|
||||
/msg nickserv info <nick>
|
||||
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
title: Google Analytics
|
||||
----
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Track events
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Heroku
|
||||
layout: default
|
||||
---
|
||||
|
||||
## `create` - Create an app
|
||||
|
||||
heroku create sushi
|
||||
|
63
homebrew.md
63
homebrew.md
@ -1,26 +1,47 @@
|
||||
class Tweetx < Formula
|
||||
homepage 'http://code.google.com/p/tweetx/'
|
||||
url 'http://tweetx.googlecode.com/files/tweetx-0.1.tar.gz'
|
||||
version '0.1'
|
||||
sha1 'e676f895ac5df1574f6fd4086ee57b9bf8d71e20'
|
||||
---
|
||||
title: Homebrew
|
||||
layout: default
|
||||
---
|
||||
|
||||
head 'https://github.com/b4winckler/macvim.git', :branch => 'master'
|
||||
### Commands
|
||||
|
||||
def options
|
||||
[
|
||||
["--custom-icons", "Try to generate custom document icons."],
|
||||
]
|
||||
end
|
||||
brew unlink git
|
||||
brew link git
|
||||
|
||||
depends_on 'cscope' if ARGV.include? '--with-cscope'
|
||||
brew list # List all installed
|
||||
|
||||
def install
|
||||
system "./configure",
|
||||
"--prefix=#{prefix}",
|
||||
"--libdir=#{lib}"
|
||||
system "make install"
|
||||
brew list --versions git # See what versions of `git` you have
|
||||
brew info git # List versions, caveats, etc
|
||||
brew cleanup git # Remove old versions
|
||||
brew edit git # Edit this formula
|
||||
brew home git # Open homepage
|
||||
|
||||
man1.install 'manpage.1'
|
||||
bin.install "foo"
|
||||
end
|
||||
end
|
||||
### Stuff
|
||||
|
||||
Nice Homebrew packages:
|
||||
|
||||
* `tig` - Git "GUI" for the console
|
||||
* `mysql`
|
||||
* `postgresql`
|
||||
* `fmdiff` - Adaptor to use Apple's FileMerge as `diff` (`git config --global merge-tool fmdiff`)
|
||||
* `cmus` - Curses-based music player
|
||||
* `cclive` - Video downloader
|
||||
|
||||
Not from brew:
|
||||
|
||||
* `DiffMerge` - nice free merge tool for OSX
|
||||
|
||||
Tmux
|
||||
----
|
||||
|
||||
Install a more-recent version that supports tmux -C
|
||||
|
||||
brew install https://github.com/adamv/homebrew-alt/raw/master/other/tmux-iterm2.rb
|
||||
|
||||
Install the wrapper for stuff to enable OSX clipboard to work
|
||||
|
||||
brew install reattach-to-user-namespace --wrap-pbcopy-and-pbpaste
|
||||
|
||||
Make sure that your VIM alias uses it
|
||||
|
||||
alias vim="reattach-to-user-namespace /Application/MacVim/Contents/MacOS/Vim"
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: HTML/CSS
|
||||
layout: default
|
||||
---
|
||||
|
||||
### CSS - Selectors
|
||||
|
||||
.class {
|
||||
|
@ -1,4 +1,6 @@
|
||||
title: IE bug compenduum
|
||||
---
|
||||
title: IE bugs
|
||||
layout: default
|
||||
----
|
||||
|
||||
### IE8: 'change' event doesn't always fire
|
||||
|
@ -1,3 +1,7 @@
|
||||
---
|
||||
title: Imagemagick
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Resize to fit
|
||||
|
||||
|
10
index.haml
10
index.haml
@ -1,10 +0,0 @@
|
||||
title: Cheat sheets
|
||||
---
|
||||
%ul.pages
|
||||
- Dir['./*.*'].each do |p|
|
||||
- name = File.basename(p, '.*')
|
||||
- ext = File.extname(p)
|
||||
- next if %w[.sass .scss].include?(ext) || %w[config Gemfile Rakefile README index].include?(name) || name[0] == '_'
|
||||
- url = name + ".html"
|
||||
%li
|
||||
%a{href: url}= name
|
5
ios.md
5
ios.md
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: iOS
|
||||
layout: default
|
||||
---
|
||||
|
||||
Multiple Exchange accounts:
|
||||
|
||||
scp root@iphone.local:/private/var/mobile/Library/Preferences/com.apple.accountsettings.plist .
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Jasmine
|
||||
layout: default
|
||||
---
|
||||
|
||||
[Jasmine](http://pivotal.github.com/jasmine/).
|
||||
|
@ -1,4 +1,9 @@
|
||||
# JavaScript arrays
|
||||
---
|
||||
title: JavaScript arrays
|
||||
layout: default
|
||||
---
|
||||
|
||||
## JavaScript arrays
|
||||
|
||||
array = [a,b,c,d,e]
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: JavaScript workers
|
||||
layout: default
|
||||
---
|
||||
|
||||
## Web workers
|
||||
|
||||
// Client code
|
||||
|
65
jekyll.md
65
jekyll.md
@ -1,5 +1,6 @@
|
||||
---
|
||||
title: Jekyll
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Installation
|
||||
@ -60,36 +61,36 @@ Configuration
|
||||
Variables
|
||||
---------
|
||||
|
||||
{{ site }} - from config.yml
|
||||
{{ page }} - from frontmatter, and page-specific info
|
||||
{{ content }} - html content (use in layouts)
|
||||
{{ paginator }} - ...
|
||||
{\{ site }} - from config.yml
|
||||
{\{ page }} - from frontmatter, and page-specific info
|
||||
{\{ content }} - html content (use in layouts)
|
||||
{\{ paginator }} - ...
|
||||
|
||||
### Site
|
||||
|
||||
{{ site.time }} - current time
|
||||
{{ site.pages }} - list of pages
|
||||
{{ site.posts }} - list of posts
|
||||
{{ site.related_posts }} - list
|
||||
{{ site.categories.CATEGORY }} - list
|
||||
{{ site.tags.TAG }} - list
|
||||
{\{ site.time }} - current time
|
||||
{\{ site.pages }} - list of pages
|
||||
{\{ site.posts }} - list of posts
|
||||
{\{ site.related_posts }} - list
|
||||
{\{ site.categories.CATEGORY }} - list
|
||||
{\{ site.tags.TAG }} - list
|
||||
|
||||
### Page
|
||||
|
||||
{{ page.content }} - un-rendered content
|
||||
{{ page.title }}
|
||||
{{ page.excerpt }} - un-rendered excerpt
|
||||
{{ page.url }}
|
||||
{{ page.date }}
|
||||
{{ page.id }}
|
||||
{{ page.categories }}
|
||||
{{ page.tags }}
|
||||
{{ page.path }}
|
||||
{\{ page.content }} - un-rendered content
|
||||
{\{ page.title }}
|
||||
{\{ page.excerpt }} - un-rendered excerpt
|
||||
{\{ page.url }}
|
||||
{\{ page.date }}
|
||||
{\{ page.id }}
|
||||
{\{ page.categories }}
|
||||
{\{ page.tags }}
|
||||
{\{ page.path }}
|
||||
|
||||
### Paginator
|
||||
|
||||
{{ paginator.per_page }}
|
||||
{{ paginator.posts }}
|
||||
{\{ paginator.per_page }}
|
||||
{\{ paginator.posts }}
|
||||
...
|
||||
|
||||
Sample code
|
||||
@ -97,26 +98,26 @@ Sample code
|
||||
|
||||
### Loops
|
||||
|
||||
{% for post in site.posts %}
|
||||
{\% for post in site.posts %}
|
||||
<a href="{{ post.url }}">
|
||||
<h2>{{ post.title }} — {{ post.date | date_to_string }}</h2>
|
||||
<h2>{\{ post.title }} — {\{ post.date | date_to_string }}</h2>
|
||||
</a>
|
||||
{{ post.content }}
|
||||
{% endfor %}
|
||||
{\{ post.content }}
|
||||
{\% endfor %}
|
||||
|
||||
### Dates
|
||||
|
||||
{{ page.date | date: "%b %d, %Y" }}
|
||||
{\{ page.date | date: "%b %d, %Y" }}
|
||||
|
||||
### If
|
||||
|
||||
{% if page.image.feature %}
|
||||
{% else %}
|
||||
{% endif %}
|
||||
{\% if page.image.feature %}
|
||||
{\% else %}
|
||||
{\% endif %}
|
||||
|
||||
### Includes
|
||||
|
||||
{% include header.html %}
|
||||
{\% include header.html %}
|
||||
|
||||
Integration
|
||||
-----------
|
||||
@ -129,5 +130,5 @@ Integration
|
||||
|
||||
### Compass
|
||||
|
||||
https://gist.github.com/parkr/2874934
|
||||
https://github.com/matthodan/jekyll-asset-pipeline
|
||||
* [Compass](https://gist.github.com/parkr/2874934)
|
||||
* [Asset pipeline](https://github.com/matthodan/jekyll-asset-pipeline)
|
||||
|
5
linux.md
5
linux.md
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Linux
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Mounting a RAM drive
|
||||
|
||||
$ mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs /tmp
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Machinist
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Installing
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Makefile
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Var assignment
|
||||
|
||||
JS_COMPRESSOR := $(uglify)
|
||||
|
5
man.md
5
man.md
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Man
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Man paths
|
||||
|
||||
1 General User Commands
|
||||
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
title: Markdown
|
||||
----
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Headers
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
24 classical micronutrients
|
||||
---------------------------
|
||||
---
|
||||
title: Essential micronutrients
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Vitamin D
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Middleman
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Compass config
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Minitest
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Usage
|
||||
|
5
mocha.md
5
mocha.md
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Mocha.js
|
||||
layout: Default
|
||||
---
|
||||
|
||||
### BDD
|
||||
|
||||
mocha.setup('bdd');
|
||||
|
@ -1,4 +1,7 @@
|
||||
---
|
||||
title: Modernizr
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Script
|
||||
|
||||
|
13
nodejs.md
13
nodejs.md
@ -1,4 +1,6 @@
|
||||
title: NodeJS api
|
||||
---
|
||||
title: Node.js API
|
||||
layout: default
|
||||
----
|
||||
|
||||
## Globals
|
||||
@ -116,10 +118,6 @@ title: NodeJS api
|
||||
|
||||
assert.throws(fn)
|
||||
|
||||
[all]: http://nodejs.org/api/all.html
|
||||
[process]: http://nodejs.org/api/process.html
|
||||
[fs]: http://nodejs.org/api/fs.html
|
||||
|
||||
## Snippets
|
||||
|
||||
info = require('../package.json')
|
||||
@ -139,3 +137,8 @@ title: NodeJS api
|
||||
|
||||
// also { stdio: [process.stdin, process.stderr, process.stdout] }
|
||||
|
||||
[all]: http://nodejs.org/api/all.html
|
||||
[path]: http://nodejs.org/api/path.html
|
||||
[process]: http://nodejs.org/api/process.html
|
||||
[fs]: http://nodejs.org/api/fs.html
|
||||
[assert]: http://nodejs.org/api/assert.html
|
||||
|
5
npm.md
5
npm.md
@ -1,2 +1,7 @@
|
||||
---
|
||||
title: npm
|
||||
layout: default
|
||||
---
|
||||
|
||||
npm install
|
||||
npm owner add rstacruz PACKAGENAME
|
||||
|
5
osx.md
5
osx.md
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: OS X
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Locations of startup items
|
||||
|
||||
/System/Library/LaunchAgents/
|
||||
|
@ -1,4 +1,6 @@
|
||||
title: Package JSON
|
||||
---
|
||||
title: Package.json
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Basic
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Phusion Passenger
|
||||
layout: default
|
||||
---
|
||||
|
||||
server {
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Postgresql
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Console
|
||||
|
||||
$ psql
|
||||
|
33
pry.md
33
pry.md
@ -1,5 +1,8 @@
|
||||
---
|
||||
|
||||
title: Pry
|
||||
--
|
||||
layout: default
|
||||
---
|
||||
|
||||
### cd / ls
|
||||
|
||||
@ -35,15 +38,15 @@ Commands with `.` are shell commands
|
||||
|
||||
### Inspection
|
||||
|
||||
> show-method Array#select
|
||||
> show-method Array#select
|
||||
|
||||
> ri Array#each
|
||||
> cd Gem
|
||||
> show-doc try_activate
|
||||
> ri Array#each
|
||||
> cd Gem
|
||||
> show-doc try_activate
|
||||
|
||||
Finding
|
||||
|
||||
> find-method each
|
||||
> find-method each
|
||||
Array#each
|
||||
Array#each_index
|
||||
Enumerable#each_slice
|
||||
@ -51,18 +54,18 @@ Finding
|
||||
|
||||
### Editing
|
||||
|
||||
> edit-method Pry#repl
|
||||
> edit-method Pry#repl
|
||||
|
||||
### Gems
|
||||
|
||||
> gem-cd foo # Switch to gem's dir
|
||||
> gem-install foo
|
||||
> gem-list
|
||||
> gem-cd foo # Switch to gem's dir
|
||||
> gem-install foo
|
||||
> gem-list
|
||||
|
||||
### Misc commands
|
||||
|
||||
> hist # History
|
||||
> wtf? # Trace of recent exception
|
||||
> hist # History
|
||||
> wtf? # Trace of recent exception
|
||||
|
||||
### Rails console
|
||||
|
||||
@ -70,9 +73,9 @@ Finding
|
||||
|
||||
### Bonus: hirb
|
||||
|
||||
> table User.all
|
||||
> view User.all
|
||||
> view User.all, fields: %w[id name email]
|
||||
> table User.all
|
||||
> view User.all
|
||||
> view User.all, fields: %w[id name email]
|
||||
|
||||
### Reference
|
||||
|
||||
|
2
qjs.md
2
qjs.md
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Q.js
|
||||
layout: default
|
||||
----
|
||||
|
||||
### Creating promises (Q.promise)
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Rails Controllers
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Common stuff
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Rails features
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Caching
|
||||
|
||||
https://github.com/rails/actionpack-page_caching
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Rails form helpers
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Forms
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Rails helpers
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Date helpers
|
||||
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
title: Rails migrations
|
||||
-------
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Automatically make migrations
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
title: Rails Models
|
||||
----
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Generating models
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Rails plugins
|
||||
layout: default
|
||||
---
|
||||
|
||||
Generate a plugin
|
||||
-----------------
|
||||
|
||||
@ -103,12 +108,12 @@ Use `NamedBase` instead if you want to take an argument. It will be available as
|
||||
|
||||
When invoking `rails g XXX`:
|
||||
|
||||
* [rails/]generators/XXX/XXX_generator.rb
|
||||
* [rails/]generators/XXX_generator.rb
|
||||
[rails/]generators/XXX/XXX_generator.rb
|
||||
[rails/]generators/XXX_generator.rb
|
||||
|
||||
When invoking `rails g XXX:YYY`:
|
||||
|
||||
* [rails/]generators/XXX/YYY_generator.rb
|
||||
[rails/]generators/XXX/YYY_generator.rb
|
||||
|
||||
ActiveModel 'acts as'
|
||||
---------------------
|
||||
|
@ -1,4 +1,6 @@
|
||||
title: Rails Routes
|
||||
---
|
||||
title: Rails routes
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Multiple resources
|
||||
|
@ -1,3 +1,7 @@
|
||||
---
|
||||
title: Rails tricks
|
||||
layout: default
|
||||
---
|
||||
|
||||
in config/environments/development.rb:
|
||||
|
||||
|
3
rsync.md
3
rsync.md
@ -1,3 +1,6 @@
|
||||
---
|
||||
title: Rsync
|
||||
layout: default
|
||||
---
|
||||
|
||||
rsync --progress -avz --exclude '.Trashes' --exclude '.Spotlight-V100' --exclude '.fseventsd'
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Rtorrent
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Global
|
||||
|
6
ruby.md
6
ruby.md
@ -1,3 +1,7 @@
|
||||
---
|
||||
title: Ruby
|
||||
layout: default
|
||||
---
|
||||
|
||||
* `$!` - latest error message
|
||||
* `$@` - location of error
|
||||
@ -5,7 +9,7 @@
|
||||
* `$.` - line number last read by interpreter
|
||||
* `$&` - string last matched by regexp
|
||||
* `$~` - the last regexp match, as an array of subexpressions
|
||||
* `$n` - the nth subexpression in the last match (same as $~[n])
|
||||
* `$n` - the nth subexpression in the last match (same as `$~[n]`)
|
||||
* `$=` - case-insensitivity flag
|
||||
* `$/` - input record separator
|
||||
* `$\` - output record separator
|
||||
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
title: Rubygems
|
||||
----
|
||||
layout: default
|
||||
---
|
||||
|
||||
gem build *.gemspec # Build a gem
|
||||
gem install *.gem # Install locally
|
||||
|
5
sass.md
5
sass.md
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Sass
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Compass: Sprites
|
||||
|
||||
@import compass/utilities/sprites
|
||||
|
386
sequel.md
Normal file
386
sequel.md
Normal file
@ -0,0 +1,386 @@
|
||||
---
|
||||
title: Sequel
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Open a database
|
||||
|
||||
require 'rubygems'
|
||||
require 'sequel'
|
||||
|
||||
DB = Sequel.sqlite('my_blog.db')
|
||||
DB = Sequel.connect('postgres://user:password@localhost/my_db')
|
||||
DB = Sequel.postgres('my_db', :user => 'user', :password => 'password', :host => 'localhost')
|
||||
DB = Sequel.ado('mydb')
|
||||
|
||||
### Open an SQLite memory database
|
||||
|
||||
Without a filename argument, the sqlite adapter will setup a new sqlite database in memory.
|
||||
|
||||
DB = Sequel.sqlite
|
||||
|
||||
### Logging SQL statements
|
||||
|
||||
require 'logger'
|
||||
DB = Sequel.sqlite '', :loggers => [Logger.new($stdout)]
|
||||
# or
|
||||
DB.loggers << Logger.new(...)
|
||||
|
||||
### Using raw SQL
|
||||
|
||||
DB.run "CREATE TABLE users (name VARCHAR(255) NOT NULL, age INT(3) NOT NULL)"
|
||||
dataset = DB["SELECT age FROM users WHERE name = ?", name]
|
||||
dataset.map(:age)
|
||||
DB.fetch("SELECT name FROM users") do |row|
|
||||
p row[:name]
|
||||
end
|
||||
|
||||
### Create a dataset
|
||||
|
||||
dataset = DB[:items]
|
||||
dataset = DB.from(:items)
|
||||
|
||||
### Most dataset methods are chainable
|
||||
|
||||
dataset = DB[:managers].where(:salary => 5000..10000).order(:name, :department)
|
||||
|
||||
### Insert rows
|
||||
|
||||
dataset.insert(:name => 'Sharon', :grade => 50)
|
||||
|
||||
### Retrieve rows
|
||||
|
||||
dataset.each{|r| p r}
|
||||
dataset.all # => [{...}, {...}, ...]
|
||||
dataset.first # => {...}
|
||||
|
||||
### Update/Delete rows
|
||||
|
||||
dataset.filter(~:active).delete
|
||||
dataset.filter('price < ?', 100).update(:active => true)
|
||||
|
||||
### Datasets are Enumerable
|
||||
|
||||
dataset.map{|r| r[:name]}
|
||||
dataset.map(:name) # same as above
|
||||
|
||||
dataset.inject(0){|sum, r| sum + r[:value]}
|
||||
dataset.sum(:value) # same as above
|
||||
|
||||
### Filtering (see also doc/dataset_filtering.rdoc)
|
||||
|
||||
#### Equality
|
||||
|
||||
dataset.filter(:name => 'abc')
|
||||
dataset.filter('name = ?', 'abc')
|
||||
|
||||
#### Inequality
|
||||
|
||||
dataset.filter{value > 100}
|
||||
dataset.exclude{value <= 100}
|
||||
|
||||
#### Inclusion
|
||||
|
||||
dataset.filter(:value => 50..100)
|
||||
dataset.where{(value >= 50) & (value <= 100)}
|
||||
|
||||
dataset.where('value IN ?', [50,75,100])
|
||||
dataset.where(:value=>[50,75,100])
|
||||
|
||||
dataset.where(:id=>other_dataset.select(:other_id))
|
||||
|
||||
#### Subselects as scalar values
|
||||
|
||||
dataset.where('price > (SELECT avg(price) + 100 FROM table)')
|
||||
dataset.filter{price > dataset.select(avg(price) + 100)}
|
||||
|
||||
#### LIKE/Regexp
|
||||
|
||||
DB[:items].filter(:name.like('AL%'))
|
||||
DB[:items].filter(:name => /^AL/)
|
||||
|
||||
#### AND/OR/NOT
|
||||
|
||||
DB[:items].filter{(x > 5) & (y > 10)}.sql
|
||||
# SELECT * FROM items WHERE ((x > 5) AND (y > 10))
|
||||
|
||||
DB[:items].filter({:x => 1, :y => 2}.sql_or & ~{:z => 3}).sql
|
||||
# SELECT * FROM items WHERE (((x = 1) OR (y = 2)) AND (z != 3))
|
||||
|
||||
#### Mathematical operators
|
||||
|
||||
DB[:items].filter((:x + :y) > :z).sql
|
||||
# SELECT * FROM items WHERE ((x + y) > z)
|
||||
|
||||
DB[:items].filter{price - 100 < avg(price)}.sql
|
||||
# SELECT * FROM items WHERE ((price - 100) < avg(price))
|
||||
|
||||
### Ordering
|
||||
|
||||
dataset.order(:kind)
|
||||
dataset.reverse_order(:kind)
|
||||
dataset.order(:kind.desc, :name)
|
||||
|
||||
### Limit/Offset
|
||||
|
||||
dataset.limit(30) # LIMIT 30
|
||||
dataset.limit(30, 10) # LIMIT 30 OFFSET 10
|
||||
|
||||
### Joins
|
||||
|
||||
DB[:items].left_outer_join(:categories, :id => :category_id).sql
|
||||
# SELECT * FROM items LEFT OUTER JOIN categories ON categories.id = items.category_id
|
||||
|
||||
DB[:items].join(:categories, :id => :category_id).join(:groups, :id => :items__group_id)
|
||||
# SELECT * FROM items INNER JOIN categories ON categories.id = items.category_id INNER JOIN groups ON groups.id = items.group_id
|
||||
|
||||
### Aggregate functions methods
|
||||
|
||||
dataset.count #=> record count
|
||||
dataset.max(:price)
|
||||
dataset.min(:price)
|
||||
dataset.avg(:price)
|
||||
dataset.sum(:stock)
|
||||
|
||||
dataset.group_and_count(:category)
|
||||
dataset.group(:category).select(:category, :AVG.sql_function(:price))
|
||||
|
||||
### SQL Functions / Literals
|
||||
|
||||
dataset.update(:updated_at => :NOW.sql_function)
|
||||
dataset.update(:updated_at => 'NOW()'.lit)
|
||||
|
||||
dataset.update(:updated_at => "DateValue('1/1/2001')".lit)
|
||||
dataset.update(:updated_at => :DateValue.sql_function('1/1/2001'))
|
||||
|
||||
### Schema Manipulation
|
||||
|
||||
DB.create_table :items do
|
||||
primary_key :id
|
||||
String :name, :unique => true, :null => false
|
||||
TrueClass :active, :default => true
|
||||
foreign_key :category_id, :categories
|
||||
DateTime :created_at
|
||||
|
||||
index :created_at
|
||||
end
|
||||
|
||||
DB.drop_table :items
|
||||
|
||||
DB.create_table :test do
|
||||
String :zipcode
|
||||
enum :system, :elements => ['mac', 'linux', 'windows']
|
||||
end
|
||||
|
||||
### Aliasing
|
||||
|
||||
DB[:items].select(:name.as(:item_name))
|
||||
DB[:items].select(:name___item_name)
|
||||
DB[:items___items_table].select(:items_table__name___item_name)
|
||||
# SELECT items_table.name AS item_name FROM items AS items_table
|
||||
|
||||
### Transactions
|
||||
|
||||
DB.transaction do
|
||||
dataset.insert(:first_name => 'Inigo', :last_name => 'Montoya')
|
||||
dataset.insert(:first_name => 'Farm', :last_name => 'Boy')
|
||||
end # Either both are inserted or neither are inserted
|
||||
|
||||
Database#transaction is re-entrant:
|
||||
|
||||
DB.transaction do # BEGIN issued only here
|
||||
DB.transaction
|
||||
dataset << {:first_name => 'Inigo', :last_name => 'Montoya'}
|
||||
end
|
||||
end # COMMIT issued only here
|
||||
|
||||
Transactions are aborted if an error is raised:
|
||||
|
||||
DB.transaction do
|
||||
raise "some error occurred"
|
||||
end # ROLLBACK issued and the error is re-raised
|
||||
|
||||
Transactions can also be aborted by raising Sequel::Rollback:
|
||||
|
||||
DB.transaction do
|
||||
raise(Sequel::Rollback) if something_bad_happened
|
||||
end # ROLLBACK issued and no error raised
|
||||
|
||||
Savepoints can be used if the database supports it:
|
||||
|
||||
DB.transaction do
|
||||
dataset << {:first_name => 'Farm', :last_name => 'Boy'} # Inserted
|
||||
DB.transaction(:savepoint=>true) # This savepoint is rolled back
|
||||
dataset << {:first_name => 'Inigo', :last_name => 'Montoya'} # Not inserted
|
||||
raise(Sequel::Rollback) if something_bad_happened
|
||||
end
|
||||
dataset << {:first_name => 'Prince', :last_name => 'Humperdink'} # Inserted
|
||||
end
|
||||
|
||||
### Miscellaneous:
|
||||
|
||||
dataset.sql # "SELECT * FROM items"
|
||||
dataset.delete_sql # "DELETE FROM items"
|
||||
dataset.where(:name => 'sequel').exists # "EXISTS ( SELECT * FROM items WHERE name = 'sequel' )"
|
||||
dataset.columns #=> array of columns in the result set, does a SELECT
|
||||
DB.schema(:items) => [[:id, {:type=>:integer, ...}], [:name, {:type=>:string, ...}], ...]
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
### Documents
|
||||
|
||||
http://sequel.rubyforge.org/rdoc/files/doc/association_basics_rdoc.html
|
||||
http://sequel.rubyforge.org/rdoc/classes/Sequel/Schema/Generator.html
|
||||
http://sequel.rubyforge.org/rdoc/files/doc/validations_rdoc.html
|
||||
http://sequel.rubyforge.org/rdoc/classes/Sequel/Model.html
|
||||
|
||||
### Alter table
|
||||
|
||||
database.alter_table :deals do
|
||||
add_column :name, String
|
||||
drop_column :column_name
|
||||
rename_column :from, :to
|
||||
|
||||
add_constraint :valid_name, :name.like('A%')
|
||||
drop_constraint :constraint
|
||||
|
||||
add_full_text_index :body
|
||||
add_spacial_index [columns]
|
||||
|
||||
add_index :price
|
||||
drop_index :index
|
||||
|
||||
add_foreign_key :artist_id, :table
|
||||
add_primary_key :id
|
||||
add_unique_constraint [columns]
|
||||
set_column_allow_null :foo, false
|
||||
set_column_default :title, ''
|
||||
|
||||
set_column_type :price, 'char(10)'
|
||||
end
|
||||
|
||||
### Model associations
|
||||
|
||||
class Deal < Sequel::Model
|
||||
|
||||
# Us (left) <=> Them (right)
|
||||
many_to_many :images,
|
||||
left_id: :deal_id,
|
||||
right_id: :image_id,
|
||||
join_table: :image_links
|
||||
|
||||
one_to_many :files,
|
||||
key: :deal_id,
|
||||
class: :DataFile,
|
||||
|
||||
many_to_one :parent, class: self
|
||||
one_to_many :children, key: :parent_id, class: self
|
||||
|
||||
one_to_many :gold_albums, class: :Album do |ds|
|
||||
ds.filter { copies_sold > 50000 }
|
||||
end
|
||||
|
||||
Provided by many_to_many
|
||||
|
||||
Deal[1].images
|
||||
Deal[1].add_image
|
||||
Deal[1].remove_image
|
||||
Deal[1].remove_all_images
|
||||
|
||||
### Validations
|
||||
|
||||
def validate
|
||||
super
|
||||
errors.add(:name, 'cannot be empty') if !name || name.empty?
|
||||
|
||||
validates_presence [:title, :site]
|
||||
validates_unique :name
|
||||
validates_format /\Ahttps?:\/\//, :website, :message=>'is not a valid URL'
|
||||
validates_includes %w(a b c), :type
|
||||
validates_integer :rating
|
||||
validates_numeric :number
|
||||
validates_type String, [:title, :description]
|
||||
|
||||
validates_integer :rating if new?
|
||||
|
||||
# options: :message =>, :allow_nil =>, :allow_blank =>,
|
||||
# :allow_missing =>,
|
||||
|
||||
validates_exact_length 17, :isbn
|
||||
validates_min_length 3, :name
|
||||
validates_max_length 100, :name
|
||||
validates_length_range 3..100, :name
|
||||
|
||||
# Setter override
|
||||
def filename=(name)
|
||||
@values[:filename] = name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
deal.errors
|
||||
|
||||
### Model stuff
|
||||
|
||||
deal = Deal[1]
|
||||
deal.changed_columns
|
||||
deal.destory # Calls hooks
|
||||
deal.delete # No hooks
|
||||
deal.exists?
|
||||
deal.new?
|
||||
deal.hash # Only uniques
|
||||
deal.keys #=> [:id, :name]
|
||||
deal.modified!
|
||||
deal.modified?
|
||||
|
||||
deal.lock!
|
||||
|
||||
### Callbacks
|
||||
|
||||
before_create
|
||||
after_create
|
||||
|
||||
before_validation
|
||||
after_validation
|
||||
before_save
|
||||
before_update
|
||||
UPDATE QUERY
|
||||
after_update
|
||||
after_save
|
||||
|
||||
before_destroy
|
||||
DELETE QUERY
|
||||
after_destroy
|
||||
|
||||
### Schema
|
||||
|
||||
class Deal < Sequel::Model
|
||||
set_schema do
|
||||
primary_key :id
|
||||
primary_key [:id, :title]
|
||||
String :name, primary_key: true
|
||||
|
||||
String :title
|
||||
Numeric :price
|
||||
DateTime :expires
|
||||
|
||||
unique :whatever
|
||||
check(:price) { num > 0 }
|
||||
|
||||
foreign_key :artist_id
|
||||
String :artist_name, key: :id
|
||||
|
||||
index :title
|
||||
index [:artist_id, :name]
|
||||
full_text_index :title
|
||||
|
||||
# String, Integer, Fixnum, Bignum, Float, Numeric, BigDecimal,
|
||||
# Date, DateTime, Time, File, TrueClass, FalseClass
|
||||
end
|
||||
end
|
||||
|
||||
### Unrestrict primary key
|
||||
|
||||
Category.create id: 'travel' # error
|
||||
Category.unrestrict_primary_key
|
||||
Category.create id: 'travel' # ok
|
386
sequel.rdoc
386
sequel.rdoc
@ -1,386 +0,0 @@
|
||||
title: Sequel
|
||||
----
|
||||
|
||||
= Cheat Sheet
|
||||
|
||||
== Open a database
|
||||
|
||||
require 'rubygems'
|
||||
require 'sequel'
|
||||
|
||||
DB = Sequel.sqlite('my_blog.db')
|
||||
DB = Sequel.connect('postgres://user:password@localhost/my_db')
|
||||
DB = Sequel.postgres('my_db', :user => 'user', :password => 'password', :host => 'localhost')
|
||||
DB = Sequel.ado('mydb')
|
||||
|
||||
== Open an SQLite memory database
|
||||
|
||||
Without a filename argument, the sqlite adapter will setup a new sqlite database in memory.
|
||||
|
||||
DB = Sequel.sqlite
|
||||
|
||||
== Logging SQL statements
|
||||
|
||||
require 'logger'
|
||||
DB = Sequel.sqlite '', :loggers => [Logger.new($stdout)]
|
||||
# or
|
||||
DB.loggers << Logger.new(...)
|
||||
|
||||
== Using raw SQL
|
||||
|
||||
DB.run "CREATE TABLE users (name VARCHAR(255) NOT NULL, age INT(3) NOT NULL)"
|
||||
dataset = DB["SELECT age FROM users WHERE name = ?", name]
|
||||
dataset.map(:age)
|
||||
DB.fetch("SELECT name FROM users") do |row|
|
||||
p row[:name]
|
||||
end
|
||||
|
||||
== Create a dataset
|
||||
|
||||
dataset = DB[:items]
|
||||
dataset = DB.from(:items)
|
||||
|
||||
== Most dataset methods are chainable
|
||||
|
||||
dataset = DB[:managers].where(:salary => 5000..10000).order(:name, :department)
|
||||
|
||||
== Insert rows
|
||||
|
||||
dataset.insert(:name => 'Sharon', :grade => 50)
|
||||
|
||||
== Retrieve rows
|
||||
|
||||
dataset.each{|r| p r}
|
||||
dataset.all # => [{...}, {...}, ...]
|
||||
dataset.first # => {...}
|
||||
|
||||
== Update/Delete rows
|
||||
|
||||
dataset.filter(~:active).delete
|
||||
dataset.filter('price < ?', 100).update(:active => true)
|
||||
|
||||
== Datasets are Enumerable
|
||||
|
||||
dataset.map{|r| r[:name]}
|
||||
dataset.map(:name) # same as above
|
||||
|
||||
dataset.inject(0){|sum, r| sum + r[:value]}
|
||||
dataset.sum(:value) # same as above
|
||||
|
||||
== Filtering (see also doc/dataset_filtering.rdoc)
|
||||
|
||||
=== Equality
|
||||
|
||||
dataset.filter(:name => 'abc')
|
||||
dataset.filter('name = ?', 'abc')
|
||||
|
||||
=== Inequality
|
||||
|
||||
dataset.filter{value > 100}
|
||||
dataset.exclude{value <= 100}
|
||||
|
||||
=== Inclusion
|
||||
|
||||
dataset.filter(:value => 50..100)
|
||||
dataset.where{(value >= 50) & (value <= 100)}
|
||||
|
||||
dataset.where('value IN ?', [50,75,100])
|
||||
dataset.where(:value=>[50,75,100])
|
||||
|
||||
dataset.where(:id=>other_dataset.select(:other_id))
|
||||
|
||||
=== Subselects as scalar values
|
||||
|
||||
dataset.where('price > (SELECT avg(price) + 100 FROM table)')
|
||||
dataset.filter{price > dataset.select(avg(price) + 100)}
|
||||
|
||||
=== LIKE/Regexp
|
||||
|
||||
DB[:items].filter(:name.like('AL%'))
|
||||
DB[:items].filter(:name => /^AL/)
|
||||
|
||||
=== AND/OR/NOT
|
||||
|
||||
DB[:items].filter{(x > 5) & (y > 10)}.sql
|
||||
# SELECT * FROM items WHERE ((x > 5) AND (y > 10))
|
||||
|
||||
DB[:items].filter({:x => 1, :y => 2}.sql_or & ~{:z => 3}).sql
|
||||
# SELECT * FROM items WHERE (((x = 1) OR (y = 2)) AND (z != 3))
|
||||
|
||||
=== Mathematical operators
|
||||
|
||||
DB[:items].filter((:x + :y) > :z).sql
|
||||
# SELECT * FROM items WHERE ((x + y) > z)
|
||||
|
||||
DB[:items].filter{price - 100 < avg(price)}.sql
|
||||
# SELECT * FROM items WHERE ((price - 100) < avg(price))
|
||||
|
||||
== Ordering
|
||||
|
||||
dataset.order(:kind)
|
||||
dataset.reverse_order(:kind)
|
||||
dataset.order(:kind.desc, :name)
|
||||
|
||||
== Limit/Offset
|
||||
|
||||
dataset.limit(30) # LIMIT 30
|
||||
dataset.limit(30, 10) # LIMIT 30 OFFSET 10
|
||||
|
||||
== Joins
|
||||
|
||||
DB[:items].left_outer_join(:categories, :id => :category_id).sql
|
||||
# SELECT * FROM items LEFT OUTER JOIN categories ON categories.id = items.category_id
|
||||
|
||||
DB[:items].join(:categories, :id => :category_id).join(:groups, :id => :items__group_id)
|
||||
# SELECT * FROM items INNER JOIN categories ON categories.id = items.category_id INNER JOIN groups ON groups.id = items.group_id
|
||||
|
||||
== Aggregate functions methods
|
||||
|
||||
dataset.count #=> record count
|
||||
dataset.max(:price)
|
||||
dataset.min(:price)
|
||||
dataset.avg(:price)
|
||||
dataset.sum(:stock)
|
||||
|
||||
dataset.group_and_count(:category)
|
||||
dataset.group(:category).select(:category, :AVG.sql_function(:price))
|
||||
|
||||
== SQL Functions / Literals
|
||||
|
||||
dataset.update(:updated_at => :NOW.sql_function)
|
||||
dataset.update(:updated_at => 'NOW()'.lit)
|
||||
|
||||
dataset.update(:updated_at => "DateValue('1/1/2001')".lit)
|
||||
dataset.update(:updated_at => :DateValue.sql_function('1/1/2001'))
|
||||
|
||||
== Schema Manipulation
|
||||
|
||||
DB.create_table :items do
|
||||
primary_key :id
|
||||
String :name, :unique => true, :null => false
|
||||
TrueClass :active, :default => true
|
||||
foreign_key :category_id, :categories
|
||||
DateTime :created_at
|
||||
|
||||
index :created_at
|
||||
end
|
||||
|
||||
DB.drop_table :items
|
||||
|
||||
DB.create_table :test do
|
||||
String :zipcode
|
||||
enum :system, :elements => ['mac', 'linux', 'windows']
|
||||
end
|
||||
|
||||
== Aliasing
|
||||
|
||||
DB[:items].select(:name.as(:item_name))
|
||||
DB[:items].select(:name___item_name)
|
||||
DB[:items___items_table].select(:items_table__name___item_name)
|
||||
# SELECT items_table.name AS item_name FROM items AS items_table
|
||||
|
||||
== Transactions
|
||||
|
||||
DB.transaction do
|
||||
dataset.insert(:first_name => 'Inigo', :last_name => 'Montoya')
|
||||
dataset.insert(:first_name => 'Farm', :last_name => 'Boy')
|
||||
end # Either both are inserted or neither are inserted
|
||||
|
||||
Database#transaction is re-entrant:
|
||||
|
||||
DB.transaction do # BEGIN issued only here
|
||||
DB.transaction
|
||||
dataset << {:first_name => 'Inigo', :last_name => 'Montoya'}
|
||||
end
|
||||
end # COMMIT issued only here
|
||||
|
||||
Transactions are aborted if an error is raised:
|
||||
|
||||
DB.transaction do
|
||||
raise "some error occurred"
|
||||
end # ROLLBACK issued and the error is re-raised
|
||||
|
||||
Transactions can also be aborted by raising Sequel::Rollback:
|
||||
|
||||
DB.transaction do
|
||||
raise(Sequel::Rollback) if something_bad_happened
|
||||
end # ROLLBACK issued and no error raised
|
||||
|
||||
Savepoints can be used if the database supports it:
|
||||
|
||||
DB.transaction do
|
||||
dataset << {:first_name => 'Farm', :last_name => 'Boy'} # Inserted
|
||||
DB.transaction(:savepoint=>true) # This savepoint is rolled back
|
||||
dataset << {:first_name => 'Inigo', :last_name => 'Montoya'} # Not inserted
|
||||
raise(Sequel::Rollback) if something_bad_happened
|
||||
end
|
||||
dataset << {:first_name => 'Prince', :last_name => 'Humperdink'} # Inserted
|
||||
end
|
||||
|
||||
== Miscellaneous:
|
||||
|
||||
dataset.sql # "SELECT * FROM items"
|
||||
dataset.delete_sql # "DELETE FROM items"
|
||||
dataset.where(:name => 'sequel').exists # "EXISTS ( SELECT * FROM items WHERE name = 'sequel' )"
|
||||
dataset.columns #=> array of columns in the result set, does a SELECT
|
||||
DB.schema(:items) => [[:id, {:type=>:integer, ...}], [:name, {:type=>:string, ...}], ...]
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
== Documents
|
||||
|
||||
http://sequel.rubyforge.org/rdoc/files/doc/association_basics_rdoc.html
|
||||
http://sequel.rubyforge.org/rdoc/classes/Sequel/Schema/Generator.html
|
||||
http://sequel.rubyforge.org/rdoc/files/doc/validations_rdoc.html
|
||||
http://sequel.rubyforge.org/rdoc/classes/Sequel/Model.html
|
||||
|
||||
== Alter table
|
||||
|
||||
database.alter_table :deals do
|
||||
add_column :name, String
|
||||
drop_column :column_name
|
||||
rename_column :from, :to
|
||||
|
||||
add_constraint :valid_name, :name.like('A%')
|
||||
drop_constraint :constraint
|
||||
|
||||
add_full_text_index :body
|
||||
add_spacial_index [columns]
|
||||
|
||||
add_index :price
|
||||
drop_index :index
|
||||
|
||||
add_foreign_key :artist_id, :table
|
||||
add_primary_key :id
|
||||
add_unique_constraint [columns]
|
||||
set_column_allow_null :foo, false
|
||||
set_column_default :title, ''
|
||||
|
||||
set_column_type :price, 'char(10)'
|
||||
end
|
||||
|
||||
== Model associations
|
||||
|
||||
class Deal < Sequel::Model
|
||||
|
||||
# Us (left) <=> Them (right)
|
||||
many_to_many :images,
|
||||
left_id: :deal_id,
|
||||
right_id: :image_id,
|
||||
join_table: :image_links
|
||||
|
||||
one_to_many :files,
|
||||
key: :deal_id,
|
||||
class: :DataFile,
|
||||
|
||||
many_to_one :parent, class: self
|
||||
one_to_many :children, key: :parent_id, class: self
|
||||
|
||||
one_to_many :gold_albums, class: :Album do |ds|
|
||||
ds.filter { copies_sold > 50000 }
|
||||
end
|
||||
|
||||
Provided by many_to_many
|
||||
|
||||
Deal[1].images
|
||||
Deal[1].add_image
|
||||
Deal[1].remove_image
|
||||
Deal[1].remove_all_images
|
||||
|
||||
== Validations
|
||||
|
||||
def validate
|
||||
super
|
||||
errors.add(:name, 'cannot be empty') if !name || name.empty?
|
||||
|
||||
validates_presence [:title, :site]
|
||||
validates_unique :name
|
||||
validates_format /\Ahttps?:\/\//, :website, :message=>'is not a valid URL'
|
||||
validates_includes %w(a b c), :type
|
||||
validates_integer :rating
|
||||
validates_numeric :number
|
||||
validates_type String, [:title, :description]
|
||||
|
||||
validates_integer :rating if new?
|
||||
|
||||
# options: :message =>, :allow_nil =>, :allow_blank =>,
|
||||
# :allow_missing =>,
|
||||
|
||||
validates_exact_length 17, :isbn
|
||||
validates_min_length 3, :name
|
||||
validates_max_length 100, :name
|
||||
validates_length_range 3..100, :name
|
||||
|
||||
# Setter override
|
||||
def filename=(name)
|
||||
@values[:filename] = name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
deal.errors
|
||||
|
||||
== Model stuff
|
||||
|
||||
deal = Deal[1]
|
||||
deal.changed_columns
|
||||
deal.destory # Calls hooks
|
||||
deal.delete # No hooks
|
||||
deal.exists?
|
||||
deal.new?
|
||||
deal.hash # Only uniques
|
||||
deal.keys #=> [:id, :name]
|
||||
deal.modified!
|
||||
deal.modified?
|
||||
|
||||
deal.lock!
|
||||
|
||||
== Callbacks
|
||||
|
||||
before_create
|
||||
after_create
|
||||
|
||||
before_validation
|
||||
after_validation
|
||||
before_save
|
||||
before_update
|
||||
UPDATE QUERY
|
||||
after_update
|
||||
after_save
|
||||
|
||||
before_destroy
|
||||
DELETE QUERY
|
||||
after_destroy
|
||||
|
||||
== Schema
|
||||
|
||||
class Deal < Sequel::Model
|
||||
set_schema do
|
||||
primary_key :id
|
||||
primary_key [:id, :title]
|
||||
String :name, primary_key: true
|
||||
|
||||
String :title
|
||||
Numeric :price
|
||||
DateTime :expires
|
||||
|
||||
unique :whatever
|
||||
check(:price) { num > 0 }
|
||||
|
||||
foreign_key :artist_id
|
||||
String :artist_name, key: :id
|
||||
|
||||
index :title
|
||||
index [:artist_id, :name]
|
||||
full_text_index :title
|
||||
|
||||
# String, Integer, Fixnum, Bignum, Float, Numeric, BigDecimal,
|
||||
# Date, DateTime, Time, File, TrueClass, FalseClass
|
||||
end
|
||||
end
|
||||
|
||||
== Unrestrict primary key
|
||||
|
||||
Category.create id: 'travel' # error
|
||||
Category.unrestrict_primary_key
|
||||
Category.create id: 'travel' # ok
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Sequelize
|
||||
layout: default
|
||||
---
|
||||
|
||||
### API
|
||||
|
@ -1,4 +1,6 @@
|
||||
title: Bash
|
||||
---
|
||||
title: Shell scripting
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Clever one liners
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Shell.js
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Require
|
||||
|
||||
require 'shelljs/global'
|
||||
|
@ -1,3 +1,10 @@
|
||||
---
|
||||
title: Sinon-chai
|
||||
layout: default
|
||||
---
|
||||
|
||||
* [Sinon-chai](https://github.com/domenic/sinon-chai)
|
||||
|
||||
### Assert
|
||||
|
||||
expect(spy).called
|
||||
@ -43,5 +50,3 @@
|
||||
spy.should.have.always.returned(returnVal)
|
||||
spy.should.have.thrown(errorObjOrErrorTypeStringOrNothing)
|
||||
spy.should.have.always.thrown(errorObjOrErrorTypeStringOrNothing)
|
||||
|
||||
https://github.com/domenic/sinon-chai
|
||||
|
@ -1,4 +1,7 @@
|
||||
# Spreadsheet macros
|
||||
---
|
||||
title: Spreadsheet functions
|
||||
layout: default
|
||||
---
|
||||
|
||||
### If
|
||||
|
||||
|
224
style.sass
224
style.sass
@ -1,224 +0,0 @@
|
||||
@import 'compass/css3'
|
||||
|
||||
= scrollbar
|
||||
&::-webkit-scrollbar
|
||||
width: 10px
|
||||
height: 10px
|
||||
|
||||
&::-webkit-scrollbar-thumb
|
||||
background: rgba(0, 0, 0, 0.1)
|
||||
border-radius: 5px
|
||||
border: solid 2px (#f7f7f2 * 1.04)
|
||||
|
||||
&:hover::-webkit-scrollbar-thumb
|
||||
background: rgba(0, 0, 0, 0.2)
|
||||
|
||||
body, input, td, textarea
|
||||
font-family: Muli, Helvetica Neue, helvetica, sans-serif
|
||||
font-size: 14px
|
||||
line-height: 1.5
|
||||
|
||||
html
|
||||
background: #505060 * 0.8
|
||||
padding: 60px 20px
|
||||
|
||||
a
|
||||
&, &:visited
|
||||
background-color: mix(#db3, white, 30%)
|
||||
color: #db3 * 0.6
|
||||
text-shadow: 0 1px 1px rgba(white, 0.2)
|
||||
|
||||
padding: 1px 2px
|
||||
box-shadow: 0 1px 1px rgba(black, 0.3)
|
||||
border-radius: 2px
|
||||
|
||||
text-decoration: none
|
||||
|
||||
&:hover
|
||||
background-color: mix(#db3, white, 50%)
|
||||
|
||||
@media screen and (max-width: 800px)
|
||||
html
|
||||
padding: 20px
|
||||
@media screen and (max-width: 500px)
|
||||
html
|
||||
padding: 0
|
||||
|
||||
.background
|
||||
position: fixed
|
||||
top: 0
|
||||
left: 0
|
||||
height: 100%
|
||||
width: 100%
|
||||
z-index: -2
|
||||
background: url(bg.jpg)
|
||||
background-size: 200% 200%
|
||||
opacity: 1
|
||||
|
||||
.all
|
||||
position: relative
|
||||
z-index: 1
|
||||
|
||||
max-width: 700px
|
||||
min-width: 400px
|
||||
margin: 0 auto
|
||||
padding: 40px
|
||||
+box-shadow(1px 0 0 rgba(black, 0.05), -1px 0 0 rgba(black, 0.05), 0 0 4px rgba(black, 0.1), 0 0 0 5px rgba(black, 0.05))
|
||||
+border-radius(2px)
|
||||
background: #fff
|
||||
color: #333
|
||||
|
||||
p, ul, ol, pre
|
||||
margin: 15px 0
|
||||
|
||||
p
|
||||
margin: 25px 100px 25px 0
|
||||
|
||||
h1, h2, h3, h4, h5, h6
|
||||
margin: 40px 0 15px 0
|
||||
|
||||
h1
|
||||
text-align: left
|
||||
font-size: 26pt
|
||||
line-height: 30pt
|
||||
color: #ccc
|
||||
|
||||
margin: -40px -40px 40px -40px
|
||||
padding: 40px 40px
|
||||
border-bottom: solid 1px #f5f5f5
|
||||
|
||||
font-weight: 100
|
||||
|
||||
overflow: hidden
|
||||
|
||||
// Back button!
|
||||
h1 .back
|
||||
float: right
|
||||
|
||||
display: inline-block
|
||||
padding: 0 20px
|
||||
height: 32px
|
||||
line-height: 32px
|
||||
|
||||
font-size: 9pt
|
||||
|
||||
+transition(all 100ms linear)
|
||||
background-color: white
|
||||
+box-shadow(inset 0 0 0 1px rgba(black, 0.1), inset 0 2px 0 rgba(white, 0.5))
|
||||
+border-radius(3px)
|
||||
|
||||
color: #aaa
|
||||
text-shadow: 0 1px 0 rgba(white, 0.9)
|
||||
text-decoration: none
|
||||
|
||||
&:hover
|
||||
background-color: #fafafa
|
||||
+background(linear-gradient(top, #fafafa, #fafafa * 0.98))
|
||||
+box-shadow(inset 0 0 0 1px rgba(black, 0.2), inset 0 2px 0 rgba(white, 0.5), 0 1px 3px rgba(black, 0.05))
|
||||
|
||||
&:active
|
||||
+box-shadow(inset 0 0 0 1px rgba(black, 0.1), inset 2px 2px 4px rgba(black, 0.1))
|
||||
|
||||
&:before
|
||||
content: '\238b'
|
||||
margin-right: 5px
|
||||
color: #888
|
||||
|
||||
// Individual headings
|
||||
h2, h3
|
||||
color: #38d
|
||||
font-size: 1.2em
|
||||
padding-bottom: 10px
|
||||
font-weight: normal
|
||||
|
||||
h3
|
||||
font-size: 1.3em
|
||||
|
||||
pre, code
|
||||
font-family: Menlo, Ubuntu Mono, monaco, monospace
|
||||
font-size: 12px
|
||||
color: #444
|
||||
|
||||
// Blocks!
|
||||
.all >
|
||||
pre, ul
|
||||
line-height: 1.6
|
||||
background: #f7f7f2
|
||||
padding: 20px
|
||||
+box-shadow(inset 0 3px 2px -2px rgba(black, 0.1))
|
||||
|
||||
text-shadow: 0 1px 0 rgba(white, 0.9)
|
||||
|
||||
border-top: solid 1px #ddd
|
||||
border-bottom: solid 1px #ddd
|
||||
|
||||
overflow-x: auto
|
||||
+scrollbar
|
||||
|
||||
margin-left: -40px
|
||||
margin-right: -40px
|
||||
padding: 20px 40px
|
||||
// border: solid 1px #eee
|
||||
// +border-radius(2px)
|
||||
|
||||
ul, .all > ul
|
||||
padding-left: 60px
|
||||
list-style-type: circle
|
||||
|
||||
h2
|
||||
font-size: 1.6em
|
||||
border-top: dotted 3px mix(#37d, white, 20%)
|
||||
padding: 40px 40px 0 40px
|
||||
margin-left: -40px
|
||||
margin-right: -40px
|
||||
|
||||
h1 + h2
|
||||
border-top: 0
|
||||
padding-top: 0
|
||||
|
||||
em
|
||||
opacity: 0.7
|
||||
font-size: 0.9em
|
||||
|
||||
// Code block
|
||||
h2+pre, h3+pre
|
||||
margin-top: -16px
|
||||
|
||||
ul.pages
|
||||
&, li
|
||||
list-style-type: none
|
||||
li
|
||||
margin: 0
|
||||
padding: 0
|
||||
|
||||
li
|
||||
width: 20%
|
||||
min-width: 100px
|
||||
float: left
|
||||
|
||||
a
|
||||
display: block
|
||||
text-decoration: none
|
||||
padding: 7px 8px
|
||||
+border-radius(4px)
|
||||
|
||||
color: #558
|
||||
font-weight: normal
|
||||
font-size: 9pt
|
||||
|
||||
a:before
|
||||
content: '\203a'
|
||||
color: #999
|
||||
margin-right: 7px
|
||||
|
||||
a:visited
|
||||
opacity: 0.8
|
||||
|
||||
a:hover
|
||||
background: #eef
|
||||
+box-shadow(inset 0 -1px 0 rgba(black, 0.05), inset 0 0 0 3px rgba(black, 0.03))
|
||||
|
||||
li:first-letter
|
||||
text-transform: uppercase
|
||||
|
||||
@import '_prettify'
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Textile
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Pre blocks
|
||||
|
6
tig.md
6
tig.md
@ -1,5 +1,7 @@
|
||||
Tig shortcuts
|
||||
-------------
|
||||
---
|
||||
title: Tig
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Installing
|
||||
|
||||
|
4
tmux.md
4
tmux.md
@ -1,4 +1,6 @@
|
||||
title: tmux Terminal Multiplexer
|
||||
---
|
||||
title: tmux
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Commands
|
||||
|
@ -1,4 +1,6 @@
|
||||
title: Travis (.travis.yml)
|
||||
---
|
||||
title: Travis.yml
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Node
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Ubuntu/Debian
|
||||
layout: default
|
||||
----
|
||||
|
||||
### Aptitude stuff
|
||||
|
@ -1,4 +1,7 @@
|
||||
# Underscore-string
|
||||
---
|
||||
title: Underscore-string
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Usage
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
---
|
||||
title: Vagrant
|
||||
layout: default
|
||||
---
|
||||
|
||||
* [Vagrant](http://vagrantup.com)
|
||||
|
||||
### Get started
|
||||
|
||||
Add some base boxes:
|
||||
|
4
vim.md
4
vim.md
@ -1,4 +1,6 @@
|
||||
---
|
||||
title: vim
|
||||
layout: default
|
||||
----
|
||||
|
||||
Command line
|
||||
@ -87,7 +89,7 @@ Marks
|
||||
|
||||
### Calculator
|
||||
|
||||
(Insert mode) <C-r>=128/2
|
||||
(Insert mode) <C-r>=128/2
|
||||
|
||||
### Highlights
|
||||
|
||||
|
6
vows.md
6
vows.md
@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Vows
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Vows
|
||||
|
||||
* [Vowsjs.org](http://vowsjs.org/)
|
||||
* [Vowsjs.org](http://vowsjs.org/)
|
||||
|
||||
### CoffeeScript usage
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
---
|
||||
title: Weechat
|
||||
layout: default
|
||||
---
|
||||
|
||||
### Keys
|
||||
|
||||
(`A-` is alt)
|
||||
|
13
weinre.md
13
weinre.md
@ -1,3 +1,10 @@
|
||||
---
|
||||
title: Weinre
|
||||
layout: default
|
||||
---
|
||||
|
||||
* [Weinre](http://people.apache.org/~pmuellr/weinre/)
|
||||
|
||||
Install:
|
||||
|
||||
$ npm install -g weinre
|
||||
@ -7,7 +14,5 @@ Start the server:
|
||||
$ weinre --boundHost 0.0.0.0
|
||||
$ open http://localhost:8080
|
||||
|
||||
<script src="http://localhost:8080/target/target-script-min.js#anonymous"></script>
|
||||
|
||||
|
||||
See http://people.apache.org/~pmuellr/weinre/
|
||||
<script
|
||||
src="http://localhost:8080/target/target-script-min.js#anonymous"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user