query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
PINS spectral modeling (SMS) | def pins(start, dur, file, amp, *args)
assert_type(File.exists?(file), file, 2, "an existing file")
transposition, time_scaler, fftsize, highest_bin, max_peaks, attack = nil
optkey(args, binding,
[:transposition, 1.0], # this can be used to transpose the sound
[:time_scaler, 1.0], # this can make things happen faster
# (< 1.0)/slower (> 1.0) in the output
[:fftsize, 256], # should be a power of 2
# at 22050 srate, this is ok for
# sounds above 300Hz or so, below that
# you need 512 or 1024, at 44100,
# probably best to double these sizes
# -- it takes some searching
# sometimes.
[:highest_bin, 128], # how high in fft data should we search for pks
[:max_peaks, 16], # how many spectral peaks to track at the max
:attack) # whether to use original attack via time domain
# splice do the sliding fft shuffle,
# translate to polar coordinates, find
# spectral peaks, match with current,
# do some interesting transformation,
# resynthesize using oscils All the
# envelopes are created on the fly.
# max-peaks is how many of these peaks
# we are willing to track at any given
# time.
fil = make_file2sample(file)
file_duration = ws_duration(file)
fdr = make_vct(fftsize)
fdi = make_vct(fftsize)
window = make_fft_window(Blackman2_window, fftsize)
fftamps = make_vct(fftsize)
max_oscils = 2 * max_peaks
current_peak_freqs = make_vct(max_oscils)
last_peak_freqs = make_vct(max_oscils)
current_peak_amps = make_vct(max_oscils)
last_peak_amps = make_vct(max_oscils)
peak_amps = make_vct(max_peaks)
peak_freqs = make_vct(max_peaks)
resynth_oscils = make_array(max_oscils) do make_oscil(:frequency, 0) end
# run-time generated amplitude and frequency envelopes
amps = make_vct(max_oscils)
rates = make_vct(max_oscils)
freqs = make_vct(max_oscils)
sweeps = make_vct(max_oscils)
lowest_magnitude = 0.001
hop = (fftsize / 4).floor
outhop = (time_scaler * hop).floor
ifreq = 1.0 / outhop
ihifreq = hz2radians(ifreq)
# integrate Blackman-Harris window = .42323*window
fftscale = 1.0 / (fftsize * 0.42323)
# width and shift by fftsize
fft_mag = @srate / fftsize
furthest_away_accepted = 0.1
filptr = 0
cur_oscils = max_oscils
ramped = (attack or 0)
splice_attack = attack.kind_of?(Numeric)
attack_size = (attack or 1)
ramp_ind = 0
ramped_attack = make_vct(attack_size)
if (dur / time_scaler) > file_duration
error("%s is %1.3f seconds long, \
but we'll need %1.3f seconds of data for this note",
file, file_duration, dur / time_scaler)
end
trigger = outhop
vct_scale!(window, fftscale)
run_instrument(start, dur) do
if splice_attack
ramp = 1.0 / attack_size
# my experience in translating SMS, and rumor via Greg Sandell
# leads me to believe that there is in fact no way to model some
# attacks successfully in this manner, so this block simply
# splices the original attack on to the rest of the note.
# "attack" is the number of samples to include bodily.
out_val = amp * file2sample(fil, filptr)
filptr += 1
if filptr > attack_size
mult = 1.0
attack_size.times do |j|
ramped_attack[j] = mult * file2sample(fil, filptr + j)
mult -= ramp
end
splice_attack = false
end
# if out_val
out_val
else
if trigger >= outhop
peaks = 0
# get next block of data and apply window to it
trigger = 0
fftsize.times do |j|
fdr[j] = window[j] * file2sample(fil, filptr)
filptr += 1
end
vct_fill!(fdi, 0.0)
filptr -= fftsize - hop
# get the fft
mus_fft(fdr, fdi, fftsize, 1)
# change to polar coordinates (ignoring phases)
highest_bin.times do |j|
# no need to paw through the upper half
# (so (<= highest-bin (floor fft-size 2)))
x = fdr[j]
y = fdi[j]
fftamps[j] = 2.0 * sqrt(x * x + y * y)
end
max_oscils.times do |j|
last_peak_freqs[j] = current_peak_freqs[j]
last_peak_amps[j] = current_peak_amps[j]
current_peak_amps[j] = 0.0
end
vct_fill!(peak_amps, 0.0)
ra = fftamps[0]
la = ca = 0.0
# search for current peaks following Xavier Serra's recommendations in
# "A System for Sound Analysis/Transformation/Synthesis
# Based on a Deterministic Plus Stochastic Decomposition"
highest_bin.times do |j|
la, ca, ra = ca, ra, fftamps[j]
if ca > lowest_magnitude and ca > ra and ca > la
# found a local maximum above the current threshold
# (its bin number is j-1)
logla = log10(la)
logca = log10(ca)
logra = log10(ra)
offset = (0.5 * (logla - logra)) / (logla + -2 * logca + logra)
amp_1 = 10.0 ** (logca - (0.25 * (logla - logra) * offset))
freq = fft_mag * (j + offset - 1)
if peaks == max_peaks
# gotta either flush this peak,
# or find current lowest and flush him
minp = 0
minpeak = peak_amps[0]
1.upto(max_peaks - 1) do |k|
if peak_amps[k] < minpeak
minp = k
minpeak = peak_amps[k]
end
end
if amp_1 > minpeak
peak_freqs[minp] = freq
peak_amps[minp] = amp_1
end
else
peak_freqs[peaks] = freq
peak_amps[peaks] = amp_1
peaks += 1
end
end
end
# now we have the current peaks -- match them to the previous
# set and do something interesting with the result the end
# results are reflected in the updated values in the rates and
# sweeps arrays. search for fits between last and current,
# set rates/sweeps for those found try to go by largest amp
# first
peaks.times do |j|
maxp = 0
maxpk = peak_amps[0]
1.upto(max_peaks - 1) do |k|
if peak_amps[k] > maxpk
maxp = k
maxpk = peak_amps[k]
end
end
# now maxp points to next largest unmatched peak
if maxpk > 0.0
closestp = -1
closestamp = 10.0
current_freq = peak_freqs[maxp]
icf = 1.0 / current_freq
max_peaks.times do |k|
if last_peak_amps[k] > 0.0
closeness = icf * (last_peak_freqs[k] - current_freq).abs
if closeness < closestamp
closestamp = closeness
closestp = k
end
end
end
if closestamp < furthest_away_accepted
# peak_amp is transferred to appropriate current_amp and zeroed,
current_peak_amps[closestp] = peak_amps[maxp]
peak_amps[maxp] = 0.0
current_peak_freqs[closestp] = current_freq
end
end
end
max_peaks.times do |j|
if peak_amps[j] > 0.0
# find a place for a new oscil and start it up
new_place = -1
max_oscils.times do |k|
if last_peak_amps[k].zero? and current_peak_amps[k].zero?
new_place = k
break
end
end
current_peak_amps[new_place] = peak_amps[j]
peak_amps[j] = 0.0
current_peak_freqs[new_place] = peak_freqs[j]
last_peak_freqs[new_place] = peak_freqs[j]
set_mus_frequency(resynth_oscils[new_place],
transposition * peak_freqs[j])
end
end
cur_oscils = 0
max_oscils.times do |j|
rates[j] = ifreq * (current_peak_amps[j] - last_peak_amps[j])
if current_peak_amps[j].nonzero? or last_peak_amps[j].nonzero?
cur_oscils = j
end
sweeps[j] = ihifreq * transposition *
(current_peak_freqs[j] - last_peak_freqs[j])
end
cur_oscils += 1
end
# run oscils, update envelopes
trigger += 1
if ramped.zero?
sum = 0.0
else
sum = ramped_attack[ramp_ind]
ramp_ind += 1
ramped = 0 if ramp_ind == ramped
end
cur_oscils.times do |j|
if amps[j].nonzero? or rates[j].nonzero?
sum = sum + amps[j] * oscil(resynth_oscils[j], freqs[j])
amps[j] += rates[j]
freqs[j] += sweeps[j]
end
end
# else out_val
amp * sum
end
end
mus_close(fil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_spectra(sequence)\n @sequence = sequence\n #TODO Generate a ms1 \n ms1_entries = normalize(isotopic_distribution(sequence))\n #TODO Generate a ms2\n #ms2_entries = Fragmenter.new(fragmenter_opts).fragment(sequence, fragment_opts)\n #spectrum_to_mgf(ms1_entries)\n ms1... | [
"0.57836103",
"0.5285602",
"0.52160937",
"0.52014357",
"0.516875",
"0.5152",
"0.51505023",
"0.5116517",
"0.50842845",
"0.5029122",
"0.50253695",
"0.5019076",
"0.49483973",
"0.4886783",
"0.4876786",
"0.48750165",
"0.4869887",
"0.48670226",
"0.48564392",
"0.48519948",
"0.484763... | 0.44178036 | 97 |
ZN notches are spaced at srate/len, feedforward sets depth thereof so sweep of len from 20 to 100 sweeps the notches down from 1000 Hz to ca 200 Hz so we hear our downward glissando beneath the pulses. | def zn(start, dur, freq, amp, length1, length2, feedforward)
s = make_pulse_train(:frequency, freq)
d0 = make_notch(:size, length1,
:max_size, [length1, length2].max + 1,
:scaler, feedforward)
zenv = make_env(:envelope, [0, 0, 1, 1],
:scaler, length2 - length1,
:duration, dur)
run_instrument(start, dur) do
notch(d0, amp * pulse_train(s), env(zenv))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stair_climb(n)\n end",
"def skynet (target, blanks_words_sizes, index, track, trace)\n\tif index == 1\n\t\t$seed[ blanks_words_sizes[1] ][:num_groups].each do |key, obj|\n\t\t\tif(track + key < target && key != 0) \n\t\t\t\tif( $seed[blanks_words_sizes[0]][:num_groups][target - (track+key)] )\n\t\t\t\t\tc =... | [
"0.5272126",
"0.4953067",
"0.49069375",
"0.4877517",
"0.4769857",
"0.47647578",
"0.47456944",
"0.47401306",
"0.47343642",
"0.47003433",
"0.46588305",
"0.46465102",
"0.46434328",
"0.46374062",
"0.46351227",
"0.46074805",
"0.46019638",
"0.45907182",
"0.4589098",
"0.45714143",
"... | 0.58084565 | 0 |
EXPSND granulate with envelopes on the expansion amount, segment envelope shape, segment length, hop length, and input file resampling rate | def exp_snd(file, start, dur, amp,
exp_amt = 1.0, ramp = 0.4, seglen = 0.15,
sr = 1.0, hop = 0.05, ampenv = nil)
assert_type(File.exists?(file), file, 0, "an existing file")
f0 = make_ws_reader(file, :start, 0)
expenv = make_env(:envelope,
(exp_amt.kind_of?(Array) ?
exp_amt : [0, exp_amt, 1, exp_amt]),
:duration, dur)
lenenv = make_env(:envelope,
(seglen.kind_of?(Array) ?
seglen : [0, seglen, 1, seglen]),
:duration, dur)
max_seg_len, initial_seg_len = if seglen
if seglen.kind_of?(Array)
[max_envelope(seglen), seglen[1]]
else
[seglen, seglen]
end
else
[0.15, 0.15]
end
scaler_amp = ((max_seg_len > 0.15) ? ((0.6 * 0.15) / max_seg_len) : 0.6)
srenv = make_env(:envelope, (sr.kind_of?(Array) ? sr : [0, sr, 1, sr]),
:duration, dur)
rampdata = (ramp.kind_of?(Array) ? ramp : [0, ramp, 1, ramp])
rampenv = make_env(:envelope, rampdata, :duration, dur)
initial_ramp_time = if ramp
if ramp.kind_of?(Array)
ramp[1]
else
ramp
end
else
0.4
end
hopenv = make_env(:envelope, (hop.kind_of?(Array) ? hop : [0, hop, 1, hop]),
:duration, dur)
max_out_hop, initial_out_hop = if hop
if hop.kind_of?(Array)
[max_envelope(hop), hop[1]]
else
[hop, hop]
end
else
[0.05, 0.05]
end
min_exp_amt, initial_exp_amt = if exp_amt
if exp_amt.kind_of?(Array)
[min_envelope(exp_amt), exp_amt[1]]
else
[exp_amt, exp_amt]
end
else
[1.0, 1.0]
end
max_in_hop = max_out_hop / min_exp_amt.to_f
max_len = (@srate * ([max_out_hop, max_in_hop].max + max_seg_len)).ceil
ampe = make_env(:envelope, (ampenv or [0, 0, 0.5, 1, 1, 0]),
:scaler, amp,
:duration, dur)
ex_a = make_granulate(:input, lambda do |dir| ws_readin(f0) end,
:expansion, initial_exp_amt,
:max_size, max_len,
:ramp, initial_ramp_time,
:hop, initial_out_hop,
:length, initial_seg_len,
:scaler, scaler_amp)
ex_samp = next_samp = 0.0
vol = env(ampe)
val_a0 = vol * granulate(ex_a)
val_a1 = vol * granulate(ex_a)
if min_envelope(rampdata) <= 0.0 or max_envelope(rampdata) >= 0.5
error("ramp argument to expand must always be between 0.0 and 0.5: %1.3f",
ramp)
else
run_instrument(start, dur) do
expa = env(expenv) # current expansion amount
segl = env(lenenv) # current segment length
resa = env(srenv) # current resampling increment
rmpl = env(rampenv) # current ramp length (0 to 0.5)
hp = env(hopenv) # current hop size
# now we set the granulate generator internal state to reflect all
# these envelopes
sl = (segl * @srate).floor
rl = (rmpl * sl).floor
vol = env(ampe)
set_mus_length(ex_a, sl)
set_mus_ramp(ex_a, rl)
set_mus_frequency(ex_a, hp)
set_mus_increment(ex_a, expa)
next_samp += resa
if next_samp > (ex_samp + 1)
(next_samp - ex_samp).floor.times do
val_a0, val_a1 = val_a1, vol * granulate(ex_a)
ex_samp += 1
end
end
if next_samp == ex_samp
val_a0
else
val_a0 + (next_samp - ex_samp) * (val_a1 - val_a0)
end
end
close_ws_reader(f0)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extend(envelope)\r\n e = Envelope.from_points([Point.from_x_y(lower_corner.x,lower_corner.y),\r\n Point.from_x_y(upper_corner.x,upper_corner.y)],srid,with_z)\r\n e.extend!(envelope)\r\n e\r\n end",
"def ex1\n WaveFile::Reader.new(\n File.expand_path('../... | [
"0.49280924",
"0.49132264",
"0.474051",
"0.4614807",
"0.45625597",
"0.45611855",
"0.4559586",
"0.45442593",
"0.45315617",
"0.45208248",
"0.45125577",
"0.4509545",
"0.44486612",
"0.4420583",
"0.44125283",
"0.4377018",
"0.43324438",
"0.4319114",
"0.43043867",
"0.42991754",
"0.4... | 0.6176274 | 0 |
ANOI a kind of noise reduction ongoing average spectrum is squelched to some extent obviously aimed at intermittent signal in background noise this is based on Perry Cook's Scrubber.m | def anoi(infile, start, dur, fftsize = 128, amp_scaler = 1.0, r = TWO_PI)
assert_type(File.exists?(infile), infile, 0, "an existing file")
freq_inc = (fftsize / 2).floor
fdi = make_vct(fftsize)
fdr = make_vct(fftsize)
spectr = make_vct(freq_inc, 1.0)
scales = make_vct(freq_inc, 1.0)
diffs = make_vct(freq_inc)
win = make_fft_window(Blackman2_window, fftsize)
k = 0
amp = 0.0
incr = amp_scaler * 4.0 / @srate
file = make_file2sample(infile)
radius = 1.0 - r / fftsize.to_f
bin = @srate / fftsize
fs = make_array(freq_inc) do |i| make_formant(i * bin, radius) end
samp = 0
run_instrument(start, dur) do
inval = file2sample(file, samp)
samp += 1
fdr[k] = inval
k += 1
amp += incr if amp < amp_scaler
if k >= fftsize
k = 0
spectrum(fdr, fdi, win, 1)
freq_inc.times do |j|
spectr[j] = 0.9 * spectr[j] + 0.1 * fdr[j]
if spectr[j] >= fdr[j]
diffs[j] = scales[j] / -fftsize
else
diffs[j] = ((fdr[j] - spectr[j]) / fdr[j] - scales[j]) / fftsize
end
end
end
outval = 0.0
1.upto(freq_inc - 1) do |j|
cur_scale = scales[j]
outval = outval + cur_scale * formant(fs[j], inval)
scales[j] += diffs[j]
end
amp * outval
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_noise\n\t\tputs @noise\n\tend",
"def remove_noise(data)\n noise(data, :-)\n end",
"def noise?\n @cr[0xd][7] == 1\n end",
"def make_noise\n noise_seed = 16383\n lambda do |amp|\n noise_seed = (noise_seed * 1103515245 + 12345) & 0xffffffff\n # ;; (bil) added the logand ... | [
"0.5847098",
"0.58454466",
"0.5799834",
"0.56927305",
"0.5671018",
"0.5640819",
"0.56014603",
"0.556315",
"0.5553594",
"0.54892147",
"0.5461079",
"0.5442339",
"0.5384997",
"0.52779055",
"0.5255711",
"0.5212718",
"0.5200598",
"0.51041365",
"0.5083206",
"0.5076445",
"0.5063521"... | 0.45426208 | 86 |
=begin Date: Fri, 25 Sep 1998 09:56:41 +0300 | def fullmix(in_file,
start = 0.0,
outdur = nil,
inbeg = 0.0,
matrix = nil,
srate = nil,
reverb_amount = 0.05)
assert_type(File.exists?(in_file), in_file, 0, "an existing file")
dur = Float((outdur or (ws_duration(in_file) / Float((srate or 1.0)).abs)))
in_chans = ws_channels(in_file)
inloc = (Float(inbeg) * ws_srate(in_file)).round
mx = file = envs = rev_mx = revframe = false
if srate
file = make_array(in_chans) do |chn|
make_ws_reader(in_file, :start, inloc, :channel, chn)
end
else
file = in_file
end
mx = if matrix
make_mixer([in_chans, @channels].max)
else
make_scalar_mixer([in_chans, @channels].max, 1.0)
end
if @ws_reverb and reverb_amount.positive?
rev_mx = make_mixer(in_chans)
in_chans.times do |chn|
mixer_set!(rev_mx, chn, 0, reverb_amount)
end
revframe = make_frame(1)
end
case matrix
when Array
in_chans.times do |ichn|
inlist = matrix[ichn]
@channels.times do |ochn|
outn = inlist[ochn]
case outn
when Numeric
mixer_set!(mx, ichn, ochn, outn)
when Array, Mus
unless envs
envs = make_array(in_chans) do
make_array(@channels, false)
end
end
if env?(outn)
envs[ichn][ochn] = outn
else
envs[ichn][ochn] = make_env(:envelope, outn, :duration, dur)
end
else
Snd.warning("unknown element in matrix: %s", outn.inspect)
end
end
end
when Numeric
# matrix is a number in this case (a global scaler)
in_chans.times do |i|
if i < @channels
mixer_set!(mx, i, i, matrix)
end
end
end
start = Float(start)
# to satisfy with_sound-option :info and :notehook
with_sound_info(get_func_name, start, dur)
run_fullmix(start, dur, in_chans, srate,
inloc, file, mx, rev_mx, revframe, envs)
array?(file) and file.each do |rd| close_ws_reader(rd) end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date; end",
"def date; end",
"def date; end",
"def date; end",
"def date()\n\t\t(@start_date.to_time + (10**9)).to_date\n\tend",
"def start_date\n @raw.first.date\n end",
"def read_date; end",
"def immersive_start_date\n @p0_start_date + 63\n end",
"def date() self[:date]; end",
"... | [
"0.66260016",
"0.66260016",
"0.66260016",
"0.66260016",
"0.62534314",
"0.6219837",
"0.6205985",
"0.61192244",
"0.60680443",
"0.60389847",
"0.60013515",
"0.5947823",
"0.59177655",
"0.5866471",
"0.58378476",
"0.5831959",
"0.5824018",
"0.5811345",
"0.5811345",
"0.5811345",
"0.58... | 0.0 | -1 |
Original header: ;;; grani: a granular synthesis instrument ;;; by Fernando LopezLezcano ;;; ;;; ;;; Original grani.ins instrument written for the 220a Course by ;;; Fernando LopezLezcano & Juan Pampin, November 6 1996 ;;; ;;; Mar 21 1997: working with hop and graindur envelopes ;;; Mar 22 1997: working with src envelope (grain wise) & src spread ;;; Jan 26 1998: started work on new version ;;; Nov 7 1998: input soundfile duration calculation wrong ;;; Nov 10 1998: bug in insamples (thanks to Kristopher D. Giesing for this one) ;;; Dec 20 1998: added standard locsig code ;;; Feb 19 1999: added "nil" as default value of where to avoid warning (by bill) ;;; Jan 10 2000: added inputchannel to select which channel of the input file ;;; to process. ;;; added grainstartinseconds to be able to specify input file ;;; locations in seconds for the grainstart envelope ;;; May 06 2002: fixed array passing of wherebins in clisp (reported by Charles ;;; Nichols and jennifer l doering ;;; Mar 27 2003: added option for sending grains to all channels (requested by ;;; Oded BenTal) ;;; calculate a random spread around a center of 0 | def random_spread(spread)
spread.nonzero? ? (random(spread) - spread / 2.0) : 0.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instrument(midiIn, duration: 1.0, gmBank: \"000\", gmPatch: \"000\", gmPathDir: \"C:/Users/Michael Sutton/Midiloop/default/\", amp: 1.0, attack: 0.01, decay: 0.3, sustain: 0.5, release: 1.0, lpf: 128, hpf: 1, bpm: 60, pan: 0.0, glIn: \"none\", glFunc: \"none\", midiFlag: \"N\") \r\n\r\n #puts \"xgmPathDir: \... | [
"0.6923045",
"0.6734955",
"0.6528273",
"0.6395042",
"0.5930524",
"0.5816152",
"0.5737341",
"0.56337917",
"0.5595156",
"0.5542218",
"0.5458213",
"0.54286003",
"0.54208213",
"0.540897",
"0.5353326",
"0.53453386",
"0.5342185",
"0.5338569",
"0.5320377",
"0.526772",
"0.5231841",
... | 0.0 | -1 |
;;; create a constant envelope if argument is a number | def envelope_or_number(val)
assert_type((number?(val) or array?(val) or vct?(val)),
val, 0, "a number, an array or a vct")
case val
when Numeric
[0, Float(val), 1, Float(val)]
when Vct
val.to_a
when Array
val
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number=(_arg0); end",
"def define_num\n self.num ||= from.new_num_message\n end",
"def Integer(p0) end",
"def extraNumber(a, b, c)\n \nend",
"def SAC15=(arg)",
"def const(n1)\n # Raise error if the input is not an integer\n if not(n1.is_a?(Integer))\n raise \"can only calculate int\"\n... | [
"0.5810234",
"0.52053994",
"0.5191658",
"0.5096847",
"0.50714135",
"0.5038422",
"0.50289786",
"0.50119144",
"0.5000186",
"0.49994466",
"0.49726236",
"0.49653307",
"0.49460354",
"0.49416947",
"0.49399638",
"0.49368304",
"0.49315026",
"0.49137664",
"0.48839325",
"0.48797885",
"... | 0.63017464 | 0 |
;;; create a vct from an envelope | def make_gr_env(env, length = 512)
length_1 = (length - 1).to_f
make_vct!(length) do |i|
envelope_interp(i / length_1, env)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_test_envelope\n Docusign::Envelope.new.tap do |e|\n doc = Docusign::Document.new\n tabs = doc.tabs do |d| \n d.tab :name => 'Make'\n d.tab :name => 'Model'\n d.tab :name => 'VIN'\n end\n \n e.tabs = tabs\n \n e.recipients = [\n Docusign::R... | [
"0.5935356",
"0.57884294",
"0.5710548",
"0.56965166",
"0.568883",
"0.5687595",
"0.5537261",
"0.5471054",
"0.5448079",
"0.54183686",
"0.5339167",
"0.53312606",
"0.53312606",
"0.5302153",
"0.52281654",
"0.51939213",
"0.5156443",
"0.5123229",
"0.5119298",
"0.5085491",
"0.5042813... | 0.47356173 | 32 |
make_fm2(1000, 100, 1000, 100, 0, 0, HALF_PI, HALF_PI) make_fm2(1000, 100, 1000, 100, 0, 0, 0, HALF_PI) | def make_fm2(f1, f2, f3, f4, p1, p2, p3, p4)
Fm2.new(f1, f2, f3, f4, p1, p2, p3, p4)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metres_to_furlongs(m)\n (m / METER_TO_FURLONG).round(2)\n end",
"def mtof(pitch)\n 440.0 * (2.0 ** ((pitch.to_f-69)/12))\n end",
"def ftom(pitch)\n (69 + 12 * (Math.log2(pitch / 440.0))).round\n end",
"def ctof (degres)\n return ((degres * 1.8) + 32)\nend",
"def ftoc(fahrenheit)\n\n (fahre... | [
"0.5937631",
"0.57684475",
"0.5719093",
"0.5703813",
"0.5596452",
"0.5585686",
"0.55367607",
"0.5504127",
"0.55005765",
"0.5470029",
"0.5458825",
"0.544932",
"0.54341733",
"0.53765",
"0.53667325",
"0.53604615",
"0.53419816",
"0.53126264",
"0.5292721",
"0.52596986",
"0.5257812... | 0.71164906 | 0 |
Create a resource object, associate it with a client, and set its properties. | def initialize(client, params = {}, api_ver = nil)
super
# Default values:
@data['type'] ||= 'StoragePoolV2'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(resource)\n resource.client = self\n resource.create\n end",
"def create_resource object\n object.save\n end",
"def new_resource(*args)\n Freemle::Client::Resource.new(*args)\n end",
"def create_resource\n class_name.new(get_secure_params).tap do |model|\n ... | [
"0.8125146",
"0.6744726",
"0.66518265",
"0.6636486",
"0.6615964",
"0.6558532",
"0.6549547",
"0.6484018",
"0.63969696",
"0.62349766",
"0.6205153",
"0.6198438",
"0.61950725",
"0.61766493",
"0.61706775",
"0.6143044",
"0.6135432",
"0.6131366",
"0.6128547",
"0.61206716",
"0.611114... | 0.0 | -1 |
Method is not available | def create
unavailable_method
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def methods; end",
"def methods; end",
"def methods; end",
... | [
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.72013324",
"0.72013324",
"0.72013324",
"0.72013324",
"0.7130576",
"0.7105018",
"0.70910186",
"0.6906028",
"0.68597037... | 0.0 | -1 |
Method is not available | def delete
unavailable_method
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def methods; end",
"def methods; end",
"def methods; end",
... | [
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.72013324",
"0.72013324",
"0.72013324",
"0.72013324",
"0.7130576",
"0.7105018",
"0.70910186",
"0.6906028",
"0.68597037... | 0.0 | -1 |
Method is not available | def update
unavailable_method
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def methods; end",
"def methods; end",
"def methods; end",
... | [
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.7300936",
"0.72013324",
"0.72013324",
"0.72013324",
"0.72013324",
"0.7130576",
"0.7105018",
"0.70910186",
"0.6906028",
"0.68597037... | 0.0 | -1 |
Sets the storage system | def set_storage_system(storage_system)
fail IncompleteResource, 'Please set the storage system\'s uri attribute!' unless storage_system['uri']
set('storageSystemUri', storage_system['uri'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_storage_system(storage_system)\n storage_system.retrieve! unless storage_system['uri']\n @data['storageSystemUri'] = storage_system['uri']\n end",
"def set_storage_system(storage_system)\n assure_uri(storage_system)\n set('storageSystemUri', storage_system['uri'])\n ... | [
"0.80348253",
"0.7927269",
"0.72177297",
"0.70855457",
"0.70855457",
"0.70855457",
"0.70855457",
"0.6847232",
"0.6772803",
"0.67568845",
"0.66900444",
"0.66253483",
"0.66225356",
"0.65248877",
"0.6439559",
"0.64390993",
"0.64247733",
"0.6319408",
"0.6296736",
"0.6260447",
"0.... | 0.7641839 | 2 |
GET /entrants GET /entrants.json | def index
event_id = current_event.id
event_id = params[:event_id] if params.has_key?(:event_id)
@entrants = Entrant.all(:conditions => "event_id = #{event_id}",
:order => "number ASC")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @entrants }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tenants = keystone.tenants\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tenants }\n end\n end",
"def index\n @entrants = Entrant.all\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",... | [
"0.7156517",
"0.7072602",
"0.67927784",
"0.66921234",
"0.65667504",
"0.65239096",
"0.6444807",
"0.6444807",
"0.641861",
"0.63111377",
"0.6298406",
"0.6293878",
"0.62902796",
"0.627166",
"0.6255883",
"0.62360364",
"0.6226203",
"0.62258124",
"0.6211122",
"0.6203738",
"0.6201343... | 0.6511033 | 6 |
GET /entrants/1 GET /entrants/1.json | def show
@entrant = Entrant.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @entrant }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tenants = keystone.tenants\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tenants }\n end\n end",
"def index\n @entrants = Entrant.all\n end",
"def show\n @lent = Lent.find(params[:id])\n\n respond_to do |format|\n form... | [
"0.70026964",
"0.67630833",
"0.6711924",
"0.66194504",
"0.6568414",
"0.6487117",
"0.6467907",
"0.6427158",
"0.64258575",
"0.6425476",
"0.64174247",
"0.6416487",
"0.64102817",
"0.64029825",
"0.63689905",
"0.63597906",
"0.6354728",
"0.6330706",
"0.63052344",
"0.6298295",
"0.629... | 0.6654127 | 4 |
GET /entrants/new GET /entrants/new.json | def new
@entrant = Entrant.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @entrant }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @entity = Entity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end",
"def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n... | [
"0.74713486",
"0.7382461",
"0.7299258",
"0.72564584",
"0.7240797",
"0.7235477",
"0.7232563",
"0.72276765",
"0.7227041",
"0.7188985",
"0.7167517",
"0.71474165",
"0.7087338",
"0.70839113",
"0.70626605",
"0.7062392",
"0.7040465",
"0.7033907",
"0.70281416",
"0.7025966",
"0.701464... | 0.7304586 | 2 |
POST /entrants POST /entrants.json | def create
@entrant = Entrant.new(params[:entrant])
respond_to do |format|
if @entrant.save
format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }
format.json { render json: @entrant, status: :created, location: @entrant }
else
format.html { render action: "new" }
format.json { render json: @entrant.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tent = Tent.new(tent_params)\n\n respond_to do |format|\n if @tent.save\n format.html { redirect_to admin_tent_path(@tent), notice: 'Tent was successfully created.' }\n format.json { render :show, status: :created, location: @tent }\n else\n format.html { render :... | [
"0.66403866",
"0.6398506",
"0.62372804",
"0.62319624",
"0.61944044",
"0.611078",
"0.60820454",
"0.6057062",
"0.60123485",
"0.60098344",
"0.600149",
"0.5956446",
"0.59527034",
"0.59469235",
"0.5945087",
"0.59432864",
"0.5935487",
"0.5918529",
"0.5888301",
"0.5884158",
"0.58825... | 0.63746834 | 2 |
PUT /entrants/1 PUT /entrants/1.json | def update
@entrant = Entrant.find(params[:id])
respond_to do |format|
if @entrant.update_attributes(params[:entrant])
format.html { redirect_to @entrant, notice: 'Entrant was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @entrant.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants... | [
"0.6817103",
"0.6594518",
"0.62007433",
"0.6150762",
"0.6145356",
"0.6029069",
"0.6009669",
"0.5986504",
"0.5972245",
"0.59718823",
"0.5965157",
"0.59621704",
"0.59484655",
"0.5916364",
"0.59069204",
"0.5897272",
"0.58945733",
"0.58935237",
"0.5880719",
"0.5876598",
"0.586637... | 0.6171229 | 3 |
DELETE /entrants/1 DELETE /entrants/1.json | def destroy
@entrant = Entrant.find(params[:id])
@entrant.destroy
respond_to do |format|
format.html { redirect_to entrants_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:... | [
"0.7297012",
"0.7178114",
"0.7063629",
"0.69769406",
"0.6956626",
"0.68384844",
"0.6830208",
"0.6811619",
"0.6789159",
"0.6788605",
"0.67817456",
"0.67540634",
"0.67505205",
"0.67502064",
"0.6733817",
"0.67272204",
"0.6726507",
"0.67138237",
"0.6707283",
"0.6704891",
"0.66922... | 0.67912835 | 8 |
def find_by_credit_card_expiration_date(x) repository.find do |transaction| transaction.credit_card_expiration_date == x end end def find_all_by_credit_card_expiration_date(x) repository.select do |transaction| transaction.all_by_credit_card_expiration_date == x end end | def find_by_result(x)
repository.find do |transaction|
transaction.result == x
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_cards_like_this\n user.creditcards.where(:cc_type => cc_type, :last_digits => last_digits, :first_name => first_name, :last_name => last_name, :year => year, :month => month)\n end",
"def get_supplier_payments0(fecha1,fecha2)\n @vouchers = SupplierPayment.where([\" company_id = ? AND fecha1 >= ? a... | [
"0.6270271",
"0.58779496",
"0.58779496",
"0.58779496",
"0.5747922",
"0.5694391",
"0.56809694",
"0.56809694",
"0.5633352",
"0.5614267",
"0.5576389",
"0.5494667",
"0.54752237",
"0.54546654",
"0.5437822",
"0.54233295",
"0.5414413",
"0.5414413",
"0.5408999",
"0.5399703",
"0.53831... | 0.56416684 | 8 |
Opens a GPX file. Both "abc.shp" and "abc" are accepted. | def initialize(file, *opts) # with_z = true, with_m = true)
@file_root = file.gsub(/\.gpx$/i, '')
fail MalformedGpxException.new('Missing GPX File') unless
File.exist? @file_root + '.gpx'
@points, @envelope = [], nil
@gpx = File.open(@file_root + '.gpx', 'rb')
opt = opts.reduce({}) { |a, e| e.merge(a) }
parse_file(opt[:with_z], opt[:with_m])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_geojson_file_as_param\n file_name = \"#{File.dirname(__FILE__)}/geojson_files/line_string_data.json\"\n file = File.new(file_name, 'r')\n gpx_file = GPX::GeoJSON.convert_to_gpx(geojson_file: file)\n assert_equal(1, gpx_file.tracks.size)\n end",
"def xdg_open(file_name)\n pid = spawn(\"xdg-... | [
"0.58468276",
"0.5699551",
"0.565865",
"0.5562059",
"0.5471015",
"0.54494643",
"0.52980566",
"0.5263366",
"0.5261353",
"0.5221667",
"0.51890594",
"0.5164526",
"0.5118278",
"0.50922513",
"0.50501853",
"0.50415015",
"0.50279564",
"0.5005052",
"0.49848092",
"0.49810374",
"0.4961... | 0.5819036 | 1 |
force the reopening of the files compsing the shp. Close before calling this. | def reload!
initialize(@file_root)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reopen\n end",
"def after_fork\n @files_to_reopen.each do |file|\n begin\n file.reopen file.path, \"a+\"\n file.sync = true\n rescue ::IOError # rubocop:disable HandleExceptions\n end\n end\n end",
"def reopen!\n synchronize do\n @outputs.each do... | [
"0.6792095",
"0.66003346",
"0.6574545",
"0.64169854",
"0.62388486",
"0.6188197",
"0.61744153",
"0.6122945",
"0.6077614",
"0.6036686",
"0.6036496",
"0.6024062",
"0.5995846",
"0.5965408",
"0.5919658",
"0.5912975",
"0.59056467",
"0.5879778",
"0.5879778",
"0.58450454",
"0.5834711... | 0.0 | -1 |
Tests if the file has no record | def empty?
record_count == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty?\n @records.empty?\n end",
"def empty?\n RECORDS.each do |name, _|\n return false unless @records[name].empty?\n end\n true\n end",
"def empty?\n load # make sure we have determined the number of fetched records\n\n @number_of_records.zero?\n end",
"def... | [
"0.69075453",
"0.6842216",
"0.6738046",
"0.6650366",
"0.6527164",
"0.64851314",
"0.6479413",
"0.636762",
"0.63580364",
"0.6308561",
"0.6303019",
"0.62895536",
"0.62165254",
"0.621593",
"0.61913615",
"0.616489",
"0.611625",
"0.6074608",
"0.6050477",
"0.603866",
"0.60203767",
... | 0.6848229 | 1 |
Goes through each record | def each
(0...record_count).each do |i|
yield get_record(i)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each\n @records.each { |record| \n yield record\n }\n end",
"def each_record\n return enum_for(:each_record) unless block_given?\n\n while (rec = record)\n yield rec\n end\n end",
"def each(&block)\n @records.each(&block)\n end",
"d... | [
"0.7418512",
"0.7409026",
"0.72745264",
"0.7146968",
"0.7032786",
"0.7005057",
"0.69991404",
"0.6891028",
"0.6879214",
"0.6833103",
"0.68286085",
"0.67017424",
"0.65816087",
"0.65815717",
"0.6552413",
"0.6542977",
"0.6542977",
"0.6533044",
"0.64159286",
"0.63447785",
"0.63284... | 0.7602569 | 0 |
Returns all the records | def records
@points
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\r\n copy_and_return(@records)\r\n end",
"def all\n all_records = Array.new(self.real_size)\n\n self.each_with_index { |record, index| all_records[index] = record }\n\n all_records\n end",
"def all \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_... | [
"0.8567718",
"0.77479726",
"0.7660207",
"0.761782",
"0.7602786",
"0.75378376",
"0.74453384",
"0.7436662",
"0.74264795",
"0.7423236",
"0.7383197",
"0.7383197",
"0.7383197",
"0.7383197",
"0.7383197",
"0.73066074",
"0.72771853",
"0.72470075",
"0.72298765",
"0.72223955",
"0.72038... | 0.0 | -1 |
Return the GPX file as LineString | def as_line_string
GeoRuby::SimpleFeatures::LineString.from_points(@points)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geometry\n linestring\n end",
"def create_linestring(coords)\n Rails.logger.debug \"RgeoGeometryAdapter Creating line string geometry from #{coords.inspect}\"\n a = []\n coords.each do |c|\n a << @geometry_factory.point(c.first, c.last) unless c.empty?\n end\n @geometry_factor... | [
"0.6433525",
"0.6026175",
"0.591478",
"0.55796576",
"0.55795187",
"0.5393304",
"0.53655887",
"0.5342207",
"0.5282409",
"0.5249464",
"0.52483445",
"0.52164185",
"0.52139175",
"0.52064633",
"0.51891726",
"0.5171068",
"0.51626235",
"0.5142711",
"0.51358414",
"0.51264656",
"0.510... | 0.6292192 | 1 |
Return the GPX file as a Polygon If the GPX isn't closed, a line from the first to the last point will be created to close it. | def as_polygon
GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : (@points + [@points[0].clone])])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def envelope_to_polygon\n exp = /^\\s*ENVELOPE\\(\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*\n \\)\\s*$/x # uses 'x' option for free-spacing mode\n bbox_match = exp.match(geom)... | [
"0.61699325",
"0.6045437",
"0.5787718",
"0.5592713",
"0.55554956",
"0.55024534",
"0.5481895",
"0.5456083",
"0.54520714",
"0.5444692",
"0.5316542",
"0.52792484",
"0.52744484",
"0.52731264",
"0.52625996",
"0.5246317",
"0.5246317",
"0.5205164",
"0.520479",
"0.519501",
"0.5182125... | 0.67146856 | 0 |
wpt => waypoint => TODO? rte(pt) => route trk(pt) => track / | def parse_file(with_z, with_m)
data = @gpx.read
@file_mode = data =~ /trkpt/ ? '//trkpt' : (data =~ /wpt/ ? '//wpt' : '//rtept')
Nokogiri.HTML(data).search(@file_mode).each do |tp|
z = z.inner_text.to_f if with_z && z = tp.at('ele')
m = m.inner_text if with_m && m = tp.at('time')
@points << GeoRuby::SimpleFeatures::Point.from_coordinates([tp['lon'].to_f, tp['lat'].to_f, z, m], 4326, with_z, with_m)
end
close
@record_count = @points.length
envelope
rescue => e
raise MalformedGpxException.new("Bad GPX. Error: #{e}")
# trackpoint.at("gpxdata:hr").nil? # heartrate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def waypointBehaviour _args\n \"waypointBehaviour _args;\" \n end",
"def waypointPosition _args\n \"waypointPosition _args;\" \n end",
"def waypointType _args\n \"waypointType _args;\" \n end",
"def waypointDescription _args\n \"waypointDescription _args;\" \n end",
"def Fol... | [
"0.6147748",
"0.6115486",
"0.6099374",
"0.60568136",
"0.6040667",
"0.60086393",
"0.5883397",
"0.58632183",
"0.5791333",
"0.5749868",
"0.57256925",
"0.57222736",
"0.5716848",
"0.56912506",
"0.56675386",
"0.56657296",
"0.56626326",
"0.56587267",
"0.5653088",
"0.56512815",
"0.56... | 0.0 | -1 |
handles thread pooling and new connections | def run
loop do
#Kernel.exit
if @workQ.size < (@pool_size-1)
Thread.start(@replicaServer.accept) do | client |
@workQ.push 1
message_handler(client)
@workQ.pop(true)
end
else
# if thread pool is full
sleep 5
client.close
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_connection_pooling\n # Verify active connections and remove and disconnect connections\n # associated with stale threads.\n ActiveRecord::Base.verify_active_connections!\n\n yield\n\n # This code checks in the connection being used by the current thread back\n # into the conn... | [
"0.7365816",
"0.72211725",
"0.72211725",
"0.714933",
"0.714933",
"0.70937407",
"0.70826054",
"0.68892395",
"0.68814987",
"0.68724954",
"0.68630743",
"0.6794447",
"0.6786297",
"0.6750196",
"0.6615134",
"0.6608763",
"0.6576628",
"0.6549581",
"0.6535726",
"0.6466981",
"0.6420747... | 0.6569946 | 17 |
backs up updated files | def backup_request(client, filename, message)
filename = "BACKUP_#{filename}"
aFile = File.open(filename, 'w+')
if aFile
File.write(filename, message)
puts "Updated: #{filename}"
else
client.puts "ERROR: Unable to open file #{filename}"
end
aFile.close
return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollback!\n files.each { |file, contents| rollback_file(file, contents) }\n @files = {}\n end",
"def do_backed_up\n self.update_attributes(:needs_initial_scan => false)\n update_last_backup_times\n end",
"def commit\n # TODO\n # Update ./docProps\n # app.xml slides, not... | [
"0.6620699",
"0.65795743",
"0.61980516",
"0.611547",
"0.60325754",
"0.6004525",
"0.5952378",
"0.58459675",
"0.5763618",
"0.57563156",
"0.57346714",
"0.5733784",
"0.5720835",
"0.56950253",
"0.5663259",
"0.5649501",
"0.5649495",
"0.56178194",
"0.56170446",
"0.5592655",
"0.55863... | 0.0 | -1 |
def index end def show end def new end | def create
assignment = Assignment.new assignment_params
contract = Contract.find_by(id: assignment_params[:contract_id])
# staff = Staff.find_by(id: assignment_params[:staff_id])
flat = Flat.find_by(id: contract.flat_id)
p "flat : " + flat.to_s
assignment.created_at = DateTime.now
# only if have parent
# assignment.book_id = params[:book_id]
if assignment.save
flat_serializer = parse_json flat
assignment_serializer = parse_json assignment
json_response "Created assignment successfully", true, {assignment: assignment_serializer, flat: flat_serializer}, :ok
else
json_response "Create assignment failed", false, {}, :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n index\n end",
"def index\n new\n end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; en... | [
"0.8015869",
"0.8000358",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
"0.76781213",
... | 0.0 | -1 |
runs a single instruction and moves | def run_one_instruction
if paused
@paused_counter -= 1
parent.log.debug "^ T#{id} C:#{parent.cycles} is paused for #{@paused_counter} cycles"
if @paused_counter <= 0
parent.log.debug "^ T#{id} is unpaused"
unpause
end
return
end
instruction = parent.instructions.get_instruction(position_x, position_y)
parent.log.info "T#{id} C:#{parent.cycles} Running #{instruction.class} @ #{position_x}, #{position_y} CV: #{instruction.color_value.to_s 16}"
instruction.run(self, instruction.color_value)
parent.log.debug '^ Thread state:'
parent.log.debug "^ mw:#{memory_wheel.to_s}"
parent.log.debug "^ s_1:#{stage_1}"
parent.log.debug "^ s_2:#{stage_2}"
parent.log.debug "^ d:#{direction}"
parent.log.debug '^ Machine state:'
parent.log.debug "^ static: #{parent.memory}"
parent.log.debug "^ output: #{parent.output}"
parent.log.debug "^ input: #{parent.input}"
#move unless we called here recently.
move 1 unless instruction.class == Call
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_one_instruction\n #Wait if paused\n if paused\n @paused_counter -= 1\n if @paused_counter <= 0\n unpause\n end\n return\n end\n\n #wrap the reader around if it moves off screen.\n if position_x < 0\n @position_x = parent.instructions.width - (position_x.abs % ... | [
"0.7655434",
"0.7114291",
"0.6681102",
"0.66335934",
"0.6581489",
"0.65414906",
"0.64883596",
"0.6447056",
"0.6439598",
"0.63704824",
"0.6343431",
"0.6337301",
"0.63310564",
"0.62882155",
"0.62597924",
"0.625124",
"0.62410975",
"0.61787164",
"0.61782",
"0.617156",
"0.61713403... | 0.7176238 | 1 |
turns the thread left | def turn_right
index = DIRECTIONS.index(direction) + 1
index = 0 if index >= DIRECTIONS.length
change_direction(DIRECTIONS[index])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leave\n @leaving = true\n @leave_start_milliseconds = Gosu.milliseconds\n end",
"def turn_left\n turn(:left)\n end",
"def leave; end",
"def on_leave\n @_entered = false\n super\n end",
"def stop_thread; end",
"def leave_queue(time)\n self.left_queue_at = time\n end",
... | [
"0.6339439",
"0.63381356",
"0.6040331",
"0.6023022",
"0.59498954",
"0.5910728",
"0.58959264",
"0.58909905",
"0.5874762",
"0.5822783",
"0.5822783",
"0.58079094",
"0.57961315",
"0.57961315",
"0.57774246",
"0.5773177",
"0.5765451",
"0.57624096",
"0.57476455",
"0.57223177",
"0.56... | 0.0 | -1 |
turns the thread right | def turn_left
index = DIRECTIONS.index(direction) - 1
index = DIRECTIONS.length-1 if index < 0
change_direction(DIRECTIONS[index])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running?; !!@thread end",
"def thread; end",
"def thread; end",
"def thread; end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def allowing_other_threads; end",
"def do_not_thread\n true\n end",
"def with_own_thread()\n ... | [
"0.6743045",
"0.6652005",
"0.6652005",
"0.6652005",
"0.6438514",
"0.6438514",
"0.6438514",
"0.6370269",
"0.635331",
"0.6316496",
"0.6171171",
"0.6171171",
"0.6139331",
"0.6110593",
"0.608789",
"0.608789",
"0.6040603",
"0.59513885",
"0.5898949",
"0.58870417",
"0.58870417",
"... | 0.0 | -1 |
moves the instruction cursor amount units in a direction | def move(amount)
case direction
when :up
@position_y -= amount
when :down
@position_y += amount
when :left
@position_x -= amount
when :right
@position_x += amount
else
throw ArgumentError.new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move\n @cursor.x = wrap(@cursor.x + @delta.x, @code.width)\n @cursor.y = wrap(@cursor.y + @delta.y, @code.height)\n end",
"def move(direction)\n @old = @pos\n @pos += direction\n end",
"def cursor_forward\n $multiplier = 1 if $multiplier == 0\n if @curpos < @cols\n @cur... | [
"0.70973355",
"0.6781944",
"0.66842335",
"0.66339654",
"0.66100466",
"0.64461625",
"0.6408114",
"0.6388237",
"0.6377243",
"0.63768935",
"0.63574433",
"0.6304224",
"0.62797046",
"0.619829",
"0.6196812",
"0.6136401",
"0.61238396",
"0.61171186",
"0.60989696",
"0.6090399",
"0.608... | 0.65133405 | 6 |
jumps to a relative position | def jump(x, y)
@position_x += x
@position_y += y
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jmp(pos=0)\n @pos = pos\n end",
"def move_ahead\n @posx, @posy = coords_ahead\n activate\n end",
"def jump_forever\n jump_to_negative_relative_offset(current_assembly_position)\n end",
"def reset_pos(dur = 30, jump = 0)\n goto(@ori_x, @ori_y, dur, jump)\n end",
"d... | [
"0.7328675",
"0.6920567",
"0.68971515",
"0.6803632",
"0.6803632",
"0.67976505",
"0.6670333",
"0.6628598",
"0.65948606",
"0.6581998",
"0.6549367",
"0.65362966",
"0.65120375",
"0.65120375",
"0.6494979",
"0.6494979",
"0.6491854",
"0.648656",
"0.64862204",
"0.6470767",
"0.6467621... | 0.7143756 | 1 |
pauses the thread for a certain amount of cycles | def pause(cycles)
@paused = true
@paused_counter = cycles
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pause_after_run\n sleep @sleep_seconds\n end",
"def pause\n \tsleeper(25)\n end",
"def pause\n \tsleeper(25)\n end",
"def pause(seconds)\n sleep seconds\n end",
"def sleep(n)\n Kernel.sleep(n)\n end",
"def pause(p)\n \tsleep p\n \tputs\nend",
"def p... | [
"0.68125504",
"0.6806556",
"0.6806556",
"0.64356184",
"0.6385519",
"0.6341504",
"0.6336479",
"0.6336479",
"0.6264089",
"0.6189873",
"0.61675143",
"0.6164071",
"0.61556965",
"0.6120093",
"0.6097548",
"0.60844237",
"0.60067785",
"0.60051787",
"0.59891367",
"0.59682244",
"0.5963... | 0.71162856 | 1 |
Build slots to verify availabilities ====== Params: +users+:: +Array+ users to check disponibility +start_day+:: +Date+ start day to get slots +finish_day+:: +Date+ finish day to get slots +start_hour+:: +Time+ start hour at each day to get slots +finish_hour+:: +Time+ finish hour at each day to get slots +slots_size+:: +Integer+ slots size duration Returns The Graph mounted | def verify_availabilities(users, start_day, finish_day, start_hour = Time.parse("00:00"),
finish_hour = Time.parse("23:59"), slots_size = SocialFramework.slots_size)
return unless finish_day_ok? start_day, finish_day
@slots_size = slots_size
start_time = start_day.to_datetime + start_hour.seconds_since_midnight.seconds
finish_time = finish_day.to_datetime + finish_hour.seconds_since_midnight.seconds
build_users(users)
build_slots(start_time, finish_time, start_hour, finish_hour)
unless @fixed_users.empty?
build_edges(@fixed_users, start_time, finish_time)
@slots.select! { |slot| slot.edges.count == @fixed_users.count }
end
build_edges(@users, start_time, finish_time)
@slots.sort_by! { |slot| -slot.attributes[:gained_weight] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_edges(users, start_time, finish_time)\n users.each do |user|\n schedule = ModelFabric.get_class(SocialFramework.schedule_class).find_or_create_by(user_id: user.id)\n\n events = schedule.events_in_period(start_time, finish_time)\n i = 0\n\n @slots.each do |slot|\... | [
"0.7425937",
"0.67526805",
"0.6416262",
"0.57547075",
"0.5742764",
"0.57107085",
"0.5686187",
"0.55124176",
"0.5467457",
"0.54055226",
"0.5339379",
"0.53221256",
"0.52621377",
"0.52143097",
"0.51704985",
"0.5162292",
"0.515817",
"0.5150856",
"0.51294833",
"0.5128497",
"0.5122... | 0.7634415 | 0 |
Verify if finish day is between start day and max duration ====== Params: +start_day+:: +Date+ start day to get slots +finish_day+:: +Date+ finish day to get slots Returns true is ok or false if no | def finish_day_ok?(start_day, finish_day)
finish = start_day + @max_duration
return finish_day <= finish
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def more_than_a_day_passed?(start_time, end_time)\n end_time - start_time > 60 * 60 * 24\n end",
"def range_finished?\n with_missing_days\n .select { |day| !day.is_day_off }\n .all? do |day|\n return false if day.is_missing\n day.is_finished\n end\n end",
"def timeslot_... | [
"0.6729787",
"0.62841284",
"0.6207005",
"0.6199786",
"0.6139077",
"0.6126368",
"0.6094859",
"0.6089488",
"0.6081192",
"0.60707355",
"0.6064478",
"0.60592765",
"0.6005622",
"0.5932083",
"0.59255964",
"0.59075654",
"0.5885837",
"0.58771795",
"0.586272",
"0.5804952",
"0.58037186... | 0.81214786 | 0 |
Build slots whitin a period of time ====== Params: +current_time+:: +Datetime+ start date to build slots +finish_time+:: +Datetime+ finish date to build slots +start_hour+:: +Time+ start hour in days to build slots +finish_hour+:: +Time+ finish hour in days to build slots Returns schedule graph with slots | def build_slots(current_time, finish_time, start_hour, finish_hour)
while current_time < finish_time
slots_quantity = get_slots_quantity(start_hour, finish_hour)
(1..slots_quantity).each do
verterx = @elements_factory.create_vertex(current_time, current_time.class,
{gained_weight: 0, duration: @slots_size})
@slots << verterx
current_time += @slots_size
break if current_time >= finish_time
end
current_time = current_time.beginning_of_day + start_hour.seconds_since_midnight.seconds + 1.day if start_hour.seconds_since_midnight > finish_hour.seconds_since_midnight
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_time_slots\n return unless params[:start_time]\n\n start_time = Time.from_picker(params.delete(:start_time))\n end_time = Time.from_picker(params.delete(:end_time))\n\n return if end_time < start_time # Prevent infinite loop\n\n shift_length = params.delete(:shift_length).to_i\n shift_... | [
"0.69897455",
"0.6736206",
"0.64120215",
"0.6156513",
"0.6065767",
"0.6005286",
"0.59822",
"0.5947285",
"0.5924139",
"0.5836673",
"0.5820464",
"0.58051205",
"0.57189965",
"0.57154244",
"0.56964195",
"0.56950706",
"0.5672226",
"0.5663932",
"0.5656068",
"0.56187445",
"0.5586132... | 0.8213 | 0 |
Build edges to schedule graph ====== Params: +users+:: +Array+ users to check disponibility +start_time+:: +Datetime+ used to get events with that start date +finish_time+:: +Datetime+ used to get events with that finish date Returns Schedule graph with edges between slots and users | def build_edges(users, start_time, finish_time)
users.each do |user|
schedule = ModelFabric.get_class(SocialFramework.schedule_class).find_or_create_by(user_id: user.id)
events = schedule.events_in_period(start_time, finish_time)
i = 0
@slots.each do |slot|
if events.empty? or slot_empty?(slot, events[i])
slot.add_edge(user)
slot.attributes[:gained_weight] += user.attributes[:weight] if user.attributes[:weight] != :fixed
end
if not events.empty? and((slot.id + @slots_size).to_datetime >= events[i].finish.to_datetime)
events.clear if events[i] == events.last
i += 1
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_availabilities(users, start_day, finish_day, start_hour = Time.parse(\"00:00\"),\n finish_hour = Time.parse(\"23:59\"), slots_size = SocialFramework.slots_size)\n\n return unless finish_day_ok? start_day, finish_day\n\n @slots_size = slots_size\n start_time = start_day.to_dat... | [
"0.62932605",
"0.56891626",
"0.56358844",
"0.5575019",
"0.5477034",
"0.53833175",
"0.5379398",
"0.53239167",
"0.53234196",
"0.518731",
"0.51584107",
"0.5114251",
"0.5108755",
"0.5076803",
"0.50395304",
"0.50156885",
"0.50140345",
"0.4999308",
"0.49855274",
"0.49813858",
"0.49... | 0.8574565 | 0 |
Verify if event match with a slot ====== Params: +slot+:: +Vertex+ represent a slot in schedule built Returns true if match or false if no | def slot_empty?(slot, event)
return ((slot.id + @slots_size).to_datetime <= event.start.to_datetime or
slot.id >= event.finish.to_datetime)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_slot(day, slot)\n\t\t\tevents = Event.where(day: day)\n\t\t\tused_slots = events.pluck(:slot)\n\n\t\t\tif used_slots.include? slot\n\t\t\t\treturn false\n\t\t\telse\n\t\t\t\treturn true\n\t\t\tend \n\t\tend",
"def has_slot?(slot)\n slots.include? valid_slot_name!(slot)\n end",
"def slot_val... | [
"0.7832078",
"0.7193215",
"0.698414",
"0.69562435",
"0.6570873",
"0.6414915",
"0.630702",
"0.6218321",
"0.61309856",
"0.6063581",
"0.5835188",
"0.580481",
"0.5764808",
"0.57618064",
"0.5748357",
"0.57397187",
"0.569456",
"0.569456",
"0.56838053",
"0.5662356",
"0.5660303",
"... | 0.712132 | 2 |
Calculate the quantity of slot that fit over in a period of time ====== Params: +start_hour+:: +Time+ start date to build slots +finish_hour+:: +Time+ finish date to build slots Returns the quantity of slots | def get_slots_quantity(start_hour, finish_hour)
if start_hour.seconds_since_midnight <= finish_hour.seconds_since_midnight
hours = finish_hour.seconds_since_midnight - start_hour.seconds_since_midnight
else
hours = start_hour.seconds_until_end_of_day + finish_hour.seconds_since_midnight + 1.second
end
return (hours / @slots_size).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_slots(current_time, finish_time, start_hour, finish_hour)\n while current_time < finish_time\n slots_quantity = get_slots_quantity(start_hour, finish_hour)\n\n (1..slots_quantity).each do\n verterx = @elements_factory.create_vertex(current_time, current_time.class,\n ... | [
"0.713124",
"0.65927655",
"0.65398866",
"0.6264161",
"0.6186481",
"0.6105108",
"0.5912342",
"0.5833479",
"0.5696364",
"0.56713796",
"0.5670298",
"0.5646184",
"0.5614763",
"0.5582086",
"0.5548162",
"0.5545311",
"0.55396175",
"0.5514138",
"0.55097765",
"0.55083936",
"0.5487312"... | 0.8249626 | 0 |
Build vertecies to each user with weight ====== Params: +users+:: +Hash+ to add weight, key is user and value is weight, can be a simple Array, in this case all users will have the max weight Returns the users vertices | def build_users(users)
users.each do |user, weight|
if weight != :fixed and (weight.nil? or weight > SocialFramework.max_weight_schedule)
weight = SocialFramework.max_weight_schedule
end
vertex = @elements_factory.create_vertex(user.id, user.class, {weight: weight})
array = (weight == :fixed ? @fixed_users : @users)
array << vertex
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight(u, v)\n @weights[[u,v]]\n end",
"def vote_for(user, weight)\n votes.create(:user => user, :weight => weight)\n end",
"def build_edges(users, start_time, finish_time)\n users.each do |user|\n schedule = ModelFabric.get_class(SocialFramework.schedule_class).find_or_crea... | [
"0.5874723",
"0.5717965",
"0.55935556",
"0.5550472",
"0.52969253",
"0.52939314",
"0.5205485",
"0.5185318",
"0.5136416",
"0.5123635",
"0.51173854",
"0.50784045",
"0.5061361",
"0.5059032",
"0.50347966",
"0.5028618",
"0.49892518",
"0.49465895",
"0.4936965",
"0.49129468",
"0.4901... | 0.80952495 | 0 |
Build slots to verify availabilities | def verify_availabilities(users, start_day, finish_day, start_hour = Time.parse("00:00"),
finish_hour = Time.parse("23:59"), slots_size = SocialFramework.slots_size)
@strategy.verify_availabilities(users, start_day, finish_day, start_hour, finish_hour, slots_size)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_availabilities(users, start_day, finish_day, start_hour = Time.parse(\"00:00\"),\n finish_hour = Time.parse(\"23:59\"), slots_size = SocialFramework.slots_size)\n\n return unless finish_day_ok? start_day, finish_day\n\n @slots_size = slots_size\n start_time = start_day.to_dat... | [
"0.65621394",
"0.62556356",
"0.61845803",
"0.61782724",
"0.61278373",
"0.60394496",
"0.59880424",
"0.5907978",
"0.58929545",
"0.5851084",
"0.58231056",
"0.58157414",
"0.57933235",
"0.57923657",
"0.57362443",
"0.570354",
"0.56418395",
"0.5599515",
"0.556563",
"0.5561275",
"0.5... | 0.6273015 | 1 |
The message type is used to determine which Processor will process the message. The type can be static or dynamic if a message should be handled by a different Processor depending on it's state. | def type
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_type\n @message_type ||= \"message\"\n end",
"def message_type\n MESSAGE_TYPES[message_type_id] || \"unknown_type_#{message_type_id}\".to_sym\n end",
"def message_type\n @message_type ||= payload[:json][:message_type] if payload[:json].present?\n end",
"def message... | [
"0.8019516",
"0.7665834",
"0.7505305",
"0.731695",
"0.70954233",
"0.70739275",
"0.68653977",
"0.67934036",
"0.6624181",
"0.66139287",
"0.65654135",
"0.64988345",
"0.64518774",
"0.62785673",
"0.6254874",
"0.6254874",
"0.6188934",
"0.6155507",
"0.61510015",
"0.6123213",
"0.6089... | 0.0 | -1 |
The protocol that this message's connection has negotiated. This will be used when searching for protocol specific routes added through the event router. | def protocol
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def protocol\n @connection.protocol\n end",
"def protocol\n @protocol ||= @raw_protocol[0..-4]\n end",
"def protocol_name\n self.class.protocol_name\n end",
"def protocol\n @context.registers[:protocol]\n end",
"def protocol_version\n @protocol_version\n... | [
"0.7818708",
"0.7498865",
"0.7489573",
"0.74490327",
"0.7222543",
"0.71379745",
"0.70845836",
"0.7023989",
"0.70110023",
"0.6974706",
"0.6942286",
"0.68243074",
"0.6769917",
"0.67037094",
"0.67037094",
"0.66832525",
"0.656842",
"0.65420675",
"0.6533181",
"0.65066344",
"0.6497... | 0.0 | -1 |
Returns a protocol compliant serialized form of the message that will be sent to the client through the socket. | def serialize
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(message)\n message.to_msgpack\n end",
"def serialize_to_string\n sio = ProtocolBuffers.bin_sio\n serialize(sio)\n return sio.string\n end",
"def to_s\r\n return to_socket\r\n end",
"def to_s\n @message.to_s\n end",
"def to_s\n @message\n end",
"... | [
"0.7748737",
"0.7196227",
"0.7114029",
"0.68116194",
"0.66649514",
"0.66649514",
"0.66372323",
"0.6480289",
"0.64368296",
"0.64333594",
"0.6389111",
"0.6370974",
"0.63281363",
"0.6308408",
"0.62978184",
"0.6254661",
"0.6187041",
"0.6185376",
"0.6171234",
"0.6171234",
"0.61532... | 0.0 | -1 |
I worked on this challenge with Yi Lu I spent 1 hours on this challenge. Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented. 0. Pseudocode What is the input? => We are taking in an array What is the output? (i.e. What should the code return?) => And trying to return an array of the most frequent element in the original array (mode) What are the steps needed to solve the problem? => 1. Convert the array to a hash, where the keys are the elements of the array, values are the counts of the keys in the array => 2. Find the max value in the hash => 3. Output an array with the keys whose values equal the max value 1. Initial Solution | def mode(array)
hash = Hash.new(0)
array.each { |key| hash[key] += 1}
max_value = hash.values.max
output_array = hash.select { |key, value| value == max_value }.keys
output_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mode(array)\n freq_hash = Hash.new(0)\n #hash_array = Hash[array.map{|x| [x,0]}]\n array.each do |arg|\n freq_hash[arg] += 1\n end\n freq_hash\n new_array = Array.new\n\n freq_hash.each do |key,value|\n if value == freq_hash.values.max\n new_array.push(key)\n end\n end\n new_array\nend",... | [
"0.87833995",
"0.8726653",
"0.8703395",
"0.8702385",
"0.86899453",
"0.8666296",
"0.8664305",
"0.86440337",
"0.86415327",
"0.8634787",
"0.86083114",
"0.860781",
"0.8601469",
"0.8596893",
"0.85710335",
"0.8570551",
"0.8561597",
"0.85578406",
"0.8557513",
"0.85551035",
"0.851983... | 0.8545146 | 20 |
GET /mpayments GET /mpayments.json | def index
@mpayments = Mpayment.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apayments\n\t\t@request = Request.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json {} # aPayments.json.jbuilder\n\t\tend\n\tend",
"def index\n @api_v1_mentorings = Api::V1::Mentoring.all\n end",
"def index\n if params[:meeting_id] && params[:team_id... | [
"0.66044134",
"0.59594214",
"0.58128417",
"0.5788603",
"0.5764736",
"0.5755786",
"0.5698459",
"0.5681478",
"0.56682193",
"0.56524163",
"0.5642177",
"0.56280184",
"0.56263846",
"0.5583999",
"0.55599684",
"0.5543617",
"0.5541989",
"0.5522379",
"0.55183595",
"0.5485807",
"0.5485... | 0.70941305 | 0 |
GET /mpayments/1 GET /mpayments/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @mpayments = Mpayment.all\n end",
"def apayments\n\t\t@request = Request.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json {} # aPayments.json.jbuilder\n\t\tend\n\tend",
"def index\n @api_v1_mentorings = Api::V1::Mentoring.all\n end",
"def... | [
"0.68131155",
"0.6313762",
"0.5967111",
"0.578755",
"0.57391566",
"0.5718408",
"0.57109296",
"0.57002205",
"0.56925243",
"0.5685278",
"0.56697255",
"0.5654573",
"0.56469995",
"0.5637362",
"0.5619397",
"0.56080645",
"0.56037045",
"0.5603268",
"0.5602091",
"0.5582548",
"0.55814... | 0.0 | -1 |
POST /mpayments POST /mpayments.json | def create
@mpayment = Mpayment.new(mpayment_params)
respond_to do |format|
if @mpayment.save
format.html { redirect_to @mpayment, notice: 'Mpayment was successfully created.' }
format.json { render action: 'show', status: :created, location: @mpayment }
else
format.html { render action: 'new' }
format.json { render json: @mpayment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @mpayments = Mpayment.all\n end",
"def create_batch\n all_months.each do |month|\n cash_flow = find_or_build_cash_flow(month, @category.id)\n\n cash_flow.planned = cash_flow_params[:value]\n cash_flow.save!\n end\n\n render json: { success: true }, status: :created\n end"... | [
"0.592015",
"0.56782216",
"0.56329",
"0.5605976",
"0.55921185",
"0.5439777",
"0.54041845",
"0.53767645",
"0.5341741",
"0.53164583",
"0.5307297",
"0.530408",
"0.5300554",
"0.5286725",
"0.52621853",
"0.5255804",
"0.52512425",
"0.52463555",
"0.52379423",
"0.52343047",
"0.5230933... | 0.5684634 | 1 |
PATCH/PUT /mpayments/1 PATCH/PUT /mpayments/1.json | def update
respond_to do |format|
if @mpayment.update(mpayment_params)
format.html { redirect_to @mpayment, notice: 'Mpayment was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @mpayment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @appointment.check_updated_params(appointment_params)\n if @appointment.update(appointment_params)\n render json: @appointment, status: 200\n else\n render json: @appointment.errors, status: 422\n end\n else\n p \"did not work\"\n end\n end",
"def updat... | [
"0.5996843",
"0.5907343",
"0.5866719",
"0.58177406",
"0.5808854",
"0.5785925",
"0.57609206",
"0.5745641",
"0.5744978",
"0.57421243",
"0.57419676",
"0.5738647",
"0.5725108",
"0.57136345",
"0.5693636",
"0.5689744",
"0.5689654",
"0.5681352",
"0.56771946",
"0.56757104",
"0.567322... | 0.61613125 | 0 |
DELETE /mpayments/1 DELETE /mpayments/1.json | def destroy
@mpayment.destroy
respond_to do |format|
format.html { redirect_to mpayments_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @masut_assay = MasutAssay.find(params[:id])\n @masut_assay.destroy\n\n respond_to do |format|\n format.html { redirect_to masut_assays_url }\n format.json { head :no_content }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n ... | [
"0.68918353",
"0.6805146",
"0.6730019",
"0.6687725",
"0.6653694",
"0.6647059",
"0.66460365",
"0.6639852",
"0.66129684",
"0.66114163",
"0.66023797",
"0.6585208",
"0.6555774",
"0.6553166",
"0.65478516",
"0.6539971",
"0.6531259",
"0.6526565",
"0.651955",
"0.65108556",
"0.6510057... | 0.7290915 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_mpayment
@mpayment = Mpayment.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def mpayment_params
params.require(:mpayment).permit(:pdate, :financial_to, :amount, :reference, :details, :MeansPayment_id, :Member_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
GET /pages GET /pages.xml | def index
@pages = Page.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @pages }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = @user.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n ... | [
"0.73507947",
"0.73469174",
"0.73281235",
"0.7325902",
"0.7321559",
"0.7321559",
"0.73211336",
"0.7250258",
"0.7236279",
"0.7222911",
"0.7185808",
"0.7114185",
"0.70770466",
"0.7059181",
"0.7058981",
"0.7049995",
"0.69887555",
"0.6874528",
"0.67916787",
"0.6769147",
"0.674664... | 0.7300898 | 8 |
GET /pages/1 GET /pages/1.xml | def show
if params[:name]
@page = Page.where(:name => params[:name]).limit(1)
@page = @page[0]
elsif params[:id].to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil
@page = Page.where(:name => params[:id]).limit(1)
@page = @page[0]
else
@page = Page.find(params[:id])
end
respond_to do |format|
format.html { render @page.type.name } # show.html.erb
format.xml { render :xml => @page }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n... | [
"0.7240595",
"0.7175242",
"0.71416986",
"0.71416986",
"0.7135126",
"0.7135126",
"0.7057775",
"0.70284396",
"0.6986637",
"0.6978276",
"0.697713",
"0.6938267",
"0.69377303",
"0.68386036",
"0.6821595",
"0.6812652",
"0.6787446",
"0.67184156",
"0.6716908",
"0.6694082",
"0.66778725... | 0.0 | -1 |
GET /pages/new GET /pages/new.xml | def new
@page = Page.new
@types = Type.all
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @page }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page = current_cms.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n ... | [
"0.7837418",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7714634",
"0.7693529",
"0.76722115",
"0.7594718",
"0.75105387",
"0.7480689",
"0.7444072",
"0.73575026",
"0.73414886",
"0.73297346",
"0.72564614",
"0.72548366",
"0.7247537",
"0.724282... | 0.7235321 | 22 |
POST /pages POST /pages.xml | def create
@page = Page.new(params[:page])
respond_to do |format|
if @page.save
format.html { redirect_to(@page, :notice => 'Page was successfully created.') }
format.xml { render :xml => @page, :status => :created, :location => @page }
else
format.html { render :action => "new" }
format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @page = Page.new(params[:page])\n\n respond_to do |format|\n if @page.save\n format.json { render json: @page, status: :created, location: [:api, @page] }\n format.xml { render xml: @page, status: :created, location: [:api, @page] }\n else\n format.json { render ... | [
"0.6393701",
"0.63614",
"0.62852484",
"0.6194392",
"0.61868143",
"0.6163854",
"0.6158837",
"0.61517274",
"0.6139733",
"0.6139733",
"0.6122696",
"0.6118308",
"0.6105398",
"0.6104559",
"0.60812664",
"0.60769343",
"0.60662496",
"0.6062452",
"0.60615647",
"0.60525924",
"0.6052004... | 0.6161021 | 6 |
PUT /pages/1 PUT /pages/1.xml | def update
@page = Page.find(params[:id])
respond_to do |format|
if @page.update_attributes(params[:page])
format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n for... | [
"0.6628961",
"0.65013754",
"0.6484854",
"0.63489664",
"0.63176894",
"0.63176894",
"0.63075536",
"0.6285401",
"0.627316",
"0.6267482",
"0.62560314",
"0.6249458",
"0.62459475",
"0.62175804",
"0.6211811",
"0.62094486",
"0.615437",
"0.6139454",
"0.6128921",
"0.6099357",
"0.609707... | 0.6273136 | 10 |
DELETE /pages/1 DELETE /pages/1.xml | def destroy
@page = Page.find(params[:id])
@page.destroy
respond_to do |format|
format.html { redirect_to(pages_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",
"def delete_page(page)\n transaction \"delete `#{page.title}'\" do\n store.delete(page.title + '.md')\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n ... | [
"0.7252332",
"0.7106013",
"0.7086914",
"0.7062609",
"0.7045329",
"0.69755495",
"0.6959714",
"0.6921489",
"0.69133663",
"0.68900084",
"0.68893564",
"0.68533075",
"0.684198",
"0.68271697",
"0.6813839",
"0.68092585",
"0.6808972",
"0.68045884",
"0.6800845",
"0.67993665",
"0.67888... | 0.7161119 | 8 |
GET /datasets GET /datasets.xml | def index
@page_title = "VDW Datasets"
@datasets = Dataset.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @datasets }
format.pdf
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_datasets\n authenticate unless authenticated?\n response = RestClient::Request.execute(\n url: @@datasets_endpoint,\n method: :get,\n headers: headers('application/json')\n )\n return response\n end",
"def index\n @datasets = Dataset.all\n end",
"def inde... | [
"0.753298",
"0.6892824",
"0.6892824",
"0.6892824",
"0.6813552",
"0.6754465",
"0.6754465",
"0.6622356",
"0.655275",
"0.655275",
"0.6168882",
"0.6156508",
"0.61541",
"0.6105366",
"0.60999507",
"0.60952085",
"0.6019521",
"0.6001793",
"0.5979236",
"0.59703606",
"0.5948212",
"0.... | 0.53575253 | 67 |
GET /datasets/1 GET /datasets/1.xml | def show
@dataset = Dataset.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @dataset }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @datasets = Dataset.published\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @datasets }\n end\n end",
"def get_datasets\n authenticate unless authenticated?\n response = RestClient::Request.execute(\n url: @... | [
"0.6661511",
"0.6634303",
"0.65964204",
"0.65964204",
"0.65964204",
"0.6593396",
"0.62481284",
"0.6050008",
"0.60254884",
"0.60209507",
"0.5992551",
"0.59816825",
"0.59480345",
"0.5942293",
"0.59397584",
"0.59397584",
"0.5886561",
"0.58710945",
"0.58452433",
"0.5802621",
"0.5... | 0.6937888 | 1 |
GET /datasets/new GET /datasets/new.xml | def new
@dataset = Dataset.new
3.times do
@dataset.dataset_variables << DatasetVariable.new
end
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @dataset }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dataset }\n end\n end",
"def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dataset }\... | [
"0.74070996",
"0.74070996",
"0.71054286",
"0.7015896",
"0.6829064",
"0.68218493",
"0.6791604",
"0.6726968",
"0.67176145",
"0.6583294",
"0.6583294",
"0.650435",
"0.6277079",
"0.6269645",
"0.6168528",
"0.6165478",
"0.61319005",
"0.61319005",
"0.61084765",
"0.60559744",
"0.59764... | 0.6596271 | 9 |
POST /datasets POST /datasets.xml | def create
@dataset = Dataset.new(params[:dataset])
respond_to do |format|
if @dataset.save
flash[:notice] = 'Dataset was successfully created.'
format.html { redirect_to(@dataset) }
format.xml { render :xml => @dataset, :status => :created, :location => @dataset }
else
format.html { render :action => "new" }
format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @dataset = Dataset.new(params[:dataset])\n\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully created.') }\n format.xml { render :xml => @dataset, :status => :created, :location => @dataset }\n else\n ... | [
"0.64057773",
"0.6340367",
"0.61581206",
"0.61139226",
"0.60565925",
"0.5844556",
"0.58094054",
"0.5764553",
"0.57569027",
"0.5755463",
"0.57161283",
"0.56881595",
"0.5617457",
"0.56094533",
"0.5606813",
"0.560531",
"0.55948615",
"0.55882657",
"0.555601",
"0.55529916",
"0.553... | 0.63516057 | 1 |
PUT /datasets/1 PUT /datasets/1.xml | def update
# raise("boobies!")
@dataset = Dataset.find(params[:id])
# raise(params[:dataset][:dataset_variables_attributes]["0"].class.to_s)
respond_to do |format|
if @dataset.update_attributes(params[:dataset])
flash[:notice] = 'Dataset was successfully updated.'
format.html { redirect_to(@dataset) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n flash[:notice] = 'Dataset was successfully updated.'\n format.html { redirect_to dataset_url(@dataset) }\n format.xml { head :ok }\n else\n f... | [
"0.6552326",
"0.6526648",
"0.6329613",
"0.61218303",
"0.6041167",
"0.5998395",
"0.59983724",
"0.59983724",
"0.59983724",
"0.59983724",
"0.59376717",
"0.59293675",
"0.58789486",
"0.58299065",
"0.5808605",
"0.57836634",
"0.5779558",
"0.568264",
"0.5639311",
"0.5623167",
"0.5608... | 0.6190557 | 3 |
DELETE /datasets/1 DELETE /datasets/1.xml | def destroy
@dataset = Dataset.find(params[:id])
@dataset.destroy
respond_to do |format|
format.html { redirect_to(datasets_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to datasets_u... | [
"0.7555829",
"0.7516238",
"0.73041487",
"0.7236394",
"0.71158844",
"0.696906",
"0.6787174",
"0.6709635",
"0.66876745",
"0.6687568",
"0.6682777",
"0.6649033",
"0.6610473",
"0.6578266",
"0.6490765",
"0.647115",
"0.6467891",
"0.6435245",
"0.64293873",
"0.64135337",
"0.6412986",
... | 0.7610614 | 1 |
Since the Transformer output is rather wild (an array of occurrencehashes), we will turn it into a useful internal representation | def contain
raise UnparsedInstanceError unless @output
array_keys = MULTIPLES.keys
@internal = @output.reduce({}) do |internal, occurrence|
if !occurrence.is_a?(Hash)
raise NonHashTransformedElementError
elsif key = occurrence.keys.any_included(array_keys)
internal.array_assoc!(MULTIPLES[key], occurrence[key])
else
key = occurrence.keys.first
internal[key] = occurrence[key]
end
internal
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform; end",
"def transformed_entries entries\n\t\tentries\n\tend",
"def classificateResult(label, sampleMap, foundAllArr)\n puts \"[classificateResult] started label #{label}\"\n foundArr = foundAllArr.select{|found| matchLabels?(found.label, label)}\n expRecognitionResult = Spnt... | [
"0.585344",
"0.58010864",
"0.54989266",
"0.5486063",
"0.54461527",
"0.53999674",
"0.5395306",
"0.53527135",
"0.53507704",
"0.53337777",
"0.52495533",
"0.52356756",
"0.52073765",
"0.52071035",
"0.52064365",
"0.51741344",
"0.5166178",
"0.5114718",
"0.5114718",
"0.5114718",
"0.5... | 0.0 | -1 |
Returns the representation but executes `with` methods beforehand | def represent(with: [:parse])
with.each { |m| self.send(m) }
@internal ||= contain
{circuit: internal, raw: internal.pretty_inspect}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with\n @with\n end",
"def with\n yield self\n end",
"def with_serializer(object, serializer); end",
"def with!( &blk )\n self.instance_eval &blk\n self\n end",
"def serialize(with: nil)\n serializer = case with\n when nil\n ... | [
"0.67319036",
"0.66707575",
"0.59845245",
"0.580199",
"0.5800812",
"0.57358384",
"0.5661474",
"0.5614891",
"0.55440205",
"0.55124956",
"0.5477598",
"0.54468304",
"0.54104465",
"0.5410108",
"0.53980744",
"0.5351845",
"0.53251344",
"0.52903473",
"0.52350134",
"0.5227661",
"0.52... | 0.63271487 | 2 |
Ensure valid credentials, either by restoring from the saved credentials files or intitiating an OAuth2 authorization. If authorization is required, the user's default browser will be launched to approve the request. | def authorize
FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)
token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
# changed SCOPE to SCOPES to pass in multiple OAUTH scopes
authorizer = Google::Auth::UserAuthorizer.new(
client_id, SCOPES, token_store)
user_id = 'default'
credentials = authorizer.get_credentials(user_id)
if credentials.nil?
url = authorizer.get_authorization_url(
base_url: OOB_URI)
puts "Open the following URL in the browser and enter the " +
"resulting code after authorization"
puts url
code = gets
credentials = authorizer.get_and_store_credentials_from_code(
user_id: user_id, code: code, base_url: OOB_URI)
end
credentials
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials use... | [
"0.6931206",
"0.67210054",
"0.6657709",
"0.66506517",
"0.65554804",
"0.6523764",
"0.6496995",
"0.64926916",
"0.646251",
"0.645516",
"0.6453579",
"0.6451559",
"0.64492416",
"0.6447337",
"0.6439317",
"0.6436507",
"0.64074755",
"0.63989055",
"0.6393423",
"0.6392714",
"0.6383842"... | 0.64707637 | 8 |
return contact by id | def get_contact(id)
contacts = read_contacts
contacts.select { |contact| contact[:id] == id }.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contact(id)\n self.contacts.detect { |c| c.id == id }\n end",
"def get_contact_by_id(contact_id)\n get_contact(contact_id)\n end",
"def get_contact_by_id(contact_id)\n get_contact(contact_id)\n end",
"def find_contact(id)\n \t@contacts.find {|contact| contact.id == id}\n \tend",
... | [
"0.88870615",
"0.87063384",
"0.87063384",
"0.86913264",
"0.85296595",
"0.8336069",
"0.8275071",
"0.8190862",
"0.813817",
"0.8094162",
"0.80403006",
"0.8002238",
"0.79819876",
"0.794904",
"0.794904",
"0.794904",
"0.794904",
"0.794904",
"0.79406816",
"0.79005754",
"0.7878787",
... | 0.8402751 | 5 |
return next id in the contacts | def get_next_id
id = 0
contacts = read_contacts
contacts.each do |contact|
if id < contact[:id]
id = contact[:id]
end
end
id + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_id\n self[:next_id]\n end",
"def read_next_id\n id = nil\n list = current_list\n\n if @co_index <= list.size\n id = list[@co_index - 1][:id]\n end\n\n @co_index += 1\n\n id\n end",
"def next_id\n @id ||= 0\n @id += 1\n end",
"def next_id\n self.lates... | [
"0.7468486",
"0.73091954",
"0.7187516",
"0.71277905",
"0.7090986",
"0.70366335",
"0.69949746",
"0.6981143",
"0.69413483",
"0.69372696",
"0.69096625",
"0.6907639",
"0.68269014",
"0.67816937",
"0.6779004",
"0.67189336",
"0.6691543",
"0.666019",
"0.66601145",
"0.66586685",
"0.66... | 0.8604871 | 0 |
GET /roomtables GET /roomtables.json | def index
@roomtables = Roomtable.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end",
"def index\n\t\t@rooms = ... | [
"0.67979383",
"0.6642086",
"0.6616883",
"0.65495163",
"0.64478195",
"0.64134973",
"0.6355172",
"0.6337649",
"0.6332376",
"0.6230919",
"0.6210607",
"0.6196459",
"0.61873245",
"0.61707246",
"0.6168508",
"0.61465585",
"0.6135062",
"0.6135062",
"0.6135062",
"0.6135062",
"0.613506... | 0.6944181 | 0 |
GET /roomtables/1 GET /roomtables/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @roomtables = Roomtable.all\n end",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:... | [
"0.6811662",
"0.67898583",
"0.662628",
"0.6533286",
"0.649986",
"0.6489409",
"0.6356252",
"0.6333455",
"0.62937397",
"0.62768584",
"0.6224033",
"0.61984783",
"0.61770433",
"0.61764294",
"0.61764294",
"0.61764294",
"0.61221206",
"0.60790145",
"0.60790145",
"0.60790145",
"0.607... | 0.0 | -1 |
POST /roomtables POST /roomtables.json | def create
@roomtable = Roomtable.new(roomtable_params)
respond_to do |format|
if @roomtable.save
format.html { redirect_to @roomtable, notice: 'Roomtable was successfully created.' }
format.json { render :show, status: :created, location: @roomtable }
else
format.html { render :new }
format.json { render json: @roomtable.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roomtable_params\n params.require(:roomtable).permit(:inpatient_id,:room_no, :room_type, :status)\n end",
"def create\n @table = Table.new(params[:table].permit(:name, :notes, :x, :y, :table_type, :guest_ids => []))\n\n respond_to do |format|\n if @table.save\n format.html { redirec... | [
"0.6453716",
"0.62146294",
"0.6086252",
"0.602774",
"0.602101",
"0.60179937",
"0.6014422",
"0.60129815",
"0.5941191",
"0.59325427",
"0.5887777",
"0.5858152",
"0.5854463",
"0.5854463",
"0.5839934",
"0.5837654",
"0.5772165",
"0.5772165",
"0.5772165",
"0.57637346",
"0.5691802",
... | 0.72375876 | 0 |
PATCH/PUT /roomtables/1 PATCH/PUT /roomtables/1.json | def update
respond_to do |format|
if @roomtable.update(roomtable_params)
format.html { redirect_to @roomtable, notice: 'Roomtable was successfully updated.' }
format.json { render :show, status: :ok, location: @roomtable }
else
format.html { render :edit }
format.json { render json: @roomtable.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @table = Table.find(params[:id])\n\n respond_to do |format|\n if @table.update_attributes(params[:table].permit(:name, :notes, :x, :y, :table_type, :guest_ids => []))\n format.html { redirect_to @table, notice: 'Table was successfully updated.' }\n format.json { head :no_conte... | [
"0.65708154",
"0.63510865",
"0.63451314",
"0.6337654",
"0.6239108",
"0.62284696",
"0.62181705",
"0.62078685",
"0.62078685",
"0.61848646",
"0.61764973",
"0.6176183",
"0.61718255",
"0.61665916",
"0.6129718",
"0.6080755",
"0.60703784",
"0.6008109",
"0.60012436",
"0.5982448",
"0.... | 0.7058514 | 0 |
DELETE /roomtables/1 DELETE /roomtables/1.json | def destroy
@roomtable.destroy
respond_to do |format|
format.html { redirect_to roomtables_url, notice: 'Roomtable was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tddbc_room = Tddbc::Room.find(params[:id])\n @tddbc_room.destroy\n\n respond_to do |format|\n format.html { redirect_to tddbc_rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @serverroom = Serverroom.find(params[:id])\n @serverroom.destroy\n\n res... | [
"0.6982013",
"0.69456685",
"0.69107914",
"0.68167615",
"0.6743244",
"0.6742848",
"0.6741182",
"0.6740966",
"0.6729767",
"0.67034614",
"0.6674896",
"0.6672177",
"0.6666565",
"0.66440326",
"0.6641474",
"0.6640038",
"0.6614201",
"0.66100127",
"0.66054916",
"0.66054916",
"0.65939... | 0.75391304 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_roomtable
@roomtable = Roomtable.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def roomtable_params
params.require(:roomtable).permit(:inpatient_id,:room_no, :room_type, :status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
===================================================== helpers for events ===================================================== | def number_to_string_with_zero(number, characters_count = 2 )
num_str = number.to_s
if num_str.length < characters_count
num_str = '0'*(characters_count - num_str.length ) + num_str
end
num_str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def event; end",
"def event; end",
"def event; end",
"def events\n end",
"def define_event_helpers; end",
"def send_events; end",
"def... | [
"0.8062245",
"0.8062245",
"0.8062245",
"0.8062245",
"0.8062245",
"0.8062245",
"0.8062245",
"0.8062245",
"0.79084474",
"0.79084474",
"0.79084474",
"0.7746276",
"0.76828146",
"0.7597136",
"0.7565027",
"0.75087416",
"0.7493696",
"0.71948373",
"0.71948373",
"0.71605134",
"0.71327... | 0.0 | -1 |
load_and_authorize_resource GET /evaluation_results GET /evaluation_results.json | def index
@evaluation_results = EvaluationResult.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @evaluation_results }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend",
"def index\n \n @evaluation = Evaluation.find_by(user_id: params[:user_id], study_case_id: params[:study_case_id])\n\n if @evaluation.prese... | [
"0.7401428",
"0.7080126",
"0.6901657",
"0.6809524",
"0.67111105",
"0.6659811",
"0.6618346",
"0.6579515",
"0.6573201",
"0.6554296",
"0.65294",
"0.65294",
"0.65294",
"0.65294",
"0.65294",
"0.6463873",
"0.6449658",
"0.64101374",
"0.63640726",
"0.63609296",
"0.6318674",
"0.6317... | 0.70145476 | 2 |
GET /evaluation_results/1 GET /evaluation_results/1.json | def show
@evaluation_result = EvaluationResult.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @evaluation_result }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end",
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params... | [
"0.7481146",
"0.7373165",
"0.7073973",
"0.6981189",
"0.6821165",
"0.67808354",
"0.6774783",
"0.67678374",
"0.67259586",
"0.66274625",
"0.66274625",
"0.66274625",
"0.66274625",
"0.66274625",
"0.65989876",
"0.65676486",
"0.65627754",
"0.6529607",
"0.6527041",
"0.64997494",
"0.6... | 0.73864186 | 1 |
GET /evaluation_results/new GET /evaluation_results/new.json | def new
@evaluation_result = EvaluationResult.new
#Carregar a apointment dinamicamente
@appoint_id = 0
if !params[:appID].blank?
@appoint_id = params[:appID].to_i
end
@wais = nil
@wms = nil
@tmt = nil
@ftt = nil
@clock = nil
app = Appointment.find(@appoint_id)
s = AppointmentStatus.find_by_name("Realizada")
app.appointment_status = s
app.save
#atual (a que acabou de se realizada)
appoint_plan = AppointmentPlan.where(:appointment_id => @appoint_id)
@patient = appoint_plan.first.appointment.patient
appoint_plan.each do |a|
if(a.evaluation_test.name == "wais")
@wais = WaisResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "wms")
@wms = WmsResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "ftt")
@ftt = FttResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "tmt")
@tmt = TmtResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "clock")
@clock = ClockResult.where(:appointment_plan_id => a.id)
end
end
#a antiga
@waisOld = nil
@wmsOld = nil
@tmtOld = nil
@fttOld = nil
@clockOld = nil
old_appoint = Appointment.joins(:appointment_status).where("appointments.patient_id = #{@patient.id} AND appointments.id != #{@appoint_id} AND appointments.appointment_day < '#{app.appointment_day.strftime("%Y-%m-%d")}' AND appointment_statuses.name = 'Realizada'").order("appointments.appointment_day DESC")
if old_appoint.count > 0
appoint_old_plan = AppointmentPlan.where(:appointment_id => old_appoint.first.id)
appoint_old_plan.each do |a|
if(a.evaluation_test.name == "wais")
@waisOld = WaisResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "wms")
@wmsOld = WmsResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "ftt")
@fttOld = FttResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "tmt")
@tmtOld = TmtResult.where(:appointment_plan_id => a.id)
end
if(a.evaluation_test.name == "clock")
@clockOld = ClockResult.where(:appointment_plan_id => a.id)
end
end
end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @evaluation_result }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @evaluation_criterium = EvaluationCriterium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end",
"def new\n @score_evaluation = ScoreEvaluation.new\n \n respond_to do |format|\n format.html #... | [
"0.7637054",
"0.7566443",
"0.75105196",
"0.7471408",
"0.74135417",
"0.7240107",
"0.71417457",
"0.7098841",
"0.7081929",
"0.6991452",
"0.6991452",
"0.6991452",
"0.6991452",
"0.6991147",
"0.69562274",
"0.6951149",
"0.6940805",
"0.6940805",
"0.6928093",
"0.692796",
"0.6898149",
... | 0.0 | -1 |
POST /evaluation_results POST /evaluation_results.json | def create
#raise params.inspect
@evaluation_result = EvaluationResult.new(params[:evaluation_result])
@evaluation_result.appointment_id = params[:appoint_id].to_i
if params[:commit].to_s == "Gravar Rascunho"
app = Appointment.find(params[:appoint_id].to_i)
s = AppointmentStatus.find_by_name("Em Avaliacao")
app.appointment_status = s
app.save
else
app = Appointment.find(params[:appoint_id].to_i)
s = AppointmentStatus.find_by_name("Realizada")
app.appointment_status = s
app.save
end
respond_to do |format|
if @evaluation_result.save
if params[:commit].to_s == "Gravar Rascunho"
format.html { redirect_to appointments_path, notice: 'Resultados da avaliacao guardados com sucesso.' }
else
format.html { redirect_to "http://teste93.di.uminho.pt:8000/reporting?report=Avaliacao&Appointment_Id=#{params[:appoint_id].to_s}", notice: 'Resultados da avaliacao guardados com sucesso.' }
end
format.json { render json: @evaluation_result, status: :created, location: @evaluation_result }
else
format.html { render action: "new" }
format.json { render json: @evaluation_result.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n render :show, status: :created\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end",
"def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do... | [
"0.70667",
"0.6993682",
"0.68016493",
"0.6745947",
"0.6745947",
"0.6723304",
"0.6716674",
"0.66847014",
"0.6674668",
"0.66062784",
"0.66062784",
"0.65733236",
"0.6567791",
"0.64992815",
"0.6408621",
"0.63824505",
"0.6378213",
"0.62590283",
"0.62417674",
"0.6229383",
"0.622310... | 0.0 | -1 |
PUT /evaluation_results/1 PUT /evaluation_results/1.json | def update
#raise params.inspect
@evaluation_result = EvaluationResult.find(params[:id])
if params[:commit].to_s == "Gravar Rascunho"
app = Appointment.find(params[:appoint_id].to_i)
s = AppointmentStatus.find_by_name("Em Avaliacao")
app.appointment_status = s
app.save
else
app = Appointment.find(params[:appoint_id].to_i)
s = AppointmentStatus.find_by_name("Realizada")
app.appointment_status = s
app.save
end
respond_to do |format|
if @evaluation_result.update_attributes(params[:evaluation_result])
if params[:commit].to_s == "Gravar Rascunho"
format.html { redirect_to appointments_path, notice: 'Resultados da avaliacao guardados com sucesso.' }
else
format.html { redirect_to "http://localhost:8000/reporting?report=Avaliacao&Appointment_Id=#{params[:appoint_id].to_s}", notice: 'Resultados da avaliacao guardados com sucesso.' }
end
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @evaluation_result.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @evaluation.update(evaluation_params)\n render :show, status: :ok\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to re... | [
"0.7305009",
"0.71272373",
"0.6954757",
"0.6899922",
"0.6893215",
"0.6893215",
"0.6893215",
"0.681372",
"0.6811606",
"0.6811606",
"0.68110174",
"0.6749816",
"0.6639483",
"0.66349095",
"0.6586382",
"0.6551227",
"0.6517343",
"0.6504049",
"0.643835",
"0.64354163",
"0.6402645",
... | 0.6224539 | 34 |
DELETE /evaluation_results/1 DELETE /evaluation_results/1.json | def destroy
@evaluation_result = EvaluationResult.find(params[:id])
@evaluation_result.destroy
respond_to do |format|
format.html { redirect_to evaluation_results_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { h... | [
"0.7762006",
"0.7762006",
"0.7679683",
"0.74880934",
"0.74754",
"0.74522024",
"0.74406695",
"0.7439916",
"0.7439916",
"0.7439916",
"0.7439916",
"0.7439916",
"0.7439916",
"0.74390936",
"0.73892003",
"0.73283565",
"0.73201495",
"0.73201495",
"0.73084986",
"0.72568333",
"0.72060... | 0.79281056 | 0 |
Create a subtype with the specified name | def create_subtype(name)
Class.new(self) do
@name = Dry::Inflector.new.classify(name.to_s)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtype(name, options=nil)\n @subtypes ||= Hash.new\n\n return @subtypes[name] if options.nil?\n raise ArgumentError unless options.is_a? Hash\n\n @subtypes[name] = Aura::Subtype.new(options.merge({:id => name }))\n end",
"def create_type(name, **options)\n register(Type.n... | [
"0.70202976",
"0.6880496",
"0.6166106",
"0.6148566",
"0.59778374",
"0.59728634",
"0.5943047",
"0.5846682",
"0.5830216",
"0.5823646",
"0.58125544",
"0.5757602",
"0.5748404",
"0.56732255",
"0.5594084",
"0.5543872",
"0.551366",
"0.5491855",
"0.548574",
"0.5457518",
"0.5453519",
... | 0.8251834 | 0 |
params hash: username dictionaryname dictionarykind create / open | def login
logger.debug(params.inspect)
reset_message
username=params[:username].strip
dictionaryname=params[:dictionaryname].strip
dictionarykind=params[:dictionarykind].strip
logger.debug("#{username}/#{dictionaryname}/#{dictionarykind}")
# Once we have user registration and password
# authentification, this should be done here.
if username.empty?
set_message('User ID missing')
elsif dictionarykind.empty?
set_message('Dictionary language missing')
elsif params.has_key?('create')
redirect_to url_for(:controller => :dicts, :action => :new)
# redirect_to url_for(:controller => :dicts, :action => :create, :method => :post)
elsif params.has_key?('open')
if dictionaryname.empty?
set_message('not implemented yet')
action='open'
else
set_message('not implemented yet')
action='pick'
end
else
set_message('Unexpected submit key')
end
if has_message?
logger.debug(message)
render 'init'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user(user)\n user.downcase!\n hash = Hash.new\n hash[:name] = \"#{user}\"\n hash[:balance] = 0\n puts \"Please create a password: \"\n hash[:password] = gets.chomp\n write_to_file(\"userdata/#{user}.txt\",hash)\n write_to_file(\"userdata/#{user}_history.txt\", nil)\nend",
"def ... | [
"0.62323546",
"0.58921707",
"0.5805444",
"0.577023",
"0.5673178",
"0.560933",
"0.55756265",
"0.55635566",
"0.55635566",
"0.55587995",
"0.55568844",
"0.55526066",
"0.5547166",
"0.55302334",
"0.5510834",
"0.5486869",
"0.54626316",
"0.54599035",
"0.5415148",
"0.5399511",
"0.5386... | 0.5470207 | 16 |
init the node with a single value | def initialize(value)
@value = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(val, next_in_line)\r\n\t\t@value = val\r\n\t\t@next_node = next_in_line\r\n\t\tputs \"Initialized a Node with value: \" + @value.to_s\r\n\tend",
"def init_node\n end",
"def init_node\n end",
"def initialize(value)\n value==nil ? raise : #throw an exception if there were no value... | [
"0.74811554",
"0.7177529",
"0.7177529",
"0.7111569",
"0.70805216",
"0.70355225",
"0.70064145",
"0.69219166",
"0.68840396",
"0.6819446",
"0.68180317",
"0.67206776",
"0.67097205",
"0.6674125",
"0.6650982",
"0.6600075",
"0.65912104",
"0.6582042",
"0.65804535",
"0.65121067",
"0.6... | 0.62187934 | 63 |
Format: [VALUE, LEFT, RIGHT] | def print
"[#{@value},#{@left ? @left.print : "nil"},#{@right ? @right.print : "nil"}]"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n \"[ value: #{@value} Left: #{@left} Right: #{@right} ]\"\n end",
"def right\n value.rjust(width, options[:pad])\n end",
"def to_s\n \"#{@left} #{@right}\"\n end",
"def right_to_left(val = nil)\n @display_arabic = val.nil? ? 1 : val\n end",
"def to_s\n \"[#@left vs. ... | [
"0.7028311",
"0.61676204",
"0.60402435",
"0.58494484",
"0.58475006",
"0.5740951",
"0.5716966",
"0.5707018",
"0.57008564",
"0.5678218",
"0.56570625",
"0.56564057",
"0.5645807",
"0.5616046",
"0.5603399",
"0.55466944",
"0.55422306",
"0.54698443",
"0.54448354",
"0.54228914",
"0.5... | 0.51746696 | 52 |
this is to add new client if he do not exist in the db | def new_client
client_name = @prompt.ask("Please Enter Your Name")
client_phone = @prompt.ask("Please Enter Your Phone Number")
client_email = @prompt.ask("Please Enter Your Email Address")
@client = Client.create(name: client_name, phone: client_phone, email: client_email)
appointment_system
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addClient(raison_sociale, division, departement, adresse, cp, ville, nom_contact, tel_contact)\n\t\tid = \"0\"\n\t\tunless @sqlQuery.nil? then\n\t\t\tid = @sqlQuery.insertClient(raison_sociale, division, departement, adresse, cp, ville, nom_contact,tel_contact)\n\t\telse\n\t\t\tputs \"SqlQuery wasn't created :... | [
"0.7217173",
"0.67527455",
"0.66097575",
"0.65489054",
"0.6482968",
"0.6454116",
"0.64413816",
"0.63587856",
"0.6351475",
"0.6284378",
"0.6244992",
"0.62235284",
"0.62235284",
"0.6221986",
"0.6198592",
"0.61842453",
"0.61708456",
"0.6165871",
"0.61472094",
"0.6142277",
"0.613... | 0.0 | -1 |
This is login method is displayed first | def login
puts "Welcome to Singh Accounting Online Appointment System"
@prompt.select "Are you a returning client?" do |menu|
menu.choice "Yes", -> do
phone = @prompt.ask("Please Enter Your Phone Number")
@client = Client.find_by(phone: phone)
if @client.nil?
puts "Sorry, cannot find client with that phone"
@prompt.select "What would you like to do?" do |m|
m.choice "Try Again", -> { login }
m.choice "Create Account", -> { new_client }
m.choice "Exit", -> { exit_method }
end
end
end
menu.choice "No (Create New Client Portal)", -> { new_client }
menu.choice "Exit The System", -> { exit_method }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login; end",
"def login\n\n end",
"def login\n\n end",
"def login\n\tend",
"def... | [
"0.84582883",
"0.8425049",
"0.8425049",
"0.8425049",
"0.8425049",
"0.8425049",
"0.8425049",
"0.8425049",
"0.8425049",
"0.8425049",
"0.833597",
"0.8329737",
"0.8329737",
"0.83289945",
"0.8028985",
"0.8007705",
"0.79553676",
"0.78733224",
"0.7809691",
"0.7805523",
"0.77277386",... | 0.0 | -1 |
this is helper method | def ask
@prompt.select "Would you like to schedule appointment now" do |menu|
menu.choice " Yes", -> { schedule_appointment }
menu.choice " No <Go Back>", -> { appointment_system }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def suivre; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def formation; end",
"def probers; end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def refutal()\n end",
"def custom; end",
"def ... | [
"0.7163398",
"0.6444575",
"0.6361894",
"0.63416207",
"0.63416207",
"0.63416207",
"0.63416207",
"0.61939526",
"0.6162676",
"0.6014998",
"0.6014998",
"0.6014998",
"0.59494996",
"0.5947865",
"0.5947865",
"0.58083814",
"0.5772347",
"0.57611656",
"0.57611656",
"0.5750727",
"0.5733... | 0.0 | -1 |
This method is checking the appointments array if the client has appointments it will display | def view_appointment
if @client.appointments.length < 1
puts "You currently have no appointments"
sleep(2)
else
puts "Here are your appointments:"
@client.appointments.pluck(:time).each { |time| puts " - #{time}" }
@prompt.select "" do |m|
m.choice "<Go Back>", -> { appointment_system }
end
end
appointment_system
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_appts_avail?\n appointments.empty?\n end",
"def client_appointments\n self.clients.map(&:appointments)\n end",
"def appointments(officer_id)\n client.get(\"officers/#{officer_id}/appointments/\")\n end",
"def appointments\n Appointment.all.filter { |appointment| appoin... | [
"0.7500944",
"0.70246536",
"0.7005216",
"0.69783884",
"0.69349825",
"0.69082445",
"0.6880158",
"0.685887",
"0.6858353",
"0.6657225",
"0.66444826",
"0.66444826",
"0.66369784",
"0.65958816",
"0.65866876",
"0.6525529",
"0.6507669",
"0.6500865",
"0.64775515",
"0.642806",
"0.64210... | 0.65014577 | 17 |
this is a helper method for changing appointments | def change_appt(appt)
time = @prompt.ask("Plase Enter The New Date and Time -> Ex. 12/12/12 AT 12:00 PM")
appt.update(time: time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_appointment\n @appointment = current_user.appointments.find(params[:id])\n end",
"def reschedule_appointment\n if @patient.appointments.length < 1\n puts \"You currently have no appointments\"\n sleep(2)\n else\n @prompt.select \"Which appointment would you like to Re... | [
"0.7073023",
"0.70603794",
"0.705739",
"0.704644",
"0.6916919",
"0.6899395",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0.6890503",
"0... | 0.6292485 | 56 |
this method is for re | def reschedule_appointment
if @client.appointments.length < 1
puts "You currently have no appointments"
sleep(2)
else
@prompt.select "Which appointment would you like to Reschedule?" do |menu|
@client.appointments.each do |appt|
menu.choice appt.time, -> { change_appt(appt) }
end
menu.choice "<Go Back>", -> { appointment_system } #back
end
end
@client.reload
appointment_system
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def re; end",
"def pre_match() end",
"def start_re; end",
"def start_re=(_); end",
"def post_match() end",
"def regexps; end",
"def longexpr\n end",
"def regexp; end",
"def regexp; end",
"def match; end",
"def match; end",
"def regexp=(_arg0); end",
"def pattern; end",
"def pattern; ... | [
"0.7785246",
"0.70568687",
"0.7028423",
"0.69559264",
"0.66928923",
"0.6660971",
"0.6538018",
"0.65272415",
"0.65272415",
"0.6476486",
"0.6476486",
"0.6399563",
"0.6391534",
"0.6391534",
"0.6391534",
"0.6323875",
"0.6323875",
"0.6200267",
"0.6200267",
"0.61750734",
"0.6123268... | 0.0 | -1 |
This method is for canceling the appointment using .destory | def cancel_appointment
if @client.appointments.length < 1
puts "You currently have no appointments"
sleep(2)
else
@prompt.select "Which appointment would you like to cancel?" do |menu|
@client.appointments.each do |appt|
menu.choice appt.time, -> { appt.destroy }
end
menu.choice "<Go Back>", -> { appointment_system } #back
end
end
@client.reload
appointment_system
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_appointment\n if @patient.appointments.length < 1\n puts \"You currently have no appointments\"\n sleep(2)\n else\n @prompt.select \"Which appointment would you like to cancel?\" do |menu|\n @patient.appointments.each do |appt|\n menu.choice appt.time, -> { app... | [
"0.77583647",
"0.7672438",
"0.7561555",
"0.7285596",
"0.7160357",
"0.70855874",
"0.7076817",
"0.7070798",
"0.7064731",
"0.6811455",
"0.680244",
"0.67951375",
"0.66728586",
"0.6637962",
"0.6557781",
"0.6540059",
"0.6540059",
"0.6539285",
"0.64800227",
"0.6435434",
"0.6399447",... | 0.7485391 | 3 |
Return ruby object named in a string. s = "Socket".constantize puts s.name Prints "Socket" puts s.class Prints "Class" | def constantize
return self.to_s.split('::').reduce(Module){ |m, c| m.const_get(c) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_by_name name\n # http://stackoverflow.com/questions/14070369/how-to-instantiate-class-from-name-string-in-rails\n Object.const_get name.to_s\n\n end",
"def class_from_string(class_name)\n parts = class_name.split('::')\n constant = Object\n parts.each do |part|\n constant = constant.const_... | [
"0.72180194",
"0.675352",
"0.6593331",
"0.6558463",
"0.64215624",
"0.64056665",
"0.63998854",
"0.63037235",
"0.6301413",
"0.62252253",
"0.61604434",
"0.6112353",
"0.6096808",
"0.60948586",
"0.607977",
"0.60353106",
"0.60243744",
"0.6020395",
"0.5992228",
"0.5982651",
"0.59320... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.