Skip to content

Instantly share code, notes, and snippets.

@fotock
fotock / nginx.conf
Last active May 2, 2024 02:43 — forked from plentz/nginx.conf
Nginx SSL 安全配置最佳实践.
# 生成 dhparam.pem 文件, 在命令行执行任一方法:
# 方法1: 很慢
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
# 方法2: 较快
# 与方法1无明显区别. 2048位也足够用, 4096更强
openssl dhparam -dsaparam -out /etc/nginx/ssl/dhparam.pem 4096
@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
@mpospese
mpospese / CGRectIntegralScaled.m
Created February 28, 2013 03:34
Pixel aligns rectangles, taking the device's screen scale into account.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}
@TonnyXu
TonnyXu / UITableView_SeparatorLine.md
Created May 10, 2012 13:21
set UITableView.separatorLine to 2px and with different colors each pixel

Question

How to implement a UITableView with a separator line like this:

doubly separator line

Usually, you can only set the separatorLine property of a UITableView with to single line or single line etched. Sometimes, it is not enough. So, how to implement a separator line like this?

Answer

@parndt
parndt / gist:709496
Created November 22, 2010 03:58
Upgrading from Refinery CMS 0.9.8.5 to git master (0.9.9.pre)
## MAKE SURE YOU BACKUP FIRST - THIS PROCESS WILL WIPE YOUR DEVELOPMENT DATABASE
## e.g. using git source control and database sql export.
## This is not for people who don't want to have to do some manual work
## getting everything working.
## This also is not officially "supported" but we will hopefully
## be able to write an upgrade task later on based on feedback.
## Notable files that get overriden:
# CSS: (put yours back afterwards but remove any @import for refinery css)
@Superbil
Superbil / make-xcode-ignore.sh
Created September 25, 2010 11:40
auto make xcode ignore file script
#!/bin/bash
## call git init
git init
## make .gitignore
cat > .gitignore << EOF
# Mac OS X Finder and whatnot
.DS_Store
# no useful files
@norio-nomura
norio-nomura / UIWebView target="_blank" hack
Created February 13, 2009 07:23
UIWebView target="_blank" hack
static NSObject *webViewcreateWebViewWithRequestIMP(id self, SEL _cmd, NSObject* sender, NSObject* request) {
return [sender retain];
}
Class UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate");
class_addMethod(UIWebViewWebViewDelegate, @selector(webView:createWebViewWithRequest:), (IMP)webViewcreateWebViewWithRequestIMP, "@@:@@");