Updates.
This commit is contained in:
parent
07b7550718
commit
b67f66f0cd
|
@ -0,0 +1,11 @@
|
|||
Convert mp4 to gif:
|
||||
|
||||
mkdir -p gif
|
||||
mplayer -ao null -vo gif89a:outdir=gif $mp4
|
||||
mogrify -format gif *.png
|
||||
gifsicle --colors=256 --delay=4 --loopcount=0 --dither -O3 gif/*.gif > ${mp4%.*}.gif
|
||||
rm -rf gif
|
||||
|
||||
Or a given range (-ss -endpos):
|
||||
|
||||
mplayer -ao null -ss 0:02:06 -endpos 0:05:00 -vo gif89a:outdir=gif videofile.mp4
|
|
@ -0,0 +1,56 @@
|
|||
# Bookshelf.js
|
||||
|
||||
Model
|
||||
-----
|
||||
|
||||
class Book extends Bookshelf.Model
|
||||
tableName: 'books'
|
||||
|
||||
### Associations
|
||||
|
||||
class Book extends Bookshelf.Model
|
||||
# Associations
|
||||
author: -> @belongsTo(Author)
|
||||
summary: -> @hasOne(Summary)
|
||||
pages: -> @hasMany(Pages)
|
||||
shelves: -> @belongsToMany(Shelves)
|
||||
|
||||
@hasMany(Comment)
|
||||
.through(Chapter)
|
||||
|
||||
@belongsToMany(Comment)
|
||||
.withPivot(['created_at'])
|
||||
|
||||
### Collections
|
||||
|
||||
class Books extends Bookshelf.Collection
|
||||
model: Book
|
||||
|
||||
books = new Books()
|
||||
books.query(where: { id: 2 })
|
||||
.fetch()
|
||||
.then ->
|
||||
|
||||
### Fetching associations
|
||||
|
||||
new Book(id: 1).summary().fetch()
|
||||
.then (summary) ->
|
||||
|
||||
Manipulation
|
||||
------------
|
||||
|
||||
### Reading (Fetch by ID)
|
||||
|
||||
new Story(id: 2).fetch()
|
||||
.then (story) ->
|
||||
story.id #=> 2
|
||||
story.title #=> "Through the Looking Glass"
|
||||
|
||||
story.summary = "Hello"
|
||||
story.save()
|
||||
|
||||
.then -> ...
|
||||
|
||||
### References
|
||||
|
||||
* http://bookshelfjs.org/
|
|
@ -0,0 +1,57 @@
|
|||
## Paths
|
||||
|
||||
/
|
||||
app/
|
||||
assets/
|
||||
vendor/
|
||||
public/
|
||||
config.coffee
|
||||
|
||||
## Config
|
||||
|
||||
files:
|
||||
javascripts: # or 'stylesheets' or 'templates'
|
||||
order:
|
||||
before: [ 'normalize.css' ]
|
||||
after: [ 'helpers.css' ]
|
||||
|
||||
joinTo: 'app.js'
|
||||
joinTo:
|
||||
'js/app.js': /^app/
|
||||
'js/vendor.js': /^vendor/
|
||||
pluginHelpers: 'js/vendor.js'
|
||||
|
||||
paths:
|
||||
public: 'public' # where to compile
|
||||
watched: ['app','test','vendor'] # what to monitor
|
||||
|
||||
modules:
|
||||
wrapper: 'amd'
|
||||
definition: 'amd'
|
||||
nameCleaner: (path) -> path.replace /^app\//, ''
|
||||
|
||||
# brunch b --apply production
|
||||
overrides:
|
||||
production:
|
||||
optimize: true
|
||||
sourceMaps: false
|
||||
plugins: autoReload: enabled: false
|
||||
|
||||
## Plugins
|
||||
|
||||
plugins:
|
||||
uglify:
|
||||
mangle: true
|
||||
compress:
|
||||
global_defs:
|
||||
DEBUG: false
|
||||
|
||||
## Stuff
|
||||
|
||||
* uglify-js-brunch
|
||||
* stylus-brunch
|
||||
* coffee-script-brunch
|
||||
|
||||
## References
|
||||
|
||||
* https://github.com/brunch/brunch/blob/master/docs/config.md
|
|
@ -0,0 +1,24 @@
|
|||
Loading
|
||||
|
||||
image = ChunkyPNG::Image.from_file('filename.png')
|
||||
image = ChunkyPNG::Image.from_blob(File.read('file.png'))
|
||||
image = ChunkyPNG::Image.from_io(io)
|
||||
|
||||
Saving
|
||||
|
||||
image.save('filename.png')
|
||||
File.open('newfile.png', 'wb') { |io| image.write(io) }
|
||||
binary_string = image.to_blob
|
||||
|
||||
Drawing
|
||||
|
||||
image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
|
||||
image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f'))
|
||||
|
||||
Canvas
|
||||
|
||||
crop(x, y, w, h)
|
||||
|
||||
Transforms
|
||||
|
||||
new_image = image.flip_horizontally.rotate_right
|
|
@ -35,49 +35,6 @@ Sorting:
|
|||
|
||||
-h Human-readable size (3k)
|
||||
|
||||
## Find (find)
|
||||
|
||||
Usage:
|
||||
|
||||
find <path> <conditions> <actions>
|
||||
|
||||
Conditions:
|
||||
|
||||
-name "*.c"
|
||||
|
||||
-user jonathan
|
||||
-nouser
|
||||
|
||||
-type f # File
|
||||
-type d # Directory
|
||||
-type l # Symlink
|
||||
|
||||
-depth 2 # At least 3 levels deep
|
||||
-regex PATTERN
|
||||
|
||||
-newer file.txt
|
||||
-newerm file.txt # modified newer than file.txt
|
||||
-newerX file.txt # [c]hange, [m]odified, [B]create
|
||||
-newerXt "1 hour ago" # [t]imestamp
|
||||
|
||||
Condition flow:
|
||||
|
||||
\! -name "*.c"
|
||||
\( x -or y \)
|
||||
|
||||
Actions:
|
||||
|
||||
-exec rm {} \;
|
||||
-print
|
||||
-delete
|
||||
|
||||
Examples:
|
||||
|
||||
find . -name '*.jpg'
|
||||
find . -name '*.jpg' -exec rm {} \;
|
||||
|
||||
find . -newerBt "24 hours ago"
|
||||
|
||||
## Tail
|
||||
|
||||
Usage:
|
||||
|
|
11
express.md
11
express.md
|
@ -34,11 +34,14 @@ title: Express.js
|
|||
|
||||
### Request
|
||||
|
||||
req.params
|
||||
|
||||
// GET /user/tj
|
||||
req.params.name //=> "tj"
|
||||
|
||||
req.path //=> "/user/tj"
|
||||
req.url //=> "/user/tj"
|
||||
req.xhr //=> true|false
|
||||
req.method //=> "GET"
|
||||
req.params
|
||||
req.params.name //=> "tj"
|
||||
req.params[0]
|
||||
|
||||
// GET /search?q=tobi+ferret
|
||||
|
@ -53,8 +56,6 @@ title: Express.js
|
|||
req.is('html')
|
||||
req.is('text/html')
|
||||
|
||||
req.path
|
||||
req.xhr
|
||||
|
||||
## Response
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
# Find
|
||||
|
||||
Usage:
|
||||
|
||||
find <path> <conditions> <actions>
|
||||
|
||||
Conditions:
|
||||
|
||||
-name "*.c"
|
||||
|
||||
-user jonathan
|
||||
-nouser
|
||||
|
||||
-type f # File
|
||||
-type d # Directory
|
||||
-type l # Symlink
|
||||
|
||||
-depth 2 # At least 3 levels deep
|
||||
-regex PATTERN
|
||||
|
||||
-newer file.txt
|
||||
-newerm file.txt # modified newer than file.txt
|
||||
-newerX file.txt # [c]hange, [m]odified, [B]create
|
||||
-newerXt "1 hour ago" # [t]imestamp
|
||||
|
||||
Condition flow:
|
||||
|
||||
\! -name "*.c"
|
||||
\( x -or y \)
|
||||
|
||||
Actions:
|
||||
|
||||
-exec rm {} \;
|
||||
-print
|
||||
-delete
|
||||
|
||||
Examples:
|
||||
|
||||
find . -name '*.jpg'
|
||||
find . -name '*.jpg' -exec rm {} \;
|
||||
|
||||
find . -newerBt "24 hours ago"
|
||||
|
|
@ -12,6 +12,12 @@
|
|||
# Transfer to another owner
|
||||
heroku sharing:transfer new@owner.com
|
||||
|
||||
## `logs` - Show logs
|
||||
|
||||
heroku logs
|
||||
heroku logs -t # --tail (stream)
|
||||
heroku logs -s app # --source (only on app logs)
|
||||
|
||||
## `pg` - Postgresql
|
||||
|
||||
# Start a database
|
||||
|
|
37
makefile.md
37
makefile.md
|
@ -19,10 +19,25 @@
|
|||
$< -- Prerequisite (first)
|
||||
$* -- Basename without extension of the target (?)
|
||||
|
||||
### Command prefixes
|
||||
|
||||
- Ignore errors
|
||||
@ Don't print command
|
||||
+ Run even if Make is in 'don't execute' mode
|
||||
|
||||
Examples:
|
||||
|
||||
build:
|
||||
@echo "Building"
|
||||
-gcc $< $@
|
||||
@echo "Construction complete"
|
||||
|
||||
-include .depend
|
||||
|
||||
### Cool stuff
|
||||
|
||||
gitdir ?= $(shell git --exec-path)
|
||||
gitver ?= $(word 3,$(shell git --version))
|
||||
gitdir ?= $(shell git --exec-path)
|
||||
gitver ?= $(word 3,$(shell git --version))
|
||||
|
||||
### Find files
|
||||
|
||||
|
@ -31,13 +46,11 @@
|
|||
|
||||
$(patsubst images/%, assets/%, $(shell find images -name "*"))
|
||||
|
||||
|
||||
|
||||
### Substitutions
|
||||
|
||||
# Same
|
||||
$(SOURCE:.cpp=.o)
|
||||
$(patsubst %.cpp, %.c, $(SOURCES))
|
||||
$(SOURCE:.cpp=.o)
|
||||
$(patsubst %.cpp, %.c, $(SOURCES))
|
||||
|
||||
$(strip $(string_var))
|
||||
|
||||
|
@ -53,15 +66,9 @@
|
|||
|
||||
### Building files
|
||||
|
||||
%.o: %.c
|
||||
ffmpeg -i $< > $@ # Input and output
|
||||
foo $^
|
||||
|
||||
### Default task
|
||||
|
||||
default:
|
||||
@echo "hello."
|
||||
@false
|
||||
%.o: %.c
|
||||
ffmpeg -i $< > $@ # Input and output
|
||||
foo $^
|
||||
|
||||
### Inclusion
|
||||
|
||||
|
|
|
@ -58,5 +58,4 @@ title: Package JSON
|
|||
"preferGlobal": true,
|
||||
"license": "MIT"
|
||||
|
||||
|
||||
[Reference](http://package.json.nodejitsu.com/) (Nodejitsu.com)
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
# PSD.rb
|
||||
|
||||
### Opening
|
||||
|
||||
psd = PSD.new(file, parse_layer_images: true)
|
||||
psd.parse!
|
||||
|
||||
### Traversing
|
||||
|
||||
# Gets the root node.
|
||||
# A #<Node> can be a Group or a Layer.
|
||||
node = psd.tree
|
||||
|
||||
node.root
|
||||
node.descendants
|
||||
node.ancestors
|
||||
node.siblings
|
||||
node.subtree
|
||||
|
||||
node.descendant_groups
|
||||
node.descendant_layers
|
||||
|
||||
### Layer info
|
||||
|
||||
node.name #=> "Layer 2"
|
||||
|
||||
node.top #=> 3
|
||||
node.left #=> 3
|
||||
node.bottom
|
||||
node.right
|
||||
|
||||
# Note: these are interchanged (?)
|
||||
node.width
|
||||
node.height
|
||||
|
||||
node.visible?
|
||||
node.hidden?
|
||||
|
||||
node.layer?
|
||||
node.group?
|
||||
|
||||
node.blending_mode #=> "normal"
|
||||
node.opacity #=> 0..255
|
||||
node.fill_opacity #=> 0..255
|
||||
|
||||
### Layer text
|
||||
|
||||
node.text #=> (Hash)
|
||||
node.text[:value] #=> "Text here"
|
||||
node.text[:font][:name] #=> "Arial"
|
||||
node.text[:font][:sizes] #=> [6.9]
|
||||
node.text[:font][:colors] #=> [[255,255,255,255]]
|
||||
node.text[:font][:css] #=> "font-family: ...;"
|
||||
node.text[:left] #=> 3
|
||||
node.text[:top]
|
||||
node.text[:right]
|
||||
node.text[:bottom]
|
||||
node.text[:transform] #=> (Hash)
|
||||
|
||||
### Layer effects
|
||||
|
||||
fx = node.info[:object_effects]
|
||||
fx.data['Scl '] # ?
|
||||
fx.data['GrFl'] # Gradient fill
|
||||
|
||||
### Layer mask
|
||||
|
||||
node.mask["mask_size"] == 0 # No mask
|
||||
node.mask["mask_size"] == 20 # Has mask
|
||||
node.mask["top"]
|
||||
node.mask["left"]
|
||||
node.mask["bottom"]
|
||||
node.mask["right"]
|
||||
|
||||
### Reference
|
||||
|
||||
* https://github.com/layervault/psd.rb
|
27
qjs.md
27
qjs.md
|
@ -3,12 +3,29 @@ title: Q.js
|
|||
|
||||
### Creating promises (Q.promise)
|
||||
|
||||
Q.promise (resolve, reject) ->
|
||||
Q.promise (ok, fail) =>
|
||||
asyncFunction ->
|
||||
if error
|
||||
reject new Error("Failure")
|
||||
fail new Error("Failure")
|
||||
else
|
||||
resolve deferred
|
||||
ok(data)
|
||||
|
||||
### For arrays
|
||||
|
||||
promises = [saveDisk(), saveCloud()]
|
||||
|
||||
# When all succeeds, or *at least one* error
|
||||
Q.all(promises).done ->
|
||||
alert "Saved"
|
||||
|
||||
# Same, but get the values
|
||||
Q.all(promises).spread (a, b) ->
|
||||
alert "Result A:" + a
|
||||
alert "Result B:" + b
|
||||
|
||||
# When all either succeeds or errors
|
||||
Q.allSettled(promises).done -> ...
|
||||
|
||||
|
||||
### Creating promises from Node
|
||||
|
||||
|
@ -50,3 +67,7 @@ title: Q.js
|
|||
|
||||
.catch (e) ->
|
||||
console.error "Oh well", e
|
||||
|
||||
### Reference
|
||||
|
||||
* https://github.com/kriskowal/q/wiki/API-Reference
|
||||
|
|
Loading…
Reference in New Issue