Skip to content

Instantly share code, notes, and snippets.

View salverde's full-sized avatar

salomonic salverde

View GitHub Profile
@salverde
salverde / gist:1560874
Created January 4, 2012 16:42
Convert devise views from erb to haml templates
find . -name '*erb' | xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")};rm #{i}"}' | bash
@salverde
salverde / afconvert.sh
Last active October 8, 2015 10:17
Convert .caf files from stereo to mono
afconvert -v -f caff -d ima4 -c 1 sourceFile.caf -o destFile.caf
@salverde
salverde / .bash_profile
Last active October 9, 2015 18:48
Display Git branch shell prompt & Autocomplete
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# set the PS1 variable
#PS1="\w\[\e[0;33;49m\]\$(parse_git_branch)\[\e[0;0m\]$ "
PS1="\w\[\e[0;37m\]\$(parse_git_branch)\[\e[0;0m\]$ "
# Set git autocompletion and PS1 integration
if [ -f /usr/local/Cellar/git/2.1.3/etc/bash_completion.d/git-completion.bash ]; then
@salverde
salverde / launch-services-quarantine.sh
Last active December 12, 2015 02:38
Launch Services Quarantine OS X tracks everything you download. This gist is both shell scripts (and Applescript) that lists and clears your Quarantine.
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'SELECT LSQuarantineDataURLString FROM LSQuarantineEvent'
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'DELETE FROM LSQuarantineEvent'
# Applescript
do shell script
"sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'DELETE FROM LSQuarantineEvent'"
@salverde
salverde / web-ios-user-agents
Created April 22, 2013 04:54
iOS Web User Agents Examples
iOS WebView:
Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B141
Mobile Safari:
Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari
@salverde
salverde / .gitignore
Last active August 29, 2015 14:16
GitIgnore Xcode 6
# IMPORTANT: If you committed to the git repository before you added this .gitignore file
# you need to delete the excluded files manually from your git repository, to ensure,
# that they are not tracked anymore. To delete them from git, just do the following:
#
# git rm --cached FILENAME
#
.DS_Store
UserInterfaceState.xcuserstate
@salverde
salverde / Abuser.swift
Last active February 8, 2017 04:21
Unbox example
import Foundation
import Unbox
struct Abuser {
let username: String
let fullName: String
let age: Int
let photos: [Photo]?
}
@salverde
salverde / UnboxedAlamofire.swift
Created February 8, 2017 04:57
UnboxedAlamofire snippet
let url = apiBaseURL + "/abusers.json"
Alamofire.request(url, method: .get, parameters: params, encoding: URLEncoding.default).validate(statusCode: 200..<300).responseObject { (response: DataResponse<Abuser>) in
switch response.result {
case .success(let searchResult):
completion?(searchResult)
case .failure(let error):
print("error: \(error)")
}
}

Keybase proof

I hereby claim:

  • I am salomoko on github.
  • I am salomoko (https://keybase.io/salomoko) on keybase.
  • I have a public key ASBi1q5KlgJ9keGAy-kHcTDH_tO3dewW3t8MojJBl61bkwo

To claim this, I am signing this object:

@salverde
salverde / friendly_urls.markdown
Created March 14, 2017 06:45 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.