Skip to content

Instantly share code, notes, and snippets.

View bcylin's full-sized avatar

Cheng-Yao Lin bcylin

View GitHub Profile
require "nokogiri"
require "open-uri"
url = "https://developer.apple.com/videos/play/fall2017"
base_url = "#{URI(url).scheme}://#{URI(url).host}"
html = Nokogiri::HTML(open(url))
pages = html.css("section.col-70 > a").map { |a| base_url + a[:href] }
pages.each do |page|
struct JSONResource {
static func dictionary(fromResource filename: String, ofType type: String) -> [String: AnyObject]? {
return object(fromResource: filename, ofType: type) as? [String: AnyObject]
}
static func array(fromResource filename: String, ofType type: String) -> [AnyObject]? {
return object(fromResource: filename, ofType: type) as? [AnyObject]
}
@bcylin
bcylin / Objective-C.sublime-build.json
Last active August 29, 2015 14:12
~/Application Support/Sublime Text 3/Packages/User/Objective-C.sublime-build
{
"cmd": ["clang", "$file", "-std=c99", "-framework", "Foundation", "-ObjC", "-o", "$file_base_name"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.objc, source.m",
"variants":
[
{
"name": "Run",
@bcylin
bcylin / toggle-screenshot-shadow.scpt
Created August 22, 2014 07:21
Toggle the shadow of screenshots on Mac.
property message : "Toggle screenshot shadow?"
property remove_button : "Remove Shadow"
property keep_button : "Keep Shadow"
set dialog to display dialog message buttons {"Cancel", remove_button, keep_button} default button keep_button cancel button "Cancel"
if button returned of dialog is remove_button then
do shell script "defaults write com.apple.screencapture disable-shadow -bool true && killall SystemUIServer"
else if button returned of dialog is keep_button then
do shell script "defaults delete com.apple.screencapture disable-shadow && killall SystemUIServer"
@bcylin
bcylin / markdown2evernote.rb
Last active August 29, 2015 13:57 — forked from kopischke/markdown2evernote.rb
Support non-ASCII characters and avoid Invalid byte sequence in US-ASCII (ArgumentError)
#!/usr/bin/env ruby -wKU
# encoding: utf-8
# Adapted from:
# - Martin Kopichke's "Markdown to Evernote" service
# https://gist.github.com/kopischke/1009149
# - Benabik's arkdown to Evernote, RubyCocoa edition
# https://gist.github.com/Benabik/4743741
# - Brett Terpstra’s post
# http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/
@bcylin
bcylin / open_with_sublime_text.applescript
Created February 17, 2013 14:41
An AppleScript to open Finder selections or current directory using Sublime Text 2 command line tool.
--
-- Open with Sublime Text 2
--
-- Open Finder selections or current directory using Sublime Text 2 command line tool.
-- Save the script as application and drag it to the Finder toolbar.
--
-- Action on double clicking the icon
on run
@bcylin
bcylin / compress_sparseimage.applescript
Last active December 12, 2015 02:39
An AppleScript (saved as an application) to compress sparseimages by drag and drop files onto the icon.
-- When double clicking the icon
on run
set selectedItems to (choose file with multiple selections allowed)
repeat with thisItem in selectedItems
my run_hdiutil(thisItem)
end repeat
end run
-- When dragging files onto the icon
@bcylin
bcylin / repair_disk_permissions.applescript
Last active April 28, 2016 09:38
Script to repair disk permissions
-- involve GUI
tell application "Disk Utility" to activate
delay 1 -- wait for the good old mac to get ready
tell application "Disk Utility" to activate
tell application "System Events"
tell process "Disk Utility"
select row 2 of outline 1 of scroll area 1 of splitter group 1 of window 1
click button 3 of group 1 of tab group 1 of splitter group 1 of window 1
@bcylin
bcylin / changeFont.js
Created January 13, 2013 01:39
Try Google Web Fonts
// javascript:
fontName = prompt("Try Merienda, Risque, or more on https://www.google.com/webfonts", "Merienda");
WebFontConfig = {
google: { families: [ fontName.replace(/\ /, "+") + '::latin' ] }
};
(function() {
var wf = document.createElement('script');
@bcylin
bcylin / droplet.applescript
Created January 10, 2013 06:32
AppleScript droplet template
-- When double clicking the icon
on run
set selectedItems to (choose file with multiple selections allowed)
repeat with thisItem in selectedItems
my subRoutine(thisItem)
end repeat
end run
-- When dragging files onto the icon