Skip to content

Instantly share code, notes, and snippets.

Avatar

Davide Barranca undavide

View GitHub Profile
@undavide
undavide / lexer.py
Last active Apr 21, 2021 — forked from mandiwise/lexer.py
Mostly working JSX lexer for Pygments
View lexer.py
# -*- coding: utf-8 -*-
"""
pygments.lexers.jsx
~~~~~~~~~~~~~~~~~~~~
Lexers for JSX formats.
Based on https://github.com/fcurella/jsx-lexer
"""
import re
View gulpfile.js
var gulp = require('gulp');
var clean = require('gulp-clean');
var shell = require('gulp-shell');
// 0. Clean all ZXPs found everywhere
gulp.task('clean-all', function () {
return gulp.src('./**/*.zxp', { read: false })
.pipe(clean());
});
View PartialSerialNumberVerification.js
/**
* Generates a Key Byte
* @param {32bit integer} seed e.g. 0xA2791717
* @param {8bit integer} a
* @param {8bit integer} b
* @param {8bit integer} c
* @return {8bit hex string}
*/
function PKV_GetKeyByte(seed, a, b, c) {
var result;
View index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link id="hostStyle" rel="stylesheet" href="css/theme.css"/>
<link id="theme" rel="stylesheet" href="css/light.css"/>
<title></title>
</head>
<body>
View main.js
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global $, window, location, CSInterface, SystemPath, themeManager*/
line
(function () {
'use strict';
var csInterface = new CSInterface();
var extensionId = csInterface.getExtensionID();
function PersistentOn() {
@undavide
undavide / javascriptobfuscator.js
Last active Feb 28, 2019
JavascriptObfuscator Gulp Plugin
View javascriptobfuscator.js
var http = require('http'),
fs = require('fs'),
Readable = require('stream').Readable,
through = require('through2'),
gutil = require('gulp-util'),
Vinyl = require('vinyl');
module.exports = function() {
var transform = function(file, encoding, callback) {
View DropDown.vue
<template>
<div class="spectrum-Dropdown" :class="{ 'is-open': showMenu }" style="width: 240px;">
<button class="spectrum-FieldButton spectrum-Dropdown-trigger is-selected" aria-haspopup="true" @click="toggleMenu">
<span class="spectrum-Dropdown-label">{{ displayedItem }}</span>
<svg class="spectrum-Icon spectrum-UIIcon-ChevronDownMedium spectrum-Dropdown-icon" focusable="false" aria-hidden="true">
<use xlink:href="#spectrum-css-icon-ChevronDownMedium" />
</svg>
</button>
<div class="spectrum-Popover spectrum-Popover--bottom spectrum-Dropdown-popover" :class="{ 'is-open': showMenu }"
@undavide
undavide / find-corrupted-files.sh
Last active May 8, 2018 — forked from JavierAroche/find-corrupted-files.sh
Find corrupted files using GM identify
View find-corrupted-files.sh
folderToCheck='/Volumes/16TB/whatever/path'
outputFile=~/Desktop/FileIntegrity.log
counter=1
Red="\033[0;31m" # Red
Green="\033[0;32m" # Green
Color_Off="\033[0m" # Text Reset
cd "${folderToCheck}"
# Find all files and get count
@undavide
undavide / panels201_4.js
Last active Mar 14, 2018
Passing a JSON string from the JSX back to the panel
View panels201_4.js
// JS file (panel)
// ...
csInterface.evalScript('getDocumentInfo()', function(res) {
var resObj = JSON.parse(res);
// you have now access to the same docInfo object
});
// JSX file (Photoshop)
function getDocumentInfo() {
//... I just make up data here...
@undavide
undavide / panels201_3.js
Created Mar 14, 2018
Including a callback
View panels201_3.js
// JS file (panel)
// ...
csInterface.evalScript('addSharpeningForWeb(' + paramString + ')', function(res) {
// "res" is the response that comes from Photoshop
});
// JSX file (Photoshop)
function addSharpeningForWeb(paramObj) {
// ... lots of code here
return true;