Skip to content

Instantly share code, notes, and snippets.

View schenkman's full-sized avatar

Chris Schenk schenkman

View GitHub Profile
@schenkman
schenkman / ffmpeg_commands.sh
Created August 26, 2018 00:01
ffmpeg tricks
# Adjust the bitrate of a wav file to be slightly faster (or slower?) than before
ffmpeg -i 20180607-104614.wav -af 'asetrate=44080,aresample=44100' retimed.wav
@schenkman
schenkman / rest_based_routing.txt
Last active September 24, 2017 17:17
REST-based routing
The idea is to have the notion of a 'resource' that is being edited. This isn't a hard rule,
but generally most edit patterns follow this structure. Anything custom can be easily made
to be different.
Let's say I have the notion of a 'prospect' in the system that I can modify. The number of
attributes it has are unimportant at the moment, it's more about the high-level logical
resource that is being modified. Using REST-based resource routing, most frameworks
would give you something like this (this is Rails-based, but others are similar):
endpoint | verb | controller file | action (function to be executed)
@schenkman
schenkman / veh_avail_rate_rq.xml
Last active August 26, 2015 05:23
Vehicle availability search between LAX and SFO 2016-10-02 - 2016-10-07
<OTA_VehAvailRateRQ Version='2.000' xmlns='http://www.opentravel.org/OTA/2003/05'>
<POS>
<Source ISOCountry='US'>
<RequestorID ID='6BF4143044B340B19FCE76788EB11271' ID_Context='Vibe' MessagePassword='abc123' Type='29'>
<CompanyName Code='TESTPART' CodeContext='Vibe'></CompanyName>
</RequestorID>
</Source>
</POS>
<VehAvailRQCore>
<VehRentalCore PickUpDateTime='2016-10-03T15:00:00' ReturnDateTime='2016-10-07T10:00:00'>
module External::Api1
class AuthorizedApiController < ActionController::Base
protected
...
#If an array of objects is given in params key @resource, create them and create array of error hashes
def create_multiple(relation)
errors = []
class MercatorProjection
TILE_SIZE = 256
constructor: ->
@pixelOrigin_ = new google.maps.Point(TILE_SIZE / 2, TILE_SIZE / 2)
@pixelsPerLonDegree_ = TILE_SIZE / 360
@pixelsPerLonRadian_ = TILE_SIZE / (2 * Math.PI)
bound: (value, opt_min, opt_max) ->
value = Math.max(value, opt_min) if opt_min is not null
def media_mentions(start_date, end_date)
PersonNewsMention.media_mentions(self, start_date, end_date)
end
def PersonFacebookFollowerAggregate.metric_facebook_fans_dates(entity, dates)
raise(ArgumentError,"missing dates for query") if dates.nil? || dates.empty?
in_clause="AND date_collected IN ('#{dates.join('\',\'')}')"
if entity.class == PeerGroup
person_id_clause = "SELECT person_id FROM person_gov_organizations WHERE account_status_id = 1 AND person_id in (select member_id from peer_group_memberships where peer_group_id = #{entity.id} and membership_type_id = 1 and peer_group_membership_status_id = 1)"
else
person_id_clause = "#{entity.id}"
end
person_id_clause
query=<<-QUERY
  1. ActivityType
  • name:string
  • description:string
  • is_default:string
$ rails generate model activity_definition name:string description:string is_default:boolean
```ruby
<% flash.each do |name, msg| %>
<div class="alert fade in<%= flash_class(name) -%>">
<a class="close" data-dismiss="alert">&#215;</a>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
</div>
<% end %>
```
```erb
"params"=>{
"wt"=>"ruby",
"facet.range.end"=>"2012-08-26T00:00:00Z",
"q"=>"jobs",
"rows"=>"25",
"sort"=>"date desc",
"facet.range.start"=>"2012-06-25T00:00:00Z",
"fq"=>"((((((media_type:twitter) AND (twitter_is_retweet:true OR twitter_is_mention_by_name:true OR twitter_is_handle:true OR twitter_is_at_reply:true)) OR media_type:news) OR media_type:facebook) AND (related_groups:(us_house us_senate))) AND date:[2012-07-01T00:00:00Z TO 2012-08-22T00:00:00Z])",
"facet"=>"true",
"facet.range.gap"=>"+7DAYS",