nc -l 5566 > data-dump.sql
Listen on port 5566 and redirect output to data-dump.sql
def determine_file_extension_with_mime_type(mimetype) | |
fe = `grep #{mimetype} -i mime.types`.gsub(mimetype, '').strip.split(' ')[0] | |
if fe == '' || fe.nil? | |
'' | |
else | |
".#{fe}" | |
end | |
end |
@error = :invalid_type and return if (type = params[:type]) and (type != :iphone && type != :android) | |
# exactly the same as: (if prefer the former) | |
if type = params[:type] and (type != :iphone && type != :android) | |
@error = :invalid_type | |
return | |
end | |
# or |
twfbCounters = -> | |
$twitterFacebook = $('#twfb') | |
$.ajax { | |
url: 'http://api.twitter.com/1/users/show.json', | |
data: 'screen_name=zeptojs', | |
dataType: 'jsonp' | |
success: (data, status, xhr) -> | |
$twitterFacebook.html(data.followers_count) | |
error: (xhr, errorType, error) -> |
class Card | |
constructor: (selector) -> | |
@$container = $('.cards') | |
@$element = @$container.find(selector) | |
@$text = @$element.find('.card-menu li:first-child a span') | |
toggleClass: -> | |
@$element.toggleClass('is-favorited') | |
changeText: -> | |
cardText = if @$element.favorited then 'Unfavorite' else 'Favorite' | |
@$text.text(cardText) |
class Duration | |
attr_accessor :duration | |
def initialize(string) | |
@duration = string | |
end | |
def to_i | |
value_units.map(&:to_i).reduce(&:+) | |
end |
module Taggable | |
extend ActiveSupport::Concern | |
included do | |
attr_accessible :tags | |
after_save :set_tags | |
after_destroy :unset_tags | |
end |
# Single object | |
<%= render partial: 'thumbnail', object: video, as: :video %> | |
<%= render partial: 'thumbnail', locals: { video: video } %> | |
<%= render 'thumbnail', video: video %> | |
# Collection | |
<%= render partial: 'thumbnail', collection: videos, as: :video %> |
import PureRenderMixin from 'react-addons-pure-render-mixin'; | |
import React from 'react'; | |
import Audio from './Audio'; | |
import Image from './Image'; | |
import MediaRecord from 'ph/records/MediaRecord'; | |
import PostRecord from 'ph/records/PostRecord'; | |
import Video from './Video'; | |
import {MEDIA_TYPE_AUDIO, MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO} from 'ph/constants/MediaConstants'; |
class ApplicationController < ActionController::Base | |
include EtagWithLayout | |
end |