Skip to content

Instantly share code, notes, and snippets.

View Arahnoid's full-sized avatar

Igor Grinchesku Arahnoid

  • Chernivtsi, Ukraine
View GitHub Profile
@Arahnoid
Arahnoid / makeLayerActiveByName.js
Created April 1, 2014 20:27
Make layer active by name
/**
* makeLayerActiveByName
* @param string nm Layer name]
* @return
* @usage selects layer by name and mak it active
* @env Photoshop
*/
function makeLayerActiveByName(nm) {
function cTID(s) { return app.charIDToTypeID(s); };
var doc = app.activeDocument;
var guides = app.activeDocument.guides;
var w = doc.width;
var h = doc.height;
function MakeGuidesGrid(numVerticalGuides, gutterVertical, numHorisontalGuides, gutterHorisontal) {
if (numHorisontalGuides !== 0) {
var j = h / numHorisontalGuides;
for (var i = 0; i < numHorisontalGuides; i++) {
guides.add(Direction.HORIZONTAL, j * i);
var doc = app.activeDocument;
var guides = app.activeDocument.guides;
var w = doc.width;
var h = doc.height;
function MakeGuidesGrid(unitVertical, gutterVertical, unitHorisontal, gutterHorisontal) {
if (unitHorisontal !== 0) {
var j = h / unitHorisontal;
for (var i = 0; i < j; i++) {
guides.add(Direction.HORIZONTAL, i * unitHorisontal);
var layerNum = app.activeDocument.layers.length;
var arr = [];
for (var i = 0; i < layerNum; i++) {
arr[i] = '"'+app.activeDocument.layers[i].name+'"';
}
// taken from: http://stackoverflow.com/questions/840781/easiest-way-to-find-duplicate-values-in-a-javascript-array
var sorted_arr = arr.sort(); // You can define the comparing function here.
var layerNum = app.activeDocument.layers.length;
prompt("Layers Number:", layerNum);
# Generate Txt File With Directory Tree
http://superuser.com/questions/258287/how-can-i-export-a-directory-structure
Assuming your directory tree is of reasonable size, you could also use the built in tree command, which produces a rather pretty looking directory tree. Unfortunately this prettiness is difficult to get working outside of a cmd instance, so you'll probably want to tell it to just use ascii characters with the /A switch.
### Example:
From a small multi-level structure
/*******************************************************************************
1. DEPENDENCIES
*******************************************************************************/
var gulp = require('gulp'); // gulp core
sass = require('gulp-sass'), // sass compiler
uglify = require('gulp-uglify'), // uglifies the js
jshint = require('gulp-jshint'), // check if js is ok
rename = require("gulp-rename"); // rename files
concat = require('gulp-concat'), // concatinate js
@Arahnoid
Arahnoid / raterizeLayerStyle
Last active August 29, 2015 14:16
raterizeLayerStyle PS Function
raterizeLayerStyle = ->
idrasterizeLayer = stringIDToTypeID('rasterizeLayer')
desc = new ActionDescriptor
idnull = charIDToTypeID('null')
ref = new ActionReference
idLyr = charIDToTypeID('Lyr ')
idOrdn = charIDToTypeID('Ordn')
idTrgt = charIDToTypeID('Trgt')
ref.putEnumerated idLyr, idOrdn, idTrgt
desc.putReference idnull, ref
@Arahnoid
Arahnoid / DrawShape.js
Created November 4, 2015 18:03 — forked from vladocar/DrawShape.js
Draw Shape in Photoshop with JavaScript
/* Code by Mike Hale http://www.ps-scripts.com/bb/viewtopic.php?f=14&t=1802&start=15
with small modification by Vladimir Carrer
*/
function DrawShape() {
var doc = app.activeDocument;
var y = arguments.length;
var i = 0;
@Arahnoid
Arahnoid / LayersToSpriteSheet.js
Created November 5, 2015 19:40 — forked from ChrisAntaki/LayersToSpriteSheet.js
Photoshop: Layers To Sprite Sheet
// Notes:
// 1. Save this file in Program Files\Adobe\Photoshop\Presets\Scripts\
// 2. Run the script by going to menu File > Scripts > LayersToSpriteSheet
// Based on http://alessandroituarte.com/blag/2012/07/03/470
if (documents.length > 0) {
// Adjust this to the number of columns you want
// leave -1 if you want it to calculate an optimal column value.