# Change prompt
PS1_OLD=${PS1}
export PS1="[\[\033[0;32m\]\w\[\033[0m\]] $ "
#enables color in the terminal bash shell
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
| #!/usr/bin/env python3 | |
| import sys | |
| import csv | |
| import plistlib | |
| import os | |
| csv_file = sys.argv[1] | |
| with open(csv_file, 'r', encoding='utf-8') as f: | |
| result = list(csv.DictReader(f)) |
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
| #!/usr/bin/env python3 | |
| import sys | |
| import csv | |
| import plistlib | |
| import os | |
| csv_file = sys.argv[1] | |
| with open(csv_file, 'r', encoding='utf-8') as f: | |
| result = list(csv.DictReader(f)) |
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
| #!/usr/bin/ruby | |
| require 'rss' | |
| p 'Downloading rss index' | |
| rss_string = open('http://feeds.feedburner.com/railscasts').read | |
| rss = RSS::Parser.parse(rss_string, false) | |
| videos_urls = rss.items.map { |it| it.enclosure.url }.reverse | |
| videos_filenames = videos_urls.map {|url| url.split('/').last } |
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
| function invoke_and_add(a,b){ | |
| return a()+b(); | |
| } | |
| function one(){ | |
| return 1; | |
| } | |
| function two(){ | |
| return 2; |
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
| /** | |
| Handle multiple socket connections with select and fd_set on Linux | |
| Silver Moon ( m00n.silv3r@gmail.com) | |
| */ | |
| #include <stdio.h> | |
| #include <string.h> //strlen | |
| #include <stdlib.h> | |
| #include <errno.h> |
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 "MyException" | |
| class MyException: public exception | |
| { | |
| ... | |
| }; | |
| // Class "A" | |
| class A | |
| { | |
| public: |
Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.
For the sake of this example, let’s pretend the subfolder containing your site is named dist.
Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).
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
| /** | |
| * A generic confirmation for risky actions. | |
| * Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function | |
| */ | |
| angular.module('app').directive('ngReallyClick', [function() { | |
| return { | |
| restrict: 'A', | |
| link: function(scope, element, attrs) { | |
| element.bind('click', function() { | |
| var message = attrs.ngReallyMessage; |
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
| uploader = $fileUploader.create( | |
| scope: $scope | |
| url: "http://#{$rootScope.api}/proposal/upload" | |
| formData: [{ | |
| key: \value | |
| }] | |
| filters: [ | |
| (item) -> | |
| if item.size >10000000 | |
| alert \size不得超過10mb |
