Skip to content

Instantly share code, notes, and snippets.

function chromeStorageLocal() {
this.storageArea = chrome.storage.local;
this.async = true;
}
chromeStorageLocal.prototype.get = function(key, callback) {
this.storageArea.get(key, function(items) {
if (chrome.runtime.lastError) {
callback(chrome.runtime.lastError);
} else {
callback(null, items[key]);
@stu43005
stu43005 / embed_script.js
Last active August 5, 2022 10:12
Pixiv動態圖錄製,完成後在原圖下方會出現gif圖
(function(file){
var script=document.createElement('script');
script.type='text/javascript';
script.src=file;
document.body.appendChild(script);
})("https://rawgit.com/stu43005/49ff25325b357053b8e9/raw/pixiv_gif_encoder.js");
/*
網址列(或書籤)用:
javascript:(function(file){var script=document.createElement('script');script.type='text/javascript';script.src=file;document.body.appendChild(script)})("https://rawgit.com/stu43005/49ff25325b357053b8e9/raw/pixiv_gif_encoder.js")
@jorng
jorng / progressBar.applescript
Last active July 7, 2019 13:17
Simple AppleScript progress bar demo for Yosemite
set progress description to "A simple progress indicator"
set progress additional description to "Preparing…"
set progress total steps to -1
delay 5
set progress total steps to 100
repeat with i from 1 to 100
try
set progress additional description to "I am on step " & i
@oliveratgithub
oliveratgithub / Batch File Rename.scpt
Last active January 5, 2025 03:03
Simple AppleScript to easily batch rename multiple files sequentially. GUI asks user to select files and input a name before renaming.
-- This code comes from https://gist.github.com/oliveratgithub/
-- Open in AppleScript Editor and save as Application
-- ------------------------------------------------------------
--this is required to break the filename into pieces (separate name and extension)
set text item delimiters to "."
tell application "Finder"
set all_files to every item of (choose file with prompt "Choose the Files you'd like to rename:" with multiple selections allowed) as list
display dialog "New file name:" default answer ""
set new_name to text returned of result
--now we start looping through all selected files. 'index' is our counter that we initially set to 1 and then count up with every file.
@n8henrie
n8henrie / duplicateFinderTab.applescript
Created August 2, 2014 16:44
Uses a hacky workaroud to duplicate the frontmost Finder tab, since Apple hasn't provided great AppleScript support for this.
-- duplicateFinderTab.scpt
-- Uses a hacky workaroud to duplicate the frontmost Finder tab,
-- since Apple hasn't provided great AppleScript support for this.
-- Details at:
on new_tab()
tell application "System Events" to tell application process "Finder"
set frontmost to true
tell front menu bar to tell menu "File" to tell menu item "New Tab"
perform action "AXPress"
@abernier
abernier / README.md
Last active May 16, 2021 23:18
CSS cheat sheet
@pqnelson
pqnelson / numerical.js
Created September 29, 2014 16:36
Rudimentary numerical analysis tools, written for node.js
var exports = module.exports = {};
/**********************************************************
* @author Alex Nelson
* @email [email protected]
* @date 29 September 2014
**********************************************************/
/**
* My todo list...
@tyler-johnson
tyler-johnson / asyncwhile.js
Created October 14, 2014 16:26
Asynchronous while loop for ES6 Promises.
function asyncWhile(condition, action, ctx) {
var whilst = function(data) {
return condition.call(ctx, data) ?
Promise.resolve(action.call(ctx, data)).then(whilst) :
data;
}
return whilst();
}
@SamRothCA
SamRothCA / gitfinderstats.sh
Last active April 1, 2019 17:59
Git status for repo currently open in Finder
cd "$(osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)')" &&
git status --short --branch
@tkambler
tkambler / gist:5222d276f783def5ece8
Last active April 1, 2019 18:02
Displaying Tabular Data in Today Scripts for Yosemite Notification Center
#!/usr/local/bin/node
var Table = require('cli-table');
var table = new Table({
chars: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': ''
, 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': ''
, 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': ''
, 'right': '' , 'right-mid': '' , 'middle': ' ' },
style: { 'padding-left': 0, 'padding-right': 0 }