Skip to content

Instantly share code, notes, and snippets.

Alexa, ask the future of America to be great again! (try it)

Daniel (dB.) Doubrovkine dblock

Alexa, ask the future of America to be great again! (try it)
View GitHub Profile
dblock / clickhacking.html
Created Sep 22, 2014
Clickjacking test.
View clickhacking.html
<title>Clickjacking Test</title>
<p>If you can see the website below, it's vulnerable to clickjacking.</p>
<iframe src="" width="500" height="500"></iframe>
View gist:fc2a864713d664f33f6a6bdeac3f518f
I am attesting that this GitHub handle dblock is linked to the Tezos account tz1ivFsNqtfLTSDh7uzqJ6pArNRG13pkJt4a for tzprofiles
dblock / carrierwave.rb
Created Jan 31, 2012
Delayed image processing with CarrierWave
View carrierwave.rb
CarrierWave.configure do |config|
Mongoid::Document::ClassMethods.send(:include, DelayedImageProcessing)
module CarrierWave
# Note: is_processing_delayed should be set before calling recreate_version! if the version depends on it.
dblock / getWeek.js
Created Jul 13, 2011
get week of the year in JavaScript
View getWeek.js
function( d ) {
// Create a copy of this date object
var target = new Date(d.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (d.getDay() + 6) % 7;
// Set the target to the thursday of this week so the
dblock / api_logger.rb
Created Dec 10, 2012
API logger with Grape under Rails
View api_logger.rb
class ApiLogger < Grape::Middleware::Base
def before "[api] Requested: #{request_log_data.to_json}\n" +
"[api] #{response_log_data[:description]} #{response_log_data[:source_file]}:#{response_log_data[:source_line]}"
def request_log_data
dblock /
Last active Sep 11, 2020
Auto-start Dropbox.
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
dblock /
Created Jun 9, 2011
Delete merged git branches.
git branch --merged | grep -v master | xargs git branch -d
git branch -r --merged | awk -F'/' '/^ *origin/{if(!match($0, /(>|master)/)){print $2}}' | xargs git push origin --delete
dblock /
Last active Jun 11, 2020
Backup MongoDB databases with Dropbox and Dokku
set -e
echo "Backing up MongoDB databases to Dropbox ..."
dt=$(date +"%Y-%m-%d")
echo " today is $dt"
dblock / api_page_helper.rb
Created Nov 2, 2011
pagination helper with Grape
View api_page_helper.rb
module ApiPageHelper
:default_page_size => 10
PAGINATE_PARAMS = [ "page", "offset", "size" ]
def paginate(coll, options = {})
options = PAGINATE_OPTIONS.merge(options)
if params[:page]
page = params[:page].to_i
size = (params[:size] || options[:default_page_size]).to_i
dblock / grape-rackup-with-static.rb
Created Feb 20, 2012
Rackup static pages along with a Grape API, inspired by Rack::TryStatic
View grape-rackup-with-static.rb
class App
def initialize(options)
@try = ['', *options.delete(:try)]
@static =
lambda { [404, {}, []] },
def call(env)