Skip to content

Instantly share code, notes, and snippets.

View zetavg's full-sized avatar

Pokai Chang zetavg

View GitHub Profile
@zetavg
zetavg / httpd.conf
Created March 9, 2014 18:14
Apache2 conf to ban access to sensitive files
<Files ~ "(^\.git|.swp$)">
Order allow,deny
Deny from all
Satisfy all
</Files>
@zetavg
zetavg / README.md
Last active August 29, 2015 13:59
2014 西門子超級實習生初選投票 網站漏洞

2014 西門子超級實習生投票 網站漏洞

http://www.siemens-greenplus.com/2014ssip/

此漏洞已回報。

Facebook 登入竟然直接寫在前端,登入後把資料寫在 hidden 的 input 欄位,按下投票就把 hidden input 的 value 丟給後端直接建立投票資料 Orz。

實作

brew install https://raw.github.com/cbguder/homebrew/53ea33bab5372ea74117ace8c44aa7ea988e93c2/Library/Formula/pngout.rb
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
// ----- z-index ----- //
@mixin z-index($element, $elements: $zIndex-elements, $base: 10) {
$index: index($elements, $element);
@if $index == false {
@warn "There is no item "#{$element}" in the z-index list, please choose one of: #{$elements}'";
} @else {
z-index: index($elements, $element) + $base;
}
}
@zetavg
zetavg / README.md
Last active August 29, 2015 14:04
Synology NAS Auto Sync Script

Synology NAS Auto Sync Script

Use with autorun, requires screen (/opt/screen).

功能

適用於 S 牌的 NAS (需要裝 optware/screen、第三方套件 autorun),可以設定當外接 USB 裝置插入後,自動同步 NAS 內某目錄到 USB 裝置中。

  • 把 script 用 autorun 設成自動執行就不用任何操作。

In vim, press CtrlZ and Enter on the end of line 12.

@zetavg
zetavg / regexWithNamedCapturingGroup.js
Last active August 29, 2015 14:05
JavaScript Regex With Named Capturing Group
/*
* Usage exapmle:
* 'b10132023@mail.ntust.edu.tw'.keyMatch('^(?<student_id>(?<identity_id>[bmd])(?<admission_year>\\d*)(?<admission_department_id>\\d{3})\\d{2})@mail\\.ntust\\.edu\\.tw$')
*
* The \ must be replaced as \\ in regex string.
*/
String.prototype.keyMatch = function (re, flags) {
re = re.replace(/\(\?</gm, '(?P<');
@zetavg
zetavg / preference.rb
Last active August 29, 2015 14:05
ActiveAdmin rails-settings-cached
ActiveAdmin.register_page "Preference" do
menu priority: 2
content do
form :action => admin_preference_update_path, :method => :post do |f|
f.input :name => 'authenticity_token', :type => :hidden, :value => form_authenticity_token.to_s
panel "Preference" do
fieldset do
ol do
li do
#!/bin/bash
echo "Copying assets from $1 to $2 ..."
find "$1/app/assets/javascripts" -mindepth 1 -maxdepth 1 ! -name "pages" ! -name "application.js" -exec cp -r {} "$2/app/assets/javascripts/" \;
find "$1/app/assets/stylesheets" -mindepth 1 -maxdepth 1 ! -name "pages" ! -name "application.css.scss" ! -name "_settings.scss" ! -name "_settings.scss.erb" -exec cp -r {} "$2/app/assets/stylesheets/" \;
cp -r "$1/app/assets/images/core" "$2/app/assets/images/"
cp -r "$1/app/views/layouts" "$2/app/views/"
cp -r "$1/app/views/partials" "$2/app/views/"