Get it from the App Store.
In XCode's Preferences > Downloads you can install command line tools.
function guidGenerator() { | |
var S4 = function() { | |
return (((1+Math.random())*0x10000)|0).toString(16).substring(1); | |
}; | |
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); | |
} | |
// How to use it: | |
guidGenerator(); |
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
class ActionDispatch::Routing::Mapper | |
def draw(routes_name) | |
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
end | |
end | |
BCX::Application.routes.draw do | |
draw :api | |
draw :account | |
draw :session |
var user = { | |
validateCredentials: function (username, password) { | |
return ( | |
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' } | |
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' } | |
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' } | |
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' } | |
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' } | |
: false | |
); |
require 'open-uri' | |
class Story | |
attr_accessor :title, :url | |
def initialize(title, url) | |
@title = title | |
@url = url | |
end | |
# config/initializers/redcarpet.rb | |
module ActionView | |
module Template::Handlers | |
class Markdown | |
class_attribute :default_format | |
self.default_format = Mime::HTML | |
def call(template) | |
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true) | |
markdown.render(template.source).html_safe.inspect |
#get the attribute from a given url (image) by using OCR | |
def ocr_attribute url | |
dir = "/tmp/scrapers" | |
file = rand(36**10).to_s(36) | |
path = "#{dir}/#{file}" | |
pnm_path = "#{dir}/#{file}.pnm" | |
open(url) do |f| | |
Dir.mkdir(dir) if !File.exists? dir | |
image = Image.from_blob(f.read)[0] | |
image.write(path) |
[ | |
// Make paste-and-indent the default paste behavior | |
{ "keys": ["super+v"], "command": "paste_and_indent" }, | |
{ "keys": ["super+shift+v"], "command": "paste" } | |
] |