Skip to content

Instantly share code, notes, and snippets.

View jfahrenkrug's full-sized avatar

Johannes Fahrenkrug jfahrenkrug

View GitHub Profile
@jfahrenkrug
jfahrenkrug / cloudos_custom_icons.js
Created August 2, 2011 09:17
Add custom icons to the iCloud.com CloudOS SpringBoard
SC.run(function() {
COS.apps.github = {path: 'http://www.github.com', requiredServices: ["ubiquity"]};
COS.appsController._appsInfo.github = COS.AppInfo.create(COS.apps.github);
var github = {name: 'github', icon: 'http://ripthejacker.github.com/images/github_icon.png'};
var c = {
maskAsset: "/system/cloudos/en-us/14F/source/resources/images/mask.png",
warningArrowAsset: "/system/cloudos/en-us/14F/source/resources/images/warning_arrow.png",
shadowAsset: "/system/cloudos/en-us/14F/source/resources/images/shadow.png",
focusAsset: "/system/cloudos/en-us/14F/source/resources/images/app_icon_ring.png",
@jfahrenkrug
jfahrenkrug / dead_snippets.rb
Created January 29, 2013 14:56
A small script to find unused or invalid snippets in Radiant CMS.
# encoding: utf-8
# Find unused and invalid Radiant CMS snippets
# @author Johannes Fahrenkrug
class DeadSnippetsFinder
SNIPPET_REGEX = /\<r\:snippet\s+name\=[\"\']([\w\d\:\-]+)[\"\']/
def self.scan(obj, field = 'id')
puts " #{field}: #{obj.send(field)} name='#{obj.name}'"
(obj.content || '').scan(SNIPPET_REGEX) do |m|
@jfahrenkrug
jfahrenkrug / TemplateInfo.plist
Created November 4, 2013 21:17
An Xcode 5 template that lets you deselect the use of storyboards.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ancestors</key>
<array>
<string>com.apple.dt.unit.cocoaTouchApplication</string>
</array>
<key>Concrete</key>
<true/>

Keybase proof

I hereby claim:

  • I am jfahrenkrug on github.
  • I am jfahrenkrug (https://keybase.io/jfahrenkrug) on keybase.
  • I have a public key whose fingerprint is BE25 078F A534 3D3F E12D B915 3105 2A52 D4CA A081

To claim this, I am signing this object:

@jfahrenkrug
jfahrenkrug / extract_wwdc_samplecode.js
Created June 7, 2017 23:01
Extract the WWDC 2017 Sample Code URL from the sessions page. Just paste it into the JS console on https://developer.apple.com/wwdc/schedule/
$.getJSON( "https://devimages-cdn.apple.com/wwdc-services/h8a19f8f/049CCC2F-0D8A-4F7D-BAB9-2D8F5BAA7030/contents.json", function( data ) {
var items = [];
$.each( data.contents, function( key, val ) {
if (val.type == 'Session' && val.eventId == 'wwdc2017' && val.related && val.related.resources) {
$.each(val.related.resources, function (resKey, resId) {
var resource = data.resources[resId]
if (resource && resource['resource_type'] == 'samplecode') {
items.push(resource);
import UIKit
import JavaScriptCore
/// An analyzer of sentiments
class SentimentAnalyzer: NSObject {
/// Singleton instance. Much more resource-friendly than creating multiple new instances.
static let shared = SentimentAnalyzer()
private let vm = JSVirtualMachine()
private let context: JSContext
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var sentimentLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
self.sentimentLabel.text = SentimentAnalyzer.shared.emoji(forScore: 0)
}
const Sentiment = require('sentiment')
export class Analyzer {
static analyze(phrase) {
let sentiment = new Sentiment()
let result = sentiment.analyze(phrase)
return result['score']
}
}
var path = require('path')
module.exports = {
mode: "production",
entry: { Sentimentalist: "./index.js" },
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].bundle.js",
library: "[name]",
libraryTarget: "var"
let jsCode = try? String.init(contentsOf: Bundle.main.url(forResource: "Sentimentalist.bundle", withExtension: "js")!)