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
| module API | |
| class Lists < Grape::API | |
| # /api/lists | |
| # all of your methods go here! | |
| end | |
| end |
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
| # Add this to your application.rb | |
| config.middleware.use Rack::Cors do | |
| allow do | |
| origins '*' | |
| # location of your API | |
| resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put] | |
| end | |
| end |
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
| # Initialize the taskk api. With your api token. Get yours at https://api.taskk.it | |
| taskk_api = new TaskkAPI('token') | |
| # Test your API key with the ping method | |
| ping = taskk_api.ping() | |
| # define what to do on success. Should say "pong" if you have a valid key. | |
| ping.success (data) -> alert(JSON.stringify(data)) | |
| # define what to do on error |
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
| # Create a task "Do homework" with an estimate of "1m" for list 1234 | |
| params = {title: "Do homework", estimate: "1m", list_id: 1234} | |
| new_task = taskk_api.create_task(params) | |
| # define what to do on success. | |
| new_task.success (data) -> alert(JSON.stringify(data)) | |
| # define what to do on error | |
| new_task.error (data) -> alert(JSON.stringify(data)) |
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 Api < Grape::API | |
| # /private | |
| resource :private do | |
| http_basic do |email, password| | |
| user = User.find_by_email(email) | |
| user && user.valid_password?(password) | |
| end | |
| # this method requires authentication! |
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
| 1 Dyno: | |
| Transactions: 12715 hits | |
| Availability: 99.99 % | |
| Elapsed time: 59.85 secs | |
| Data transferred: 0.13 MB | |
| Response time: 0.44 secs | |
| Transaction rate: 212.45 trans/sec | |
| Throughput: 0.00 MB/sec | |
| Concurrency: 94.16 |
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 bash | |
| # kill all connections to the postgres server | |
| if [ -n "$1" ] ; then | |
| where="where pg_stat_activity.datname = '$1'" | |
| echo "killing all connections to database '$1'" | |
| else | |
| where="where pg_stat_activity.datname in (select datname from pg_database where datname != 'postgres')" | |
| echo "killing all connections to database" | |
| fi |
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
| # Edit a project | |
| desc "Edit a project" | |
| params do | |
| group :project do | |
| optional :title, type: String, desc: "Edit title." | |
| optional :description, type: String, desc: "Edit description." | |
| end | |
| end | |
| put '/:id' do | |
| project = Project.find_by_id(params[:id]) |
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
| @MyController = ($scope, Shared) -> | |
| $scope.attribute_one = Shared.get_attribute_one() | |
| $scope.attribute_two = Shared.get_attribute_two() | |
| $scope.some_function = (new_value) -> | |
| # A function that can be called from the DOM/controller | |
| Shared.set_attribute_one(new_value) | |
| # When attribute_one is updated in another controller. Retrieve new value | |
| $scope.$on('attribute_one', -> |
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
| File.open(ARGV[0]).each_line{ |line| | |
| input = line.split(',') | |
| position = 0 | |
| input[0].split("").each_with_index { |char, x| | |
| if char == input[1] | |
| position = x | |
| end | |
| } | |
| puts position | |
| } |