Skip to content

Instantly share code, notes, and snippets.

@bencao
bencao / redirect-to-slash.js
Last active October 5, 2021 16:57
redirect if url does not end with slash
if (window && window.location && !window.location.href.endsWith("/")) {
window.location = window.location.href + "/";
}

Keybase proof

I hereby claim:

  • I am bencao on github.
  • I am bencao (https://keybase.io/bencao) on keybase.
  • I have a public key ASCJO6CTg4J6HU-qA8k2s3X9HTb-6YRL39ynutHVt54TIgo

To claim this, I am signing this object:

@bencao
bencao / capacity repo
Last active March 21, 2019 15:52
concourse capacity pattern
git repo should have structure similar to this. those capacity numbers are just empty files which represent a single capacity unit.
├── capacity
│   ├── claimed
│   │   └── 2
│   └── unclaimed
│   ├── 1
│   ├── 3
│   ├── 4
│   ├── 5
@bencao
bencao / gist:9a676414a2959ab74e7c
Created June 3, 2015 11:19
registry.docker.dev.fwmrm.net/ca.crt
-----BEGIN CERTIFICATE-----
MIICrzCCAhgCCQCodJZtXxzIXDANBgkqhkiG9w0BAQUFADCBmzELMAkGA1UEBhMC
Q04xEDAOBgNVBAgMB0JlaWppbmcxEDAOBgNVBAcMB0JlaWppbmcxEjAQBgNVBAoM
CUZyZWVXaGVlbDELMAkGA1UECwwCVUkxJjAkBgNVBAMMHXJlZ2lzdHJ5LmRvY2tl
ci5kZXYuZndtcm0ubmV0MR8wHQYJKoZIhvcNAQkBFhBvcHNAZnJlZXdoZWVsLnR2
MB4XDTE0MTExODA2MTgxMFoXDTE1MTExODA2MTgxMFowgZsxCzAJBgNVBAYTAkNO
MRAwDgYDVQQIDAdCZWlqaW5nMRAwDgYDVQQHDAdCZWlqaW5nMRIwEAYDVQQKDAlG
cmVlV2hlZWwxCzAJBgNVBAsMAlVJMSYwJAYDVQQDDB1yZWdpc3RyeS5kb2NrZXIu
ZGV2LmZ3bXJtLm5ldDEfMB0GCSqGSIb3DQEJARYQb3BzQGZyZWV3aGVlbC50djCB
nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA11QthyhTcurOKa9Dgfz188/pU2z/
build_package_ree_patch() {
curl -L https://gist.githubusercontent.com/bencao/c6d548c29cbaedf20918/raw/3534ffc8eee7d83c18b1b25affbc8e7f365ffeb6/ree-1.8.7-2011.12.patch > /tmp/ree-1.8.7-2011.12.patch
patch -p1 < /tmp/ree-1.8.7-2011.12.patch
}
require_gcc
install_package "ruby-enterprise-1.8.7-2011.12" "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.12.tar.gz#9a8efc4befc136e17a1360de549aac9e79283c7238a13215350720e4393c5da2" ree_patch ree_installer
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#cb5261818b931b5ea2cb54bc1d583c47823543fcf9682f0d6298849091c1cea7" ruby
--- a/source/distro/google-perftools-1.7/src/tcmalloc.cc 2013-11-21 15:32:22.408760179 -0500
+++ b/source/distro/google-perftools-1.7/src/tcmalloc.cc 2013-11-21 15:23:43.908972961 -0500
@@ -1669,5 +1669,5 @@
MallocHook::InvokeNewHook(result, size);
return result;
}
-void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
+void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
#endif // #ifndef TCMALLOC_FOR_DEBUGALLOCATION
--- a/source/distro/google-perftools-1.7/src/debugallocation.cc 2013-11-21 15:33:07.105408776 -0500
@bencao
bencao / designer.html
Created March 12, 2015 15:19
designer
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../paper-radio-button/paper-radio-button.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../topeka-elements/avatars.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../topeka-elements/theme.html">
<link rel="import" href="../topeka-elements/topeka-resources.html">
<link rel="import" href="../topeka-elements/topeka-app.html">
@bencao
bencao / read_password_in_shell.sh
Last active January 2, 2016 02:49
read password in shell
read -s -p "Enter Password: " mypassword
echo $mypassword
@bencao
bencao / start_web_server.sh
Created September 16, 2013 11:56
start current directory as web server on port 8000
python -m SimpleHTTPServer