This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Create YAML test fixtures from data in an existing database. | |
Defaults to development database. Set RAILS_ENV to override.' | |
task :extract_fixtures => :environment do | |
sql = "SELECT * FROM %s" | |
skip_tables = ["schema_info"] | |
ActiveRecord::Base.establish_connection | |
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name| | |
i = "000" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# god | |
# | |
# chkconfig: - 85 15 | |
# description: start, stop, restart God (bet you feel powerful) | |
# | |
RETVAL=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# texis | |
# | |
# chkconfig: - 85 15 | |
# | |
# description: start, stop, restart Texis | |
# | |
RETVAL=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XGET http://localhost:9200/youthletics/program/_search -d '{"query": { "match_all": {} }, | |
"facets": { | |
"avg_price": { | |
"terms_stats": { | |
"key_field": "_parent", | |
"value_field": "registration.cost", | |
"order": "mean" | |
}, | |
"facet_filter": { | |
"terms": { "sport": ["soccer"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# uses "null_value" to set default value if field is missing and then add that | |
# to the terms query. | |
# requires change to mapping that you index the necessary field with "null_value": "NOT APPLICABLE" | |
# "NOT APPLICABLE" can be anything you want. | |
curl -XGET http://localhost:9200/youthletics/organization/_search -d '{ | |
"query": { "match_all": {} }, | |
"filter": { | |
"has_child": { | |
"type": "program", | |
"filter": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first: notice the need to fully specify 'program' in 'script' field, due to | |
# https://github.com/elasticsearch/elasticsearch/issues/3285 | |
# | |
# this will create a custom_score based on the avg of program's registration cost | |
# the value is negated so that it sorts cheapest to highest | |
# | |
# this example filters organizations on programs: sport and community | |
curl -s -XGET http://172.19.0.48:9200/youthletics/organization/_search -d '{ | |
"query": { | |
"has_child": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reindex(name, &block) | |
Tire::Search::Scan.new(name, &block).each do |results| | |
documents = results.map do |document| | |
document.to_hash.except(:type, :_index, :_explanation, :_score, :highlight, :sort) | |
end | |
Tire.index(name).bulk_store documents | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule AdventOfCode do | |
def start(path) do | |
results = File.stream!(path, [:read, :utf8], :line) | |
|> Enum.map(&type_of/1) | |
|> my_map(%{}) | |
results["a"] | |
end | |
''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Wav do | |
defstruct size: 0, audio_format: 0, number_of_channels: 0, sample_rate: 0, | |
byte_rate: 0, block_align: 0, bits_per_sample: 0, bytes_in_data: 0, | |
samples: [] | |
@format %{1 => :pcm, 3 => :ieee_float, 6 => :alaw, 7 => :mulaw, 65534 => :extensible} | |
@doc """ | |
Parses a a WAV file with 16 byte fmt sub-chunk. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func copyConstraints(sourceView: UIView, toView: UIView) { | |
for constraint in sourceView.superview!.constraints { | |
if let firstItem = constraint.firstItem as? UIView where firstItem == sourceView { | |
sourceView.superview?.addConstraint(NSLayoutConstraint(item: toView, attribute: constraint.firstAttribute, relatedBy: constraint.relation, toItem: constraint.secondItem, attribute: constraint.secondAttribute, multiplier: constraint.multiplier, constant: constraint.constant)) | |
} else if let secondItem = constraint.secondItem as? UIView where secondItem == sourceView { | |
sourceView.superview?.addConstraint(NSLayoutConstraint(item: constraint.firstItem, attribute: constraint.firstAttribute, relatedBy: constraint.relation, toItem: toView, attribute: constraint.secondAttribute, multiplier: constraint.multiplier, constant: constraint.constant)) | |
} | |
} | |
} |
OlderNewer