Skip to content

Instantly share code, notes, and snippets.

Danny Ben Shitrit DannyBen

Block or report user

Report or block DannyBen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DannyBen
DannyBen / asn
Last active Oct 27, 2019 — forked from nitefood/asn
ASN/IP/Route/hostname command line lookup tool to map any network to the corresponding ASN and prefix
View asn
#!/usr/bin/env bash
##############################################################################
# ----------------------------------------------------------------------
# ASN/IPv4/Prefix lookup tool. Uses Team Cymru's whois service for data.
# ----------------------------------------------------------------------
# example usage:
# asn <ASnumber> -- to lookup matching ASN data. Supports "as123" and
# "123" formats (case insensitive)
# asn <IP.AD.DR.ESS> -- to lookup matching route and ASN data
@DannyBen
DannyBen / Ruby Benchmark Helper.md
Last active Sep 20, 2019
Ruby Benchmark Helper
View Ruby Benchmark Helper.md

Ruby Benchmark Helper

Usage

require './bm'

bm = BM.new

bm.add(:sleep_long) { sleep 0.1 }
@DannyBen
DannyBen / config.ru
Last active May 7, 2019
Minimal Server for Request Header Debugging
View config.ru
# Usage:
# $ rackup -p3000
# $ curl localhost:3000
require 'rack'
require 'yaml'
run proc { |env| [200, {'Content-Type' => 'text/html'}, [env.select { |key| key.include?('HTTP_') }.to_yaml ] ] }
@DannyBen
DannyBen / Runfile
Created Aug 26, 2018
Ruby UDP Example
View Runfile
require 'socket'
title "UDP Test"
action :server do
s = UDPSocket.new
s.bind(nil, 1234)
5.times do
text, sender = s.recvfrom(16)
puts "received #{text} from #{sender}"
@DannyBen
DannyBen / spec_helper.rb
Last active Feb 15, 2018 — forked from nu7hatch/spec_helper.rb
Testing standard input with RSpec
View spec_helper.rb
module Helpers
# Replace standard input with faked one StringIO.
def stdin_send(*args)
begin
$stdin = StringIO.new
$stdin.puts(args.shift) until args.empty?
$stdin.rewind
yield
ensure
$stdin = STDIN
View Xenial Xerus Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
forward_port = ->(guest, host = guest) do
config.vm.network :forwarded_port,
guest: guest,
host: host,
auto_correct: true
end
@DannyBen
DannyBen / ssx
Last active Feb 25, 2016
Run a ruby or shell script remotely
View ssx
# Run a ruby or shell script remotely
#
# Install:
# - Put the file in your home directory
# - Source it from your .bashrc:
# if [ -f $HOME/ssx ]; then source $HOME/ssx; fi
ssx() {
show_usage() {
echo "Run a ruby or shell script remotely"
@DannyBen
DannyBen / apache_bench.sh
Created Oct 10, 2015 — forked from seyhunak/apache_bench.sh
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
View apache_bench.sh
1.
LOGIN_PAGE=http://localhost/users/sign_in
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
2.
<meta content="csrf-token" name="csrf-token" />
@DannyBen
DannyBen / gh-pages-deploy.md
Last active Aug 29, 2015 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).
View gh-pages-deploy.md

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@DannyBen
DannyBen / ChromeRefreshOnFocus
Created Jul 19, 2015
Refresh Chrome whenever it receives focus
View ChromeRefreshOnFocus
; Chrome Refresh On Focus
; Refresh Chrome whenever it receives focus
#SingleInstance force
#Persistent
Gosub WaitForChrome
Return
WaitForChrome:
You can’t perform that action at this time.