Skip to content

Instantly share code, notes, and snippets.

View shunwen's full-sized avatar
🐢

shunwen shunwen

🐢
View GitHub Profile
@phith0n
phith0n / README.md
Last active December 23, 2019 11:15
『代码审计』小密圈入圈指南

『代码审计』小密圈入圈指南

加入代码审计小密圈: https://wx.xiaomiquan.com/mweb/views/joingroup/join_group.html?group_id=2212251881

代码审计小密圈从去年11月成立至今已有近半年时间,一直没有把我们的宗旨和规则明文写出来,一是我比较懒事儿也比较多,二是我发现大家都是善良的小纯白,并没有谁是揣着恶意来到这里,所以这个事儿也不是特别急。但一直没有成文的规定总不是办法,有的新人进来后,四顾何茫茫,不领要旨,可能会觉得钱花的不值。

宗旨

办这个圈子,脑子里有几句话,我一直奉为圭臬,在这里说一下。

@cheeaun
cheeaun / rdrc2016.md
Last active June 13, 2018 08:39
RedDotRubyConf 2016 links & resources 😘
@dragonjet
dragonjet / 1-server.md
Last active July 31, 2021 21:01
Setup Web Server on EC2 Amazon Linux AMI

Step 1: Server Credentials

This assumes you are now connected to the server via SSH.

  • sudo -s Enter root mode for admin access
  • groupadd devgroup Create new group to be later granted access to /var/www/html

Creating a new Root User

  • useradd -G root,devgroup masterdev Create new root user. Also add to the devgroup
  • passwd masterdev Change password for the new root user
  • At this point, you'll need to input your new root user's new password
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@gampleman
gampleman / tracking_interceptor.md
Last active June 19, 2020 21:34
Adding tracking to emails in Rails

This gist illustrates how you would add Google Analytics tracking into your Rails mailers. Add the tracking_interceptor.rb into your path and enable it for your mailers with:

register_interceptor TrackingInterceptor
@tadast
tadast / ssl_puma.sh
Last active January 29, 2024 04:41 — forked from trcarden/gist:3295935
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@edubkendo
edubkendo / RubyNext.tmLanguage
Created August 10, 2013 03:58
A better ruby syntax highlighter for sublime text. Combines the ruby bundle with ST, recent updates to the textmate bundle, and a tmLanguage file called "Experimental Ruby".
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>
TODO: unresolved issues
text:
@bf4
bf4 / Gemfile
Created July 2, 2013 18:36
Rails lograge and logstash request logging
gem 'lograge' # more readable logs
gem 'logstash-event' # for logstash json format
gem 'mono_logger' # threadsafe logging
@nightire
nightire / Changes in Rails 4_1.md
Last active May 11, 2022 04:50
拥抱 Rails 4 —— 详述 Rails 4 的新变化

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb