This file contains 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
// Sample A. Inline export with implicit import | |
import React from 'react'; | |
export default class SampleA extends React.Component { | |
} | |
// Sample B. Inline export with explicit import | |
import React, { Component } from 'react'; | |
export default class SampleB extends Component { | |
} |
This file contains 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
require "../src/sdl" | |
require "../src/image" | |
SDL.init(SDL::Init::VIDEO); at_exit { SDL.quit } | |
SDL::IMG.init(SDL::IMG::Init::PNG); at_exit { SDL::IMG.quit } | |
SCREEN_WIDTH = 640 | |
SCREEN_HEIGHT = 480 | |
window = SDL::Window.new("SDL tutorial", SCREEN_WIDTH, SCREEN_HEIGHT) |
This file contains 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
require "kemal" | |
class RequestPathMiddleware < Kemal::Handler | |
def initialize(@number : String, @use_header : Bool = false) | |
end | |
def call(env) | |
if @use_header | |
process_request(env) | |
end |
This file contains 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
require "kemal" | |
class AuthorizationHandler < HTTP::Handler | |
ACCEPT = "application/vnd.api.v1+json" | |
def call(env) | |
if env.request.headers["Accept"] != ACCEPT | |
env.response.status_code = 401 | |
end | |
call_next(env) | |
end |
This file contains 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
require "kemal" | |
require "pg" | |
DB = PG.connect(ENV["DATABASE_URL"]) | |
get "/" do |env| | |
env.response.content_type = "application/json" | |
result = DB.exec("SELECT id, username FROM members LIMIT 1000") | |
result.to_hash.to_json | |
end |
This file contains 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 TimeZone | |
DAYLIGHT = [ | |
{name: 'Dateline Daylight Time', offset: -12, alt: 'International Date Line West'}, | |
{name: 'UTC-11', offset: -11, alt: 'International Date Line West'}, | |
{name: 'Hawaiian Daylight Time', offset: -10, alt: 'Hawaii'}, | |
{name: 'Alaskan Daylight Time', offset: -9, alt: 'Alaska'}, | |
{name: 'Pacific Daylight Time', offset: -8, alt: 'Pacific Time (US & Canada)'}, | |
{name: 'US Mountain Daylight Time', offset: -7, alt: 'Mountain Time (US & Canada)'}, | |
{name: 'Mountain Daylight Time', offset: -7, alt: 'Mountain Time (US & Canada)'}, | |
{name: 'Central America Daylight Time', offset: -6, alt: 'Central Time (US & Canada)'}, |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<a href="#" onclick="process.mainModule.exports.printer()">Click to print</a> | |
</body> | |
</html> |
This file contains 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 dependencies | |
asterisk/contrib/scripts/install_prereq | |
# dialplan examples | |
exten => some_ext,priority,application | |
same => n(label),application | |
same => n,Goto(label) ;comments |
This file contains 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
# assumes there's already a window.timer = {} | |
app.directive 'callTimer', -> | |
opts = | |
restrict: 'E' | |
controller: ($scope, $rootScope)-> | |
$scope.minutes = (window.timer?.state.minutes || 0) | |
$scope.seconds = (window.timer?.state.seconds || 0) | |
$scope.$on 'start-timer', -> $scope.startTimer() |
This file contains 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
require 'spec_helper' | |
describe HomeController do | |
describe '#show' do | |
it 'renders the taco view when params[:page] is set to taco' do | |
get(:show, :page => 'pricing') | |
response.should render_template('home/pricing') | |
end | |
end |