Skip to content

Instantly share code, notes, and snippets.

View jkeen's full-sized avatar

Jeff Keen jkeen

View GitHub Profile
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites you only want to give yourself
# access to during certain times of day.
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#
# In this case, I can visit hacker news only over the lunch hour,
@asbjornu
asbjornu / export-address-book.scpt
Created September 10, 2011 12:26
Export all Mac OS X Address Book entries as single vCard files to a chosen folder
property targetfolder : "" as Unicode text
try
set targetfolder to choose folder with prompt "Choose a folder or volume:" as Unicode text
on error
beep
display dialog "Invalid path" buttons "Exit"
return
end try
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@nschum
nschum / README.md
Created September 21, 2014 20:44
OS X Yosemite Messages database merger

OS X Yosemite Messages database merger

Early betas of OS X Yosemite had a bug where the library of old messages wasn't migrated. Instead a new library was created and all old messages were gone.

The bug has been fixed, but if you were affected, you still have two separate libraries. This script merged them for me. Use it at your own risk! You might end up worse than before. Backup everything beforehand. Twice.

This is what your ~/Library/Messages folder will look like if you're affected:

  • chat.db
@jamesarosen
jamesarosen / 01-intro.md
Last active May 24, 2018 08:44
Ember-CLI + Ember-Data + Custom API

I had some trouble getting Ember-CLI and Ember-Data working with my existing HTTP API. These are the things I had to do to get it working:

Use ActiveModelSerializer by default

My API returns underscored_keys, not camelizedKeys. It's not exactly the standard ActiveModel, but it's quite similar. I started by defining a default (application) serializer that's a simple subclass of DS.ActiveModelSerializer:

// app/serializers/application.js
import DS from "ember-data";
@protrolium
protrolium / ffmpeg.md
Last active November 12, 2024 21:27
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

@tlowrimore
tlowrimore / address_books_controller.rb
Last active June 22, 2024 18:39
Keeps your API lookin' good! No need for all that nested_attributes pollution in your request/response payloads
class V1::AddressBooksController < V1::BaseController
def create
@address_book = AddressBook.new address_book_params
unless @address_book.save
errors = @address_book.errors.to_hash(true)
render status: 422, json: { errors: errors }
end
end
private
@varemenos
varemenos / 1.README.md
Last active October 23, 2024 13:07
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@indiesquidge
indiesquidge / subdomain-localhost-rails-5.md
Created January 19, 2016 07:42
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@abuiles
abuiles / mirage-tils.org
Created February 24, 2016 17:01
Mirage TILS

Version: ^0.2.0-beta.5

How can I check the serialized version of a model?

server.get('api/employee's, function(schema, request) {
  employee = schema.employee.find(1);
  this.serializerOrRegistry.serialize(employee, request);

  return foo;
});