Skip to content

Instantly share code, notes, and snippets.

View larryzhao's full-sized avatar
🐱
Meow

Larry Zhao larryzhao

🐱
Meow
View GitHub Profile
@neekey
neekey / gist-blog-browser-js-error-catch-summary.md
Last active July 31, 2020 10:14
浏览器错误捕捉总结

捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。

window.onerror 讲接收3个参数:

  • msg:错误描述,比如:a is not defined
  • url:出错脚本所在的url
  • lineNumber:出错脚本的行数

本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。

@prognostikos
prognostikos / app.js
Created September 11, 2012 13:45
AngularJS & Rails
/**
* Angular needs to send the Rails CSRF token with each post request.
*
* Here we get the token from the meta tags (make sure <%= csrf_meta_tags %>
* is present in your layout.)
*/
angular.module('myapp',[]).
// configure our http requests to include the Rails CSRF token
config(["$httpProvider", function(p) {
var m = document.getElementsByTagName('meta');
@enplotz
enplotz / tm2-shortcuts-osx.textile
Created September 11, 2012 13:41
Textmate 2 Shortcuts (Mac OS X)

Navigation in the File Browser

⌘⇡ Go to Enclosing Folder
⌘⇣ Open
⌘⇠ Go Back
⌘⇢ Go Forward
Rename
QuickLook
⇧⌘N New Folder
⌥⌘N New Tab
@johnantoni
johnantoni / unicorn.rb
Created August 2, 2012 15:48
unicorn + nginx setup + ssl
unicorn.rb
-----------------------------------
application = "jarvis"
remote_user = "vagrant"
env = ENV["RAILS_ENV"] || "development"
RAILS_ROOT = File.join("/home", remote_user, application)
worker_processes 8
timeout 30
@malditogeek
malditogeek / gist:3156358
Created July 21, 2012 16:36
Goliath + HAProxy deploy recipe
after "deploy:update", "deploy:cleanup"
after "deploy:update", "foreman:export"
after "deploy:symlink", "update_haproxy_config_symlink"
namespace :deploy do
task :stop do
run "sudo stop goliath_app"
end
task :start do
run "sudo start goliath_app"
@djones
djones / gist:2642094
Created May 9, 2012 05:26
Grape API being served with Goliath
#!/usr/bin/env ruby
# gem install grape --pre
# http://localhost:9000/hello.json
# => {"hello":"world"}
$:<< '../lib' << 'lib'
require 'goliath'
require 'rubygems'
require 'redis'
require 'redis/distributed'
r = Redis::Distributed.new %w[redis://host1:6379 redis://host2:6379]
# show node for key "foo"
p r.node_for("foo")
# set the value of "foo"
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@killercup
killercup / README.md
Created March 16, 2012 11:03
Unicorn, RVM Wrapper, Init.d

You have your Rails Apps with specific Gemsets in RVM.

The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.

rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails

Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails I will refer to [GEMSET]_unicorn_rails as [WRAPPED_NAME]

#!/bin/sh
### BEGIN INIT INFO
# Provides: jboss
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop JBoss AS v7.0.0
### END INIT INFO
#