Skip to content

Instantly share code, notes, and snippets.

@lsfalimis
lsfalimis / private.xml
Created May 4, 2014 22:31
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--
@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--
@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
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' && killall Dock
@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
@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 / 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 / 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 / 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 / ywdFinder.scpt
Created July 16, 2014 17:16
copy Finder current path
tell application "Finder"
set thePath to POSIX path of (target of window 1 as alias)
set the clipboard to thePath
end tell