Compare commits

..

36 Commits

Author SHA1 Message Date
Ted Nyman
b666123f8e Version 2.10.10 2014-01-06 12:02:39 -08:00
Ted Nyman
8e36ddbafe Regenerate samples 2014-01-06 12:01:53 -08:00
Ted Nyman
abd0c47838 More C samples 2014-01-06 12:00:58 -08:00
Ted Nyman
8625f91b1b Merge pull request #886 from ruben2020/master
Fix for *.ts conflict between TypeScript and Qt Translation files
2014-01-04 13:51:42 -08:00
Ted Nyman
6c6b07fc68 Merge pull request #885 from GiampaoloFalqui/master
Add PAWN language
2014-01-04 13:50:37 -08:00
ruben2020
f5a6f20af0 renamed Qt translation ts file to have XML ext and updated test_heuristics.rb 2014-01-04 23:14:58 +08:00
ruben2020
76ee294c29 Removing second ts from languages.yml, but adding to test code for heuristics 2014-01-04 23:01:17 +08:00
ruben2020
77bff8fd6a *.ts conflict between TypeScript and Qt translation files: attempting roll back of samples.json 2014-01-04 22:04:53 +08:00
ruben2020
40b2e19310 Fix for *.ts conflict between TypeScript and Qt Translation files 2014-01-04 21:32:16 +08:00
Giampaolo Falqui
aaf281ec0e PAWN .inc extension & sample removed 2014-01-04 13:24:38 +01:00
Giampaolo Falqui
82bc320843 Add PAWN language 2014-01-04 01:39:49 +01:00
Arfon Smith
1f38db61df Merge pull request #884 from jmromer/add-tex-cls-extension
Add tex cls extension
2014-01-03 14:38:13 -08:00
Arfon Smith
db20462481 Merge pull request #834 from berkerpeksag/add-hy
Add Hy language.
2014-01-03 14:35:50 -08:00
Jake Romer
79be60bf8f adds cls file sample 2014-01-03 16:30:15 -05:00
Jake Romer
d57ff3abd6 adds latex cls extension 2014-01-03 16:29:20 -05:00
Ted Nyman
cd6c315fc8 Merge pull request #783 from jimhester/master
Add r alias
2014-01-02 18:55:10 -08:00
Ted Nyman
60bc772d48 New year 2014-01-02 12:17:28 -08:00
Jim Hester
7ad99baf32 Add check for R alias 2014-01-02 13:39:19 -05:00
Ted Nyman
252ae63854 Merge pull request #880 from emma-burrows/VBnet-samples
VB.net samples
2014-01-01 12:06:58 -08:00
Emma Burrows
7e3a9434ef Updated sample.json to include VB.Net samples 2014-01-01 17:35:45 +00:00
Emma Burrows
f388daab39 Added Visual Basic .NET sample files (a console code file and a Razor vbhtml file) 2013-12-31 19:20:21 +00:00
Berker Peksag
89f4885b62 Add Hy language.
Hy is a dialect of Lisp that’s embedded in Python.
2013-12-31 14:43:29 +02:00
Ted Nyman
23a1ae5085 Merge pull request #878 from kevmoo/master
updated Dart sample to align with best practices
2013-12-30 19:20:28 -08:00
Kevin Moore
9cd6d6f001 updated Dart sample to align with best practices 2013-12-30 16:39:25 -08:00
Ted Nyman
a15ed48377 Regenerate samples 2013-12-30 14:41:28 -08:00
Ted Nyman
f5e8671481 Merge pull request #877 from emma-burrows/Csharp-samples
Csharp samples, including ASP.Net MVC view file
2013-12-30 14:40:50 -08:00
Emma Burrows
614f4f31ed Merge branch 'Csharp-samples' of https://github.com/emma-burrows/linguist into Csharp-samples 2013-12-30 22:32:57 +00:00
Emma Burrows
95c8405e0c Corrected order of C# file extentions 2013-12-30 22:31:52 +00:00
Emma Burrows
e6baa1d690 Updated sample.json to include C# samples 2013-12-30 22:06:16 +00:00
Emma Burrows
928409a355 Added cshtml extention for C# ASP.Net MVC Views. 2013-12-30 21:46:30 +00:00
Emma Burrows
86c9c9f6f3 Added a C# console file and cshtml Razor MVC View file. 2013-12-30 21:24:14 +00:00
Ted Nyman
49f29a53c0 Nicer breakdown output 2013-12-29 23:56:13 -08:00
Arfon Smith
40c04c8f6f travis/bundler fix 2013-12-29 19:27:20 -08:00
Arfon Smith
800d26cdad Adding Perl heuristic (and fixing up Prolog) 2013-12-29 19:22:31 -08:00
Ted Nyman
016f9852d6 Update prolog samples 2013-12-29 12:24:02 -08:00
Jim Hester
c2ca9f40ac Add r alias 2013-11-18 13:45:11 -05:00
23 changed files with 2394 additions and 136 deletions

View File

@@ -1,4 +1,7 @@
before_install: sudo apt-get install libicu-dev -y
before_install:
- sudo apt-get install libicu-dev -y
# Short-term fix addressing https://github.com/bundler/bundler/issues/2784
- gem update --system 2.1.11
rvm:
- 1.8.7
- 1.9.2

View File

@@ -1,4 +1,4 @@
Copyright (c) 2011-2013 GitHub, Inc.
Copyright (c) 2011-2014 GitHub, Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -47,11 +47,21 @@ These stats are also printed out by the `linguist` binary. You can use the
You can try running `linguist` on the `lib/` directory in this repository itself:
$ bundle exec linguist lib/ --breakdown
100% Ruby
Ruby: ["linguist/blob_helper.rb", "linguist/classifier.rb", "linguist/file_blob.rb", "linguist/generated.rb",
"linguist/heuristics.rb", "linguist/language.rb", "linguist/md5.rb", "linguist/repository.rb",
"linguist/samples.rb", "linguist/tokenizer.rb", "linguist.rb"]
100.00% Ruby
Ruby:
linguist/blob_helper.rb
linguist/classifier.rb
linguist/file_blob.rb
linguist/generated.rb
linguist/heuristics.rb
linguist/language.rb
linguist/md5.rb
linguist/repository.rb
linguist/samples.rb
linguist/tokenizer.rb
linguist.rb
#### Ignore vendored files

View File

