This file contains 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
> ./ruby test.rb | |
test.rb:9: warning: 'sub!' called on a string that could, in the future be frozen. string created at test.rb:4 | |
test.rb:14: warning: '[]=' called on a string that could, in the future be frozen. string created at test.rb:4 |
This file contains 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 EAN13Outputter < Barby::RmagickOutputter | |
attr_writer :font_size | |
def to_image(opts = {}) | |
with_options opts do | |
canvas = Magick::Image.new(full_width, full_height) | |
bars = Magick::Draw.new | |
x1 = margin + offset_width | |
y1 = margin + (offset_height / 2) |
This file contains 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" | |
Bundler.require | |
require "addressable" | |
require "socket" | |
require "ipaddr" | |
proxy_address = Addressable::URI.parse("socks5://user:password@host:1080") | |
remote_ip = IPAddr.new(IPSocket::getaddress("icanhazip.com")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule TestApp.Serializer do | |
defmacro __using__(_) do | |
quote do | |
defimpl Msgpax.Packer, for: __MODULE__ do | |
def transform(struct) do | |
type = String.replace_prefix(to_string(__MODULE__), "Elixir.Msgpax.Packer.TestApp.Data.", "") | |
Msgpax.Packer.Map.transform(Map.merge(Map.from_struct(struct), %{"__type" => type})) | |
end | |
end | |
end |
This file contains 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 Template | |
def initialize(content) | |
@content = content | |
end | |
def render(context) | |
context = Hashie::Mash.new(context) | |
@content.gsub(/(%{([^}]+)})/) do | |
context[Regexp.last_match[2]] |
This file contains 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
# delete index if exists | |
curl -XDELETE localhost:9200/test_nesting/ | |
# create index with default settings | |
curl -XPOST localhost:9200/test_nesting/ | |
# create mapping | |
curl -XPUT localhost:9200/test_nesting/link/_mapping -d ' | |
{ | |
"link" : { |
This file contains 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
"sort": { | |
"_script": { | |
"script": "long lowestPublishedAt; for (int i = 0; i < _source.sources.size(); i++) { Boolean foundInList = false; for (int x = 0; x < external_ids.size(); x++) { if (external_ids[x] == _source.sources[i].external_id) { foundInList = true; break; } } if (foundInList) { if (i == 0 || _source.sources[i].published_at < lowestPublishedAt) { lowestPublishedAt = _source.sources[i].published_at; } } } return lowestPublishedAt;", | |
"type": "number", | |
"params": { | |
"external_ids": [ | |
"a99240f3", | |
"a217f93" | |
] | |
}, |
This file contains 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
<script type="text/javascript"> | |
window.notifications = <%= flash[:notifications].to_json %>; | |
</script> | |
growl.js.psuedo | |
-------- | |
foreach (notification in window.notifications) { | |
showNotification(notification); | |
} |
This file contains 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 Bootstrapper : WindsorNancyBootstrapper { | |
private readonly IWindsorContainer _container; | |
public Bootstrapper(IWindsorContainer container) | |
{ | |
_container = container; | |
} | |
protected override Castle.Windsor.IWindsorContainer GetApplicationContainer () | |
{ |
This file contains 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
Oct 24 11:37:02 ip-10-58-137-38 varnishd[1225]: Platform: Linux,3.4.62-53.42.amzn1.x86_64,x86_64,-sfile,-smalloc,-hcritbit | |
Oct 24 11:37:02 ip-10-58-137-38 varnishd[1225]: child (1226) Started | |
Oct 24 11:37:02 ip-10-58-137-38 varnishd[1225]: Child (1226) said Child starts | |
Oct 24 11:37:02 ip-10-58-137-38 varnishd[1225]: Child (1226) said SMF.s0 mmap'ed 1073741824 bytes of 1073741824 | |
Oct 24 11:52:02 ip-10-58-137-38 varnishd[1225]: Manager got SIGINT |
NewerOlder