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
require 'minitest/autorun' | |
class String | |
def match_index_to(other) | |
this = self.to_trigrams.first | |
other = other.to_trigrams.first | |
2.0 * ((this & other).size).to_f / (this.size + other.size).to_f | |
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
INFINITY = (1/0.0) | |
count = case violations.length | |
when 0..5 | |
[yellow, violations.length.to_s, clear].join | |
when 6..10 | |
[red, violations.length.to_s, clear].join | |
when 11..INFINITY | |
[bold, red, violations.length.to_s, clear].join | |
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
clang -DPACKAGE_NAME=\"shmup\" -DPACKAGE_TARNAME=\"shmup\" -DPACKAGE_VERSION=\"0.1\" -DPACKAGE_STRING=\"shmup\ 0.1\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE=\"shmup\" -DVERSION=\"0.1\" -I. -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/usr/local/include/SDL -Wall -Werror -ansi -finline-functions -g -O2 -MT shmup-sprite_stack.o -MD -MP -MF .deps/shmup-sprite_stack.Tpo -c -o shmup-sprite_stack.o `test -f 'sprite_stack.c' || echo './'`sprite_stack.c | |
In file included from sprite_stack.c:1: | |
./sprite_stack.h:9:5: error: unknown type name 'sprite_node' | |
sprite_node *previous; | |
^ | |
./sprite_stack.h:10:5: error: unknown type name 'sprite_node' | |
sprite_node *next; | |
^ | |
2 errors generated. | |
make[1]: *** [shmup-sprite_stack.o] Error 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
#include "sprite_stack.h" | |
void stack_remove(sprite_node *node) | |
{ | |
node->previous->next = node->next; | |
SDL_FreeSurface(node->sprite->image); | |
free(node); | |
} |
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
void stack_remove(sprite_node *node) | |
{ | |
node->previous->next = node->next; | |
SDL_FreeSurface(node->image); | |
free(node); | |
} |
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
#ifndef H_STACK_COLLECTION | |
#define H_STACK_COLLECTION | |
#define traverse_stack(stack) sprite_node *current = first; \ | |
while(*current = *current->next) | |
#include "graphics.h" | |
typedef struct { | |
sprite *sprite; |
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
typedef struct { | |
int up; | |
int down; | |
int left; | |
int right; | |
} movement; | |
typedef movement acceleration; | |
typedef movement speed; |
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
import java.util.Locale; | |
class LocaleStealer { | |
public static void main(String[] args) { | |
Locale[] availableLocales = Locale.getAvailableLocales(); | |
System.out.println("countries:") | |
for (Locale locale : availableLocales) { | |
if(! locale.getDisplayCountry().equals("")) { | |
System.out.println(String.format(" - [\"%s\", \"%s\"]", locale, locale.getDisplayCountry())); |
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
require 'fiber' | |
class Job | |
include Enumerable | |
def initialize(jobs) | |
@jobs = jobs | |
end | |
def each(&block) |
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
$ irb | |
>> require 'bundler/setup' | |
true | |
>> require 'active_support/core_ext/string/inflections' | |
true | |
>> "FakeResource".tableize | |
"fake_resource" | |
>> require 'active_support/core_ext' | |
true | |
>> "FakeResource".tableize |