Search redemption codes
961062
def build_search_query
        string = params[:search].split ' '
        redeem_codes = DealRedemptions::RedeemCode.arel_table
        companies = DealRedemptions::Company.arel_table
        query = redeem_codes.project(
          redeem_codes[:id],
          redeem_codes[:company_id],
          redeem_codes[:code],
          redeem_codes[:status],
          redeem_codes[:created_at]
        )
        .join(companies)
        .on(redeem_codes[:company_id]
            .eq(companies[:id]))

        string.each do |s|
          query.where(redeem_codes[:code].matches("%#{s}%"))
        end

        query.to_sql
      end
1239781
def redeem(recipient_account_code)
      clear_errors
      xml = <<-XML
        <recipient_account>
            <account_code>#{recipient_account_code}</account_code>
        </recipient_account>
      XML
      @response = API.send(:post, "#{self.class.collection_path}/#{redemption_code}/redeem", xml)
      reload response
    rescue API::UnprocessableEntity => e
      apply_errors e
    end
759289
def get_allcurrencycodes(self):
        """"""
        foundcodes = []
        codeelements = self.currencies[0].iter('Ccy')
        for codeelement in codeelements:
            code = codeelement.text
            if code not in foundcodes:
                foundcodes += [code]
                yield code
765024
public function searchTransactions()
    {
        try {
            $connection = $this->getConnection();
            $select = $connection->select()
                ->from( ['order' => 'sales_order'], ['status', 'created_at', 'increment_id', 'store_id', 'entity_id'] )
                ->join( ['ps' => 'pagseguro_orders'], 'order.entity_id = ps.order_id')
                ->where('ps.transaction_code != ?', '')
                ->order('order.created_at DESC');

            if (!is_null($this->_session->getData('store_id'))) {
                $select = $select->where('order.store_id = ?', $this->_session->getData('store_id'));
            }

            if ($this->_scopeConfig->getValue('payment/pagseguro/environment')) {
                $select = $select->where('ps.environment = ?', $this->_scopeConfig->getValue('payment/pagseguro/environment'));
            }

            if (!empty($this->_idMagento)) {
                $select = $select->where('order.increment_id = ?', $this->_idMagento);
            }

            if (!empty($this->_idPagseguro)) {
                $select = $select->where('ps.transaction_code = ?', $this->_idPagseguro);
            }

            if (!empty($this->_status)) {
                $select = $this->getStatusFromPaymentKey($this->_status) == 'partially_refunded'
                    ? $select->where('ps.partially_refunded = ?', 1)
                    : $select->where('order.status = ?', $this->getStatusFromPaymentKey($this->_status));
            }

            if (!empty($this->_dateBegin) && !empty($this->_dateEnd)) {
                $startDate = date('Y-m-d H:i:s', strtotime(str_replace("/", "-", $this->_dateBegin)));
                $endDate = date('Y-m-d'.' 23:59:59', strtotime(str_replace("/", "-", $this->_dateEnd)));
                $select = $select->where('order.created_at >= ?', $startDate)->where('order.created_at <= ?', $endDate);
            }

            $connection->prepare($select);
            return $connection->fetchAll($select);
        } catch (\Exception $exception) {
            throw $exception;
        }
    }
1324600
def subsc_search(self, article_code, **kwargs):
        ''''''
        request = TOPRequest('taobao.vas.subsc.search')
        request['article_code'] = article_code
        for k, v in kwargs.iteritems():
            if k not in ('item_code', 'nick', 'start_deadline', 'end_deadline', 'status', 'autosub', 'expire_notice', 'page_size','page_no') and v==None: continue
            request[k] = v
        self.create(self.execute(request), fields=['article_subs','total_item'], models={'article_subs':ArticleSub})
        return self.article_subs
621037
def codes(self):
        '''
        
        '''
        for start, end in self:
            for item in range(start, end):
                yield item
154173
def guess_sequence(redeem_script):
    '''
    
    '''
    try:
        script_array = redeem_script.split()
        loc = script_array.index('OP_CHECKSEQUENCEVERIFY')
        return int(script_array[loc - 1], 16)
    except ValueError:
        return 0xFFFFFFFE
