Skip to content

Instantly share code, notes, and snippets.

View djpate's full-sized avatar

Christophe Verbinnen djpate

View GitHub Profile
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$ref": "#/definitions/ScanBatch",
"definitions": {
"ScanBatch": {
"type": "object",
"additionalProperties": false,
"properties": {
"version": {
"type": "string"
@djpate
djpate / README.txt
Created April 20, 2021 02:57
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
@djpate
djpate / cors.config
Created August 28, 2016 15:55
Add CORS to a ruby app with nginx in Elastic Beanstalk(EBS)
#This should be in ebextensions
container_commands:
01setup_cors:
command: "ruby .ebextensions/cors.rb"
02reload_nginx:
command: "service nginx reload"
@djpate
djpate / redis_view_counter.rb
Created August 20, 2016 04:37
Unique views store in redis with daily rotation
class RedisViewCounter
attr_reader :object
def initialize(object)
@object = object
end
def register_view(fingerprint)
created = !$redis.exists(daily_key)
@djpate
djpate / sharded_web.rb
Created December 6, 2015 00:21
Sharded Sidekiq Webui
REDIS_A = ConnectionPool.new { Redis.new(:db => 1) }
REDIS_B = ConnectionPool.new { Redis.new(:db => 2) }
class ShardedWeb < Sidekiq::Web
before do
desired_shard = params[:shard] || request.cookies['sidekiq_shard']
if desired_shard
Thread.current[:sidekiq_via_pool] = Object.const_get(desired_shard)
#this prevents us from having to override all links in the web ERBs
require 'benchmark'
module ActiveSupport
module Notifications
# This is a default queue implementation that ships with Notifications.
# It just pushes events to all registered log subscribers.
class Fanout
def initialize
@subscribers = []
@listeners_for = {}
@mutex = Mutex.new
define [
'ConsoleFactory'
'oraculum/mixins/evented-method'
'oraculum/mixins/listener'
'select2'
], (ConsoleFactory) ->
ConsoleFactory.defineMixin 'Select2.ViewMixin', {
mixinOptions:
subviews:
type_ahead:
view: 'AssessmentSearch.View'
viewOptions:
el: '#assessment_parent_assessment_id'
model: 'Model'
select2Options:
allowClear: true
curl -X DELETE "http://localhost:9200/wildcards/"
curl -X POST "http://localhost:9200/wildcards/" -d '{
"mappings": {
"post": {
properties: {
"tags": {
"type": "nested",
"properties": {
"name": {"type": "string"},
"identifier": {"type": "string", "analyzer": "keyword"}
%html
%head
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
%title= content_for?(:title) ? yield(:title) : "App_Name"
%meta{:content => content_for?(:description) ? yield(:description) : "App_Name", :name => "description"}
= stylesheet_link_tag :application, :media => "all"
= javascript_include_tag :application
= csrf_meta_tags
= yield(:head)
%body