This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package chash | |
| import ( | |
| "encoding/binary" | |
| "errors" | |
| "hash/crc32" | |
| "math" | |
| "sort" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Taken from: | |
| // https://raw.githubusercontent.com/openresty/lua-resty-balancer/refs/heads/master/chash.c | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <math.h> | |
| #include <assert.h> | |
| #include "chash.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationRecord < ActiveRecord::Base | |
| primary_abstract_class | |
| connects_to database: { writing: :primary } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this is a dirty implementation of logger that | |
| # compiles AR queries with trace into /last_request_log.html | |
| # the snippet is useful when optimizing performance of the endpoint | |
| class QueryLogSubscriber < ActiveSupport::LogSubscriber | |
| TRACE_LEVEL = :app | |
| LINES = 5 | |
| IGNORE_CACHED_QUERIES = false | |
| def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PRAGMA foreign_keys=OFF; | |
| BEGIN TRANSACTION; | |
| CREATE TABLE list (id VARCHAR(64) NOT NULL, value VARCHAR(64) NOT NULL, PRIMARY KEY(id)); | |
| INSERT INTO list VALUES('AF','Afghanistan'); | |
| INSERT INTO list VALUES('AL','Albania'); | |
| INSERT INTO list VALUES('DZ','Algerie'); | |
| INSERT INTO list VALUES('AS','Amerikansk Samoa'); | |
| INSERT INTO list VALUES('AD','Andorra'); | |
| INSERT INTO list VALUES('AO','Angola'); | |
| INSERT INTO list VALUES('AI','Anguilla'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.delMessages = function() { | |
| window.nodes = document.getElementsByClassName('mail_actions'); | |
| window.alex = 0; | |
| window.c = 0; | |
| var m = document.body.scrollHeight;var e = function() { | |
| var num = window.nodes[window.alex] | |
| if (num) { | |
| num.childNodes[1].onclick(); | |
| window.alex++; | |
| topError('Удалено ' + window.alex + ' сообщений. Made by Alexander Sergeev.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'bundler/inline' | |
| gemfile do | |
| source "https://rubygems.org" | |
| gem "resque" | |
| gem "pry" | |
| gem "activerecord" | |
| gem 'mysql2' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'google/api_client' | |
| client = Google::APIClient.new | |
| translate = client.discovered_api('translate', 'v2') | |
| client.authorization.access_token = '123' # dummy | |
| client.key = "my-key-example" # your key from Google API console | |
| response = client.execute( | |
| :api_method => translate.translations.list, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cleans up branches like: | |
| # if Shopify.rails_next? | |
| # # Rails 5 login | |
| # else | |
| # # Rails 4 login | |
| # end | |
| module RuboCop | |
| module Cop | |
| module ShopifyRails | |
| class RailsNextUnless < Cop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function() { | |
| var projectForm = $(".form-repo") | |
| var repoOwnerField = projectForm.find("select[name=owner]") | |
| var repoNameField = projectForm.find("select[name=name]") | |
| if(projectForm.length == 0) { | |
| return | |
| } | |
| repoNameField.selectize({ |
NewerOlder