1201629
def search query
      rake_yard(store)
      found = []
      code_object_paths.each do |k|
        if found.empty? || (query.include?('.') || query.include?('#')) || !(k.include?('.') || k.include?('#'))
          found.push k if k.downcase.include?(query.downcase)
        end
      end
      found
    end
1226265
function () {
    log ('     Non-strict search: node', process.argv[1], 'symbol'.green)
    log ('     Non-strict search: node', process.argv[1], 'currency'.green)
    log ('         Strict search: node', process.argv[1], '--strict', 'argument'.green)
    log ('   Search markets only: node', process.argv[1], '--markets', 'argument'.green)
    log ('Search currencies only: node', process.argv[1], '--currencies', 'argument'.green)

}
829147
def update
      if @existing_code.count > 0
        flash[:notice] = 'Redemption code already exists.'
        render :edit
      else
        if @admin_redeem_code.update(redeem_code_params)
          redirect_to admin_redeem_codes_path, notice: 'Redeem code was successfully updated.'
        else
          render :edit
        end
      end
    end
254148
def get_evcodes_all(self, inc_set=None, exc_set=None):
        """"""
        codes = self._get_grps_n_codes(inc_set) if inc_set else set(self.code2nt)
        if exc_set:
            codes.difference_update(self._get_grps_n_codes(exc_set))
        return codes
940183
def btc_make_p2sh_p2wpkh_redeem_script( pubkey_hex ):
    
    pubkey_hash = hashing.bin_hash160(pubkey_hex.decode('hex')).encode('hex')
    redeem_script = btc_script_serialize(['0014' + pubkey_hash])
    return redeem_script
1248159
def lookup_hlr(self, phonenumber, params=None):
        """"""
        if params is None: params = {}
        return HLR().load(self.request('lookup/' + str(phonenumber) + '/hlr', 'GET', params))
841160
def _get_same_codes(self):
        """"""
        same = {}
        url = '''http://www.nws.noaa.gov/nwr/data/SameCode.txt'''
        # pylint: disable=E1103
        raw = requests.get(url).content.decode('utf-8')  # py3 compatibility
        for row in raw.split('\n'):
            try:
                code, local, state = str(row).strip().split(',')
                location = {'code': code, 'local': local, 'state': state.strip()}
                # when I contacted the nws to add a missing same code
                # they added a space before the state in the samecodes file
                # stripping it out
                same[code] = location
            finally:
                pass
        cache = open(self._same_cache_file, 'wb')
        cPickle.dump(same, cache)
        cache.close()
        return same
1120159
def search_regexp(self):
        
        if ((self.season == "") and (self.episode == "")):
            regexp = '^%s.*' % self.title.lower()
        elif (self.episode == ""):
            regexp = '^%s.*(s[0]*%s|season[\s\_\-\.]*%s).*' % (self.title.lower(), self.season, self.season)
        else:
            regexp = '^%s.*((s[0]*%s.*e[0]*%s)|[0]*%sx[0]*%s).*' % (self.title.lower(), self.season, self.episode, self.season, self.episode)
        return regexp
834821
def search(self, song_title, limit=1):
        
        url = "http://music.163.com/api/search/pc"
        headers = {'Cookie': 'appver=1.5.2',
                   'Referer': 'http://music.163.com'}
        payload = {'s': song_title,
                   'limit': limit,
                   'type': 1}

        r = requests.post(url, params=payload, headers=headers)
        data = json.loads(r.text)

        if data['code'] == 200:
            return data['result']['songs'][0]
        else:
            return None
112962
function QueryString(search) {
        "use strict";
    
        if (search.substr(0, 1) === '?') {
            search = search.substr(1);
        }
    
        search = search.split('&')
    
        if (search == "") return {};
    
        for (var i = 0; i < search.length; ++i) {
    
            var param = search[i].split('=', 2);
            if (param.length != 2) {
                continue;
            }
    
            this[param[0]] = decodeURIComponent(param[1].replace(/\+/g, " "));
    
        }
    
    }