This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var basketModule = (function() { | |
| var basket = []; | |
| return { | |
| addItem: function(values) { | |
| basket.push(values); | |
| }, | |
| getItemCount: function() { | |
| return basket.length; | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if( /Android|webOS|iPhone|iPod|iPad|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { | |
| // some code.. | |
| window.location.href = "to mobile site url"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Enable GZIP | |
| <ifmodule mod_deflate.c> | |
| AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript | |
| BrowserMatch ^Mozilla/4 gzip-only-text/html | |
| BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
| BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
| </ifmodule> | |
| # Expires Headers - 2678400s = 31 days | |
| <ifmodule mod_expires.c> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mongo 進入 Command Line | |
| use <dbname> 使用特定db | |
| show collections 顯示所有collections | |
| db.<collection>.find() 顯示 collections 下所有的 document | |
| db.<collection>.drop() 刪除 collections |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 掛載 rewrite module | |
| sudo a2enmod rewrite | |
| sudo service apache2 restart | |
| 修改 /etc/apache2/sites-available/default | |
| <Directory /var/www/> | |
| Options Indexes FollowSymLinks MultiViews | |
| # changed from None to FileInfo | |
| AllowOverride FileInfo | |
| Order allow,deny |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # MySQL 連線 | |
| String driver = "com.mysql.jdbc.Driver"; | |
| Class.forName(driver); | |
| String conUrl = "jdbc:mysql://localhost/smft?user=root&password=&charset=utf8&characterEncoding=UTF-8r"; | |
| Connection con = null; | |
| PreparedStatement ps = conn.prepareStatement(SQL); | |
| ResultSet rs = pstmt.executeQuery(); | |
| while (rs.next()) { | |
| rs.getString("UserName"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 更新時間 | |
| UPDATE table SET end_dt = DATE_ADD(end_dt, INTERVAL 15 second) | |
| # Command Line Run SQL | |
| mysql -u root dbname < "path.sql" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 相框效果 | |
| img { | |
| box-shadow: 1px 1px 2px rgba(0,0,0,0.3); | |
| padding: 12px; | |
| background: rgba(255,255,255,0.9); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## find out mount/partition a directory or file is on? | |
| df -P file/goes/here | tail -1 | cut -d' ' -f 1 | |
| # delete line 135 in file, and save origin file into file.bak | |
| sed -i.bak -e '135d' file | |
| # Recursive find string from files | |
| grep -R -i -n '<string>' <directory> | |
| # nohup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArticleSerializer(serializers.ModelSerializer): | |
| tags = serializers.RelatedField(many=True) | |
| class Meta: | |
| model = Article | |
| fields = ('title','content','tags') | |
| owner = serializers.Field(source='owner.username') |