@@ -28,7 +28,11 @@ if File.directory?(path)
puts
file_breakdown = repo.breakdown_by_file
file_breakdown.each do |lang, files|
puts "#{lang}: #{files}"
puts "#{lang}:"
files.each do |file|
puts file
end
puts
end
end
elsif File.file?(path)

View File

@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'github-linguist'
s.version = '2.10.9'
s.version = '2.10.10'
s.summary = "GitHub Language detection"
s.description = 'We use this library at GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diffs, and generate language breakdown graphs.'

View File

@@ -19,6 +19,9 @@ module Linguist
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
disambiguate_pl(data, languages)
end
if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
disambiguate_ts(data, languages)
end
end
end
@@ -33,9 +36,20 @@ module Linguist
matches
end
def self_disambiguate_pl(data, languages)
def self.disambiguate_pl(data, languages)
matches = []
matches << Language["Prolog"] if data.include?(":-")
matches << Language["Perl"] if data.include?("use strict")
matches
end
def self.disambiguate_ts(data, languages)
matches = []
if (data.include?("</translation>"))
matches << Language["XML"]
else
matches << Language["TypeScript"]
end
matches
end

View File

@@ -225,6 +225,7 @@ C#:
- csharp
primary_extension: .cs
extensions:
- .cshtml
- .csx
C++:
@@ -387,7 +388,7 @@ Crystal:
lexer: Ruby
primary_extension: .cr
ace_mode: ruby
Cucumber:
lexer: Gherkin
primary_extension: .feature
@@ -732,6 +733,13 @@ Haxe:
extensions:
- .hxsl
Hy:
type: programming
lexer: Clojure
ace_mode: clojure
color: "#7891b1"
primary_extension: .hy
IDL:
type: programming
lexer: Text only
@@ -1164,6 +1172,12 @@ Oxygene:
color: "#5a63a3"
primary_extension: .oxygene
PAWN:
type: programming
lexer: C++
color: "#dbb284"
primary_extension: .pwn
PHP:
type: programming
ace_mode: php
@@ -1344,6 +1358,8 @@ R:
type: programming
color: "#198ce7"
lexer: S
aliases:
- R
primary_extension: .r
extensions:
- .R
@@ -1622,6 +1638,7 @@ TeX:
extensions:
- .aux
- .bib
- .cls
- .dtx
- .ins
- .ltx
@@ -1728,6 +1745,7 @@ Visual Basic:
- .frm
- .frx
- .vba
- .vbhtml
- .vbs
Volt:

File diff suppressed because it is too large Load Diff

45
samples/C#/Index.cshtml Normal file
View File

@@ -0,0 +1,45 @@
@{
ViewBag.Title = "Home Page";
}
@section featured {
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>@ViewBag.Message</h2>
</hgroup>
<p>
To learn more about ASP.NET MVC visit
<a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
The page features <mark>videos, tutorials, and samples</mark> to help you get the most from ASP.NET MVC.
If you have any questions about ASP.NET MVC visit
<a href="http://forums.asp.net/1146.aspx/1?MVC" title="ASP.NET MVC Forum">our forums</a>.
</p>
</div>
</section>
}
<h3>We suggest the following:</h3>
<ol class="round">
<li class="one">
<h5>Getting Started</h5>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and that gives you full control over markup
for enjoyable, agile development. ASP.NET MVC includes many features that enable
fast, TDD-friendly development for creating sophisticated applications that use
the latest web standards.
<a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
</li>
<li class="two">
<h5>Add NuGet packages and jump-start your coding</h5>
NuGet makes it easy to install and update free libraries and tools.
<a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
</li>
<li class="three">
<h5>Find Web Hosting</h5>
You can easily find a web hosting company that offers the right mix of features
and price for your applications.
<a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
</li>
</ol>

21
samples/C#/Program.cs Normal file
View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LittleSampleApp
{
/// <summary>
/// Just what it says on the tin. A little sample application for Linguist to try out.
///
/// </summary>
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, I am a little sample application to test GitHub's Linguist module.");
Console.WriteLine("I also include a Razor MVC file just to prove it handles cshtml files now.");
}
}
}

102
samples/C/bootstrap.h Normal file
View File

@@ -0,0 +1,102 @@
#ifndef BOOTSTRAP_H
#define BOOTSTRAP_H
#include <stdio.h>
#include "cxrs.h"
/* If we're not using GNU C, elide __attribute__ */
#ifndef __GNUC__
# define __attribute__(x) /*NOTHING*/
#endif
typedef struct object object;
object *true;
object *false;
object *eof;
object *empty_list;
object *global_enviroment;
enum obj_type {
scm_bool,
scm_empty_list,
scm_eof,
scm_char,
scm_int,
scm_pair,
scm_symbol,
scm_prim_fun,
scm_lambda,
scm_str,
scm_file
};
typedef object *(*prim_proc)(object *args);
object *read(FILE *in);
object *eval(object *code, object *env);
void print(FILE *out, object *obj, int display);
int check_type(enum obj_type type, object *obj, int err_on_false);
static inline int is_true(object *obj)
{
return obj != false;
}
object *make_int(int value);
int obj2int(object *i);
object *make_bool(int value);
int obj2bool(object *b);
object *make_char(char c);
char obj2char(object *ch);
object *make_str(char *str);
char *obj2str(object *str);
object *cons(object *car, object *cdr);
object *car(object *pair);
object *cdr(object *pair);
void set_car(object *pair, object *new);
void set_cdr(object *pair, object *new);
object *make_symbol(char *name);
char *sym2str(object *sym);
object *get_symbol(char *name) __attribute__((pure));
object *make_prim_fun(prim_proc fun);
prim_proc obj2prim_proc(object *proc);
object *make_lambda(object *args, object *code, object *env);
object *lambda_code(object *lambda);
object *lambda_args(object *lambda);
object *make_port(FILE *handle, int direction);
int port_direction(object *port);
FILE *port_handle(object *port);
void set_port_handle_to_null(object *port);
/*both of these should never be called*/
object *apply_proc(object *);
object *eval_proc(object *);
object *maybe_add_begin(object *code);
void init_enviroment(object *env);
void eval_err(char *msg, object *code) __attribute__((noreturn));
void define_var(object *var, object *val, object *env);
void set_var(object *var, object *val, object *env);
object *get_var(object *var, object *env);
object *cond2nested_if(object *cond);
object *let2lambda(object *let);
object *and2nested_if(object *and);
object *or2nested_if(object *or);
#endif /*include guard*/

View File

