Skip to content

Instantly share code, notes, and snippets.

@lsfalimis
lsfalimis / RenrenResize.sh
Last active August 29, 2015 14:03
Run in terminal: bash /path/to/RenrenResize.sh /path/to/folder
#!/usr/bin/bash
for file in $1/*
do
width=$(sips -g pixelWidth "$file" | cut -s -d ':' -f 2 | cut -c 2-)
if (($width>720)); then
sips --resampleWidth 720 "$file"
fi
done
@lsfalimis
lsfalimis / removeOrReplace.scpt
Last active March 15, 2017 12:21
Remove or replace texts in AppleScript
(*
I changed some parts of http://foolsworkshop.com/applescript/2008/05/an-applescript-replace-text-method/
*)
on removeText(unwanted, theText)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to unwanted
set theText to text items of theText
@lsfalimis
lsfalimis / listinTB.scpt
Last active August 29, 2015 14:02
List 'natural language "and" list' in Tinderbox 6
(*
KM macro "Create TB Child Node" http://i.imgur.com/XMnf1bQ.png
KM macro "Create TB Node" http://i.imgur.com/zkDVSb9.png
They need to be put in a global macro group.
An item/node in Tinderbox 6 must be selected to get this AppleScript work.
The 'and' list that the AppleScript will work with looks like 'a, b, c, and d'.
So a list that looks like 'a, b, c and d' will not work.
*)
@lsfalimis
lsfalimis / my-1st-crawler-alt.py
Created June 5, 2014 10:21
my-1st-crawler-alt.py download html doc instead from reading from clipboard (I haven't tested it yet)
import pprint, re, urllib, urllib2
from bs4 import BeautifulSoup
html = urllib2.urlopen('http://SOMEWEBSITE').read()
soup = BeautifulSoup(html)
stuff = soup(class_="WHATEVER")
# not quite understand the following line, it will insert '\n'
stuff.insert(0, stuff)
@lsfalimis
lsfalimis / my-1st-crawler.py
Created June 5, 2014 10:18
my-1st-crawler, from clipboard source code, batch download images with filtered names
import pprint, re, urllib
from bs4 import BeautifulSoup
from subprocess import check_output
html = check_output(["pbpaste"])
soup = BeautifulSoup(html)
stuff = soup(class_="WHATEVER")
# not quite understand the following line, it will insert '\n'
stuff.insert(0, stuff)
@lsfalimis
lsfalimis / example.scpt
Last active August 29, 2015 14:01
For beginner, http://lsfalimis.github.io/applescript-python-passing-filename/. Get file name, strip out extension, divide file name, merge or concatenate a list, get and pass UNIX path, pass multiple parameters or arguments to a python script in a shell script
tell application "Finder"
set theName to name of (theFile as alias)
set AppleScript's text item delimiters to "."
if number of text items of theName > 1 then
set theName to text items 1 thru -2 of theName
end if
set theItems to ""
repeat with i from 1 to count of theName
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' && killall Dock
@lsfalimis
lsfalimis / SS2EN.scpt
Created May 22, 2014 07:35
Save the Website Screenshot to EN
tell application "Google Chrome"
set theDate to current date
set y to text -4 thru -1 of (year of theDate as string)
set m to text -2 thru -1 of ("0" & ((month of theDate) as integer))
set d to text -2 thru -1 of ("0" & (day of theDate))
set timeStamp to y & "-" & m & "-" & d & " " & time string of (current date)
set theTitle to title of active tab of first window
set theURL to URL of active tab of first window
@lsfalimis
lsfalimis / append-attachment-en.scpt
Last active March 11, 2024 03:05
Append timestamp and theFile with line break to TARGETNOTE working with Hazel
tell application "Evernote"
set _selectedNote to false
set _notes to get every note of every notebook where its title contains "TARGETNOTE"
repeat with _note in _notes
if length of _note is not 0 then
set _selectedNote to _note
end if
end repeat
tell item 1 of _selectedNote to append text return & return & date string of (current date) & time string of (current date) & return
tell item 1 of _selectedNote to append attachment theFile
@lsfalimis
lsfalimis / private-new.xml
Last active August 29, 2015 14:00
KeyRemap4MacBook | private.xml | ~/Library/Application\ Support/KeyRemap4MacBook/private.xml
<?xml version="1.0"?>
<root>
<!-- Next part belongs to lucifr https://gist.github.com/lucifr/4971978 -->
<item>
<name>F19 to F19</name>
<appendix>(F19 to Hyper (ctrl+shift+cmd+opt) + F19 Only, F19)</appendix>
<identifier>private.f192f19</identifier>
<autogen>
--KeyOverlaidModifier--