Skip to content

Instantly share code, notes, and snippets.

@DannyBen
DannyBen / UnityWebPlayer
Last active December 24, 2015 15:49
Dropbox compatible HTML for showing Unity Player
<doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity Web Player</title>
</head>
<body>
<embed type="application/vnd.unity" width="960" height="640" tabindex="0" firstframecallback="unityObject.firstFrameCallback();" src="WebBuild.unity3d" style="display: block; width: 100%; height: 100%;">
<div style="text-align:center">
@DannyBen
DannyBen / gitclean
Created March 13, 2015 12:31
Find and delete big files from git history
#!/usr/bin/env ruby
def usage
puts """
gitclean - List and remove big files from git history
Usage: gitclean list [<rev> <threshold>]
gitclean del <file>
Example: gitclean list master 10
gitclean del that-huge-logfile.log
"""
@DannyBen
DannyBen / ff
Created April 17, 2015 12:26
Find files and content in files
if [ $# -lt 1 ]; then
echo "
ff - Find files and content in files
Find content in a file:
usage : ff [-t] EXTENSION SEARCH
example : ff php logdir
-t : omit text (show filenames only)
Find a file:
@DannyBen
DannyBen / Readme
Last active August 29, 2015 14:21
Ruby Filewatcher Interrupt Bug
# See https://github.com/thomasfl/filewatcher/issues/24
$ gem install filewatcher -v0.4.0
$ gem uninstall filewatcher -v0.5.0
$ rvm list
$ ruby -v
$ gem list filewatcher
$ ./test.rb
$ gem install filewatcher
$ gem list filewatcher
@DannyBen
DannyBen / ChromeRefreshOnFocus
Created July 19, 2015 10:51
Refresh Chrome whenever it receives focus
; Chrome Refresh On Focus
; Refresh Chrome whenever it receives focus
#SingleInstance force
#Persistent
Gosub WaitForChrome
Return
WaitForChrome:
@DannyBen
DannyBen / gh-pages-deploy.md
Last active August 29, 2015 14:25 — 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).

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 / apache_bench.sh
Created October 10, 2015 17:49 — forked from seyhunak/apache_bench.sh
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
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 / ssx
Last active February 25, 2016 09:13
Run a ruby or shell script remotely
# 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"
# -*- 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 / spec_helper.rb
Last active February 15, 2018 21:40 — forked from nu7hatch/spec_helper.rb
Testing standard input with RSpec
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