@@ -1,15 +1,19 @@
import 'dart:math' as math;
class Point {
num x, y;
Point(this.x, this.y);
distanceTo(Point other) {
num distanceTo(Point other) {
var dx = x - other.x;
var dy = y - other.y;
return Math.sqrt(dx * dx + dy * dy);
return math.sqrt(dx * dx + dy * dy);
}
var x, y;
}
main() {
Point p = new Point(2, 3);
Point q = new Point(3, 4);
void main() {
var p = new Point(2, 3);
var q = new Point(3, 4);
print('distance from p to q = ${p.distanceTo(q)}');
}

9
samples/Hy/fibonacci.hy Normal file
View File

@@ -0,0 +1,9 @@
;; Fibonacci example in Hy.
(defn fib [n]
(if (<= n 2) n
(+ (fib (- n 1)) (fib (- n 2)))))
(if (= __name__ "__main__")
(for [x [1 2 3 4 5 6 7 8]]
(print (fib x))))

13
samples/Hy/hello-world.hy Normal file
View File

@@ -0,0 +1,13 @@
;; The concurrent.futures example in Hy.
(import [concurrent.futures [ThreadPoolExecutor as-completed]]
[random [randint]]
[sh [sleep]])
(defn task-to-do []
(sleep (randint 1 5)))
(with-as (ThreadPoolExecutor 10) executor
(setv jobs (list-comp (.submit executor task-to-do) (x (range 0 10))))
(for (future (as-completed jobs))
(.result future)))

520
samples/PAWN/grandlarc.pwn Normal file
View File

@@ -0,0 +1,520 @@
//----------------------------------------------------------
//
// GRAND LARCENY 1.0
// A freeroam gamemode for SA-MP 0.3
//
//----------------------------------------------------------
#include <a_samp>
#include <core>
#include <float>
#include "../include/gl_common.inc"
#include "../include/gl_spawns.inc"
#pragma tabsize 0
//----------------------------------------------------------
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_NORMAL_PLAYER 0xFFBB7777
#define CITY_LOS_SANTOS 0
#define CITY_SAN_FIERRO 1
#define CITY_LAS_VENTURAS 2
new total_vehicles_from_files=0;
// Class selection globals
new gPlayerCitySelection[MAX_PLAYERS];
new gPlayerHasCitySelected[MAX_PLAYERS];
new gPlayerLastCitySelectionTick[MAX_PLAYERS];
new Text:txtClassSelHelper;
new Text:txtLosSantos;
new Text:txtSanFierro;
new Text:txtLasVenturas;
new thisanimid=0;
new lastanimid=0;
//----------------------------------------------------------
main()
{
print("\n---------------------------------------");
print("Running Grand Larceny - by the SA-MP team\n");
print("---------------------------------------\n");
}
//----------------------------------------------------------
public OnPlayerConnect(playerid)
{
GameTextForPlayer(playerid,"~w~Grand Larceny",3000,4);
SendClientMessage(playerid,COLOR_WHITE,"Welcome to {88AA88}G{FFFFFF}rand {88AA88}L{FFFFFF}arceny");
// class selection init vars
gPlayerCitySelection[playerid] = -1;
gPlayerHasCitySelected[playerid] = 0;
gPlayerLastCitySelectionTick[playerid] = GetTickCount();
//SetPlayerColor(playerid,COLOR_NORMAL_PLAYER);
//Kick(playerid);
/*
Removes vending machines
RemoveBuildingForPlayer(playerid, 1302, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 1209, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 955, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 1775, 0.0, 0.0, 0.0, 6000.0);
RemoveBuildingForPlayer(playerid, 1776, 0.0, 0.0, 0.0, 6000.0);
*/
/*
new ClientVersion[32];
GetPlayerVersion(playerid, ClientVersion, 32);
printf("Player %d reports client version: %s", playerid, ClientVersion);*/
return 1;
}
//----------------------------------------------------------
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
new randSpawn = 0;
SetPlayerInterior(playerid,0);
TogglePlayerClock(playerid,0);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, 30000);
if(CITY_LOS_SANTOS == gPlayerCitySelection[playerid]) {
randSpawn = random(sizeof(gRandomSpawns_LosSantos));
SetPlayerPos(playerid,
gRandomSpawns_LosSantos[randSpawn][0],
gRandomSpawns_LosSantos[randSpawn][1],
gRandomSpawns_LosSantos[randSpawn][2]);
SetPlayerFacingAngle(playerid,gRandomSpawns_LosSantos[randSpawn][3]);
}
else if(CITY_SAN_FIERRO == gPlayerCitySelection[playerid]) {
randSpawn = random(sizeof(gRandomSpawns_SanFierro));
SetPlayerPos(playerid,
gRandomSpawns_SanFierro[randSpawn][0],
gRandomSpawns_SanFierro[randSpawn][1],
gRandomSpawns_SanFierro[randSpawn][2]);
SetPlayerFacingAngle(playerid,gRandomSpawns_SanFierro[randSpawn][3]);
}
else if(CITY_LAS_VENTURAS == gPlayerCitySelection[playerid]) {
randSpawn = random(sizeof(gRandomSpawns_LasVenturas));
SetPlayerPos(playerid,
gRandomSpawns_LasVenturas[randSpawn][0],
gRandomSpawns_LasVenturas[randSpawn][1],
gRandomSpawns_LasVenturas[randSpawn][2]);
SetPlayerFacingAngle(playerid,gRandomSpawns_LasVenturas[randSpawn][3]);
}
//SetPlayerColor(playerid,COLOR_NORMAL_PLAYER);
SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL_SILENCED,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_DESERT_EAGLE,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SHOTGUN,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SPAS12_SHOTGUN,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_MP5,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_AK47,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_M4,200);
SetPlayerSkillLevel(playerid,WEAPONSKILL_SNIPERRIFLE,200);
GivePlayerWeapon(playerid,WEAPON_COLT45,100);
//GivePlayerWeapon(playerid,WEAPON_MP5,100);
TogglePlayerClock(playerid, 0);
return 1;
}
//----------------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason)
{
new playercash;
// if they ever return to class selection make them city
// select again first
gPlayerHasCitySelected[playerid] = 0;
if(killerid == INVALID_PLAYER_ID) {
ResetPlayerMoney(playerid);
} else {
playercash = GetPlayerMoney(playerid);
if(playercash > 0) {
GivePlayerMoney(killerid, playercash);
ResetPlayerMoney(playerid);
}
}
return 1;
}
//----------------------------------------------------------
ClassSel_SetupCharSelection(playerid)
{
if(gPlayerCitySelection[playerid] == CITY_LOS_SANTOS) {
SetPlayerInterior(playerid,11);
SetPlayerPos(playerid,508.7362,-87.4335,998.9609);
SetPlayerFacingAngle(playerid,0.0);
SetPlayerCameraPos(playerid,508.7362,-83.4335,998.9609);
SetPlayerCameraLookAt(playerid,508.7362,-87.4335,998.9609);
}
else if(gPlayerCitySelection[playerid] == CITY_SAN_FIERRO) {
SetPlayerInterior(playerid,3);
SetPlayerPos(playerid,-2673.8381,1399.7424,918.3516);
SetPlayerFacingAngle(playerid,181.0);
SetPlayerCameraPos(playerid,-2673.2776,1394.3859,918.3516);
SetPlayerCameraLookAt(playerid,-2673.8381,1399.7424,918.3516);
}
else if(gPlayerCitySelection[playerid] == CITY_LAS_VENTURAS) {
SetPlayerInterior(playerid,3);
SetPlayerPos(playerid,349.0453,193.2271,1014.1797);
SetPlayerFacingAngle(playerid,286.25);
SetPlayerCameraPos(playerid,352.9164,194.5702,1014.1875);
SetPlayerCameraLookAt(playerid,349.0453,193.2271,1014.1797);
}
}
//----------------------------------------------------------
// Used to init textdraws of city names
ClassSel_InitCityNameText(Text:txtInit)
{
TextDrawUseBox(txtInit, 0);
TextDrawLetterSize(txtInit,1.25,3.0);
TextDrawFont(txtInit, 0);
TextDrawSetShadow(txtInit,0);
TextDrawSetOutline(txtInit,1);
TextDrawColor(txtInit,0xEEEEEEFF);
TextDrawBackgroundColor(txtClassSelHelper,0x000000FF);
}
//----------------------------------------------------------
ClassSel_InitTextDraws()
{
// Init our observer helper text display
txtLosSantos = TextDrawCreate(10.0, 380.0, "Los Santos");
ClassSel_InitCityNameText(txtLosSantos);
txtSanFierro = TextDrawCreate(10.0, 380.0, "San Fierro");
ClassSel_InitCityNameText(txtSanFierro);
txtLasVenturas = TextDrawCreate(10.0, 380.0, "Las Venturas");
ClassSel_InitCityNameText(txtLasVenturas);
// Init our observer helper text display
txtClassSelHelper = TextDrawCreate(10.0, 415.0,
" Press ~b~~k~~GO_LEFT~ ~w~or ~b~~k~~GO_RIGHT~ ~w~to switch cities.~n~ Press ~r~~k~~PED_FIREWEAPON~ ~w~to select.");
TextDrawUseBox(txtClassSelHelper, 1);
TextDrawBoxColor(txtClassSelHelper,0x222222BB);
TextDrawLetterSize(txtClassSelHelper,0.3,1.0);
TextDrawTextSize(txtClassSelHelper,400.0,40.0);
TextDrawFont(txtClassSelHelper, 2);
TextDrawSetShadow(txtClassSelHelper,0);
TextDrawSetOutline(txtClassSelHelper,1);
TextDrawBackgroundColor(txtClassSelHelper,0x000000FF);
TextDrawColor(txtClassSelHelper,0xFFFFFFFF);
}
//----------------------------------------------------------
ClassSel_SetupSelectedCity(playerid)
{
if(gPlayerCitySelection[playerid] == -1) {
gPlayerCitySelection[playerid] = CITY_LOS_SANTOS;
}
if(gPlayerCitySelection[playerid] == CITY_LOS_SANTOS) {
SetPlayerInterior(playerid,0);
SetPlayerCameraPos(playerid,1630.6136,-2286.0298,110.0);
SetPlayerCameraLookAt(playerid,1887.6034,-1682.1442,47.6167);
TextDrawShowForPlayer(playerid,txtLosSantos);
TextDrawHideForPlayer(playerid,txtSanFierro);
TextDrawHideForPlayer(playerid,txtLasVenturas);
}
else if(gPlayerCitySelection[playerid] == CITY_SAN_FIERRO) {
SetPlayerInterior(playerid,0);
SetPlayerCameraPos(playerid,-1300.8754,68.0546,129.4823);
SetPlayerCameraLookAt(playerid,-1817.9412,769.3878,132.6589);
TextDrawHideForPlayer(playerid,txtLosSantos);
TextDrawShowForPlayer(playerid,txtSanFierro);
TextDrawHideForPlayer(playerid,txtLasVenturas);
}
else if(gPlayerCitySelection[playerid] == CITY_LAS_VENTURAS) {
SetPlayerInterior(playerid,0);
SetPlayerCameraPos(playerid,1310.6155,1675.9182,110.7390);
SetPlayerCameraLookAt(playerid,2285.2944,1919.3756,68.2275);
TextDrawHideForPlayer(playerid,txtLosSantos);
TextDrawHideForPlayer(playerid,txtSanFierro);
TextDrawShowForPlayer(playerid,txtLasVenturas);
}
}
//----------------------------------------------------------
ClassSel_SwitchToNextCity(playerid)
{
gPlayerCitySelection[playerid]++;
if(gPlayerCitySelection[playerid] > CITY_LAS_VENTURAS) {
gPlayerCitySelection[playerid] = CITY_LOS_SANTOS;
}
PlayerPlaySound(playerid,1052,0.0,0.0,0.0);
gPlayerLastCitySelectionTick[playerid] = GetTickCount();
ClassSel_SetupSelectedCity(playerid);
}
//----------------------------------------------------------
ClassSel_SwitchToPreviousCity(playerid)
{
gPlayerCitySelection[playerid]--;
if(gPlayerCitySelection[playerid] < CITY_LOS_SANTOS) {
gPlayerCitySelection[playerid] = CITY_LAS_VENTURAS;
}
PlayerPlaySound(playerid,1053,0.0,0.0,0.0);
gPlayerLastCitySelectionTick[playerid] = GetTickCount();
ClassSel_SetupSelectedCity(playerid);
}
//----------------------------------------------------------
ClassSel_HandleCitySelection(playerid)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(gPlayerCitySelection[playerid] == -1) {
ClassSel_SwitchToNextCity(playerid);
return;
}
// only allow new selection every ~500 ms
if( (GetTickCount() - gPlayerLastCitySelectionTick[playerid]) < 500 ) return;
if(Keys & KEY_FIRE) {
gPlayerHasCitySelected[playerid] = 1;
TextDrawHideForPlayer(playerid,txtClassSelHelper);
TextDrawHideForPlayer(playerid,txtLosSantos);
TextDrawHideForPlayer(playerid,txtSanFierro);
TextDrawHideForPlayer(playerid,txtLasVenturas);
TogglePlayerSpectating(playerid,0);
return;
}
if(lr > 0) {
ClassSel_SwitchToNextCity(playerid);
}
else if(lr < 0) {
ClassSel_SwitchToPreviousCity(playerid);
}
}
//----------------------------------------------------------
public OnPlayerRequestClass(playerid, classid)
{
if(IsPlayerNPC(playerid)) return 1;
if(gPlayerHasCitySelected[playerid]) {
ClassSel_SetupCharSelection(playerid);
return 1;
} else {
if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING) {
TogglePlayerSpectating(playerid,1);
TextDrawShowForPlayer(playerid, txtClassSelHelper);
gPlayerCitySelection[playerid] = -1;
}
}
return 0;
}
//----------------------------------------------------------
public OnGameModeInit()
{
SetGameModeText("Grand Larceny");
ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL);
ShowNameTags(1);
SetNameTagDrawDistance(40.0);
EnableStuntBonusForAll(0);
DisableInteriorEnterExits();
SetWeather(2);
SetWorldTime(11);
//UsePlayerPedAnims();
//ManualVehicleEngineAndLights();
//LimitGlobalChatRadius(300.0);
ClassSel_InitTextDraws();
// Player Class
AddPlayerClass(281,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(282,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(283,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(284,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(285,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(286,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(287,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(288,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(265,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(266,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(267,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(268,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(269,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(270,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(1,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(2,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(3,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(4,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(5,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(6,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(8,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(42,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(65,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
//AddPlayerClass(74,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(86,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(119,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(149,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(208,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(273,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(47,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(48,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(49,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(50,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(51,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(52,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(53,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(54,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(55,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(56,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(57,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(58,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(68,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(69,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(70,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(71,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(72,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(73,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(75,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(76,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(78,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(79,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(80,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(81,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(82,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(83,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(84,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(85,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(87,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(88,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(89,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(91,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(92,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(93,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(95,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(96,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(97,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(98,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
AddPlayerClass(99,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
// SPECIAL
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/trains.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt");
// LAS VENTURAS
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt");
// SAN FIERRO
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");
// LOS SANTOS
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");
// OTHER AREAS
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt");
printf("Total vehicles from files: %d",total_vehicles_from_files);
return 1;
}
//----------------------------------------------------------
public OnPlayerUpdate(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
if(IsPlayerNPC(playerid)) return 1;
// changing cities by inputs
if( !gPlayerHasCitySelected[playerid] &&
GetPlayerState(playerid) == PLAYER_STATE_SPECTATING ) {
ClassSel_HandleCitySelection(playerid);
return 1;
}
// No weapons in interiors
if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
SetPlayerArmedWeapon(playerid,0); // fists
return 0; // no syncing until they change their weapon
}
// Don't allow minigun
if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN) {
Kick(playerid);
return 0;
}
/* No jetpacks allowed
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) {
Kick(playerid);
return 0;
}*/
/* For testing animations
new msg[128+1];
new animlib[32+1];
new animname[32+1];
thisanimid = GetPlayerAnimationIndex(playerid);
if(lastanimid != thisanimid)
{
GetAnimationName(thisanimid,animlib,32,animname,32);
format(msg, 128, "anim(%d,%d): %s %s", lastanimid, thisanimid, animlib, animname);
lastanimid = thisanimid;
SendClientMessage(playerid, 0xFFFFFFFF, msg);
}*/
return 1;
}
//----------------------------------------------------------

View File

@@ -0,0 +1,12 @@
-/* Prolog test file */
-male(john).
-male(peter).
-
-female(vick).
-female(christie).
-
-parents(john, peter, christie).
-parents(vick, peter, christie).
-
-/* X is a brother of Y */
-brother(X, Y) :- male(X), parents(X, F, M), parents(Y, F, M).

21
samples/Prolog/turing.pl Normal file
View File

@@ -0,0 +1,21 @@
-turing(Tape0, Tape) :-
- perform(q0, [], Ls, Tape0, Rs),
- reverse(Ls, Ls1),
- append(Ls1, Rs, Tape).
-
-perform(qf, Ls, Ls, Rs, Rs) :- !.
-perform(Q0, Ls0, Ls, Rs0, Rs) :-
- symbol(Rs0, Sym, RsRest),
- once(rule(Q0, Sym, Q1, NewSym, Action)),
- action(Action, Ls0, Ls1, [NewSym|RsRest], Rs1),
- perform(Q1, Ls1, Ls, Rs1, Rs).
-
-symbol([], b, []).
-symbol([Sym|Rs], Sym, Rs).
-
-action(left, Ls0, Ls, Rs0, Rs) :- left(Ls0, Ls, Rs0, Rs).
-action(stay, Ls, Ls, Rs, Rs).
-action(right, Ls0, [Sym|Ls0], [Sym|Rs], Rs).
-
-left([], [], Rs0, [b|Rs0]).
-left([L|Ls], Ls, Rs, [L|Rs]).

380
samples/TeX/problemset.cls Normal file
View File

@@ -0,0 +1,380 @@
% =====================================
% problemset Document Style
% For Problem Sets
%
% Options:
% final hides to-dos
% worksheet hides solutions and places each problem on separate page
% expand places each problem on a separate page
% =====================================
\ProvidesClass{problemset}
\DeclareOption*{\PassOptionsToClass{final}{article}}
\DeclareOption{worksheet}{\providecommand{\@solutionvis}{0}}
\DeclareOption{expand}{\providecommand{\@expand}{1}}
\ProcessOptions\relax
% ================== Packages and Document Options ==================
\LoadClass[10pt,letterpaper]{article}
\RequirePackage[%
top=0.85in,
bottom=1in,
left=1in,
right=1in
]{geometry}
\RequirePackage{pgfkeys} % For mathtable environment.
\RequirePackage{tabularx} % For pset heading
\RequirePackage{float} % Used for floats (tables, figures, etc.)
\RequirePackage{graphicx} % Used for inserting images.
\RequirePackage{enumerate} % Used for the enumerate environment.
\RequirePackage{mathtools} % Required. Loads amsmath.
\RequirePackage{amsthm} % Required. Used for theorem environments.
\RequirePackage{amssymb} % Required.
\RequirePackage{booktabs} % Required. Used for mathtable environment.
\RequirePackage{esdiff} % For derivatives and partial derivatives
\RequirePackage{mathtools} % Optional. Used for \shortintertext.
\RequirePackage{fancyhdr} % Required. For customizing headers/footers.
\RequirePackage{lastpage} % Required. For page count in header/footer.
\RequirePackage{xcolor} % Required. For setting the color of hyperlinks
\RequirePackage[%
obeyFinal, % Disable todos by setting [final] option for class
color=@todoclr,
linecolor=red
]{todonotes} % For keeping track of to-dos.
\RequirePackage[%
colorlinks=true,
linkcolor=navy,
urlcolor=black
]{hyperref} % For following urls and references in a document.
\RequirePackage{url} % Enables urls with the \url tag
\RequirePackage[all]{hypcap}
% hypcap: Links go to object instead of caption. [Keep as last package]
% ================== Appearance Settings ==================
\definecolor{@todoclr}{gray}{0.80} % For To-Dos. 50% brightness
\definecolor{navy}{RGB}{0,0,150} % For coloring hyperlinks
\setlength{\parskip}{1.5ex} % Sets space between paragraphs.
\setlength{\parindent}{0pt} % Indent for first line of new paragraphs.
% Smaller verbatim type size
\let\VERBATIM\verbatim
\def\verbatim{%
\def\verbatim@font{\small\ttfamily}%
\VERBATIM}
% ============= Caption Modifications =============
\usepackage[small]{caption}
\usepackage[footnotesize]{subcaption}
% For no visible number, use: \caption*{Unnumbered figure caption.}
\captionsetup[table]{labelformat=simple, labelsep=period, labelfont=bf}
\captionsetup[figure]{labelformat=simple, labelsep=period, labelfont=bf}
\captionsetup[subtable]{labelformat=parens, labelsep=space, labelfont=bf}
\captionsetup[subfigure]{labelformat=simple, labelsep=period, labelfont=bf}
% ================== Booleans ==================
\def\TRUE{1}
\def\FALSE{0}
\def\SHOW{1}
\def\HIDE{0}
% ============= Gets Document Info, Generates Heading =============
\providecommand{\heading}[5][]{
\thispagestyle{empty}
\listoftodos
\clearpage
\pagenumbering{arabic}
%
\providecommand{\shortname}{#1}
\providecommand{\authorname}{#2}
\providecommand{\coursename}{#3}
\providecommand{\assignment}{#4}
\providecommand{\duedate}{#5}
\begin{minipage}{0.5\textwidth}
\begin{flushleft}
\hypertarget{@assignment}{
\textbf{\assignment}
}\\
\authorname
\end{flushleft}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{flushright}
\coursename\\
\duedate\\
\end{flushright}
\end{minipage}
\thispagestyle{empty}
}
% ============= Headers and Footers =============
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.5pt}
\pagestyle{fancyplain}
\fancyhf{}
\lfoot{%
\fancyplain{}{%
\hyperlink{@assignment}{%
\small{%
\color{black}{%
\assignment
}
}
}
}
}
\cfoot{%
\fancyplain{}{%
\small{%
\coursename
}
}
}
\rfoot{%
\fancyplain{}{%
\small{\shortname~\thepage~of~\pageref{LastPage}}
}
}
% ============= Problem Command =============
% INPUT: Points for question [#1] (Optional)
\newcounter{theproblem} % Problem counter for environment
\providecommand{\problem}[1][]{%
\addtocounter{theproblem}{1}%
\setcounter{table}{0}%
\setcounter{figure}{0}%
\setcounter{equation}{0}%
\noindent%
\textbf{%
Problem~\arabic{theproblem}.}~\textit{\small{#1}}
}
% ============= QED, Page Breaks After QED? =============
\providecommand{\@expand}{\HIDE} % Default is to omit pagebreaks after the solution
\providecommand{\qqed}{\hfill\rule{2mm}{2mm}\ifnum\@expand=\SHOW\\\pagebreak\fi}
% ============= Solution Command =============
\providecommand{\@solutionvis}{1} % Default setting is to show solutions.
\providecommand{\solution}[2][\@solutionvis]{
\vspace{0.5em}\noindent\textbf{Solution.}
\ifnum#1=\SHOW%
#2
\hfill\qqed\vspace{0.1em}
\else%
\pagebreak%
\fi
}
% ============= Chapter, Section, Item Commands =============
\providecommand{\chap}[2][0]{
\ifnum#1=0%
\else%
\setcounter{section}{#1}%
\addtocounter{section}{-1}%
\fi%
\vspace{-1.75em}%
\section{#2}
}
\providecommand{\sect}[2][0]{
\ifnum#1=0%
\else%
\setcounter{subsection}{#1}%
\addtocounter{subsection}{-1}%
\fi%
\vspace{-0.5em}%
\subsection{#2}
}
\providecommand{\subsect}[1]{\noindent\textbf{#1.}}
% ============= Insert Non-Float Image =============
\providecommand{\insertgraphic}[2][0.5\textwidth]{
\vspace{-1em}
\begin{center}
\includegraphics[width=#1]{#2}
\end{center}
\vspace{-1em}
}
% ============= Object Numbering by Problem =============
\renewcommand{\thetable}{\arabic{theproblem}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{theproblem}.\arabic{figure}}
\renewcommand{\theequation}{\arabic{theproblem}.\arabic{equation}}
% ============= Formula Environment =============
\newcounter{formula}
\newenvironment{formula}[1][Formula \arabic{formula}]
{
\addtocounter{formula}{1}
\begin{displaymath}
\tag*{\parbox{5em}{\textbf{\small{#1}}}}
}{
\end{displaymath}\\
}
% ============= Math Table =============
\newif\ifcaption
\pgfkeys
{
/mypkg/title/.store in=\Caption,% Any value assigned to title will be stored in \Caption
/mypkg/title= , % Initialize so \Caption exists
/mypkg/label/.store in=\Label, % Any value assigned to label will be stored in \Label
/mypkg/label= , % Initialize so \Label exists
/mypkg/caption/.is if=caption, % Declare a boolean, defaults to false
}
\newenvironment{mathtable}[2][]{
\pgfkeys{/mypkg/.cd, #1}%
\vspace{-1em}%
\begin{table}[ht!]%
\small \begin{center}%
\begin{displaymath}%
\begin{array}{#2}%
\toprule
}{
\bottomrule
\end{array}%
\end{displaymath}%
\ifcaption%
\vspace{-1em}\caption{\Caption}\label{\Label}%
\fi%
\end{center}%
\end{table}%
\vspace{-1em}%
}
% ============= Double-line Column-Heading for table =============
\providecommand{\double}[2]{%
\multicolumn{1}{c}{%
\genfrac{}{}{0pt}{}{\text{#1}}{\text{#2}}
}
}
% ============= Theorem-Style Environments =============
\theoremstyle{plain} % Bold label, italic letters
\newtheorem{thm}{Theorem}[section] % Numbered by section
\newtheorem{lma}[thm]{Lemma}
\newtheorem{crl}[thm]{Corollary}
\newtheorem{prp}[thm]{Proposition}
\newtheorem{cnj}[thm]{Conjecture}
\newtheorem{alg}[thm]{Algorithm}
% Associated environments (for numbered theorem environments)
\newenvironment{theorem}[2][]{\begin{thm}[#1]\label{#2}}{\end{thm}}
\newenvironment{lemma}[2][]{\begin{lma}[#1]\label{#2}}{\end{lma}}
\newenvironment{corollary}[2][]{\begin{crl}[#1]\label{#2}}{\end{thm}}
\newenvironment{proposition}[2][]{\begin{prp}[#1]\label{#2}}{\end{crl}}
\newenvironment{conjecture}[2][]{\begin{cnj}[#1]\label{#2}}{\end{cnj}}
\newenvironment{algorithm}[2][]{\begin{alg}[#1]\label{#2}}{\end{alg}}
\theoremstyle{remark} % Italic label, roman letters
\newtheorem{rmk}{Remark}[section] % Numbered by section. Remarks are used to expand on and integrate material.
\newtheorem*{note}{Note} % Un-numbered. Notes are used to comment on specific elements of the material.
\newtheorem*{caveat}{Caveat} % Un-numbered. Caveats are used to guide the reader away from a common error.
\newtheorem*{warning}{Warning} % Un-numbered. Warnings are used to guide away from especially egregious errors.
\theoremstyle{definition} % Bold label, roman letters
\newtheorem{dfn}{Definition}[section] % Numbered by section. Definitions of concepts and terms.
\newtheorem{exm}{Example}[section] % Numbered by section. Illustrative examples.
\newtheorem{smm}{Summary}[subsection] % Numbered by subsection. For section summaries.
\newtheorem*{question}{Question} % Un-numbered. For questions to motivate further analysis.
\newtheorem*{speculation}{Speculation} % Un-numbered. For questions that arise but will not be immediately answered.
% Associated environments (for numbered theorem environments)
\newenvironment{remark}[2][]{\begin{rmk}[#1]\label{#2}}{\end{rmk}}
\newenvironment{definition}[2][]{\begin{dfn}[#1]\label{#2}}{\end{dfn}}
\newenvironment{example}[2][]{\begin{exm}[#1]\label{#2}}{\end{exm}}
\newenvironment{summary}[2][]{\begin{smm}[#1]\label{#2}}{\end{smm}}
% ============= Greek Letters =============
\renewcommand{\a}{\ensuremath{\alpha}}
\renewcommand{\b}{\ensuremath{\beta}}
\renewcommand{\c}{\ensuremath{\gamma}}
\newcommand{\ch}{\ensuremath{\chi}}
\renewcommand{\d}{\ensuremath{\delta}}
\newcommand{\ep}{\ensuremath{\epsilon}}
\newcommand{\et}{\ensuremath{\eta}}
\newcommand{\ve}{\ensuremath{\varepsilon}}
\renewcommand{\r}{\ensuremath{\rho}}
\newcommand{\s}{\ensuremath{\sigma}}
\renewcommand{\t}{\ensuremath{\tau}}
\newcommand{\f}{\ensuremath{\psi}}
\newcommand{\w}{\ensuremath{\omega}}
\newcommand{\h}{\ensuremath{\phi}}
\newcommand{\m}{\ensuremath{\mu}}
\renewcommand{\l}{\ensuremath{\lambda}}
\renewcommand{\k}{\ensuremath{\kappa}}
\renewcommand{\v}{\ensuremath{\nu}}
\renewcommand{\i}{\ensuremath{\iota}}
\renewcommand{\o}{\ensuremath{\theta}}
\newcommand{\z}{\ensuremath{\zeta}}
% ============= Mathematical Symbols =============
\providecommand{\NN}{\ensuremath{\mathbb{N}}}
\providecommand{\ZZ}{\ensuremath{\mathbb{Z}}}
\providecommand{\QQ}{\ensuremath{\mathbb{Q}}}
\providecommand{\RR}{\ensuremath{\mathbb{R}}}
\providecommand{\CC}{\ensuremath{\mathbb{C}}}
\providecommand{\pd}{\partial} % 'dee' symbol for partial derivatives
\providecommand{\dd}{\mathrm{d}} % 'dee' symbol for ordinary derivatives
\providecommand{\x}{\times}
\providecommand{\n}{\scalebox{0.6}[1.0]{\ensuremath{-}}}
% ============= Mathematical Macros =============
\providecommand{\Sum}[3][n]{\ensuremath{\sum_{{#1}={#2}}^{#3}}} % Sum from [n]={1}to{2}. \Sum{1}{10}
\providecommand{\infsum}[2][n]{\ensuremath{\sum_{{#1}={#2}}^\infty}} % Infinite sum from [n]={1} \infsum{1}
\providecommand{\Int}[4][x]{\ensuremath{\int_{#3}^{#4}\!{#2}\,\mathrm{d}{#1}}} % Integrate {1} from {2} to {3} with respect to [x]
\providecommand{\Lim}[3][\infty]{\ensuremath{\displaystyle \lim_{{#2}\to{#1}}\!\!{#3}}} % Take the limit from {1} to [infinity] of {3} \Lim{x}{f(x)}
\providecommand{\Frac}[2]{\ensuremath{\,^{#1}\!/\!_{#2}}} % Slanted fraction with proper spacing. Usefule for in-line display of fractions.
\providecommand{\eval}[3]{\ensuremath{\left[ #1 \right \vert_{#2}^{#3}}}
\renewcommand{\L}{\left} % for left-hand right-sizing
\providecommand{\R}{\right} % for right-hand right-sizing
\providecommand{\D}{\diff} % for writing derivatives
\providecommand{\PD}{\diffp} % for writing partial derivatives
\providecommand{\full}{\displaystyle} % Forces display style in math mode
\providecommand{\Deg}{\ensuremath{^\circ}} % for adding a degree symbol, even if not in math mode
\providecommand{\abs}[1]{\left\vert #1 \right\vert} % Absolute Value
\providecommand{\norm}[1]{\left \Vert #1 \right \Vert} % Norm (vector magnitude)
\providecommand{\e}[1]{\ensuremath{\times 10^{#1}}} % Scientific Notation with times symbol
\providecommand{\E}[1]{\ensuremath{10^{#1}}} % Scientific Notation
\renewcommand{\u}[1]{\text{ #1}} % For inserting units in Roman text
\providecommand{\mc}{\text{,}\hspace{1em}} % For inserting comma and space into math mode
\providecommand{\mtxt}[2][]{#1\hspace{0.5em}\text{#2}\hspace{0.5em}} % For insterting text into math mode with space on either side. Option for preceding punctuation.
% ============= Probability and Statistics =============
\providecommand{\prob}[1]{\ensuremath{P\!\left(#1\right)} }
\providecommand{\cndprb}[2]{\ensuremath{P\!\left(#1 \left\vert #2 \right. \right)} }
\providecommand{\cov}[1]{\ensuremath{\text{Cov}\!\left(#1\right)} }
\providecommand{\ex}[1]{\ensuremath{E\!\left[#1\right]} }
% ============= Linear Algebra =============
% Column vectors
\providecommand{\twovector}[3][r]{\left(\begin{array}{#1} #2 \\ #3\end{array}\right)}
\providecommand{\threevector}[4][r]{\left(\begin{array}{#1} #2 \\ #3 \\ #4\end{array}\right)}
\providecommand{\fourvector}[5][r]{\left(\begin{array}{#1} #2 \\ #3 \\ #4 \\ #5 \end{array}\right)}
% ============= Vector Calculus =============
% ------------- Susan Lea's notation ---------------
\providecommand{\vecs}[1]{\ensuremath{\vec{\bm{#1}}} } % bolded symbol, arrow
\providecommand{\vect}[1]{\ensuremath{\vec{\textbf{#1}}} } % bolded text, arrow
\providecommand{\unitvecs}[1]{\bm{\hat{#1}}}
\providecommand{\unitvect}[1]{\hat{\textbf{#1}}}
\providecommand{\Div}[1]{\vecs{\del} \cdot \vect{#1}}
\providecommand{\Curl}[1]{\vecs{\del} \times \vect{#1}}
\providecommand{\Grad}{\vecs{\del}}

View File

@@ -0,0 +1,47 @@
@Code
ViewData("Title") = "Home Page"
End Code
@section featured
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>@ViewData("Title").</h1>
<h2>@ViewData("Message")</h2>
</hgroup>
<p>
To learn more about ASP.NET MVC visit
<a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
The page features <mark>videos, tutorials, and samples</mark> to help you get the most from ASP.NET MVC.
If you have any questions about ASP.NET MVC visit
<a href="http://forums.asp.net/1146.aspx/1?MVC" title="ASP.NET MVC Forum">our forums</a>.
</p>
</div>
</section>
End Section
<h3>We suggest the following:</h3>
<ol class="round">
<li class="one">
<h5>Getting Started</h5>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and that gives you full control over markup
for enjoyable, agile development. ASP.NET MVC includes many features that enable
fast, TDD-friendly development for creating sophisticated applications that use
the latest web standards.
<a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
</li>
<li class="two">
<h5>Add NuGet packages and jump-start your coding</h5>
NuGet makes it easy to install and update free libraries and tools.
<a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
</li>
<li class="three">
<h5>Find Web Hosting</h5>
You can easily find a web hosting company that offers the right mix of features
and price for your applications.
<a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
</li>
</ol>

View File

@@ -0,0 +1,8 @@
Module Module1
Sub Main()
Console.Out.WriteLine("Hello, I am a little sample application to test GitHub's Linguist module.")
Console.Out.WriteLine("I also include a Razor MVC file just to prove it handles cshtml files now.")
End Sub
End Module

47
samples/XML/pt_BR.xml Normal file
View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="pt_BR">
<context>
<name>MainWindow</name>
<message>
<location filename="../forms/mainwindow.ui" line="22"/>
<source>United Kingdom</source>
<translation>Reino Unido</translation>
</message>
<message>
<location filename="../forms/mainwindow.ui" line="38"/>
<source>God save the Queen</source>
<translation>Deus salve a Rainha</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="46"/>
<source>England</source>
<translation>Inglaterra</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="47"/>
<source>Wales</source>
<translation>Gales</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="48"/>
<source>Scotland</source>
<translation>Escócia</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="49"/>
<source>Northern Ireland</source>
<translation>Irlanda Norte</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="51"/>
<source>Portuguese</source>
<translation>Português</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="52"/>
<source>English</source>
<translation>Inglês</translation>
</message>
</context>
</TS>

View File

@@ -38,4 +38,28 @@ class TestHeuristcs < Test::Unit::TestCase
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
assert_equal Language["Objective-C"], match
end
def test_pl_prolog_by_heuristics
languages = ["Perl", "Prolog"]
results = Heuristics.disambiguate_pl(fixture("Prolog/turing.pl"), languages)
assert_equal Language["Prolog"], results.first
end
def test_pl_perl_by_heuristics
languages = ["Perl", "Prolog"]
results = Heuristics.disambiguate_pl(fixture("Perl/perl-test.t"), languages)
assert_equal Language["Perl"], results.first
end
def test_ts_typescript_by_heuristics
languages = ["TypeScript", "XML"]
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages)
assert_equal Language["TypeScript"], results.first
end
def test_ts_xml_by_heuristics
languages = ["TypeScript", "XML"]
results = Heuristics.disambiguate_ts(fixture("XML/pt_BR.xml"), languages)
assert_equal Language["XML"], results.first
end
end

View File

@@ -104,6 +104,7 @@ class TestLanguage < Test::Unit::TestCase
assert_equal Language['Raw token data'], Language.find_by_alias('raw')
assert_equal Language['Ruby'], Language.find_by_alias('rb')
assert_equal Language['Ruby'], Language.find_by_alias('ruby')
assert_equal Language['R'], Language.find_by_alias('r')
assert_equal Language['Scheme'], Language.find_by_alias('scheme')
assert_equal Language['Shell'], Language.find_by_alias('bash')
assert_equal Language['Shell'], Language.find_by_alias('sh')