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
from routes import Mapper | |
class CustomMapper(Mapper): | |
def match(self, url= None, environ= None): | |
if not url and not environ: | |
raise RoutesException('URL or environ must be provided') | |
if not 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
def render(template_name, tmpl_vars={}, cache_key=None, | |
cache_type=None, cache_expire=None): | |
globs = pylons_globals() | |
tmpl_vars.update(globs) | |
@contextfunction |
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
DELIMITER $$ | |
CREATE PROCEDURE `geodist`(IN mylat float, IN mylon float, IN dist int) | |
BEGIN | |
declare lon1 float; declare lon2 float; | |
declare lat1 float; declare lat2 float; | |
set lon1 = mylon-dist/abs(cos(radians(mylat))*111.1); | |
set lon2 = mylon+dist/abs(cos(radians(mylat))*111.1); | |
set lat1 = mylat-(dist/111.1); |
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 PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |
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
/** | |
* Exercise 3 | |
*/ | |
def countChange(money: Int, coins: List[Int]): Int = { | |
if (money == 0) 1 | |
else if (money < 0 || coins.isEmpty) 0 | |
else countChange(money, coins.tail) + countChange(money - coins.head, coins) | |
} |
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
''' | |
prefix_code.py | |
Copyright 2012-2013 Josiah Carlson | |
Released under the GNU LGPL v 2.1 license | |
This module offers the ability to encode/decode a sequence of integers into | |
strings that can then be used to compare sequences of integers (or paths on | |
trees) quickly. This module was originally intended to be used in a case- | |
preserving index in a relational database (where 'Z' comes before 'a', as is |
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
body = { | |
grant_type: 'authorization_code', | |
client_id: Rails.application.secrets[provider]['client_id'], | |
client_secret: Rails.application.secrets[provider]['client_secret'], | |
redirect_uri: integration_callback_url(provider), | |
code: params[:code] | |
}.to_query | |
uri = URI.parse('https://api.createsend.com/oauth/token') | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
# JSON | |
mailup = MailUp::API.new(credentials) | |
lists = mailup.console.user.lists | |
lists['Items'].first['Name'] | |
# => "Test List" | |
list_id = lists['Items'].first['idList'].to_i | |
# => 1 | |
list = mailup.console.list(list_id) | |
groups = list.groups(pageNumber: 1, pageSize: 25) |
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
# old | |
def get(path, opts={}, &block) # :nodoc: | |
request(:get, path, opts, &block) | |
end | |
def recipients(params = {}) | |
@api.get("#{@api.path}/Message/#{@id}/List/Recipients", params: params) | |
end | |
def views(params = {}) |